




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























4: Network Layer 4a-
4: Network Layer 4a-
4: Network Layer 4a-
Routing Algorithm classification:
Global or decentralized?
Choice 2, if dynamic: global or decentralized
information?
4: Network Layer 4a-
4: Network Layer 4a-
2
2
1
3
1
1
2
5
3
5
See the big picture; Find the best Route
What algorithm do you use?
4: Network Layer 4a-
A Link-State Routing Algorithm
Dijkstra’s algorithm
4: Network Layer 4a-
Dijsktra’s Algorithm
1 Initialization – know c(I,j) to start: 2 N = {A} 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A,v) 6 else D(v) = infty 7 8 Loop 9 find w not in N such that D(w) is a minimum (optional?) 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
4: Network Layer 4a-
Dijkstra’s algorithm: example
Step 0 1 2 3 4 5
start N A AD ADE ADEB ADEBC ADEBCF
D(B),n(B) 2,B 2,B 2,B
D(C),n(C) 5,C 4,D 3,D 3,D
D(D),n(D) 1,A
D(E),n(E) infinity 2,D
D(F),n(F) infinity infinity 4,D 4,D 4,D
2 2 1
3
1
1 2
5
3
5
4: Network Layer 4a-
Complexity of Link State
Find next w not in N such that D(w) is a minimum Then for that w, check its best path to other destinations => n*(n+1)/2 comparisons: O(n 2 )
4: Network Layer 4a-
Distance Vector Routing Algorithm
distributed: each node communicates only with directly-
iterative:
self-terminating: no “signal” to stop
asynchronous: nodes need not exchange info/iterate in lock
4: Network Layer 4a-
Example: Distance Table for E
7 8 1 2
1
2
E cost to destination via
c(E,D) + min {D (C,w)}D w
c(E,D) + min {D (A,w)}D w
Loop back through E!
c(E,B) + min {D (A,w)}B w
Loop back through E!
Column only for each neighbor
Rows for each possible dest!
4: Network Layer 4a-
Distance table gives routing table
E cost to destination via
Outgoing link to use, cost
= least cost
4: Network Layer 4a-
Distance Vector Algorithm:
1 Initialization (don’t start knowing link costs for all links in graph): 2 for all adjacent nodes v: 3 D (,v) = infty / the * operator means "for all rows" / 4 D (v,v) = c(X,v) 5 for all destinations, y 6 send min D (y,w) to each neighbor / w over all X's neighbors */
X X
X w
4: Network Layer 4a-
Distance Vector Algorithm (cont.):
8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive update from neighbor V) 11 12 if (c(X,V) changes by d) 13 /* change cost to all dest's via neighbor v by d / 14 / note: d could be positive or negative / 15 for all destinations y: D (y,V) = D (y,V) + d 16 17 else if (update received from V wrt destination Y) 18 / shortest path from V to some Y has changed / 19 / V has sent a new value for its min DV(Y,w) / 20 / call this received new value is "newval" */ 21 for the single destination y: D (Y,V) = c(X,V) + newval 22 23 if we have a new min D (Y,w)for any destination Y 24 send new value of min D (Y,w) to all neighbors 25 26 forever
w
X X
X X
X
w w