Professional Documents
Culture Documents
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) }
Dijsktra’s Algorithm
•
if:# 1 Initialization:
2 N' = {u}
IN
:[ 3 for all nodes v
optiÉtr
:÷÷
4 if v adjacent to u "
5 then D(v) = c(u,v) D. (r ) )
"
=
Clair =
6 else D(v) = ∞ ☐ ( my = N
7 D (v
=
) a
8 Loop a
D Ch)
=
1¥ytf-z.ae
0 u 2,u 5,u 1,u ∞ ∞
1 2,u 4,x 2,x a ∞
£
ux
2 uxy 2,u 3,y 4,y
3 33,yy 4,y
uxyv
,
,
4 uxyvw 4,y
5 uxyvwz
2 5
⑦
u 2
3
1 z Dtt) = min { 41 }=x to
1 2
N' x win
1
y Dlw) =
{4,2+1}--3
Network Layer 4-71
Dijkstra’s algorithm: example
Step
0
1
N'
ux
u _
D(v),p(v) D(w),p(w)
2,u
2,u
2,u
5,u
4,x
D(x),p(x)
1,u
D(y),p(y)
∞
2,x
D(z),p(z)
∞
∞
4,y
2 uxy 3,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
-
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 ∞ ∞
2,u ∞
1 ux 4,x . 2,x
4,y
2 uxy 2,u 3,y
4,y
}
3 uxyv 3,y
4 uxyvw 4,y
5 uxyvwz
5 DAD = him { to
3
v w 5 D (7) = him
{0,2+2}=4
2
u 2 1 z
3
1 2
x 1
y
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
5 node 2-
path to .
3
v w 5
2 D G) =
4
u 2 1 z
← 1
3
2
x y
⑨ ⑥ 1
→ Minimum
⑨ 9 ② Tree
Network Layer 4-76
↳④→ →
⑨ spanning
Dijkstra’s algorithm: example (2)
Resulting shortest-path tree from u:
÷☐MsT
v w
u z
x y
(u,v)
②
v -
x (u,x) #2
@y (u,x) 11=2
w (u,x)
8z (u,x) ¥+3
Network Layer 4-77
?⃝
Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
r each iteration: need to check all nodes, w, not in N
-
1 A
1+e
In reality,
2+e A
link cost =f(traffic
A on link) A
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 Does0that lead
0 to a 1problem?
1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 4-78
Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
r each iteration: need to check all nodes, w, not in N
r n(n+1)/2 comparisons: O(n2)
r more efficient implementations possible: O(nlogn)
Oscillations possible:
r 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
Network Layer 4-79
Chapter 4: Network Layer
r 4. 1 Introduction r 4.5 Routing algorithms
r 4.2 Virtual circuit and m Link state
datagram networks m Distance Vector
Hierarchical routing
r 4.3 What’s inside a
m
④→④2
:
①
Then
↳
.
④ ( Y)
dv
dx(y) = min {c(x,v) + dv(y) }
,
v dvz (Y )
dvz (4)
where min is taken over all neighbors v of x
{ ck.vi-dv.tn
":¥¥¥"-n
d
✗ (4)
= min Network Layer 4-81
' '
}
FEE
Bellman-Ford example
2
5
v 3
w 5
at#
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
Du =
Dv , ( y ) , YEN
, '
r Dx(y) = estimate of least cost from x to y ④
r Distance vector: Dx = [Dx(y): y є N ]
r Node x knows cost to each neighbor v: c(x,v)
r Node x maintains Dx = [Dx(y): y є N ]
r Node x also maintains its neighbors’ distance
vectors
m For each neighbor v, x maintains
Dv = [Dv(y): y є N ]
^
vector
neighbors only when its DV
changes if DV to any dest has
m neighbors then notify
changed, notify neighbors
their neighbors if
necessary
E
x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3 ④ ¥In
from
from
y ∞∞ ∞ y 2 0 1
from
-
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
y 2 0 1 y 2 0 1 7
from
from
y 2 0 1
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
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 71 0 z 3 1 0 z 3 1 0
time
Network Layer 4-86
Distance Vector: link cost changes
Link cost changes: 1
r node detects local link cost change y
4 1
r updates routing info, recalculates
x z
distance vector 50
r if DV changes, notify neighbors Dy (a) =
4/1
At time t0, y detects the link-cost change, updates its DV,
and informs its neighbors.
“good 5/2
news ×J=
At time t1, z receives the update from y and updates its table.
It computes a new least cost to x and sends its neighbors its DV.
travels
.
fast” At time t2, y receives z’s update and updates its distance table.
y’s least costs do not change and hence y does not send any
-
message to z.
60
x
4
y
50
1
Dzcx)
z
=
=D
win { 50 ,
Dyk)}
win {50,1+4}
I +
New DV update
from Y is
6
Dy (n)
=
Link State?
Distance Vector?
→ Vc-1-129 on interface I
☒ so _:÷""""-
☒
☒→ 17,21
10112,1511723