540 likes | 777 Views
Distance Vector Routing. EE 122, Fall 2013 Sylvia Ratnasamy http://inst.eecs.berkeley.edu/~ee122/. How Distance-Vector (DV) works. Each router maintains its shortest distance to every destination via each of its neighbors. Neighbor (next-hop). F rom node A. A.
E N D
Distance Vector Routing EE 122, Fall 2013 Sylvia Ratnasamy http://inst.eecs.berkeley.edu/~ee122/
How Distance-Vector (DV) works Each router maintains its shortest distance to every destination via each of its neighbors Neighbor (next-hop) From node A A distC(A, D): shortest distance from A to D via C Destinations
How Distance-Vector (DV) works Each router computes its shortest distance to every destination via any of its neighbors MIN { distB(A,B), distC(A, B) } A’s distance vector (DV) From node A A
How Distance-Vector (DV) works How does A initialize its dist() table and DV? A’s DV From node A A
How Distance-Vector (DV) works A B C c(A,B) Link costs c(A,C) How does A initialize its dist() table and DV?
How Distance-Vector (DV) works Each router initializes its dist() table based on its immediate neighbors and link costs A’s DV From node A A B C c(A,B) c(A,C)
How Distance-Vector (DV) works Each router sends its DV to its immediate neighbors A’s DV From node A A B C c(A,B) c(A,C)
How Distance-Vector (DV) works From node B A’s DV B’s DV Routers process received DVs 5 A B C c(A,B) c(A,C)
How Distance-Vector (DV) works From node B A’s DV B’s DV Routers process received DVs 11 5 A B C 7 7 c(A,C) new =c(B,A) + mindist(A, C) new =c(B,A) + mindist(A, D) And repeat…
Distance Vector Routing • Each router knows the links to its neighbors • Each router has provisional “shortest path” to every other router -- its distance vector (DV) • Routers exchange this DV with their neighbors • Routers look over the set of options offered by their neighbors and select the best one • Iterative process converges to set of shortest paths
Distance Vector 0 At node A 1 Initialization: 2 for alldestinations V do 3 ifVis neighbor of A 4 distV(A, V) = mindist(A,V) = c(A,V); else distV(A, V) = mindist(A,V) = ∞; sendmindist(A, *) to all neighbors loop: 8 wait (until A sees a link cost change to neighbor V /* case 1 */ 9 or until A receives mindist(V,*) from neighbor V) /* case 2 */ if(c(A,V) changes by ±d) /* case 1 */ for all destinations Y do distV(A,Y) = distV(A,Y) ± d else /* case 2:*/ for all destinations Y do distV(A,Y) = c(A,V) + mindist(V, Y); update mindist(A,*) 15 if(there is a change in mindist(A, *)) 16 sendmindist(A, *) to all neighbors 17 forever • c(i,j): link cost from node i to j • distZ(A,V): shortest dist. from A to V via Z • mindist(A,V): shortest dist. from A to V
Distance Vector 0 At node A 1 Initialization: 2 for alldestinations V do 3 ifVis neighbor of A 4 distV(A, V) = mindist(A,V) = c(A,V); else distV(A, V) = mindist(A,V) = ∞; sendmindist(A, *) to all neighbors loop: 8 wait (until A sees a link cost change to neighbor V /* case 1 */ 9 or until A receives mindist(V,*) from neighbor V) /* case 2 */ if(c(A,V) changes by ±d) /* case 1 */ for all destinations Y do distV(A,Y) = distV(A,Y) ± d else /* case 2:*/ for all destinations Y do distV(A,Y) = c(A,V) + mindist(V, Y); update mindist(A,*) 15 if(there is a change in mindist(A, *)) 16 sendmindist(A, *) to all neighbors 17 forever • c(i,j): link cost from node i to j • distZ(A,V): shortest dist. from A to V via Z • mindist(A,V): shortest dist. from A to V
C D B A Example: Initialization from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: C sends update to A from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: C sends update to A 3 2 1 1 7 from Node A
C D B A Example: C sends update to A 3 2 1 1 7 from Node A
C D B A Example: C sends update to A 3 2 1 1 7 from Node A
C D B A Example: now B sends update to A from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: now B sends update to A from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: now B sends update to A from Node B from Node D 3 2 1 1 from Node C 7 from Node A Make sure you know why this is 5, not 4!
C D B A Example: now B sends update to A from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Make sure you understand why some entries are still ∞ All nodes knows the best two-hop paths. Make sure you believe this Example: After 1st Full Exchange from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: Now A sends update to B from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A This will come back to bite us Example: Now A sends update to B from Node B from Node D 3 2 1 1 from Node C 7 from Node A
C D B A Example: End of 2nd Full Exchange Check:All nodes knows the best three-hop paths. from Node B from Node D 3 2 1 1 from Node C 7 from Node A Check
C D B A No change in DVs Convergence! Example: End of 3nd Full Exchange from Node B from Node D 3 2 1 1 from Node C 7 from Node A
Intuition • Initial state: best one-hop paths • One simultaneous round: best two-hop paths • Two simultaneous rounds: best three-hop paths • … • Kth simultaneous round: best (k+1) hop paths • Must eventually converge • as soon as it reaches longest best path • …..but how does it respond to changes in cost? The key here is that the starting point is not the initialization, but some other set of entries. Convergence could be different!
C A B Link cost changes here DV: Link Cost Changes 1 4 1 50 via Stable state C sends its DV to A, B A-B changed B sends itsDV to A, C A sends its DV to B, C Node A to Note: none of B’s paths use link (A,C) deduct 3 from distancesdistB(A,*) and distA(B,*) Node B Node C “good news travels fast”
C B A Link cost changes here DV: Link Cost Changes 60 4 1 50 via Stable state A-B changed Node A to add 56 to distancesdistB(A,*) and distA(B,*) Node B Node C
C A B Link cost changes here DV: Link Cost Changes 60 4 1 50 via Stable state C sends its DV to A, B A-B changed B sends itsDV to A, C A sends its DV to B, C Node A to This is the “Counting to Infinity” Problem Node B Node C “bad news travels slowly” (not yet converged)
The “Poisoned Reverse” Rule • Heuristic to avoid count-to-infinity • If B routes via C to get to A: • B tells C its (B’s) distance to A is infinite (so C won’t route to A via B)
C B A Link cost changes here DV: Poisoned Reverse 60 4 1 If B routes through C to get to A:B tells C its (B’s) distance to A is infinite 50 via Stable state A-B changed Node A to Node B ∞ ∞ Node C
C B A Link cost changes here DV: Poisoned Reverse 60 4 1 If B routes through C to get to A:B tells C its (B’s) distance to A is infinite 50 via Stable state A-B changed B sends itsDV to A, C A sends its DV to B, C Node A to Node B ∞ ∞ ∞ ∞ ∞ ∞ Node C ∞ ∞
C B A Link cost changes here DV: Poisoned Reverse 60 4 1 If B routes through C to get to A:B tells C its (B’s) distance to A is infinite 50 via Stable state A-B changed B sends itsDV to A, C A sends its DV to B, C Node A to Node B ∞ ∞ ∞ ∞ ∞ ∞ Node C ∞ ∞
C B A Link cost changes here DV: Poisoned Reverse 60 4 1 If B routes through C to get to A:B tells C its (B’s) distance to A is infinite 50 via Stable state C sends its DV to A, B A-B changed B sends itsDV to A, C A sends its DV to B, C Node A to Node B ∞ ∞ ∞ ∞ ∞ ∞ Node C ∞ ∞ ∞ ∞ Converges after C receives another update from B
Will Poison-Reverse Completely Solve the Count-to-Infinity Problem? D 100 1 ∞ 4 B 4 100 1 100 1 ∞ 1 1 ∞ 6 3 ∞ 1 A C ∞ 2 2 5 Numbers in blue denote the best cost to destination D advertised along the link
A few other inconvenient aspects • What if we use a non-additive metric? • E.g., maximal capacity • What if routers don’t use the same metric? • I want low delay, you want low loss rate? • What happens if nodes lie?
E.g.: All nodes want to maximize capacity A high capacity link gets reduced to low capacity Problem:“cost” does not change around loop Additive measures avoid this problem!
E.g.: no agreement on metrics Cares about price, then loss Cares about delay, then price Low price link Low loss link Low delay link Cares about loss, then delay Low delay link Low loss link Low price link
Must agree on loop-avoiding metric • When all nodes minimize same metric • And that metric increases around loops • Then process is guaranteed to converge
What happens when routers lie? • What if a router claims a 1-hop path to everywhere? • All traffic from nearby routers gets sent there • How can you tell if they are lying? • Can this happen in real life? • It has, several times….
Recap: DV • Core idea: tell your immediate neighbors about your least cost distance to all nodes • Recall LS: tell all nodes about your immediate neighbors • Each node maintains global state • O(N) forwarding tables, where N is #nodes • The same is true for LS • Vulnerable to convergence problems • count-to-infinity and loops • LS faces similar (not identical) concerns • Not robust to nodes lying • The same is truefor LS
Routing Information Protocol (RIP) • Implementation of Distance Vector • Nodes send distance vectors every 30 seconds • … or, when an update causes a change in routing • Link costs in RIP • All links have cost 1 • Valid distances of 1 through 15 (16 represents infinity) • Small “infinity” smaller“counting to infinity”problem • RIP is limited to fairly small networks • E.g., Princeton uses RIP • But UCB uses OSPF (LS-based protocol)
What are desirable goals for a routing solution? • “Least cost” paths • Avoid loops, converge quickly • Scalable • #messages • table size • processing complexity • Secure (later in the course) • Policy/rich metrics (later in the course) • Load balanced (later in the course)
What are desirable goals for a routing solution? • “Least cost” paths • Avoid loops, converge quickly • Scalable • #messages • table size • processing complexity • Secure (later in the course) • Policy/rich metrics (later in the course) • Load balanced (later in the course)
Any ideas on how to avoid loops? • Hint:
*cast Routes (later in the course) • Our model so far: find a route between two specific endpoints -- e.g., route from A to B • this is called a unicast route • What other forms of communication might A want? • broadcast: send to all • multicast: send to all members of a group • anycast: send to any member of a group • What if A and B want to communicate along more than one path? • multipath routing