Document

advertisement
Distance Vector Routing
EE 122, Fall 2013
Sylvia Ratnasamy
http://inst.eecs.berkeley.edu/~ee122/
How Distance-Vector (DV) works
From node A
via
B
A
Neighbor
(next-hop)
via
C
to B
to C
Destinations
to D
distC(A, D): shortest
distance from A to D via C
Each router maintains its shortest distance to every
destination via each of its neighbors
How Distance-Vector (DV) works
MIN { distB(A,B), distC(A, B) }
A’s distance
vector (DV)
From node A
via
B
A
min
dist
via
C
to B
to B
to C
to C
to D
to D
Each router computes its shortest distance to every
destination via any of its neighbors
How Distance-Vector (DV) works
From node A
A’s DV
min
dist
via
B
via
C
to B
?
?
to B
?
to C
?
?
to C
?
to D
?
?
to D
?
A
How does A initialize its dist() table and DV?
How Distance-Vector (DV) works
B
A
Link costs
C
How does A initialize its dist() table and DV?
How Distance-Vector (DV) works
B
A’s DV
From node A
via C
to B
c(A,B)
∞
to B
c(A,B)
to C
∞
c(A,C)
to C
c(A,C)
to D
∞
∞
to D
∞
A
C
mindist
via B
Each router initializes its dist() table based on its
immediate neighbors and link costs
How Distance-Vector (DV) works
B
A’s DV
From node A
via C
to B
c(A,B)
∞
to B
c(A,B)
5
to C
∞
c(A,C)
to C
c(A,C)
6
to D
∞
∞
to D
∞
2
A
C
mindist
via B
Each router sends its DV to its immediate neighbors
How Distance-Vector (DV) works
A’s DV
B
A
From node B
mi
n
to B
5
to C
6
to D
2
via
A
via C
to A
5
to C
to D
B’s
DVmindist
to A
5
∞
to C
1
15
1
to D
∞
∞
∞
C
Routers process received DVs
How Distance-Vector (DV) works
A’s DV
B
mi
n
to B
A
5
to C
6
to D
2
B’s
DVmindist
From node B
via
A
via C
to A
5
to A
11
5
∞
to C
1
to C
15
7
1
to D
∞7
to D
∞
∞
C
new
new == c(B,A)
c(B,A) ++ mindist(A,
mindist(A, C)
D)
Routers process received DVs
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

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 A
1 Initialization:
2 for all destinations V do
3
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 A
1 Initialization:
2 for all destinations V do
3
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
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
B
2
via
B
to A
-
via
C
-
min
dist
1
C
A
from Node A
3
7
D
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
∞
∞
7
to
0A
0
to A
7
2
to B
∞
1
∞
1
to B
2
∞
to
2B
to C
∞
7
to
7C
7
to C
-
-
-
0
to D
∞
∞
to
∞D
∞
to D
∞
∞
1
1
Example: C sends update to A
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
∞
∞
7
0
to A
7
to B
∞
1
∞
1
to B
2
∞
2
to C
∞
7
7
to C
-
-
-
0
to D
∞
∞
∞
to D
∞
∞
1
1
Example: C sends update to A
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
min
dist
min
dist
0
7
1
to B
2
∞
2
to C
∞
7
7
0
to D
∞
∞
∞
1
Example: C sends update to A
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
min
dist
min
dist
0
7
1
to B
2
8
2
to C
∞
7
7
0
to D
∞
8
∞
1
Example: C sends update to A
2
A
from Node A
min
dist
via
B
via
C
to A
-
-
to B
2
8
2
to C
∞
7
7
to D
∞
8
8
0
3
B
1
C
7
D
1
Example: now B sends update to A
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
∞
∞
7
0
to A
7
to B
∞
1
∞
1
to B
2
8
2
to C
∞
7
7
to C
-
-
-
0
to D
∞
8
8
to D
∞
∞
1
1
Example: now B sends update to A
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
∞
∞
7
0
to A
7
to B
∞
1
∞
1
to B
2
8
2
to C
∞
7
7
to C
-
-
-
0
to D
∞
8
8
to D
∞
∞
1
1
Example: now B sends update to A
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
from Node C
via
A
min
dist
0
via
B
Make sure you
to A 7know
∞
why this isto 5,
4!
B not
∞
1
via
D
min
dist
∞
7
∞
1
to B
2
8
2
to C
3
7
7
to C
-
-
-
0
to D
5
8
8
to D
∞
∞
1
1
Example: now B sends update to A
from Node B
via
A
from Node D
via
C
via
D
min
dist
via
B
via
C
min
dist
∞
to A
2
∞
∞
2
to A
∞
∞
to B
-
-
-
0
to B
3
∞
3
to C
∞
1
∞
1
to C
∞
1
1
to D
∞
∞
3
3
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
3
B
1
C
7
D
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
∞
∞
7
0
to A
7
to B
∞
1
∞
1
to B
2
8
2
to C
3
7
3
to C
-
-
-
0
to D
5
8
5
to D
∞
∞
1
1
Makeknows
sure you
understand
why
All
nodes
the
best
two-hop
paths.
st
Example: After
1
Full
Exchange
some
entries
are stillthis
∞
Make
sure
you believe
from Node B
from Node D
via
A
via
C
via
D
min
dist
to A
2
8
∞
2
to B
-
-
-
to C
9
1
to D
∞
2
via
C
to A
5
8
0
to B
3
2
4
1
to C
4
1
1
3
2
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
min
dist
via
B
3
B
1
C
7
D
5
2
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
3
∞
3
0
to A
7
to B
9
1
4
1
to B
2
8
2
to C
3
7
3
to C
-
-
-
0
to D
5
8
5
to D
∞
4
1
1
Example: Now A sends update to B
from Node B
from Node D
via
A
via
C
via
D
min
dist
to A
2
8
∞
2
to B
-
-
-
to C
9
1
to D
∞
2
via
C
to A
5
8
0
to B
3
2
4
1
to C
4
1
1
3
2
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
min
dist
via
B
3
B
1
C
7
D
5
2
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
3
∞
3
0
to A
7
to B
9
1
4
1
to B
2
8
2
to C
3
7
3
to C
-
-
-
0
to D
5
8
5
to D
∞
4
1
1
will come
backto
to B
bite us
Example: NowThis
A sends
update
from Node B
from Node D
via
A
via
C
via
D
min
dist
to A
2
8
∞
2
to B
-
-
-
to C
5
1
to D
7
2
via
C
to A
5
8
0
to B
3
2
4
1
to C
4
1
1
3
2
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
min
dist
via
B
3
B
1
C
7
D
5
2
1
from Node C
min
dist
min
dist
via
A
via
B
via
D
3
∞
3
0
to A
7
to B
9
1
4
1
to B
2
8
2
to C
3
7
3
to C
-
-
-
0
to D
5
8
5
to D
∞
4
1
1
Check: AllEnd
nodes
the Exchange
best three-hop paths.
Example:
ofknows
2nd Full
from Node B
from Node D
min
dist
via
A
via
C
via
D
to A
2
4
8
2
to B
-
-
-
to C
5
1
to D
7
2
via
C
to A
5
4
0
to B
3
2
4
1
to C
4
1
1
3
2
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
min
dist
via
B
3
B
1
C
D
4
2
1
7
from Node C
min
dist
via
A
via
B
3
via
D
min
dist
3
0
to A
7
to B
9
1
3
1
to C
-
-
-
0
to D
12
3
1
1
to B
2
8
2
to C
3
7
3
to D
4
8
4
Check
6
No change
DVs
 Exchange
