Part I: Introduction

Download Report

Transcript Part I: Introduction

Introduction to computer networking
1
Internet: the global communications
network
Internet
2
Text, audio, image and video: multimedia
communications in the Internet
bits bits bits bits bits
bits bits bits bits bits
bits bits bits bits bits
bits bits bits bits bits
bits bits bits bits bits
bits bits bits bits bits
and more bits…
“www.youtube.com” server
Browser
3
Coding black and white images
pixel
grey level = luminance
4
Coding black and white images
1 bit/pixel
21 levels
black
white
2 bits/pixel
22 levels
black
dark grey
light grey
white
= 0
= 1
=
=
=
=
00
01
10
11
5
Coding black and white images
3 bits/pixel
23 levels
black
very very
very dark
dark grey
ligth grey
very light
very very
white
black
…
4 bits/pixel
24 levels
…
…
…
…
…
…
dark grey
grey
grey
light grey
=
=
=
=
=
=
=
=
0000
0001
0010
0011
0100
0101
0110
0111
=
=
=
=
=
=
=
=
000
001
010
011
100
101
110
111
…
…
…
…
…
…
…
white
=
=
=
=
=
=
=
=
1000
1001
1010
1011
1100
1101
1110
1111
6
Coding black and white images
pixel
luminance (8 bits/pixel = 256 grey levels)
87
89
101
106
118
130
142
155
85
91
101
105
116
129
135
149
86
92
96
105
112
128
131
144
576 lines X 720 columns
= 414720 pixels
92
88
102
101
116
129
135
147
88
94
94
98
113
122
130
139
88
95
98
97
113
119
133
141
414720 pixels X 8 bits/pixel
= 3.318 Megabits
92
99
98
106
107
118
135
145
89
95
98
107
104
112
130
144
7
Colour and motion – video coding
Luminance + (two) Chrominances = 576 X 720 + 2 X 576 X
360 = 829440 pixels
829440 pixels X 8 bits/pixel X 25 images/s =
166 Mbits/s
8
Compression is needed… and possible!
Voice at 64 Kbits/s
Music at 1.4 Mbit/s
Video at 166 Mbit/s
Compression explores
redundancy and
irrelevance in multimedia
information
9
Compression is needed … and possible
10
Compression systems
Resolução
espacial
Resolução
temporal
Bits/amostra
Full HD
1080p
1080  1920
1080  960
25
imagens/s
progressivas
8
bits/amostra
830 Mbit/s
8-10 Mbit/s
80-100
HD Ready
720p
720  1280
720  640
25
imagens/s
progressivas
8
bits/amostra
370 Mbit/s
6-8 Mbit/s
60
TV e DVD
standard (MP4)
576  720
576  360
25
imagens/s
entrelaçadas
8
bits/amostra
166 Mbit/s
6 Mbit/s
27.5
Internet
streaming (MP4)
288  360
144  180
25
imagens/s
progressivas
8
bits/amostra
31 Mbit/s
150 kbit/s
200
Vídeo móveis
(MP4)
144  180
72  90
25
imagens/s
progressivas
8
bits/amostra
7.8 Mbit/s
100 kbit/s
80
Serviço
Débito
Débito binário Factor de
binário (PCM)
codificado
compressão
Música stereo
(MP3)
-
44000
amostras/s
16
bits/amostra
1.4 Mbit/s
100 kbit/s
14
Voz (GSM)
-
8000
amostras/s
8
bits/amostra
64 kbit/s
13 kbit/s
5
11
Internet: a packet
switching network
1
0
1010
0110
packet
Internet
12
“Surfing the net”
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
Packet
00001010
10010010
11011010
01101110
Internet
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
00001010
10010010
11011010
01101110
13
link
00001010
10010010
00001010
11011010
10010010
00001010
01101110
11011010
10010010
00001010
01101110
11011010
10010010
00001010
01101110
11011010
10010010
00001010
01101110
11011010
10010010
01101110
11011010
01101110
router
Routing packets
14
link
00001010
10010010
11011010
01101110
router
0000101000001010000010100000101000001010
1001001010010010100100101001001010010010
1101101011011010110110101101101011011010
0110111001101110011011100110111001101110
Routing packets
15
Internet structure: network of networks
Mobile network
ISP
Router
Internet
ISP
Domestic network
Organizational network
16
Internet structure: network of networks
 roughly hierarchical
 at center: “tier-1” ISPs (e.g., Verizon, Sprint, AT&T,
Cable and Wireless), national/international coverage
 treat each other as equals
Tier-1
providers
interconnect
(peer)
privately
Tier 1 ISP
Tier 1 ISP
Tier 1 ISP
17
Tier-1 ISP: e.g., Sprint
POP: point-of-presence
to/from backbone
…
peering
…
…
…
…
.
to/from customers
18
Internet structure: network of networks
 “Tier-2” ISPs: smaller (often regional) ISPs
 Connect to one or more tier-1 ISPs, possibly other tier-2 ISPs
Tier-2 ISP pays
tier-1 ISP for
connectivity to
rest of Internet
 tier-2 ISP is
customer of
tier-1 provider
Tier-2 ISP
Tier-2 ISP
Tier 1 ISP
Tier 1 ISP
Tier-2 ISP
Tier 1 ISP
Tier-2 ISPs
also peer
privately with
each other.
Tier-2 ISP
Tier-2 ISP
19
Internet structure: network of networks
 “Tier-3” ISPs and local ISPs
 last hop (“access”) network (closest to end systems)
local
ISP
Local and tier3 ISPs are
customers of
higher tier
ISPs
connecting
them to rest
of Internet
Tier 3
ISP
Tier-2 ISP
local
ISP
local
ISP
local
ISP
Tier-2 ISP
Tier 1 ISP
Tier 1 ISP
Tier-2 ISP
local
local
ISP
ISP
Tier 1 ISP
Tier-2 ISP
local
ISP
Tier-2 ISP
local
ISP
20
Internet structure: network of networks
 a packet passes through many networks!
