Network Layer Part II & III: Routing Algorithms Refer To Chapter 4 of The Textbook
Network Layer Part II & III: Routing Algorithms Refer To Chapter 4 of The Textbook
Network Layer Part II & III: Routing Algorithms Refer To Chapter 4 of The Textbook
Routing Algorithms
IP destination address in
arriving packet’s header
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 tree by
tracing predecessor nodes 8
ties can exist (can be broken u
3 w y z
arbitrarily) 2
3
7 4
v
Network Layer 4-8
Dijkstra’s algorithm: example
x resulting forwarding
9
table in u:
5 7
4 destination link
8 (u,w)
v
3 w z x (u,x)
u y
2
y (u,w)
3
4 w (u,w)
7
z (u,w)
v
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 1+e 1 B
0 0
0 e 0 0
1
C C 0 1
C 1+e C 0
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-10
Distance vector algorithm
Bellman-Ford equation (dynamic programming)
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min
v {c(x,v) + dv(y) }
cost from neighbor v to destination y
cost to neighbor v
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-16
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-17
Distance Vector: Link Cost Changes
algorithm
terminates
“good
news
travels
fast”
18
Distance Vector: Link Cost Changes
Link cost changes: 60
Y
• Good news travels fast 4 1
• Bad news travels slow - “count to X Z
50
infinity” problem!
algorithm
continues
on!
19
Comparison of LS and DV algorithms
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d 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-23
Inter-AS tasks
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
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-29
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-30
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 propagates to entire net
transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
R3 R4 R3 R4
source in-network
duplication duplication
R5 R4
controlled flooding: node only broadcasts pkt if it hasn’t
broadcast same packet before
node keeps track of packet ids already broadacsted
or reverse path forwarding (RPF):
• only forward packet if it arrived on shortest path between node and
source
Spanning tree
Network Layer 4-38
Spanning tree
first construct a spanning tree
nodes then forward/make copies only along
spanning tree
A A
B B
c c
D D
F E F E
G G
(a) broadcast initiated at A (b) broadcast initiated at D
A A
3
B B
c c
4
2
D D
F E F E
1 5
G G
(a) stepwise construction of (b) constructed spanning
spanning tree (center: E) tree
Network Layer 4-40
Multicast Routing
Internet Group Management Protocol (IGMP)