Routing Algorithm
Network Layer 4-11
1
23
IP destination address in
arriving packet’s header
routing algorithm
local forwarding table
dest address output link
address-range 1
address-range 2
address-range 3
address-range 4
3
2
2
1
Interplay between routing, forwarding
routing algorithm determines
end-end-path through network
forwarding table determines
local forwarding at this router
Network Layer 4-12
Routing algorithm classification
Q: global or decentralized
information?
global:
• all routers have complete
topology, link cost info
• “link state” algorithms
decentralized:
• router knows physically-
connected neighbors, link
costs to neighbors
• iterative process of
computation, exchange of
info with neighbors
Q: static or dynamic?
static:
 routes change slowly over
time
dynamic:
 routes change more
quickly
 periodic update
 in response to link cost
changes
Network Layer 4-13
A Link-State Routing Algorithm
Dijkstra’s algorithm
• net topology, link costs
known to all nodes
– accomplished via “link
state broadcast”
– all nodes have same info
• computes least cost paths
from one node (‘source”)
to all other nodes
– gives forwarding table for
that node
• iterative: after k
iterations, know least cost
path to k dest.’s
notation:
• c(x,y): link cost from node
x to y; = ∞ if not direct
neighbors
• D(v): current value of cost
of path from source to dest.
v
• p(v): predecessor node
along path from source to v
• N': set of nodes whose
least cost path definitively
known
Network Layer 4-14
Routing algorithm classification
Q: global or decentralized
information?
global:
• all routers have complete
topology, link cost info
• “link state” algorithms
decentralized:
• router knows physically-
connected neighbors, link
costs to neighbors
• iterative process of
computation, exchange of
info with neighbors
Q: static or dynamic?
static:
 routes change slowly over
time
dynamic:
 routes change more
quickly
 periodic update
 in response to link cost
changes
Network Layer 4-15
w3
4
v
x
u
5
3
7 4
y
8
z
2
7
9
Dijkstra’s algorithm: example
Step N'
D(v)
p(v)
0
1
2
3
4
5
D(w)
p(w)
D(x)
p(x)
D(y)
p(y)
D(z)
p(z)
u ∞∞7,u 3,u 5,u
uw ∞11,w6,w 5,u
14,x11,w6,wuwx
uwxv 14,x10,v
uwxvy 12,y
notes:
 construct shortest path tree