local
ISP
Tier 3
ISP
Tier-2 ISP
local
ISP
local
ISP
local
ISP
Tier-2 ISP
Tier 1 ISP
Tier 1 ISP
Tier-2 ISP
local
local
ISP
ISP
Tier 1 ISP
Tier-2 ISP
local
ISP
Tier-2 ISP
local
ISP
21
Internet addressing
153.3.2.1
153.4.2.1
11.15.2.33
Internet
11.23.35.2
153.4.2.2
15.53.19.21
15.54.18.20
153.3.2.2
20.18.3.2
128.45.138.1
20.18.3.1
192.26.12.1
192.26.1.1
128.45.233.8
192.26.5.1
192.26.1.29
Teresa
Pedro
128.45.233.7
128.45.233.6
Matilde
192.26.12.1
192.26.1.30
João
192.26.5.84
192.26.5.83
Rosário
IP address
193
.
32
.
216
.
9
11000001 00100000 11011000 00001001
232 = 4.294.967.296 addresses!
Rui
Run ipconfig
22
Internet names - DNS
hawai.com
153.4.2.1
www.ist.utl.pt
153.3.2.1
11.15.2.33
153.3.2.2
praia.edu
11.23.35.2
20.18.3.2
153.4.2.2
128.45.138.1
alameda.ist.utl.pt
15.53.19.21
taguspark.ist.utl.pt
15.54.18.20
192.26.1.1
20.18.3.1
192.26.12.1
128.45.233.8
192.26.5.1
bronze.praia.pt
192.26.1.29
beethoven.ist.utl.pt
192.26.12.1
192.26.1.30
stravinsky.ist.utl.pt
128.45.233.7
128.45.233.6
surf.praia.pt
192.26.5.84
192.26.5.83
ravel.ist.utl.pt
cromo.praia.pt
Run nslookup
23
Testing Internet destinations: the ping
command
ICMP Echo Reply
ICMP Echo Request
Run ping
24
Discovering Internet routes: traceroute
ICMP Echo Request
ICMP Echo Request
ICMP Echo Reply
ICMP Time Exceeded
ICMP Time Exceeded
ICMP Echo Request
Do a visual traceroute @
www.yougetsignal.com
25
Internet crossing oceans
26
Internet crossing oceans
27
Internet paintings
www.visual complexity.com
28
Internet paintings
www.visual complexity.com
29
Internet paintings
Convergence, Jackson Pollock (1912-1956)
30
Internet access
Download of:
2 Mbits/s
24 Mb/s
Web page (250 KB)
1 seg
0.083 seg
Music (5 MB)
20 seg
1.7 seg
Video clip (25 MB)
1 min e 40 seg
8.3 seg
Low quality movie (750 MB)
50 min
4 min e 10 seg
High quality movie (4 GB)
4 horas e 27 min
22 min e 13 seg
Internet
24 Mbits/s
Download duration =
8X4X109 bits
24X106 bits/s
31
Internet access
“The Cry”, Edvard Munch (1863-1944)
If after half an hour the
download has not ended,
Internet what went wrong?
24 Mbits/s
32
Internet access
If after2 half
Mbits/san hour the
download has not ended,
Internet what went wrong?
24 Mbits/s
server’s access
network
33
Internet access
1 Mbits/s
If after half
an hour the
24 Mbits/s
download has not ended,
Internet what went wrong?
24 Mbits/s
server’s access
network
34
Internet access: p2p
1 Mb/s
1 Mb/s
1 Mb/s
1 Mb/s
Internet
24 Mbits/s
1 Mb/s
1 Mb/s
Internet
24 Mbits/s
35
Packet-switching: store-and-forward
L
R
R
 takes L/R seconds to
transmit (push out)
packet of L bits on to
link at R bps

store and forward:
entire packet must
arrive at router before
it can be transmitted
on next link
 delay = 3L/R (assuming
zero propagation delay)
R
Example:
 L = 7.5 Mbits
 R = 1.5 Mbps
 transmission delay = 15
sec
more on delay shortly …
36
Packet Switching: Message Segmenting
Now break up the message
into 5000 packets
Each packet 1,500 bits
 1 msec to transmit
packet on one link
 pipelining: each link
works in parallel
 Delay reduced from 15
sec to 5.002 sec

37
Communication links
Two types of “links”:
 point-to-point
 PPP for dial-up access
 point-to-point link between Ethernet switch and host
 broadcast (shared wire or medium)
 old-fashioned Ethernet
 upstream HFC
 802.11 wireless LAN
shared wire (e.g.,
cabled Ethernet)
shared RF
(e.g., 802.11 WiFi)
shared RF
(satellite)
humans at a
cocktail party
(shared air, acoustical)
38
Communication links – antenna
transmission systems
39
Communication links – optical transmission
systems
40
RECEIVER
Errors in
communication links
AMPLIFIER
+
FILTER
a(t)
b(t)
S/H
DECISION
CIRCUIT
c(t)
V
SYNC
a(t)
1
0
1
1
0
1
0
0
A
Signal degrade due
to:
 Attenuation
 Distortion
 Noise
 Interference
0
received signal
transmitted signal
b(t)
A
V
sampled signal (S/H)
c(t)
A
1
0
0
1
0
1
1
0
regenerated signal
error
error
41
What’s a protocol?
 a human protocol and a computer network protocol:
Hi
Hi
Got the
time?
2:00
time
Q: Other human protocols?
42
What’s a protocol?
 human protocols:



“what’s the time?”
“I have a question”
introductions
 … specific msgs sent
 network protocols:


machines rather than
humans
all communication activity
in Internet governed by
protocols
 … specific actions
taken when msgs
received, or other
events
protocols define format,
order of msgs sent and
received among network
entities, and actions
taken on msg
transmission, receipt
43
TFTP – an example of a network
application protocol for file transfer
 Internet standard defined
in RFC (Request for
Comment) by the IETF
(Internet Engineering Task
Force)
 Includes an initial
handshake
 Files are segmented into
messages

It is not efficient to transfer a
large file in a single message
 TFTP uses the
Stop-and-
Wait protocol for error
control

