Routing 1
Routing 1
5
3
B C 5
2
A 2 1 F
3
1 2
D E
1
Dijkstra’s Algorithm: Discussion
Algorithm complexity: n nodes
each iteration: need to check all nodes, w, not in N
n*(n+1)/2 comparisons: O(n**2)
more efficient implementations possible: O(nlogn)
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
Distance Vector Algorithm Overview
destination
E D
D (C,D) = c(E,D) + minw {D (C,w)}
= 2+2 = 4 C 6 9 4
E D
D (A,D) = c(E,D) + min {D (A,w)}
w D 4 11 2
= 2+3 = 5 loop!
E B
D (A,B) = c(E,B) + minw{D (A,w)}
= 8+6 = 14
loop!
Distance Table Gives Routing Table
cost to destination via
E Outgoing link
D () A B D to use, cost
A 1 14 5 A A,1
B 7 8 5 B D,5
destination
destination
C 6 9 4 C D,4
D 4 11 2 D D,4
Y
2 1
X Z
7
Distance Vector Algorithm: Example
Y
2 1
X Z X Z
7 D (Y,Z) = c(X,Z) + minw{D (Y,w)}
= 7+1 = 8
X Y
D (Z,Y) = c(X,Y) + minw {D (Z,w)}
= 2+1 = 3
Distance Vector Algorithm: Link Cost Changes
algorithm
terminates
“good
news
travels
fast”
Count to infinity: Another Example
A B C
1 1
Distance Vector: Link Cost Changes
Link cost changes: 60
good news travels fast Y
4 1
bad news travels slow - X Z
“count to infinity” problem! 50
algorithm
continues
on!
Distance Vector: Position Reverse
If Z routes through Y to get to X :
60
Z tells Y its (Z’s) distance to X is infinite (so Y Y
won’t route to X via Z) 4 1
will this completely solve count to infinity problem? X Z
50
algorithm
terminates
Comparison of LS and DV Algorithm
Message complexity Robustness: what happens
LS: with n nodes, E links, if router malfunctions?
O(nE) msgs sent each LS:
DV: exchange between
– node can advertise
neighbors only
incorrect link cost
– convergence time varies
– each node computes only
Speed of Convergence its own table
LS: O(n**2) algorithm requires DV:
O(nE) msgs – DV node can advertise
– may have oscillations incorrect path cost
DV: convergence time varies – each node’s table used by
– may be routing loops others
o error propagate thru
– count-to-infinity problem
network
Summary