Convergence!
Example:
End of in
3nd
Full
from Node B
from Node D
min
dist
via
A
via
C
via
D
to A
2
4
7
2
to B
-
-
-
to C
5
1
to D
6
2
via
C
to A
5
4
0
to B
3
2
4
1
to C
4
1
1
3
2
to D
-
-
0
2
A
from Node A
via
B
to A
-
via
C
-
min
dist
via
B
3
B
1
C
7
D
4
2
1
from Node C
min
dist
via
A
via
B
3
via
D
min
dist
3
0
to A
7
to B
9
1
3
1
5
to B
2
8
2
to C
3
7
3
to C
-
-
-
0
to D
4
8
4
to D
11
3
1
1
Intuition

Initial state: best one-hop paths
One simultaneous round: best two-hop paths
Two
simultaneous
three-hop
The
key here is rounds:
that thebest
starting
pointpaths
is
…
not the initialization, but some other set of
entries.
Convergence
could
be hop
different!
Kth
simultaneous
round: best
(k+1)
paths

Must eventually converge






as soon as it reaches longest best path
…..but how does it respond to changes in cost?
1
4
DV: Link Cost Changes
Stable
state
via
Node A
to
Node C
1
C
50
A-B changed
A sends its
DV to B, C
B sends its
DV to A, C
C sends its
DV to A, B
B
C
B
C
B
C
B
C
1
51
1
51
B
1
51
C
C none
2 50 of B’sC 2 50
Note:
deduct 3 from distances
paths use
link
(A,C) A C
A
C
distB(A,*) and distA(B,*)
2
50
A
C
B
C
B
4
51
B
1
51
C
5
50
C
2
50
A
C
A
C
A
4
6
A
1
6
C
9
1
C
6
1
A
B
A
A 50
5
B 54
1
Node B
A
B
B
B
A
1
6
A
1
6
A
1
3
C
3
1
C
3
1
C
3
1
B
A
B
A
B
A
B
A 50
5
A 50
5
A 50
2
A 50
2
B 54
1
B 51
1
B 51
1
B 51
1
Link cost changes here
“good news travels fast”
DV: Link Cost Changes
Stable
state
via
Node A
to
Node C
A-B changed
B
C
B
B
4
51
B 60 51
C
5
50
C 61 50
A
C
A
C
A
4
6
A 60
6
C
9
1
C 65
1
A
B
A
B
A 50
5
A 50
5
B 54
1
B 54
1
Node B
60 B
4
1
A
C
50
C
Link cost changes here
add 56 to distances
distB(A,*) and distA(B,*)
60 B
4
1
A
C
50
DV: Link Cost Changes
Stable
state
via
Node A
to
B
C
Node B
Node C
A-B changed
A sends its
DV to B, C
B sends its
DV to A, C
C sends its
DV to A, B
B
B
B
B
C
B
4
51
B 60 51
5This
50
C
C
B 60 51
C
B 60 51
is Cthe61“Counting
to Infinity”
61 50
C 61
50
CProblem
50
C
B 60 51
C 61 50
A
C
A
C
A
C
A
C
A
C
A
4
6
A 60
6
A 60
6
A 60
6
A 60
8
C
9
1
C 65
1
C 110
1
C 110
1
C 110
1
A
B
A
B
A
B
A
B
A
B
A 50
5
A 50
5
A 50
5
A 50
7
A 50
7
B 54
1
B 54
1
B 101
1
B 101
1
B 101
1
Link cost changes here
“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)
DV: Poisoned Reverse
If B routes through C to get to A:
B tells C its (B’s) distance to A is infinite
Stable
state
via
Node A
to
B
C
B
B
4
51
B 60 51
C
5
50
C 61 50
A
C
6∞
A
C
A 60
6
1
C 65
1
A
B
A
B
A 50
5
A 50
5
B 54
1
B 54
1
Node B
A
C
Node C
A-B changed
4
∞
9
C
Link cost changes here
60
4
A
B
50
1
C
DV: Poisoned Reverse
60
4
A
If B routes through C to get to A:
B tells C its (B’s) distance to A is infinite
Stable
state
via
Node A
to
A sends its
DV to B, C
B sends its
DV to A, C
B
B
C
C
C
B
C
B
B
4
51
B 60 51
B 60 51
B 60 51
C
5
50
C 61 50
C 61 50
C 61 50
A
C
6∞
A
Node B
A
C
A
C
A 60
C
6∞
A 60
6∞
A 60
6∞
1
∞
C 65
1
C 110
1
C 110
1
A
B
A
B
A 50
5
A 50
5
B 54
1
B 54
1
A
C
Node C
A-B changed
4
∞
9
Link cost changes here
A
A 50
∞
B 101
B
A
B
5
A 50
7
1
∞
B 101
1
B
50
1
C
DV: Poisoned Reverse
60
4
A
If B routes through C to get to A:
B tells C its (B’s) distance to A is infinite
Stable
state
via
Node A
to
A sends its
DV to B, C
B sends its
DV to A, C
B
B
C
C
C
B
C
B
B
4
51
B 60 51
B 60 51
B 60 51
C
5
50
C 61 50
C 61 50
C 61 50
A
C
6∞
A
Node B
A
C
A
C
A 60
C
6∞
A 60
6∞
A 60
6∞
1
∞
C 65
1
C 110
1
C 110
1
A
B
A
B
A 50
5
A 50
5
B 54
1
B 54
1
A
C
Node C
A-B changed
4
∞
9
Link cost changes here
A
A 50
∞
B 101
B
A
B
5
A 50
61
1
∞
B 101
1
B
50
1
C
DV: Poisoned Reverse
60
4
A
If B routes through C to get to A:
B tells C its (B’s) distance to A is infinite
Stable
state
via
Node A
to
1
50
C
A-B changed
A sends its
DV to B, C
B sends its
DV to A, C
C sends its
DV to A, B
B
B
B
C
C
C
C
B
C
B
B
4
51
B 60 51
B 60 51
B 60 51
B 60 51
C
5
50
C 61 50
C 61 50
C 61 50
C 61 50
A
C
6∞
A
Node B
A
C
A
C
A
C
A 60
C
6∞
A 60
6∞
A 60
6∞
A 60
51
1
∞
C 65
1
C 110
1
C 110
1
C 110
1
A
B
A
B
A 50
5
A 50
5
B 54
1
B 54
1
A
C
Node C
B
4
∞
9
Link cost changes here
A
A 50
∞
B 101
B
A
B
A
5
A 50
61
A 50
B
∞
61
1
∞
B 101
1
∞
B 101
1
Converges after C receives
another update from B
Will Poison-Reverse Completely Solve
the Count-to-Infinity Problem?
D
1
100
∞
4
100
1∞
1
∞
63
A
∞
2
B
100
14
1
1
52
∞
C
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?


What if routers don’t use the same metric?


E.g., maximal capacity
I want low delay, you want low loss rate?
What happens if nodes lie?
E.g.: All nodes want to maximize capacity
Problem:“cost” does not change around loop
A high capacity link gets reduced to low capacity
Additive measures avoid this problem!
E.g.: no agreement on metrics
Cares about price,
then loss
Low price link
Low loss link
Cares about delay,
then price
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


Each node maintains global state



O(N) forwarding tables, where N is #nodes
The same is true for LS
Vulnerable to convergence problems



Recall LS: tell all nodes about your immediate neighbors
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



Link costs in RIP




Nodes send distance vectors every 30 seconds
… or, when an update causes a change in routing
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


What other forms of communication might A
want?




this is called a unicast route
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 registered
as 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
Download