Messages can be lost, corrupted
or received out of order in the
network
 How is the end of a file
transfer signaled?
44
Stop-and-wait (SW)
Operation without errors
45
Stop-and-wait (SW)
Error recovery
46
Stop-and-wait (SW)
DATA messages need to be numbered
47
Stop-and-wait (SW)
ACK messages need to be numbered
48
Stop-and-wait (SW)
Ok!
49
TFTP message format
2 bytes
n bytes
1 byte
n bytes
1 byte
READ REQ (1)
FILENAME
0
MODE
0
2 bytes
n bytes
1 byte
n bytes
1 byte
WRITE REQ (2)
FILENAME
0
MODE
0
2 bytes
2 bytes
up to 512 bytes
DATA (3)
BLOCK #
data
2 bytes
2 bytes
ACK (4)
BLOCK #
2 bytes
2 bytes
n bytes
1 byte
ERROR (5)
ERROR CODE
ERROR MESSAGE
0
ERROR CODE:
00 – Not defined
01 – File not found
02 – Access violation
03 – Disk full
04 – Invalid operation code
05 – Unknown port number
06 – File already exists
07 – No such user
50
TFTP write
 Host @ 192.168.8.227 sends request to write file f1268.txt (with 1268
bytes) in the server @ 192.168.8.226
 The server and client applications are configured to use a maximum
message size of 1024 bytes
 The second DATA message (Block No. = 2) is detected as the last one
because it has a size lower than 1024 bytes (1268 - 1024 = 244 bytes)
51
App-layer protocol defines
 Types of messages
exchanged,

e.g., request, response
 Message syntax:
 what fields in messages &
how fields are delineated
 Message semantics
 meaning of information in
fields
 Rules for when and how
Public-domain protocols:
 defined in RFCs
 allows for
interoperability
 e.g., HTTP, SMTP
 Click here for the main
TFTP RFC (RFC 1350)
Proprietary protocols:
 e.g., Skype
processes send &
respond to messages
52
Application architectures
 Client-server
 Peer-to-peer (P2P)
 Hybrid of client-server and P2P
53
Client-server architecture
client/server
server:
 always-on host
 permanent IP address
 server farms for scaling
clients:
 communicate with
server
 may be intermittently
connected
 may have dynamic IP
addresses
 do not communicate
directly with each other
54
Pure P2P architecture

no always-on server
 arbitrary end systems
directly communicate peer-peer
 peers are intermittently
connected and change IP
addresses
 example: Gnutella
Highly scalable but
difficult to manage
55
Hybrid of client-server and P2P
Skype
 voice-over-IP P2P application
 centralized server: finding address of remote
party
 client-client connection: direct (not through
server)
Instant messaging
 chatting between two users is P2P
 centralized service: client presence
detection/location
• user registers its IP address with central
server when it comes online
• user contacts central server to find IP
addresses of buddies
56
Processes communicating
Process: program running
within a host.
 within same host, two
processes communicate
using inter-process
communication (defined
by OS).
 processes in different
hosts communicate by
exchanging messages
Client process: process
that initiates
communication
Server process: process
that waits to be
contacted
 Note: applications with
P2P architectures have
client processes &
server processes
57
Sockets
 process sends/receives
messages to/from its
socket
 socket analogous to door


sending process shoves
message out door
sending process relies on
transport infrastructure
on other side of door which
brings message to socket
at receiving process
host or
server
host or
server
controlled by
app developer
process
process
socket
socket
TCP with
buffers,
variables
Internet
TCP with
buffers,
variables
controlled
by OS
 API: (1) choice of transport protocol; (2) ability to fix
a few parameters
58
Addressing processes
 to receive messages,
process must have
identifier
 host device has unique
32-bit IP address
 Q: does IP address of
host on which process
runs suffice for
identifying the
process?
A: No, many
processes can be
running on same host

identifier includes both
IP address and port
numbers associated with
process on host.
 Example port numbers:


HTTP server: 80
Mail server: 25
 to send HTTP message
to gaia.cs.umass.edu web
server:


IP address: 128.119.245.12
Port number: 80
 more shortly…
59
What transport service does an app need?
Data loss
 some apps (e.g., audio) can
tolerate some loss
 other apps (e.g., file
transfer, telnet) require
100% reliable data
transfer
Timing
 some apps (e.g.,
Internet telephony,
interactive games)
require low delay to be
“effective”
Bandwidth
 some apps (e.g.,
multimedia) require
minimum amount of
bandwidth to be
“effective”
 other apps (“elastic
apps”) make use of
whatever bandwidth
they get
60
Transport service requirements of common apps
Application
Data loss
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
no loss
loss-tolerant
stored audio/video
interactive games
instant messaging
loss-tolerant
loss-tolerant
no loss
Bandwidth
Time Sensitive
no
elastic
no
elastic
no
elastic
audio: 5kbps-1Mbps yes, 100’s msec
video:10kbps-5Mbps
yes, few secs
same as above
yes, 100’s msec
few kbps up
yes and no
elastic
61
Protocol “Layers”
Networks are complex!
 many “pieces”:
 hosts
 routers
 links of various
media
 applications
 protocols
 hardware,
software
Question:
Is there any hope of
organizing structure of
network?
Or at least our discussion
of networks?
62
Organization of air travel
ticket (purchase)
ticket (complain)
baggage (check)
baggage (claim)
gates (load)
gates (unload)
runway takeoff
runway landing
airplane routing
airplane routing
airplane routing
 a series of steps
