Chapter 4: Network Layer
Chapter 4: Network Layer
Chapter 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
network network
data link data link
physical physical
network
data link
physical
application
network transport
data link network
network
physical data link
network data link
physical
data link physical
physical
routing algorithms
routing algorithm
value in arriving
packet’s header
0111 1
3 2
application
application
transport
transport
network
data link 1. Send data 2. Receive data network
data link
physical
physical
IP destination address in
arriving packet’s header
1
3 2
otherwise 3
routing algorithm
value in arriving
packet’s header
0111 1
3 2
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
construct shortest path
8
tree by tracing
predecessor nodes 3 w z
u y
2
ties can exist (can be
broken arbitrarily) 3
7 4
v
Network Layer 4-21
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
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
Oscillations possible:
e.g., link cost = amount of carried traffic
1 A A A A
1+e 2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0 1 1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
24
Chapter 4: Network Layer
4. 1 Introduction 4.5 Routing algorithms
4.2 Virtual circuit and Link state
datagram networks Distance Vector
25
Distance Vector Algorithm
Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y
Then
dx(y) = min
v
{c(x,v) + dv(y) }
27
Distance Vector Algorithm
Dx(y) = estimate of least cost from x to y
x maintains distance vector Dx = [Dx(y): y є N ]
node x:
knows cost to each neighbor v: c(x,v)
maintains its neighbors’ distance vectors.
For each neighbor v, x maintains
Dv = [Dv(y): y є N ]
28
Distance vector algorithm (4)
Basic idea:
from time-to-time, each node sends its own
distance vector estimate to neighbors
when x receives new DV estimate from neighbor,
it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N
29
Distance Vector Algorithm (5)
Iterative, asynchronous: Each node:
each local iteration caused
by:
local link cost change wait for (change in local link
cost or msg from neighbor)
DV update message from
neighbor
Distributed: recompute estimates
each node notifies
neighbors only when its DV
changes if DV to any dest has
neighbors then notify changed, notify neighbors
their neighbors if
necessary
30
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)}
node x table = min{2+1 , 7+0} = 3
cost to cost to
x y z x y z
x 0 2 7 x 0 2 3
from
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y table
cost to
x y z y
2 1
x ∞ ∞ ∞
x z
from
y 2 0 1 7
z ∞∞ ∞
node z table
cost to
x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 71 0
time
31
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
node x table = min{2+1 , 7+0} = 3
cost to cost to cost to
x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y table
cost to cost to cost to
x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
from
from
y 2 0 1 y 2 0 1 y 2 0 1 7
z ∞∞ ∞ z 7 1 0 z 3 1 0
node z table
cost to cost to cost to
x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
z 71 0 z 3 1 0 z 3 1 0
time
32
Distance Vector: link cost changes
Link cost changes: 1
node detects local link cost change y
4 1
updates routing info, recalculates x z
distance vector 50
if DV changes, notify neighbors
33
Distance Vector: link cost changes
Link cost changes:
good news travels fast
bad news travels slow - “count to infinity” problem! 60
44 iterations before algorithm stabilizes: see text
y
Poisoned reverse:
If Z routes through Y to get to X :
4 1
Z tells Y its (Z’s) distance to X is infinite (so Y won’t route to X via Z)
x z
50
will this completely solve count to infinity problem?
34
Comparison of LS and DV algorithms
Message complexity Robustness: what happens if
LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent LS:
DV: exchange between node can advertise incorrect
neighbors only link cost
convergence time varies each node computes only its
own table
Speed of Convergence
LS: O(n2) algorithm requires
DV:
O(nE) msgs DV node can advertise
incorrect path cost
may have oscillations
each node’s table used by
DV: convergence time varies others
may be routing loops • error propagate thru
count-to-infinity problem network
35
Chapter 4: Network Layer
4. 1 Introduction 4.5 Routing algorithms
4.2 Virtual circuit and Link state
datagram networks Distance Vector
Hierarchical routing
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
1d AS1 forwarding table
configured by both
intra- and inter-AS
Intra-AS
Routing
Inter-AS
Routing routing algorithm
algorithm algorithm
intra-AS sets entries
Forwarding for internal dests
table
inter-AS & intra-As
sets entries for
external dests
Network Layer 4-37
Inter-AS tasks
AS1 must:
suppose router in AS1
receives datagram 1. learn which dests are
destined outside of reachable through
AS1: AS2, which through
AS3
router should
forward packet to 2. propagate this
gateway router, but reachability info to all
which one? 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-40
Example: Choosing among multiple ASes
now suppose AS1 learns from inter-AS protocol that
subnet x is reachable from AS3 and from AS2.
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!
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-45
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-46
RIP: Link Failure and 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
eBGP session
3a iBGP session
3b
AS3 2c other
1c 2a networks
other
1a 2b
networks 1b AS2
AS1 1d
A advertises path AW to B
B advertises path BAW to X
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!
Policy:
Inter-AS: admin wants control over how its traffic
routed, who routes through its net.
Intra-AS: single admin, so no policy decisions needed
Scale:
hierarchical routing saves table size, reduced update
traffic
Performance:
Intra-AS: can focus on performance
Inter-AS: policy may dominate over performance