Chapter - 4 - Network Layer
Chapter - 4 - Network Layer
Network Layer
Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012
layer network
physical
application
transport
value in arriving
packet’s header
0111 1
3 2
v call setup, teardown for each call before data can flow
v each packet carries VC identifier (not destination host
address)
v every router on source-dest path maintains “state” for
each passing connection
v link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable
service)
Network Layer 4-12
VC 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
v packet belonging to VC carries VC number
(rather than dest address)
v VC number can be changed on each link.
§ new VC number comes from forwarding table
1 3
2
VC number
interface
forwarding table in number
northwest router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application application
5. data flow begins 6. receive data
transport transport
network 4. call connected 3. accept call
1. initiate call network
data link 2. incoming call
data link
physical physical
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
IP destination address in
arriving packet’s header
1
3 2
otherwise 3
examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 which interface?
Network Layer 4-19
Datagram or VC network: why?
Internet (datagram) ATM (VC)
v data exchange among v evolved from telephony
computers v human conversation:
§ “elastic” service, no strict § strict timing, reliability
timing req. requirements
§ need for guaranteed service
v many link types v “dumb” end systems
§ different characteristics § telephones
§ uniform service difficult § complexity inside
v “smart” end systems network
(computers)
§ can adapt, perform control,
error recovery
§ simple inside network,
complexity at “edge”
forwarding data
plane (hardware)
high-seed
switching
fabric
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet v given datagram dest., lookup output port
see chapter 5 using forwarding table in input port
memory (“match plus action”)
v goal: complete input port processing at
‘line speed’
v queuing: if datagrams arrive faster than
forwarding rate into switch fabric
Network Layer 4-24
Switching fabrics
v transfer packet from input buffer to appropriate
output buffer
v switching rate: rate at which packets can be
transfer from inputs to outputs
§ often measured as multiple of input/output line rate
§ N inputs: switching rate N times line rate desirable
v three types of switching fabrics
memory
input output
port memory port
(e.g., (e.g.,
Ethernet) Ethernet)
system bus
datagram
switch buffer link
fabric layer line
protocol termination
queueing (send)
switch
switch
fabric
fabric
switch switch
fabric fabric
physical layer
…
in: one large datagram
§ different link types, out: 3 smaller datagrams
different MTUs
v large IP datagram divided
(“fragmented”) within net reassembly
§ one datagram becomes
several datagrams
§ “reassembled” only at …
final destination
§ IP header bits used to
identify, order related
fragments
Network Layer 4-36
IP fragmentation, reassembly
length ID fragflag offset
example: =4000 =x =0 =0
v 4000 byte datagram
one large datagram becomes
v MTU = 1500 bytes several smaller datagrams
223 1 1 1
is called a subnet
223.1.3.0/24
223.1.1.3
223.1.9.2 223.1.7.0
223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0
223.1.2.6 223.1.3.27
“class-full” addressing:
class
1.0.0.0 to
A 0 network host 127.255.255.255
B network 128.0.0.0 to
10 host
191.255.255.255
192.0.0.0 to
C 110 network host
223.255.255.255
224.0.0.0 to
D 1110 multicast address
239.255.255.255
32 bits
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server! Here’s an IP
yiaddrr: 223.1.2.4
transaction
address youID:can
654 use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll take
yiaddrr: 223.1.2.4
that IP address!
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255,
Broadcast: 68
OK. You’ve
yiaddrr: 223.1.2.4
got that IPID:
transaction address!
655
lifetime: 3600 secs
Network Layer 4-49
DHCP: more than IP addresses
DHCP can return more than just allocated IP
address on subnet:
§ address of first-hop router for client
§ name and IP address of DNS sever
§ network mask (indicating network versus host portion
of address)
Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23 with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
beginning
199.31.0.0/16”
Organization 0
200.23.16.0/23
“Send me anything
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
Organization 1 beginning 199.31.0.0/16
or 200.23.18.0/23”
200.23.18.0/23
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
3 probes 3 probes
3 probes
Network Layer 4-68
IPv6: motivation
v initial motivation: 32-bit address space soon to be
completely allocated.
v additional motivation:
§ header format helps speed processing/forwarding
§ header changes to facilitate QoS
data
32 bits
Network Layer 4-70
Other changes from IPv4
v checksum: removed entirely to reduce processing
time at each hop
v options: allowed, but outside of header, indicated
by “Next Header” field
v ICMPv6: new version of ICMP
§ additional message types, e.g. “Packet Too Big”
§ multicast group management functions
IP destination address in
arriving packet’s header
1
3 2
v 3 w
2 5
u 2 1 z
3
1 2
x y
graph: G = (N,E) 1
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
notes: 5 7
4
v construct shortest path tree by
tracing predecessor nodes 8
v ties can exist (can be broken u 3 w y z
arbitrarily) 2
3
7 4
v
Network Layer 4-84
Dijkstra’s algorithm: another example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz
v 3 w
2 5
u 2 1 z
3
1 2
x y
1
v w
u z
x y
1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D B
0 0 1+e 1
0 e 0 0
C C 0 1
C 1+e C 0
1 1
e given these costs, given these costs, given these costs,
initially find new routing…. find new routing…. find new routing….
resulting in new costs resulting in new costs resulting in new costs
Network Layer 4-87
Chapter 4: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state
datagram networks § distance vector
4.3 what’s inside a router § hierarchical routing
4.4 IP: Internet Protocol 4.6 routing in the Internet
§ datagram format § RIP
§ IPv4 addressing § OSPF
§ BGP
§ ICMP
§ IPv6 4.7 broadcast and multicast
routing
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min
v
{c(x,v) + d v (y) }
from
y ∞∞ ∞ y 2 0 1
from
z ∞∞ ∞ z 7 1 0
node y cost to
table x y z y
2 1
x ∞ ∞ ∞ x z
from
y 2 0 1 7
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Network Layer 4-94
Dx(z) = min{c(x,y) +
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
y ∞∞ ∞ y 2 0 1
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
y 2 0 1 y 2 0 1 7
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Network Layer 4-95
Distance vector: link cost changes
link cost changes: 1
v node detects local link cost change 4
y
1
v updates routing info, recalculates x z
distance vector 50
v if DV changes, notify neighbors
t2 : y receives z’s update, updates its distance table. y’s least costs
do not change, so y does not send a message to z.
v network “flat”
… not true in practice
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d v forwarding table
configured by both intra-
and inter-AS routing
Intra-AS Inter-AS algorithm
Routing Routing
algorithm algorithm § intra-AS sets entries
Forwarding
for internal dests
table § inter-AS & intra-AS
sets entries for
external dests
Network Layer 4-102
Inter-AS tasks
v suppose router in AS1 AS1 must:
receives datagram 1. learn which dests are
destined outside of AS1: reachable through AS2,
§ router should forward which through AS3
packet to gateway 2. propagate this
router, but which one? reachability info to all
routers in AS1
job of inter-AS routing!
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c … x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c … x …
3b
3a …
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 4-105
Example: choosing among multiple ASes
v now suppose AS1 learns from inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
v to configure forwarding table, router 1d must determine
towards which gateway it should forward packets for dest x
§ this is also job of inter-AS routing protocol!
v hot potato routing: send packet towards closest of two
routers.
z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to dest
w A 2
y B 2
z B 7
x -- 1
…. …. ....
Network Layer 4-110
RIP: example
A-to-D advertisement
dest next hops
w - 1
x - 1
z C 4
…. … ... z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to dest
w A 2
y B 2
A 5
z B 7
x -- 1
…. …. ....
Network Layer 4-111
RIP: link failure, recovery
if no advertisement heard after 180 sec -->
neighbor/link declared dead
§ routes via neighbor invalidated
§ new advertisements sent to neighbors
§ neighbors in turn send out new advertisements (if tables
changed)
§ link failure info quickly (?) propagates to entire net
§ poison reverse used to prevent ping-pong loops (infinite
distance = 16 hops)
transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
backbone
area
border
routers
area 3
internal
routers
area 1
area 2
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-119
BGP basics: distributing path information
v using eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
§ 1c can then use iBGP do distribute new prefix info to all routers
in AS1
§ 1b can then re-advertise new reachability info to AS2 over 1b-to-
2a eBGP session
v when router learns of new prefix, it creates entry for
prefix in its forwarding table.
eBGP session
3a iBGP session
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-120
Path attributes and BGP routes
v advertised prefix includes BGP attributes
§ prefix + attributes = “route”
v two important attributes:
§ AS-PATH: contains ASs through which prefix
advertisement has passed: e.g., AS 67, AS 17
§ NEXT-HOP: indicates specific internal-AS router to next-
hop AS. (may be multiple links from current AS to next-
hop-AS)
v gateway router receiving route advertisement uses
import policy to accept/decline
§ e.g., never route through AS x
§ policy-based routing
routing algorithms
Assume prefix is
local forwarding table in another AS.
entry prefix output port
138.16.64/22 3
124.12/16 2
212/8 4
………….. …
Dest IP
1
3 2
How does entry get in forwarding table?
High-level overview
1. Router becomes aware of prefix
2. Router determines output port for prefix
3. Router enters prefix-port in forwarding table
Router becomes aware of prefix
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
v Example: select
3c
3a
3b 111.99.86.55
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Router identifies port for route
3c router
3a port
3b
AS3 1 2c other
1c 4 2a networks
2 3
other 1a 2b
networks 1b AS2
AS1 1d
Hot Potato Routing
v Suppose there two or more best inter-routes.
v Then choose route with closest NEXT-HOP
§ Use OSPF to determine which gateway is closest
§ Q: From 1c, chose AS3 AS131 or AS2 AS17?
§ A: route AS3 AS131 since it is closer
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
How does entry get in forwarding table?
Summary
1. Router becomes aware of prefix
§ via BGP route advertisements from other routers
2. Determine router output port for prefix
§ Use BGP route selection to find best inter-AS route
§ Use OSPF to find best intra-AS route leading to best
inter-AS route
§ Router identifies router port for that best route
3. Enter prefix-port entry in forwarding table
BGP routing policy
legend: provider
B network
X
W A
customer
C network:
v A advertises path AW to B
v B advertises path BAW to X
v Should B advertise path BAW to C?
§ No way! B gets no “revenue” for routing CBAW since neither W nor
C are B’s customers
§ B wants to force C to route to w via A
§ B wants to route only to/from its customers!