63
Layering of airline functionality
ticket (purchase)
ticket (complain)
ticket
baggage (check)
baggage (claim
baggage
gates (load)
gates (unload)
gate
runway (takeoff)
runway (land)
takeoff/landing
airplane routing
airplane routing
airplane routing
departure
airport
airplane routing
airplane routing
intermediate air-traffic
control centers
arrival
airport
Layers: each layer implements a service
 via its own internal-layer actions
 relying on services provided by layer below
64
Why layering?
Dealing with complex systems:
 explicit structure allows identification,
relationship of complex system’s pieces
 layered reference model for discussion
 modularization eases maintenance, updating of
system
 change of implementation of layer’s service
transparent to rest of system
 e.g., change in gate procedure doesn’t affect
rest of system
 layering considered harmful?
65
Internet protocol stack
 application: supporting network
applications

FTP, SMTP, HTTP
 transport: process-process data
transfer

TCP, UDP
 network: routing of datagrams from
source to destination

IP, routing protocols
 link: data transfer between
application
transport
network
link
physical
neighboring network elements

PPP, Ethernet
 physical: bits “on the wire”
66
Encapsulation
source
message
segment Ht
M
M
datagram Hn Ht M
frame Hl Hn Ht M
application
transport
network
link
physical
link
physical
switch
destination
M
Ht
Hn Ht
Hl Hn Ht
M
M
M
application
transport
network
link
physical
Hn Ht
Hl Hn Ht
M
M
network
link
physical
Hn Ht
M
router
67
Internet transport protocols services
TCP service:





connection-oriented: setup
required between client and
server processes
reliable transport between
sending and receiving process
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not provide: timing,
minimum bandwidth
guarantees
UDP service:
 unreliable data transfer
between sending and
receiving process
 does not provide:
connection setup,
reliability, flow control,
congestion control, timing,
or bandwidth guarantee
Q: why bother? Why is
there a UDP?
68
Internet apps: application, transport protocols
Application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
Internet telephony
Application
layer protocol
Underlying
transport protocol
SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]
FTP [RFC 959]
proprietary
(e.g. RealNetworks)
proprietary
(e.g., Vonage,Dialpad)
TCP
TCP
TCP
TCP
TCP or UDP
typically UDP
69
Transport services and protocols
 provide
logical communication
between app processes
running on different hosts
 transport protocols run in
end systems
 send side: breaks app
messages into segments,
passes to network layer
 rcv side: reassembles
segments into messages,
passes to app layer
 more than one transport
protocol available to apps
 Internet: TCP and UDP
application
transport
network
data link
physical
application
transport
network
data link
physical
70
Multiplexing/demultiplexing
Demultiplexing at rcv host:
delivering received segments
to correct socket
= socket
= process
Multiplexing at send host:
gathering data from multiple
sockets, enveloping data with
header (later used for
demultiplexing)
P3
application
transport
network
link
physical
P1
P1 application P2
transport
network
link
physical
P4
application
transport
network
link
physical
host 1
host 2
host 3
71
How demultiplexing works
 host receives IP datagrams
each datagram has source
IP address, destination IP
address
 each datagram carries 1
transport-layer segment
 each segment has source,
destination port number
 host uses IP addresses & port
numbers to direct segment to
appropriate socket

32 bits
source port #
dest port #
other header fields
application
data
(message)
TCP/UDP segment format
72
Connectionless demultiplexing
 Create sockets with port
numbers:
DatagramSocket mySocket1 = new
DatagramSocket(12534);
DatagramSocket mySocket2 = new
DatagramSocket(12535);
 UDP socket identified by
two-tuple:
(dest IP address, dest port number)
 When host receives UDP
segment:


checks destination port
number in segment
directs UDP segment to
socket with that port
number
 IP datagrams with
different source IP
addresses and/or source
port numbers directed
to same socket
73
Connectionless demultiplexing
DatagramSocket serverSocket = new DatagramSocket(6428);
P2
SP: 6428
DP: 9157
client
IP: A
P1
P1
P3
SP: 9157
DP: 6428
SP: 6428
DP: 5775
server
IP: C
SP: 5775
DP: 6428
client
IP:B
SP provides “return address”
74
TFTP read
75
TFTP read
76
UDP: User Datagram Protocol [RFC 768]
 “no frills,” “bare bones”
Internet transport
protocol
 “best effort” service, UDP
segments may be:
 lost
 delivered out of order
to app

connectionless:


no handshaking between
UDP sender, receiver
each UDP segment
handled independently
of others
Why is there a UDP?
 no connection
establishment (which can
add delay)
 simple: no connection state
at sender, receiver
 small segment header
 no congestion control: UDP
can blast away as fast as
desired
77
UDP: more
 often used for streaming
multimedia apps
 loss tolerant
 rate sensitive
Length, in
bytes of UDP
segment,
including
header
 other UDP uses
 DNS
 SNMP
 reliable transfer over UDP:
add reliability at
application layer
 application-specific
error recovery!
32 bits
source port #
dest port #
length
checksum
Application
data
(message)
UDP segment format
78
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
Sender:
Receiver:
 treat segment contents
 compute checksum of
as sequence of 16-bit
integers
 checksum: addition (1’s
complement sum) of
segment contents
 sender puts checksum
value into UDP checksum
field
received segment
 check if computed checksum
equals checksum field value:
 NO - error detected
 YES - no error detected.
But maybe errors
nonetheless? More later
….
79
Internet Checksum Example
 Note

When adding numbers, a carryout from the
most significant bit needs to be added to the
result
 Example: add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
80
Network layer
 transport segment from




sending to receiving host
on sending side
encapsulates segments
into datagrams
on rcving side, delivers
segments to transport
layer
network layer protocols
in every host, router
router examines header
fields in all IP datagrams
passing through it
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
network
data link
data link
physical
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
81
Two Key Network-Layer Functions
 forwarding: move
packets from router’s
input to appropriate
router output
 routing: determine
route taken by
packets from source
to dest.

analogy:
 routing:
process of
planning trip from
source to dest
 forwarding:
process
of getting through
single interchange
routing algorithms
82
IP datagram format
IP protocol version
number
header length
(bytes)
“type” of data
max number
remaining hops
(decremented at
each router)
upper layer protocol
to deliver payload to
how much overhead
with TCP?
 20 bytes of TCP
 20 bytes of IP
 = 40 bytes + app
layer overhead
32 bits
ver head. type of
len service
length
fragment
16-bit identifier flgs
offset
upper
time to
header
layer
live
checksum
total datagram
length (bytes)
for
fragmentation/
reassembly
32 bit source IP address
32 bit destination IP address
Options (if any)
data
(variable length,
typically a TCP
or UDP segment)
E.g. timestamp,
record route
taken, specify
list of routers
to visit.
83
IP Addressing: introduction
 IP address: 32-bit