by tracing predecessor
nodes
 ties can exist (can be broken
arbitrarily)
uwxvyz
Network Layer 4-16
Dijkstra’s algorithm: another example
Step
0
1
2
3
4
5
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v),p(v)
2,u
2,u
2,u
D(w),p(w)
5,u
4,x
3,y
3,y
D(x),p(x)
1,u
D(y),p(y)
∞
2,x
D(z),p(z)
∞
∞
4,y
4,y
4,y
u
yx
wv
z
2
2
1
3
1
1
2
5
3
5
Network Layer 4-17
Dijkstra’s algorithm: example (2)
u
yx
wv
z
resulting shortest-path tree from u:
v
x
y
w
z
(u,v)
(u,x)
(u,x)
(u,x)
(u,x)
destination link
resulting forwarding table in u:
Network Layer 4-18
Distance vector algorithm
Bellman-Ford equation (dynamic
programming)
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min {c(x,v) + dv(y) }
v
cost to neighbor v
min taken over all neighbors v of x
cost from neighbor v to destination y
Network Layer 4-19
Bellman-Ford example
u
yx
wv
z
2
2
1
3
1
1
2
5
3
5
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
du(z) = min { c(u,v) + dv(z),
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
B-F equation says:
Network Layer 4-20
key 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
 under minor, natural conditions, the estimate
Dx(y) converge to the actual least cost dx(y)
Distance vector algorithm
Network Layer 4-21
iterative, asynchronous:
each local iteration
caused by:
• local link cost change
• DV update message from
neighbor
distributed:
• each node notifies
neighbors only when its
DV changes
– neighbors then notify their
neighbors if necessary
wait for (change in local link
cost or msg from neighbor)
recompute estimates
if DV to any dest has changed,
notify neighbors
each node:
Distance vector algorithm
Network Layer 4-22
x y z
x
y
z
0 2 7
∞∞ ∞
∞∞ ∞
from
cost to
fromfrom
x y z
x
y
z
0
x y z
x
y
z
∞ ∞
∞∞ ∞
cost to
x y z
x
y
z
∞∞ ∞
7 1 0
cost to
∞
2 0 1
∞ ∞ ∞
2 0 1
7 1 0
time
x z
12
7
y
node x
table
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
32
node y
table
node z
table
cost to
from
Network Layer 4-23
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 7
from
cost to
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 7
from
cost to
2 0 1
7 1 0
2 0 1
3 1 0
2 0 1
3 1 0
2 0 1
3 1 0
2 0 1
3 1 0
time
x y z
x
y
z
0 2 7
∞∞ ∞
∞∞ ∞
from
cost to
fromfrom
x y z
x
y
z
0
x y z
x
y
z
∞ ∞
∞∞ ∞
cost to
x y z
x
y
z
∞∞ ∞
7 1 0
cost to
∞
2 0 1
∞ ∞ ∞
2 0 1
7 1 0
time
x z
12
7
y
node x
table
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
32
node y
table
node z
table
cost to
from

Routing Algorithm

  • 1.
  • 11.
    Network Layer 4-11 1 23 IPdestination address in arriving packet’s header routing algorithm local forwarding table dest address output link address-range 1 address-range 2 address-range 3 address-range 4 3 2 2 1 Interplay between routing, forwarding routing algorithm determines end-end-path through network forwarding table determines local forwarding at this router
  • 12.
    Network Layer 4-12 Routingalgorithm classification Q: global or decentralized information? global: • all routers have complete topology, link cost info • “link state” algorithms decentralized: • router knows physically- connected neighbors, link costs to neighbors • iterative process of computation, exchange of info with neighbors Q: static or dynamic? static:  routes change slowly over time dynamic:  routes change more quickly  periodic update  in response to link cost changes
  • 13.
    Network Layer 4-13 ALink-State Routing Algorithm Dijkstra’s algorithm • net topology, link costs known to all nodes – accomplished via “link state broadcast” – all nodes have same info • computes least cost paths from one node (‘source”) to all other nodes – gives forwarding table for that node • iterative: after k iterations, know least cost path to k dest.’s notation: • c(x,y): link cost from node x to y; = ∞ if not direct neighbors • D(v): current value of cost of path from source to dest. v • p(v): predecessor node along path from source to v • N': set of nodes whose least cost path definitively known
  • 14.
    Network Layer 4-14 Routingalgorithm classification Q: global or decentralized information? global: • all routers have complete topology, link cost info • “link state” algorithms decentralized: • router knows physically- connected neighbors, link costs to neighbors • iterative process of computation, exchange of info with neighbors Q: static or dynamic? static:  routes change slowly over time dynamic:  routes change more quickly  periodic update  in response to link cost changes
  • 15.
    Network Layer 4-15 w3 4 v x u 5 3 74 y 8 z 2 7 9 Dijkstra’s algorithm: example Step N' D(v) p(v) 0 1 2 3 4 5 D(w) p(w) D(x) p(x) D(y) p(y) D(z) p(z) u ∞∞7,u 3,u 5,u uw ∞11,w6,w 5,u 14,x11,w6,wuwx uwxv 14,x10,v uwxvy 12,y notes:  construct shortest path tree by tracing predecessor nodes  ties can exist (can be broken arbitrarily) uwxvyz
  • 16.
    Network Layer 4-16 Dijkstra’salgorithm: another example Step 0 1 2 3 4 5 N' u ux uxy uxyv uxyvw uxyvwz D(v),p(v) 2,u 2,u 2,u D(w),p(w) 5,u 4,x 3,y 3,y D(x),p(x) 1,u D(y),p(y) ∞ 2,x D(z),p(z) ∞ ∞ 4,y 4,y 4,y u yx wv z 2 2 1 3 1 1 2 5 3 5
  • 17.
    Network Layer 4-17 Dijkstra’salgorithm: example (2) u yx wv z resulting shortest-path tree from u: v x y w z (u,v) (u,x) (u,x) (u,x) (u,x) destination link resulting forwarding table in u:
  • 18.
    Network Layer 4-18 Distancevector algorithm Bellman-Ford equation (dynamic programming) let dx(y) := cost of least-cost path from x to y then dx(y) = min {c(x,v) + dv(y) } v cost to neighbor v min taken over all neighbors v of x cost from neighbor v to destination y
  • 19.
    Network Layer 4-19 Bellman-Fordexample u yx wv z 2 2 1 3 1 1 2 5 3 5 clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3 du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z), c(u,w) + dw(z) } = min {2 + 5, 1 + 3, 5 + 3} = 4 B-F equation says:
  • 20.
    Network Layer 4-20 keyidea: 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  under minor, natural conditions, the estimate Dx(y) converge to the actual least cost dx(y) Distance vector algorithm
  • 21.
    Network Layer 4-21 iterative,asynchronous: each local iteration caused by: • local link cost change • DV update message from neighbor distributed: • each node notifies neighbors only when its DV changes – neighbors then notify their neighbors if necessary wait for (change in local link cost or msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors each node: Distance vector algorithm
  • 22.
    Network Layer 4-22 xy z x y z 0 2 7 ∞∞ ∞ ∞∞ ∞ from cost to fromfrom x y z x y z 0 x y z x y z ∞ ∞ ∞∞ ∞ cost to x y z x y z ∞∞ ∞ 7 1 0 cost to ∞ 2 0 1 ∞ ∞ ∞ 2 0 1 7 1 0 time x z 12 7 y node x table Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 32 node y table node z table cost to from
  • 23.
    Network Layer 4-23 xy z x y z 0 2 3 from cost to x y z x y z 0 2 7 from cost to x y z x y z 0 2 3 from cost to x y z x y z 0 2 3 from cost to x y z x y z 0 2 7 from cost to 2 0 1 7 1 0 2 0 1 3 1 0 2 0 1 3 1 0 2 0 1 3 1 0 2 0 1 3 1 0 time x y z x y z 0 2 7 ∞∞ ∞ ∞∞ ∞ from cost to fromfrom x y z x y z 0 x y z x y z ∞ ∞ ∞∞ ∞ cost to x y z x y z ∞∞ ∞ 7 1 0 cost to ∞ 2 0 1 ∞ ∞ ∞ 2 0 1 7 1 0 time x z 12 7 y node x table Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 32 node y table node z table cost to from