network layer protocols in every host, router router examines header fields in all IP datagrams passing through it application transport network data link physical application transp
Trang 1Chapter 4
Network Layer
Computer Networking: A Top Down
Approach
6 th edition Jim Kurose, Keith Ross
Addison-Wesley March 2012
A note on the use of these ppt slides:
We’re making these slides freely available to all (faculty, students, readers)
They’re in PowerPoint form so you see the animations; and can add, modify,
and delete slides (including this one) and slide content to suit your needs
They obviously represent a lot of work on our part In return for use, we only
ask the following:
If you use these slides (e.g., in a class) that you mention their source
(after all, we’d like people to use our book!)
If you post any slides on a www site, that you note that they are adapted
from (or perhaps identical to) our slides, and note our copyright of this
material.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2012
Trang 2Chapter 4: network layer
chapter goals:
understand principles behind network layer services:
network layer service models
forwarding versus routing
how a router works
routing (path selection)
broadcast, multicast
instantiation, implementation in the Internet
Trang 34.7 broadcast and multicast routingChapter 4: outline
Trang 4 network layer protocols
in every host, router
router examines header
fields in all IP datagrams
passing through it
application transport
network
data link physical
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
data link physical
network
data link physical
network
data link physical
network
data link physical
network
data link physical
network
data link physical
Trang 5Two key network-layer
forwarding : process
of getting through single interchange
Trang 62 3
0111
value in arriving packet’s header
routing algorithm
local forwarding table header value output link
0100 0101 0111 1001
3 2 2 1
Interplay between routing and forwarding
routing algorithm determines end-end-path through network forwarding table determines local forwarding at this router
Trang 7Connection setup
3rd important function in some network
architectures:
ATM, frame relay, X.25
before datagrams flow, two end hosts and
intervening routers establish virtual
connection
routers get involved
network vs transport layer connection
Trang 8Network service model
Q: What service model for “channel”
transporting datagrams from sender to
in-order datagram delivery
guaranteed minimum bandwidth to flow
restrictions on changes in inter- packet spacing
Trang 9Network layer service
VBR ABR UBR
Bandwidth none
constant rate
guaranteed rate
guaranteed minimum none
Loss no yes yes no no
Order no yes yes yes yes
Timing no
yes yes no no
Congestion feedback
no (inferred via loss) no
congestion no
congestion yes
no Guarantees ?
Trang 104.7 broadcast and multicast routingChapter 4: outline
Trang 11Connection, connection-less
service
datagram network provides
network-layer connectionless service
virtual-circuit network provides
network-layer connection service
analogous to TCP/UDP
connecton-oriented / connectionless
transport-layer services, but:
Trang 12Virtual circuits
call setup, teardown for each call before data can flow
each packet carries VC identifier (not destination host
address)
every router on source-dest path maintains “state” for
each passing connection
link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable
Trang 13VC implementation
a VC consists of:
1 path from source to destination
2 VC numbers, one number for each link
along path
3 entries in forwarding tables in routers
along path
packet belonging to VC carries VC
number (rather than dest address)
VC number can be changed on each
link.
new VC number comes from forwarding
table
Trang 14VC forwarding table
1 2 3
VC number
interface number
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
forwarding table in
northwest router:
VC routers maintain connection state information!
Trang 15application transport
network
data link physical
Virtual circuits: signaling
protocols
1 initiate call 2 incoming call
Trang 16Datagram networks
no call setup at network layer
routers: no state about end-to-end
connections
no network-level concept of “connection”
packets forwarded using destination host
address
1 send datagrams
application transport
network
data link physical
Trang 172 3
3 2 2 1
4 billion IP addresses, so rather than list individual destination address
list range of
addresses (aggregate table entries)
Trang 18Destination Address Range
Trang 19Longest prefix matching
Destination Address Range
DA: 11001000 00010111 00010110 10100001 which interface?
when looking for forwarding table entry
for given destination address, use longest
address prefix that matches destination
address.
longest prefix matching
Link interface 0
1 2 3
Trang 20 many link types
different characteristics
uniform service difficult
“smart” end systems
Trang 214.7 broadcast and multicast routingChapter 4: outline
Trang 22Router architecture overview
two key router functions:
run routing algorithms/protocol (RIP, OSPF, BGP)
forwarding datagrams from incoming to outgoing link
high-seed switching fabric
routing processor
forwarding data plane (hardware)
routing, management control plane (software)
forwarding tables computed,
pushed to input ports
Trang 23line termination
link layer protocol (receive)
lookup, forwarding
goal: complete input port processing
Trang 24Switching fabrics
transfer packet from input buffer to
appropriate output buffer
switching rate: rate at which packets
can be transferred from inputs to
outputs
often measured as multiple of input/output line rate
N inputs: switching rate N times line rate desirable
three types of switching fabrics
memory memory
Trang 25Switching via memory
first generation routers:
traditional computers with switching under direct control
of CPU
packet copied to system’s memory
CPU extracts dest address from packet’s header, looks up
output port in forwarding table, copies to output port
speed limited by memory bandwidth (2 bus crossings per
datagram)
one packet at a time
input port (e.g., Ethernet)
memory
output port (e.g., Ethernet)
system bus
Trang 26Switching via a bus
datagram from input port
memory
to output port memory via a
shared bus
bus contention: switching
speed limited by bus
Trang 27Switching via interconnection
network
forwards multiple packets in
parallel
banyan networks, crossbar, other
interconnection nets initially
developed to connect processors
in multiprocessor
When packet from port A needs to
forwarded to port Y, controller
closes cross point at intersection
of two buses
advanced design: fragmenting
datagram into fixed length cells,
switch cells through the fabric
crossbar
A B C
X Y Z
Trang 28link layer protocol (send)
switch
fabric
datagram buffer
queueing
Trang 29Output port queueing
suppose Rswitch is N times faster than Rline
still have output buffering when multiple inputs send to same output
at t, packets more
from input to output
one packet time later
switch fabric
switch fabric
Trang 30How much buffering?
RFC 3439 rule of thumb: average
buffering equal to “typical” RTT (say
250 msec) times link capacity C
e.g., C = 10 Gpbs link: 2.5 Gbit buffer
recent recommendation: with N flows,
buffering equal to
RTT C.
N
Trang 31Input port queuing
fabric slower than input ports combined
queuing may occur at input queues
queuing delay and loss due to input buffer
overflow!
Head-of-the-Line (HOL) blocking: queued
datagram at front of queue prevents others in queue from moving forward
output port contention:
only one red datagram can
be transferred.
lower red packet is blocked
switch fabric
one packet time later: green packet experiences HOL
switch fabric
Trang 324.7 broadcast and multicast routingChapter 4: outline
Trang 33The Internet network layer
forwarding table
host, router network layer functions:
• error reporting
• router “signaling”
transport layer: TCP, UDP
link layer physical layer
network
layer
Trang 34ver length
32 bits
data (variable length, typically a TCP
or UDP segment)
16-bit identifier
header checksum
time to live
32 bit source IP address
head.
len
type of service
flgs fragment
offset upper
layer
32 bit destination IP address
options (if any)
IP datagram format
IP protocol version
number header length
(bytes)
upper layer protocol
to deliver payload to
total datagram length (bytes)
reassembly max number
remaining hops (decremented at
each router)
e.g timestamp, record route taken, specify list of routers
Trang 35 IP header bits used to
identify, order related
fragmentation:
in: one large datagram
out: 3 smaller datagrams
reassembly
Trang 36IP fragmentation,
reassembly
Trang 374.7 broadcast and multicast routingChapter 4: outline
Trang 38and physical link
routers typically have
multiple interfaces
host typically has one
active interface (e.g.,
wired Ethernet, wireless
223.1.3.2 223.1.3.1
223.1.3.27
223.1.1.1 = 11011111 00000001 00000001 00000001
Trang 39223.1.3.2 223.1.3.1
223.1.3.27
A: wired Ethernet interfaces
connected by Ethernet switches
A: wireless WiFi interfaces
connected by WiFi base station
For now: don’t need to worry
about how one interface is
connected to another (with no
intervening router)
Trang 40223.1.1.2
223.1.3.27 223.1.2.2
223.1.2.1
Trang 41223.1.1.2
223.1.3.27 223.1.2.2
223.1.2.1
Trang 42how many? 223.1.1.1
223.1.1.3
223.1.1.4
223.1.2.2 223.1.2.1
223.1.2.6
223.1.3.2 223.1.3.1
223.1.3.27
223.1.1.2
223.1.7.0
223.1.7.1 223.1.8.0
223.1.8.1 223.1.9.1
223.1.9.2
Subnets
Trang 43IP addressing: CIDR
CIDR: C lassless I nter D omain R outing
subnet portion of address of arbitrary
host part
200.23.16.0/23
Trang 44IP addresses: how to get
one?
Q: how does network get subnet part of IP
addr?
A: gets allocated portion of its provider
ISP’s address space
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 … … ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
Trang 45Hierarchical addressing: route aggregation
“Send me anything with addresses beginning 200.23.16.0/20”
200.23.16.0/23 200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP Organization 0
Organization 1
ISPs-R-Us “Send me anything
with addresses beginning 199.31.0.0/16”
Trang 46ISPs-R-Us has a more specific route to Organization 1
“Send me anything with addresses beginning 200.23.16.0/20 ”
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP Organization 0
Organization 1
ISPs-R-Us “Send me anything
with addresses beginning 199.31.0.0/16
Trang 47IP addressing: how to get a
Trang 48IP addresses: how to get
one?
Windows:
control-panel->network->configuration->tcp/ip->properties
UNIX: /etc/rc.config
DHCP: Dynamic Host Configuration Protocol:
dynamically get address from as server
“plug-and-play”
Trang 49DHCP: Dynamic Host Configuration
Protocol
goal: allow host to dynamically obtain its IP address from network
server when it joins network
can renew its lease on address in use
allows reuse of addresses (only hold address while connected/“on
”)
support for mobile users who want to join network (more shortly)
DHCP overview:
host broadcasts “DHCP discover” msg [optional]
DHCP server responds with “DHCP offer” msg [optional]
host requests IP address: “DHCP request” msg
DHCP server sends address: “DHCP ack” msg
Trang 50223.1.3.27 223.1.2.2
223.1.2.1
DHCP server
arriving DHCP client needs address in this network
Trang 51DHCP server: 223.1.2.5 arriving
client
DHCP discover
src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4
transaction ID: 654 lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 223.1.2.4
transaction ID: 655 lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4
transaction ID: 655
DHCP client-server
scenario
Trang 52DHCP: more than IP
addresses
DHCP returns:
IP address
address of first-hop router for client
name and IP address of DNS sever
network mask (indicating network versus
host portion of address)
Trang 53 connecting laptop needs its IP address, addr of first-hop router, addr of DNS server: use DHCP
router with DHCP server built into router
DHCP request encapsulated in UDP, encapsulated in IP, encapsulated in 802.3 Ethernet
Ethernet frame broadcast (dest:
FFFFFFFFFFFF ) on LAN, received at router running DHCP server
Ethernet demuxed to
IP demuxed, UDP demuxed to DHCP
168.1.1.1
DHCP UDP IP Eth Phy
Trang 54 DCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name &
IP address of DNS server
encapsulation of DHCP server, frame forwarded to client, demuxing up to
DHCP at client
DHCP: example
router with DHCP server built into router
DHCP
DHCP UDP IP Eth Phy
Trang 55DHCP:
Wireshark
LAN)
Message type: Boot Reply (2)
Hardware type: Ethernet Hardware address length: 6 Hops: 0
Transaction ID: 0x6b3a11b7
Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast)
Client IP address: 192.168.1.101 (192.168.1.101)
Your (client) IP address: 0.0.0.0 (0.0.0.0)
Next server IP address: 192.168.1.1 (192.168.1.1)
Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given
Boot file name not given Magic cookie: (OK)
Option: (t=53,l=1) DHCP Message Type = DHCP ACK Option: (t=54,l=4) Server Identifier = 192.168.1.1 Option: (t=1,l=4) Subnet Mask = 255.255.255.0 Option: (t=3,l=4) Router = 192.168.1.1
Option: (6) Domain Name Server Length: 12; Value: 445747E2445749F244574092;
IP Address: 68.87.71.226;
IP Address: 68.87.73.242;
IP Address: 68.87.64.146 Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net."
reply
Message type: Boot Request (1)
Hardware type: Ethernet
Hardware address length: 6
Your (client) IP address: 0.0.0.0 (0.0.0.0)
Next server IP address: 0.0.0.0 (0.0.0.0)
Relay agent IP address: 0.0.0.0 (0.0.0.0)
Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
Server host name not given
Boot file name not given
Magic cookie: (OK)
Option: (t=53,l=1) DHCP Message Type = DHCP Request
Option: (61) Client identifier
Length: 7; Value: 010016D323688A;
Hardware type: Ethernet
Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
Option: (t=50,l=4) Requested IP Address = 192.168.1.101
Option: (t=12,l=5) Host Name = "nomad"
Option: (55) Parameter Request List
Length: 11; Value: 010F03062C2E2F1F21F92B
1 = Subnet Mask; 15 = Domain Name
3 = Router; 6 = Domain Name Server
44 = NetBIOS over TCP/IP Name Server
……
request
Trang 56NAT: network address
local network (e.g., home network)
10.0.0.0/24
rest of Internet
datagrams with source or destination in this networkhave 10.0.0.0/24 address for source, destination (as usual)
all datagrams leaving
localnetwork have same
single source NAT IP
address:
138.76.29.7,different