identifier for host,
router interface
 interface: connection
between host/router
and physical link



router’s typically have
multiple interfaces
host typically has one
interface
IP addresses
associated with each
interface
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.2
223.1.3.1
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
84
IP addresses – decimal notation
10000000
128
Classe
00001010
.
10
00000010
.
menor endereço
2
.
00011110
30
maior endereço
A
1.0.0.0 126.0.0.0
B
128.1.0.0 191.255.0.0
C
192.0.1.0 223.255.255.0
D
224.0.0.0 239.255.255.255
E
240.0.0.0 255.255.255.254
85
IP addresses – class-full
addressing
hostid
netid
Classe A
0
Classe B
1 0
Classe C
1 1 0
Classe D
1 1 1 0
31
23
15
7
0
hostid
netid
netid
hostid
endereço multicast
86
IP addresses – address space
Classe # bits no # máximo # bits no # máximo de
prefixo de redes
sufixo hosts por rede
A
7
128
24
16,777,216
B
C
14
21
16,384
16
2,097,152 8
65,536
256
NOTE: Some of these IP addresses can not be used!
87
IP addresses - example
1 28 .1 0 .2.8
1 28 .1 0 .2.2 6
E th e rn e t h o st
E th e rn e t h o st
E th e rn e t 12 8 .1 0.0 .0
1 28 .1 0 .2.3
m u lti-h o m ed h o s t
1 92 .5 .4 8.3
1 28 .1 0 .2.7 0
1 92 .5 .4 8.7
T o k en -rin g
1 92 .5 .4 8.0
1 0.0 .0 .0
1 92 .5 .4 8.6
ro u te r
1 0.0 .0 .3 7
ro u te r
1 92 .5 .4 8.1
to k en rin g h o s t
88
Special IP addresses
ESTE HOST1
tudo 0s
host
tudo 0s
BROADCAST LOCAL2
tudo 1s
tudo 1s
net
qualquer (em geral 1)
127
tudo 0s
net
1 Permitido
BROADCAST DIRIGIDO PARA net2
LOOPBACK3
ESTA net4
apenas na inicialização; nunca é endereço destino válido
2 Nunca
é endereço origem válido
3 Nunca
deve aparecer na rede
4
host NESTA REDE1
Reservado para designar a rede
89
IP addressing – Mask
 Iniatially IP addresses had fixed borders
between netid and hostid (classes A, B and
C)
 Nowadays the border is defined by the
network mask
d e c im a l
e n d e re ç o IP
m á s c a ra
b in á rio
10.
0 .0 .1
00001010
00000000 00000000 00000001
255.
0 .0 .0
11111111
00000000 00000000 00000000
host
re d e
re d e
host
90
Subnets
 IP address:
 subnet part (high
order bits)
 host part (low order
bits)

What’s a subnet ?


device interfaces with
same subnet part of IP
address
can physically reach
each other without
intervening router
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
subnet
223.1.3.1
223.1.3.2
network consisting of 3 subnets
91
Subnets
Recipe
 To determine the
subnets, detach each
interface from its
host or router,
creating islands of
isolated networks.
Each isolated network
is called a subnet.
223.1.1.0/24
223.1.2.0/24
223.1.3.0/24
Subnet mask: /24
92
Configuration of IP address
DHCP
manual
93
IP Fragmentation & Reassembly
 network links have MTU
(max.transfer size) - largest
possible link-level frame.
 different link types,
different MTUs
 large IP datagram divided
(“fragmented”) within net
 one datagram becomes
several datagrams
 “reassembled” only at final
destination
 IP header bits used to
identify, order related
fragments
fragmentation:
in: one large datagram
out: 3 smaller datagrams
reassembly
94
IP Fragmentation and Reassembly
length ID fragflag offset
=4000 =x
=0
=0
Example
 4000 byte
One large datagram becomes
datagram
several smaller datagrams
 MTU = 1500 bytes
1480 bytes in
data field
offset =
1480/8
length ID fragflag offset
=1500 =x
=1
=0
length ID fragflag offset
=1500 =x
=1
=185
length ID fragflag offset
=1040 =x
=0
=370
95
Fragmentation example (I)
10.0.0.1
10.0.0.0
Eth0
Router1
11.0.0.1
Eth1
10.0.0.2
Default Gateway: 10.0.0.1
Router>enable
Router#conf t
Router(config)#hostname Router1
Router1(config)#interface ethernet 1
Router1(config-if)#mtu 100
Router1(config-if)#exit
Router1(config)#end
Router1#write
Building configuration...
[OK]
11.0.0.0
11.0.0.2
12.0.0.1
Eth0
Eth1
Router2
11.0.0.3
12.0.0.0
12.0.0.2
Default Gateway:12.0.0.1
C:\>ping -l 300 12.0.0.2
Pinging 12.0.0.2 with 300 bytes of data:
Reply
Reply
Reply
Reply
from
from
from
from
12.0.0.2:
12.0.0.2:
12.0.0.2:
12.0.0.2:
bytes=300
bytes=300
bytes=300
bytes=300
time=223ms
time=223ms
time=223ms
time=223ms
TTL=116
TTL=116
TTL=116
TTL=116
Configuração do MTU do interface 1 do router 1
96
Fragmentation example (II)
10.0.0.1
10.0.0.0
10.0.0.2
Default Gateway: 10.0.0.1
Eth0
Router1
11.0.0.1
Eth1
11.0.0.0
11.0.0.3
11.0.0.2
12.0.0.1
Eth0
Eth1
Router2
12.0.0.0
12.0.0.2
Default Gateway:12.0.0.1
Packets captured in network 11.0.0.0
97
Fragmentation example (III)
Packet nº 1 captured in network 11.0.0.0
98
Fragmentation example (IV)
Packet nº 2 captured in network 11.0.0.0
99
Fragmentation example (V)
Packet nº 4 captured in network 11.0.0.0
100
From source to 1st router
Router
default gateway
Router
origem
destino
Router
 When a node wants to send an IP datagram to a node
