distance vector routing ee 122, fall 2013 sylvia ratnasamy ee122
TRANSCRIPT
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
via B
viaC
to B
to C
to D
From node ANeighbor (next-hop)
Destinations distC(A, D): shortest distance from A to D via C
A
How Distance-Vector (DV) works
Each router computes its shortest distance to every destination via any of its neighbors
via B
viaC
to B
to C
to D
MIN { distB(A,B), distC(A, B) }
Amindist
to B
to C
to D
From node AA’s distance vector (DV)
How Distance-Vector (DV) works
How does A initialize its dist() table and DV?
via B
viaC
to B ? ?
to C ? ?
to D ? ?
From node A
Amindist
to B ?
to C ?
to D ?
A’s DV
How Distance-Vector (DV) works
A
B
C
c(A,B
)
c(A,C)
Link costs
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
via B via C
to B c(A,B) ∞to C ∞ c(A,C)
to D ∞ ∞
From node A
A
B
C
c(A,B
)
c(A,C)
mindist
to B c(A,B)
to C c(A,C)
to D ∞
A’s DV
How Distance-Vector (DV) works
Each router sends its DV to its immediate neighbors
via B via C
to B c(A,B) ∞to C ∞ c(A,C)
to D ∞ ∞
From node A
A
B
C
mindist
to B c(A,B)
to C c(A,C)
to D ∞
A’s DV
mindist
to B 5
to C 6
to D 2
c(A,B
)
c(A,C)
How Distance-Vector (DV) works
Routers process received DVs
A
B
C
A’s DVmin
to B 5
to C 6
to D 2c(A,B
)
c(A,C)
via A
via C
to A 5 ∞
to C 15 1
to D ∞ ∞
From node B B’s DVmindist
to A 5
to C 1
to D ∞5
How Distance-Vector (DV) works
A
B
C
A’s DVmin
to B 5
to C 6
to D 2
c(A,C)
via A
via C
to A 5 ∞
to C 15 1
to D ∞ ∞
From node B B’s DVmindist
to A 5
to C 1
to D ∞
new = c(B,A) + mindist(A, C)
511
new = c(B,A) + mindist(A, D)
7 7
Routers process received DVsAnd 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
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
0 At node A1 Initialization:2 for all destinations V do3 if V is neighbor of A 4 distV(A, V) = mindist(A,V) = c(A,V);5 else 6 distV(A, V) = mindist(A,V) = ∞;7 send mindist(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 */10 if (c(A,V) changes by ±d) /* case 1 */11 for all destinations Y do 12 distV(A,Y) = distV(A,Y) ± d 13 else /* case 2: */ 14 for all destinations Y do 15 distV(A,Y) = c(A,V) + mindist(V, Y); 16 update mindist(A,*)15 if (there is a change in mindist(A, *))16 send mindist(A, *) to all neighbors 17 forever
Distance Vector
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
0 At node A1 Initialization:2 for all destinations V do3 if V is neighbor of A 4 distV(A, V) = mindist(A,V) = c(A,V);5 else 6 distV(A, V) = mindist(A,V) = ∞;7 send mindist(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 */10 if (c(A,V) changes by ±d) /* case 1 */11 for all destinations Y do 12 distV(A,Y) = distV(A,Y) ± d 13 else /* case 2: */ 14 for all destinations Y do 15 distV(A,Y) = c(A,V) + mindist(V, Y); 16 update mindist(A,*)15 if (there is a change in mindist(A, *))16 send mindist(A, *) to all neighbors 17 forever
Example: Initialization
A C12
7
B D3
1
via B
via C
to A - -
to B 2 ∞
to C ∞ 7
to D ∞ ∞
from Node A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node D
mindist
to A 0
to B 2
to C 7
to D ∞
mindist
0
2
7
∞
mindist
2
0
1
3
mindist
∞
3
1
0
mindist
7
1
0
1
Example: C sends update to A
via B
via C
to A - -
to B 2 ∞
to C ∞ 7
to D ∞ ∞
from Node A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node D
mindist
0
2
7
∞
mindist
∞
3
1
0
mindist
7
1
0
1
A C12
7
B D3
1
mindist
2
0
1
3
Example: C sends update to A
via B
via C
to A - -
to B 2 ∞
to C ∞ 7
to D ∞ ∞
from Node Amindist
0
2
7
∞
A C12
7
B D3
1
mindist
7
1
0
1
Example: C sends update to A
via B
via C
to A - -
to B 2 8
to C ∞ 7
to D ∞ 8
from Node Amindist
0
2
7
∞
A C12
7
B D3
1
mindist
7
1
0
1
Example: C sends update to A
via B
via C
to A - -
to B 2 8
to C ∞ 7
to D ∞ 8
from Node Amindist
0
2
7
8
A C12
7
B D3
1
Example: now B sends update to A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node Dmindist
∞
3
1
0
mindist
7
1
0
1
A C12
7
B D3
1
mindist
2
0
1
3
via B
via C
to A - -
to B 2 8
to C ∞ 7
to D ∞ 8
from Node Amindist
0
2
7
8
Example: now B sends update to A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node Dmindist
∞
3
1
0
mindist
7
1
0
1
A C12
7
B D3
1
mindist
2
0
1
3
via B
via C
to A - -
to B 2 8
to C ∞ 7
to D ∞ 8
from Node Amindist
0
2
7
8
Example: now B sends update to A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node Dmindist
∞
3
1
0
mindist
7
1
0
1
A C12
7
B D3
1
mindist
2
0
1
3
via B
via C
to A - -
to B 2 8
to C 3 7
to D 5 8
from Node Amindist
0
2
7
8
Make sure you know why this is 5, not 4!
Example: now B sends update to A
viaA
viaC
via D
to A 2 ∞ ∞
to B - - -
to C ∞ 1 ∞
to D ∞ ∞ 3
from Node B
from Node C
viaA
via B
via D
to A 7 ∞ ∞
to B ∞ 1 ∞
to C - - -
to D ∞ ∞ 1
via B
viaC
to A ∞ ∞
to B 3 ∞
to C ∞ 1
to D - -
from Node Dmindist
∞
3
1
0
mindist
7
1
0
1
A C12
7
B D3
1
mindist
2
0
1
3
via B
via C
to A - -
to B 2 8
to C 3 7
to D 5 8
from Node Amindist
0
2
3
5
Example: After 1st Full Exchange
viaA
viaC
via D
to A 2 8 ∞
to B - - -
to C 9 1 4
to D ∞ 2 3
from Node B
from Node C
viaA
via B
via D
to A 7 3 ∞
to B 9 1 4
to C - - -
to D ∞ 4 1
via B
viaC
to A 5 8
to B 3 2
to C 4 1
to D - -
from Node Dmindist
5
2
1
0
mindist
3
1
0
1
A C12
7
B D3
1
mindist
2
0
1
2
via B
via C
to A - -
to B 2 8
to C 3 7
to D 5 8
from Node Amindist
0
2
3
5
Make sure you understand why
some entries are still ∞ All nodes knows the best two-hop paths.
Make sure you believe this
Example: Now A sends update to B
from Node B
from Node C
from Node Dmindist
5
2
1
0
mindist
3
1
0
1
A C12
7
B D3
1
mindist
2
0
1
2
from Node Amindist
0
2
3
5
via B
via C
to A - -
to B 2 8
to C 3 7
to D 5 8
viaA
via B
via D
to A 7 3 ∞
to B 9 1 4
to C - - -
to D ∞ 4 1
via B
viaC
to A 5 8
to B 3 2
to C 4 1
to D - -
viaA
viaC
via D
to A 2 8 ∞
to B - - -
to C 9 1 4
to D ∞ 2 3
Example: Now A sends update to B
viaA
viaC
via D
to A 2 8 ∞
to B - - -
to C 5 1 4
to D 7 2 3
from Node B
from Node C
from Node Dmindist
5
2
1
0
mindist
3
1
0
1
A C12
7
B D3
1
mindist
2
0
1
2
from Node Amindist
0
2
3
5
via B
via C
to A - -
to B 2 8
to C 3 7
to D 5 8
This will come back to bite us
viaA
via B
via D
to A 7 3 ∞
to B 9 1 4
to C - - -
to D ∞ 4 1
via B
viaC
to A 5 8
to B 3 2
to C 4 1
to D - -
Example: End of 2nd Full Exchange
viaA
viaC
via D
to A 2 4 8
to B - - -
to C 5 1 4
to D 7 2 3
from Node B
from Node C
from Node Dmindist
4
2
1
0
mindist
3
1
0
1
A C12
7
B D3
1
mindist
2
0
1
2
from Node Amindist
0
2
3
4
via B
via C
to A - -
to B 2 8
to C 3 7
to D 4 8
viaA
via B
via D
to A 7 3 6
to B 9 1 3
to C - - -
to D 12 3 1
via B
viaC
to A 5 4
to B 3 2
to C 4 1
to D - -
Check
Check: All nodes knows the best three-hop paths.
Example: End of 3nd Full Exchange
viaA
viaC
via D
to A 2 4 7
to B - - -
to C 5 1 4
to D 6 2 3
from Node B
from Node C
from Node Dmindist
4
2
1
0
mindist
3
1
0
1
A C12
7
B D3
1
mindist
2
0
1
2
from Node Amindist
0
2
3
4
via B
via C
to A - -
to B 2 8
to C 3 7
to D 4 8
viaA
via B
via D
to A 7 3 5
to B 9 1 3
to C - - -
to D 11 3 1
via B
viaC
to A 5 4
to B 3 2
to C 4 1
to D - -
No change in DVs Convergence!
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!
DV: Link Cost Changes
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 1 6
C 6 1
A B
A 50 5
B 54 1
A C
A 1 6
C 3 1
A B
A 50 5
B 51 1
A C
A 1 6
C 3 1
A B
A 50 2
B 51 1
B C
B 4 51
C 5 50
Node A B C
B 1 51
C 2 50
B C
B 1 51
C 2 50
B C
B 1 51
C 2 50
A C
A 1 3
C 3 1
A B
A 50 2
B 51 1
B C
B 1 51
C 2 50
Stable state
A-B changed A sends its DV to B, C
B sends itsDV to A, C
C sends its DV to A, B
A C14
50
B1
“good news travels fast”
to
via
Note: none of B’s paths use link (A,C)
deduct 3 from distances distB(A,*) and distA(B,*)
DV: Link Cost Changes
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
Stable state
A-B changed
A C14
50
B60
to
via
add 56 to distances distB(A,*) and distA(B,*)
DV: Link Cost Changes
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
A C
A 60 6
C 110 1
A B
A 50 5
B 101 1
A C
A 60 6
C 110 1
A B
A 50 7
B 101 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
A C
A 60 8
C 110 1
A B
A 50 7
B 101 1
B C
B 60 51
C 61 50
Stable state
A-B changed A sends its DV to B, C
B sends itsDV to A, C
C sends its DV to A, B
A C14
50
B60
“bad news travels slowly” (not yet converged)
to
via
This is the “Counting to Infinity” Problem
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)
DV: Poisoned Reverse
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
Stable state
A-B changed
A C14
50
B60
to
via
If B routes through C to get to A: B tells C its (B’s) distance to A is infinite
∞
∞
DV: Poisoned Reverse
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
A C
A 60 6
C 110 1
A B
A 50 5
B 101 1
A C
A 60 6
C 110 1
A B
A 50 7
B 101 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
Stable state
A-B changed A sends its DV to B, C
B sends itsDV to A, C
A C14
50
B60
to
via
If B routes through C to get to A: B tells C its (B’s) distance to A is infinite
∞
∞ ∞
∞ ∞
∞
∞
∞
DV: Poisoned Reverse
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
A C
A 60 6
C 110 1
A B
A 50 5
B 101 1
A C
A 60 6
C 110 1
A B
A 50 61
B 101 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
Stable state
A-B changed A sends its DV to B, C
B sends itsDV to A, C
A C14
50
B60
to
via
If B routes through C to get to A: B tells C its (B’s) distance to A is infinite
∞
∞ ∞
∞ ∞
∞
∞
∞
DV: Poisoned Reverse
A C
A 4 6
C 9 1
Node B
A B
A 50 5
B 54 1
Node C
Link cost changes here
A C
A 60 6
C 65 1
A B
A 50 5
B 54 1
A C
A 60 6
C 110 1
A B
A 50 5
B 101 1
A C
A 60 6
C 110 1
A B
A 50 61
B 101 1
B C
B 4 51
C 5 50
Node A B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
B C
B 60 51
C 61 50
A B
A 50 61
B 101 1
B C
B 60 51
C 61 50
Stable state
A-B changed A sends its DV to B, C
B sends itsDV to A, C
C sends its DV to A, B
A C14
50
B60
to
via
If B routes through C to get to A: B tells C its (B’s) distance to A is infinite
∞
∞ ∞
∞ ∞
∞
∞
∞ ∞
A C
A 60 51
C 110 1
Converges after C receives another update from B
∞
Will Poison-Reverse Completely Solve the Count-to-Infinity Problem?
A C1
B
D
1
1 11 1
2 2
∞
∞ ∞
100
100 100
3
∞
4
∞ 4
5
6
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 capacityProblem:“cost” does not change around loop
Additive measures avoid this problem!
E.g.: no agreement on metrics
Low price link
Low loss link
Low delay linkLow loss link
Low delay link
Low price link
Cares about price, then loss
Cares about delay,then price
Cares about loss,then delay
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 true for 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)
Let’s back up for a minute…
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:
Any ideas on how to improve scaling?
Hint:
More thoughts on routing…
*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
Metrics
Number of router hops Propagation delay Congestion Load balance Bandwidth (available, capacity, maximal, bbw) Price Reliability Loss rate Combinations of the above
Administrivia
Homework#1 will be out tomorrow (not today)
Answers to the section worksheets will be posted on the class website by the Thursday after all sections have completed the material (Section 1 already posted)
Newly registered students: if you were registeredas of last night, you should have received an instructional account If not, email apanda@cs (copy sylvia@cs)
Routing: Just the Beginning
Link state and distance-vector are the deployed routing paradigms for intra-domain routing
But there’s a much larger design space goals, delivery models, metrics, algorithms
Next week: IP addressing and inter-domain routing (BGP) new constraints: policy, privacy new solutions: path vector routing new pitfalls: truly ugly ones