Professional Documents
Culture Documents
Link-State and Distance Vector Routing Examples: CPSC 441 University of Calgary
Link-State and Distance Vector Routing Examples: CPSC 441 University of Calgary
Notation: c(x,y): link cost from node x to y; set to if a and y are not direct neighbors D(v): current value of cost of path from source to dest. v p(v): vs predecessor node along path from source to v N': set of nodes whose least cost path is definitively known
Dijsktras Algorithm
1 Initialization (u = source node): 2 N' = {u} /* path to self is all we know */ 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) /* assign link cost to neighbours */ 6 else D(v) = 7 8 Loop 9 find w not in N' such that D(w) is a minimum 10 add w to N' 11 update D(v) for all v adjacent to w and not in N' : 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N'
3
y
6
4 1 3 1 1
v
1
9 2
x
Step 0 N x
s
4
D(u),p(u) D(v),p(v) D(w),p(w) D(y),p(y) D(z),p(z)
w
D(s),p(s)
u
3
D(t),p(t)
3,x
1,x
6,x
Initialization: - Store source node x in N - Assign link cost to neighbours (v,w,y) - Keep track of predecessor to destination node
4
y
6
4 1 3 1 1
v
1
9 2
x
Step 0 1 N x xw
s
4
D(u),p(u) D(v),p(v) D(w),p(w) D(y),p(y) D(z),p(z)
w
D(s),p(s)
u
3
D(t),p(t)
4,w
3,x
2,w
1,x
6,x 6,x
Loop step 1: - For all nodes not in N, find one that has minimum cost path (1) - Add this node (w) to N - Update cost for all neighbours of added node that are not in N repeat until all nodes are in N
5
y
6
4 1 3 1 1
v
1
9 2
x
Step 0 1 2 3 4 5 6 N x xw
s
4
D(u),p(u) D(v),p(v) D(w),p(w) D(y),p(y) D(z),p(z)
w
D(s),p(s)
u
3
D(t),p(t)
xwv
4,w 3,v
3,x
2,w
1,x
xwvu
xwvuy
xwvuyt
xwvuyts
y
6
4 1 3 1 1
v
1
9 2
x
Step 0 1 2 3 4 5 6 N x xw
s
4
D(u),p(u) D(v),p(v)
w
D(s),p(s)
u
3
D(t),p(t)
We can now build xs forwarding table. E.g. the entry to s will be constructed by looking at predecessors along shortest path: 6,t 5,u 3,v 2,w (direct link) So forward to s via w
D(w),p(w) D(y),p(y)
xwv
4,w 3,v
3,x
2,w
1,x
D(z),p(z)
xwvu
xwvuy
xwvuyt
xwvuyts
dv(y) dx(y)
v
2
w
3 1
u
1
z
2
Node that achieves minimum is next hop in shortest path entry in forwarding table
9
Each node periodically sends its own DV to neighbors When node x receives DV from neighbor, it keeps it and updates its own DV using B-F:
Dx(y) minv{c(x,v) + Dv(y)} for each node y N
recompute estimates
if DV has changed, notify neighbors
Ideally, the estimate Dx(y) converges to the actual least cost dx(y)
10
Step 1: Initialization Initialize costs of direct links Set to costs from neighbours
y
7
time
11
x 0 2 3 y 2 0 1 z 7 1 0
from
Step 2: Exchange DV and iterate -In first iteration, node x saves neighbours DVs -Then, it checks path costs to all nodes using received DVs -E.g. new cost Dx(z) is obtained by adding costs marked red time
y
7
12
In similar fashion, algorithm proceeds until all nodes have updated tables node x table cost to x y z from cost to x y z from cost to x y z
x 0 2 3 y 2 0 1 z 7 1 0
x 0 2 7 y 2 0 1 z 7 1 0 x 0 2 7 y 2 0 1 z 3 1 0 cost to x y z
cost to x y z
x 0 2 3 y 2 0 1 z 3 1 0 x 0 2 3 y 2 0 1 z 3 1 0 cost to x y z cost to x y z 2
from
y
7
from
from
x 0 2 3 y 2 0 1 z 3 1 0 time
from
from
13
y
50
At time t0, y detects the link-cost change, updates its DV, and informs its neighbors. At time t1, z receives the update from y and updates its table. It computes a new least cost to x and sends neighbors its DV.
At time t2, y receives zs update and updates its distance table. ys least costs do not change and hence y does not send any message to z.
14
y
50
Poisoned reverse:
If Z routes through Y to get to X :
Z tells Y its (Zs) distance to X is infinite (so Y wont route to X via Z)