that is in another subnet, it must send the datagram to
the default gateway


Configured by the user (or through DHCP)
IP address of one of the routers of the source node’s subnet, namely
the IP address of the router interface attached to the subnet
101
ICMP: Internet Control Message Protocol
 used by hosts & routers to
communicate network-level
information
 error reporting:
unreachable host, network,
port, protocol
 echo request/reply (used
by ping)
 network-layer “above” IP:
 ICMP msgs carried in IP
datagrams
 ICMP message: type, code plus
first 8 bytes of IP datagram
causing error
Type
0
3
3
3
3
3
3
4
Code
0
0
1
2
3
6
7
0
8
9
10
11
12
0
0
0
0
0
description
echo reply (ping)
dest. network unreachable
dest host unreachable
dest protocol unreachable
dest port unreachable
dest network unknown
dest host unknown
source quench (congestion
control - not used)
echo request (ping)
route advertisement
router discovery
TTL expired
bad IP header
102
ICMP – Encapsulation
ICMP
c a b e ç a lh o
IP
cabeçalho
MAC
Fields common to all
ICMP messages
d a d o s IP
1
ty p e
1
code
2
checksum
dados MAC
103
1
1
2
2
2
Ping
Echo Request
Echo Reply
type = 0 ou 8
code = 0
checksum
identifier
sequence number
optional data
Echo Request
Router
Echo Reply
 The source sends a message of type Echo Request
 The destination answers with a message of type Echo
Reply
 Tests (i) the protocol stack of the source up to ICMP
(ii) the same for the receiver (iii) the connectivity
between source and destination in both directions
104
Ping options
C:\>ping
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] destination-list
Options:
-t
-a
-n
-l
-f
-i
-v
-r
-s
-j
-k
-w
count
size
TTL
TOS
count
count
host-list
host-list
timeout
Ping the specifed host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
Resolve addresses to hostnames.
Number of echo requests to send.
Send buffer size.
Set Don't Fragment flag in packet.
Time To Live.
Type Of Service.
Record route for count hops.
Timestamp for count hops.
Loose source route along host-list.
Strict source route along host-list.
Timeout in milliseconds to wait for each reply.
105
Ping example
192.168.8.1
192.168.8.0
Router
192.168.8.224
1
1
2
2
2
type = 0 ou 8
code = 0
checksum
identifier
sequence number
optional data
Ping enviado pela estação:
C:\>ping 192.168.8.1
Pinging 192.168.8.1 with 32 bytes of data:
Reply
Reply
Reply
Reply
from
from
from
from
192.168.8.1:
192.168.8.1:
192.168.8.1:
192.168.8.1:
bytes=32
bytes=32
bytes=32
bytes=32
time<10ms
time<10ms
time<10ms
time<10ms
TTL=126
TTL=126
TTL=126
TTL=126
106
Traceroute
 Discovers the routers in the path from source to destination
 Uses the TTL field and the ICMP time exceeded message
TTL = 1
C:\>tracert
ICMP time exceeded
Usage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout]
target_name
Router
Options:
-d
-h maximum_hops
-j host-list
-w timeout
TTL = 2
Do not resolve addresses to hostnames.
Maximum number of hops to search for target.
Loose source route along host-list.
Wait timeout milliseconds for each reply.
ICMP time exceeded
TTL = 3
Router
TTL = 4
Router
107
Traceroute example
C:\>tracert -d 193.136.173.30
Tracing route to 193.136.173.30 over a maximum of 30 hops
1
2
3
<10 ms
<10 ms
<10 ms
<10 ms
<10 ms
<10 ms
<10 ms
<10 ms
<10 ms
193.136.92.1
193.137.172.254
193.136.173.30
Trace complete.
108
Link Layer: Introduction
Some terminology:
 hosts and routers are nodes
 communication channels that
connect adjacent nodes along
communication path are links



wired links
wireless links
LANs
 layer-2 packet is a frame,
encapsulates datagram
data-link layer has responsibility of
transferring datagram from one node
to adjacent node over a link
109
Where is the link layer implemented?
 in each and every host
 link layer implemented in
“adaptor” (aka network
interface card NIC)


Ethernet card, PCMCI
card, 802.11 card
implements link, physical
layer
 attaches into host’s
system buses
 combination of
hardware, software,
firmware
host schematic
application
transport
network
link
cpu
memory
controller
link
physical
host
bus
(e.g., PCI)
physical
transmission
network adapter
card
110
Adaptors Communicating
datagram
datagram
controller
controller
receiving host
sending host
datagram
frame
 sending side:
 encapsulates datagram in
frame
 adds error checking bits,
rdt, flow control, etc.
 receiving side
 looks for errors, rdt, flow
control, etc
 extracts datagram, passes
to upper layer at receiving
side
111
Local Area Networks (LANs)
 Interconnect nodes that are relatively close through
broadcast links
 Many technologies

Ethernet, Token Ring, 802.11, FDDI, …
estações
LAN
Servidor
Web
R
O
U
T
E
R
Internet
estações
112
Ethernet
 The MAC protocol is in geral CSMA/CD
 Supports technologies with different transmission media and
transfer rate



10 Mb/s, 100 Mb/s, 1 Gb/s, 10 Gb/s
Coaxial cable , twisted pair, optical fiber
10BASE5, 10BASE2, 10BASET, 100BASET, ...
 Segments are interconnected through hubs or receivers
Router
Repetidor
113
LAN Addresses
Each adapter on LAN has unique LAN address
1A-2F-BB-76-09-AD
71-65-F7-2B-08-53
LAN
(wired or
wireless)
Broadcast address =
FF-FF-FF-FF-FF-FF
= adapter
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
114
LAN Address (more)
 MAC address allocation administered by IEEE
 manufacturer buys portion of MAC address space
(to assure uniqueness)
 See http://standards.ieee.org/regauth/ for
obtaining addresses
 analogy:
(a) MAC address: like Social Security Number
(b) IP address: like postal address
 MAC flat address ➜ portability

can move LAN card from one LAN to another
 IP hierarchical address NOT portable
 address depends on IP subnet to which node is attached
115
Ethernet frame format
 Dois tipos de tramas: Ethernet II e 802.3
 Endereços


Endereços IEEE (6 bytes)
Se NIC recebe trama com endereço destino igual ao endereço do NIC ou com
endereço de broadcast (e.g. ARP Request), então envia trama ao módulo de
software identificado no campo Protocol; caso contrário, NIC descarta trama
 Protocol: indica o tipo de protocolo transportado na trama (IP,
ARP, IPX, ...)
 Length: comprimemto da trama (campo dados)
 LLC: vários campos incluindo tipo de protocolo
 Frame Check Sequence (FCS): usado para detecção de erros
Ethernet II
6
6
2
46 - 1500
4
destination
source
protocol
data
FCS
> 1500
802.3
6
6
2
3
43 - 1497
4
destination
source
length
LLC
data
FCS
 1500
116
Encapsulation TFTP – the complete story
builds
Ethernet
header
builds
IP
header
builds
UDP
header
builds
TFTP
header
TFTP
header
calls driver
Ethernet
Sends bits to
“the wire”
Ethernet
header
IP
header
IP
header
UDP
header
UDP
header
UDP
header
TFTP
header
TFTP
header
TFTP
header
calls IP
calls UDP
Ethernet
data
IP
data
UDP
data
message
message
message
message
TFTP
message
UDP
segment
IP
datagram
Ethernet
frame
117
ARP: Address Resolution Protocol
Question: how to determine
MAC address of B
knowing B’s IP address?
137.196.7.78
1A-2F-BB-76-09-AD
137.196.7.23
71-65-F7-2B-08-53
137.196.7.88
 Each IP node (host,
router) on LAN has
ARP table
 ARP table: IP/MAC
address mappings for
some LAN nodes
137.196.7.14
< IP address; MAC address; TTL>

LAN
58-23-D7-FA-20-B0
TTL (Time To Live): time
after which address
mapping will be forgotten
(typically 20 min)
0C-C4-11-6F-E3-98
118
ARP protocol: Same LAN (network)
 A wants to send datagram
to B, and B’s MAC address
not in A’s ARP table.
 A broadcasts ARP query
packet, containing B's IP
address
 dest MAC address = FFFF-FF-FF-FF-FF
 all machines on LAN
receive ARP query
 B receives ARP packet,
replies to A with its (B's)
MAC address

frame sent to A’s MAC
address (unicast)
 A caches (saves) IP-to-
MAC address pair in its
ARP table until information
becomes old (times out)
 soft state: information
that times out (goes
away) unless refreshed
 ARP is “plug-and-play”:
 nodes create their ARP
tables without
intervention from net
administrator
119
ARP protocol
ARP Request
4.1.1.115
00-10-4B-4E-74-25
4.1.1.1
00-60-97-D4-9F-A0
ARP Response
4.1.1.115
00-10-4B-4E-74-25
4.1.1.1
00-60-97-D4-9F-A0
120
ARP Request
ARP Request enviado pela estação 4.1.1.115 para
saber o endereço MAC da estação 4.1.1.1.
121
ARP Response
Resposta da estação 4.1.1.1 enviada através de ARP Response:
o endereço MAC é 00-60-97-d4-9f-a0
122
ARP command
ARP -a [inet_addr] [-N if_addr]
-a
-g
inet_addr
-N if_addr
-d
-s
eth_addr
if_addr
Displays current ARP entries by interrogating the current
protocol data. If inet_addr is specified, the IP and Physical
addresses for only the specified computer are displayed. If
more than one network interface uses ARP, entries for each ARP
table are displayed.
Same as -a.
Specifies an internet address.
Displays the ARP entries for the network interface specified
by if_addr.
Deletes the host specified by inet_addr.
Adds the host and associates the Internet address inet_addr
with the Physical address eth_addr. The Physical address is
given as 6 hexadecimal bytes separated by hyphens. The entry
is permanent.
Specifies a physical address.
If present, this specifies the Internet address of the
interface whose address translation table should be modified.
If not present, the first applicable interface will be used.
Example:
> arp -s 157.55.85.212
> arp -a
00-aa-00-62-c6-09
.... Adds a static entry.
.... Displays the arp table.
123
ARP example
C:\>arp -a
192.168.8.0
Estação A
192.168.8.224
Estação B
192.168.8.220
Interface: 192.168.8.224 on Interface 0x1000002
Internet Address
Physical Address
Type
192.168.8.220
00-60-97-d4-9f-a0
dynamic
1º ping
2º ping
C:\>arp -d 192.168.8.220
C:\>arp -a
No ARP Entries Found
3º ping
124
Addressing: routing to another LAN
walkthrough: send datagram from A to B via R
assume A knows B’s IP address
88-B2-2F-54-1A-0F
74-29-9C-E8-FF-55
A
111.111.111.111
E6-E9-00-17-BB-4B
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
111.111.111.112
R
222.222.222.221
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
 two ARP tables in router R, one for each IP
network (LAN)
125
 A creates IP datagram with source A, destination B
 A uses ARP to get R’s MAC address for 111.111.111.110
 A creates link-layer frame with R's MAC address as dest,





frame contains A-to-B IP datagram
This is a really important
A’s NIC sends frame
example – make sure you
R’s NIC receives frame
understand!
R removes IP datagram from Ethernet frame, sees its
destined to B
R uses ARP to get B’s MAC address
R creates frame containing A-to-B IP datagram sends to B
88-B2-2F-54-1A-0F
74-29-9C-E8-FF-55
A
E6-E9-00-17-BB-4B
111.111.111.111
222.222.222.220
111.111.111.110
111.111.111.112
222.222.222.221
1A-23-F9-CD-06-9B
R
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
126
Routing from A to B
223.1.1.2
223.1.1.1
223.1.1.4
 Host A verifies that B is on
C
its subnet, when applying
mask 255.255.255.0 to
223.1.2.2
 Does ARP to 223.1.2.2, if
required
 Sends datagram to B,
encapsulated in MAC frame
223.1.1.0/24
223.1.1.3
223.1.9.2
i1
223.1.9.0/24
223.1.9.1
223.1.7.5
223.1.7.1
i3
i2
223.1.8.2
223.1.8.0/24
i1

R2
i2
i1
223.1.2.0/24
223.1.2.1
223.1.7.3
i2
223.1.7.0/24
223.1.8.1
A
R3
i3
R1
223.1.2.6
i3
MAC dest addr = MAC of B
223.1.3.27
223.1.3.0/24
B
223.1.2.2
223.1.3.1
223.1.3.2
MAC several
223.1.2.1 223.1.2.2
header
IP
data
127
Routing from A to C
223.1.1.2
223.1.1.1
223.1.1.4
C
223.1.1.0/24
223.1.1.3
223.1.9.2
i1
223.1.9.0/24
223.1.9.1
223.1.7.5
223.1.7.1
i3
i2
223.1.8.2
223.1.8.0/24
R2
i2
i1
i1
223.1.3.27
223.1.3.0/24
223.1.2.0/24
223.1.2.1
223.1.7.3
i2
223.1.7.0/24
223.1.8.1
A
R3
i3
R1
223.1.2.6
i3
B
223.1.2.2
223.1.3.1
223.1.3.2
Initially...
 Host A verifies that C is on
another subnet, when
applying mask 255.255.255.0
to 223.1.1.4
 Does ARP to the default
gateway (223.1.2.6), if
required
 Sends datagram to R1,
encapsulated in MAC frame

MAC dest addr = MAC of
223.1.2.6
MAC several
223.1.2.1 223.1.1.4
header
IP
data
128
Routing from A to C
223.1.1.2
223.1.1.1
223.1.1.4
C
Subnet
Next hop
Interface
223.1.1.0/24
223.1.8.2
i2
223.1.2.0/24
direct
i1
223.1.3.0/24
223.1.8.2
i2
223.1.7.0/24
223.1.8.2
i2
223.1.8.0/24
direct
i2
223.1.9.0/24
direct
i3
Routing table of R1
223.1.1.0/24
223.1.1.3
223.1.9.2
i1
223.1.9.0/24
i3
R3
When datagram arrives at R1...
 Search routing table
223.1.7.3
i2

223.1.7.5
223.1.7.0/24

223.1.9.1
i3
223.1.8.1
R1
i2
223.1.2.6
i1
223.1.2.1
R2
i2
i1
223.1.2.0/24
A
223.1.8.2
223.1.8.0/24
 Send datagram to R2 via i2,
223.1.7.1
i3
Interface = i2
Next hop = 223.1.8.2
encapsulated in PPP frame
223.1.3.27
223.1.3.0/24
B
223.1.2.2
223.1.3.1
223.1.3.2
PPP several
223.1.2.1 223.1.1.4
header
IP
data
129
Routing from A to C
223.1.1.2
223.1.1.1
223.1.1.4
C
Subnet
Next hop
Interface
223.1.1.0/24
223.1.7.3
i3
223.1.2.0/24
223.1.8.1
i2
223.1.3.0/24
direct
i1
223.1.7.0/24
direct
i3
223.1.8.0/24
direct
i2
223.1.9.0/24
223.1.7.3
i3
Routing table of R2
223.1.1.0/24
223.1.1.3
223.1.9.2
i1
223.1.9.0/24
223.1.9.1
223.1.7.3
i2

223.1.7.1
223.1.8.2
223.1.8.0/24
i1
R2
i2
i1
223.1.2.0/24
223.1.3.27
223.1.3.0/24
A
B
223.1.2.1
223.1.2.2
Interface = i3
Next hop = 223.1.7.3
 Does ARP to 223.1.7.3, if
i3
i2

223.1.7.5
i3
R1
When datagram arrives at R2...
 Search routing table
R3
223.1.7.0/24
223.1.8.1
223.1.2.6
i3
required
 Sends datagram to R3 via i3,
encapsulated in MAC frame

223.1.3.1
223.1.3.2
MAC dest addr = MAC of 223.1.7.3
MAC several
223.1.2.1 223.1.1.4
header
IP
data
130
Routing from A to C
223.1.1.2
223.1.1.1
223.1.1.4
C
Rede
Next hop
Interface
223.1.1.0/24
direct
i3
223.1.2.0/24
223.1.9.1
i1
223.1.3.0/24
223.1.7.1
i2
223.1.7.0/24
direct
i2
223.1.8.0/24
223.1.7.1
i2
223.1.9.0/24
direct
i1
Routing table of R3
223.1.1.0/24
223.1.1.3
223.1.9.2
i1
223.1.9.0/24
223.1.9.1
223.1.7.3
i2

223.1.8.2
223.1.8.0/24
i1
R2
i2
i1
223.1.2.0/24
223.1.3.27
223.1.3.0/24
A
B
223.1.2.1
223.1.2.2
required
 Sends datagram to C via i3,
encapsulated in MAC frame

223.1.3.1
Interface = i3
Next hop = directo
 Does ARP to 223.1.1.4, if
223.1.7.1
i3
i2

223.1.7.5
i3
R1
When datagram arrives at R3...
 Search routing table
R3
223.1.7.0/24
223.1.8.1
223.1.2.6
i3
223.1.3.2
MAC dest addr = MAC of 223.1.1.4
MAC several
223.1.2.1 223.1.1.4
header
IP
data
131
Bibliography
 James Kurose, Keith Ross, “Computer Networking – A
Top-Down Approach”, 4th edition, 2007, Addison
Wesley






Chapter 1 – “Computer Networks and the Internet”
Section 4.1 – “Introduction”
Section 4.4 – “The Internet Protocol (IP): Forwarding and
Addressing in the Internet”
Section 5.1 – “Link Layer: Introduction and Services”
Section 5.4 – “Link-Layer Addressing”
Section 5.5 – “Ethernet”
132