link state and distance vector routingweb.eecs.umich.edu/~zmao/eecs489/lectureslides/routing1...mao...
TRANSCRIPT
1Mao F04
Link State and Distance Vector Routing
EECS 489 Computer Networkshttp://www.eecs.umich.edu/~zmao/eecs489
Z. Morley MaoTuesday Sept 21, 2004
Acknowledgement: Some slides adapted from Kurose&Ross and Katz&Stoica
2Mao F04
IP Header
§ Vers: IP versions§ HL: Header length (in 32-
bits)§ Type: Type of service§ Length: size of datagram
(header + data; in bytes) § Identification: fragment ID§ Fragment offset: offset of
current fragment (x 8 bytes)§ TTL: number of network
hops§ Protocol: protocol type (e.g.,
TCP, UDP)§ Source IP addresses§ Destination IP address
3Mao F04
What is Routing?
Routing is the core function of a networkIt ensures that
• information accepted for transfer • at a source node • is delivered to the correct• set of destination nodes, • at reasonable levels of performance.
4Mao F04
Internet Routing
§ Internet organized as a two level hierarchy§ First level – autonomous systems (AS’s)
- AS – region of network under a single administrative domain
§ AS’s run an intra-domain routing protocols- Distance Vector, e.g., Routing Information Protocol (RIP)- Link State, e.g., Open Shortest Path First (OSPF)
§ Between AS’s runs inter-domain routing protocols, e.g., Border Gateway Routing (BGP)- De facto standard today, BGP-4
5Mao F04
Example
AS-1
AS-2
AS-3
Interior router
BGP router
6Mao F04
Intra-domain Routing Protocols
§ Based on unreliable datagram delivery§ Distance vector
- Routing Information Protocol (RIP), based on Bellman-Ford- Each neighbor periodically exchange reachability information
to its neighbors- Minimal communication overhead, but it takes long to
converge, i.e., in proportion to the maximum path length
§ Link state- Open Shortest Path First (OSPF), based on Dijkstra- Each network periodically floods immediate reachability
information to other routers- Fast convergence, but high communication and computation
overhead
7Mao F04
Routing
§ Goal: determine a “good” path through the network from source to destination
- Good means usually the shortest path
§ Network modeled as a graph- Routers à nodes- Link àedges
• Edge cost: delay, congestion level,…
A
ED
CB
F
22
13
1
1
2
53
5
8Mao F04
1
23
0111
value in arrivingpacket’s header
routing algorithm
local forwarding tableheader value output link
0100010101111001
3221
Interplay between routing and forwarding
9Mao F04
u
yx
wv
z2
21
3
1
1
2
53
5
Graph: G = (N,E)
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
Graph abstraction
Remark: Graph abstraction is useful in other network contexts
Example: P2P, where N is set of peers and E is set of TCP connections
10Mao F04
Graph abstraction: costs
u
yx
wv
z2
21
3
1
1
2
53
5 • c(x,x’) = cost of link (x,x’)
- e.g., c(w,z) = 5
• cost could always be 1, or inversely related to bandwidth,or inversely related to congestion
Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)
Question: What’s the least-cost path between u and z ?
Routing algorithm: algorithm that finds least-cost path
11Mao F04
Routing Algorithm classification
Global or decentralized information?
Global:§ all routers have complete
topology, link cost info§ “link state” algorithmsDecentralized:§ router knows physically-
connected neighbors, link costs to neighbors
§ iterative process of computation, exchange of info with neighbors
§ “distance vector” algorithms
Static or dynamic?Static:§ routes change slowly over
timeDynamic:§ routes change more quickly
- periodic update- in response to link cost
changes
12Mao F04
Outline
Ø Link State§ Distance Vector
13Mao F04
A Link State Routing Algorithm
Dijkstra’s algorithm§ Net topology, link costs known
to all nodes- Accomplished via “link
state flooding” - All nodes have same info
§ Compute least cost paths from one node (‘source”) to all other nodes
§ Iterative: after k iterations, know least cost paths to k closest destinations
Notations§ c(i,j): link cost from node i
to j; cost infinite if not direct neighbors
§ D(v): current value of cost of path from source to destination v
§ p(v): predecessor node along path from source to v, that is next to v
§ S: set of nodes whose least cost path definitively known
14Mao F04
Link State Flooding Example
6
7
8
5
4
31
2
12
10
13
11
15Mao F04
Link State Flooding Example
6
7
8
5
4
31
2
12
10
13
11
16Mao F04
Link State Flooding Example
6
7
8
5
4
31
2
12
10
13
11
17Mao F04
Link State Flooding Example
6
7
8
5
4
31
2
12
10
13
11
18Mao F04
Dijsktra’s Algorithm
1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;7 8 Loop9 find w not in S such that D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );
// new cost to v is either old cost to v or known// shortest path cost to w plus cost from w to v
13 until all nodes in S;
∞
Notations
§c(i,j): link cost from node i to j; cost infinite if not direct
neighbors
§D(v): current value of cost of path from source to destination v
§p(v): predecessor node along path from source to v, that is
next to v
§S: set of nodes whose least cost path definitively known
19Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
D(B),p(B)2,A
D(C),p(C)5,A
D(D),p(D)1,A
D(E),p(E) D(F),p(F)
A
ED
CB
F
22
13
1
1
2
53
5
∞ ∞
1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;…
∞
20Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
AD
D(B),p(B)2,A
D(C),p(C)5,A4,D
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
A
ED
CB
F
22
13
1
1
2
53
5
∞ ∞∞
…8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );13 until all nodes in S;
21Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
ADADE
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
∞ ∞∞
A
ED
CB
F
22
13
1
1
2
53
5…8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );13 until all nodes in S;
22Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
ADADE
ADEB
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
∞ ∞∞
A
ED
CB
F
22
13
1
1
2
53
5…8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );13 until all nodes in S;
23Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
ADADE
ADEBADEBC
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
∞ ∞∞
A
ED
CB
F
22
13
1
1
2
53
5…8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );13 until all nodes in S;
24Mao F04
Example: Dijkstra’s Algorithm
Step012345
start SA
ADADE
ADEBADEBC
ADEBCF
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
∞ ∞∞
A
ED
CB
F
22
13
1
1
2
53
5…8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 D(v) = min( D(v), D(w) + c(w,v) );13 until all nodes in S;
25Mao F04
Complexity
§ Assume a network consisting of n nodes- Each iteration: need to check all nodes, w, not in S- n*(n+1)/2 comparisons: O(n2)- More efficient implementations possible: O(n*log(n))
26Mao F04
Oscillations
§ Assume link cost = amount of carried traffic
A
D
C
B1 1+e
e0
e
1 1
0 0
initially
A
D
C
B2+e 0
001+e 1
… recomputerouting
A
D
C
B0 2+e
1+e10 0
… recompute
A
D
C
B2+e 0
e01+e 1
… recompute
§ How can you avoid oscillations?
27Mao F04
Outline
§ Link StateØ Distance Vector
28Mao F04
Distance Vector Routing Algorithm
§ Iterative: continues until no nodes exchange info§ Asynchronous: nodes need not exchange info/iterate in lock
steps§ Distributed: each node communicates only with directly-
attached neighbors§ Each router maintains
- Row for each possible destination- Column for each directly-attached neighbor to node- Entry in row Y and column Z of node X è best known distance from X
to Y, via Z as next hop (remember this !)
§ Note: for simplicity in this lecture examples we show only the shortest distances to each destination
29Mao F04
Distance Vector Routing
§ Each local iteration caused by: - Local link cost change - Message from neighbor: its least cost
path change from neighbor to destination
§ Each node notifies neighbors onlywhen its least cost path to any destination changes- Neighbors then notify their neighbors if
necessary
wait for (change in local link cost or msg from neighbor)
recompute distance table
if least cost path to any desthas changed, notifyneighbors
Each node:
30Mao F04
Distance Vector Algorithm (cont’d)
1 Initialization:2 for all neighbors V do3 if V adjacent to A4 D(A, V) = c(A,V); 5 else• D(A, V) = 8; • loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do12 D(A,Y) = D(A,Y) + d13 else if (update D(V, Y) received from V)
/* shortest path from V to some Y has changed */14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
31Mao F04
Example: Distance Vector Algorithm
A C12
7
B D3
1-8D
C7C
B2B
NextHopCostDest.
Node A
D3D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
A7A
NextHopCostDest.
Node C
C1C
B3B
-8A
NextHopCostDest.
Node D1 Initialization:2 for all neighbors V do3 if V adjacent to A4 D(A, V) = c(A,V); 5 else6 D(A, V) = 8; …
32Mao F04
C8D
C7C
B2B
NextHopCostDest.
Node A
Example: 1st Iteration (C à A)
A C12
7
B D3
1D3D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
A7A
NextHopCostDest.
Node C
C1C
B3B
-8A
NextHopCostDest.
Node D
D(A, D) = D(A, C) + D(C,D) = 7 + 1 = 8
(D(C,A), D(C,B), D(C,D))
7 loop:…
13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
33Mao F04
B5D
B3C
B2B
NextHopCostDest.
Node A
Example: 1st Iteration (BàA, CàA)
A C12
7
B D3
1D3D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
A7A
NextHopCostDest.
Node C
C1C
B3B
-8A
NextHopCostDest.
Node D
D(A,D) = D(A,B) + D(B,D) = 2 + 3 = 5 D(A,C) = D(A,B) + D(B,C) = 2 + 1 = 3
7 loop:…
13 else if (update D(V, Y) received from V) 14 D(A,Y) = min(D(A,V), D(A,V) + D(V, Y))15 if (there is a new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
34Mao F04
Example: End of 1st Iteration
A C12
7
B D3
1B5D
B3C
B2B
NextHopCostDest.
Node A
C2D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
B3A
NextHopCostDest.
Node C
C1C
C2B
B5A
NextHopCostDest.
Node D7 loop:
…13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
35Mao F04
Example: End of 2nd Iteration
A C12
7
B D3
1B4D
B3C
B2B
NextHopCostDest.
Node A
C2D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
B3A
NextHopCostDest.
Node C
C1C
C2B
C4A
NextHopCostDest.
Node D7 loop:
…13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
36Mao F04
Example: End of 3rd Iteration
A C12
7
B D3
1B4D
B3C
B2B
NextHopCostDest.
Node A
C2D
C1C
A2A
NextHopCostDest.
Node B
D1D
B1B
B3A
NextHopCostDest.
Node C
C1C
C2B
C4A
NextHopCostDest.
Node D
Nothing changes à algorithm terminates
7 loop:…
13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
37Mao F04
Distance Vector: Link Cost Changes
A C14
50
B1
“goodnews travelsfast”
B1C
A4A
NCDNode B
B1B
B5A
NCDNode C
B1C
A1A
NCD
B1B
B5A
NCD
B1C
A1A
NCD
B1B
B2A
NCD
B1C
A1A
NCD
B1B
B2A
NCD
Link cost changes heretime
7 loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do12 D(A,Y) = D(A,Y) + d13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
Algorithm terminates
38Mao F04
Distance Vector: Count to Infinity Problem
A C14
50
B60
“badnews travelsslowly”
B1C
A4A
NCDNode B
B1B
B5A
NCDNode C
B1C
C6A
NCD
B1B
B5A
NCD
B1C
C6A
NCD
B1B
B7A
NCD
B1C
C8A
NCD
B1B
B2A
NCD
Link cost changes here; recall that B also maintains shortest distance to A through C, which is 6. Thus D(B, A) becomes 6 !
time
7 loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do12 D(A,Y) = D(A,Y) + d ;13 else if (update D(V, Y) received from V) 14 D(A,Y) = D(A,V) + D(V, Y);15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
…
39Mao F04
Distance Vector: Poisoned Reverse
A C14
50
B60§ If C routes through B to get to A:
- C tells B its (C’s) distance to A is infinite (so B won’t route to A via C)
- Will this completely solve count to infinity problem?
B1C
A4A
NCDNode B
B1B
B5A
NCDNode C
B1C
A60A
NCD
B1B
B5A
NCD
B1B
A50A
NCD
Link cost changes here; B updates D(B, A) = 60 as C has advertised D(C, A) = 8
time
B1C
A60A
NCD
B1B
A50A
NCD
B1C
C51A
NCD
B1B
A50A
NCD
B1C
C51A
NCD
Algorithm terminates
40Mao F04
Look at this example
§ Initially, both A and B have a distance 2 to D, C has a distance 1
§ Assume CD goes down§ Using split horizon, A and
B tell C that they cannot get to D
§ C concludes D is unreachable, reports to A and B
§ A hears that B has a path of length 2 to D
§ B concludes it can get to D via A in 3 hops
§ A and B set their distance to D to 4
§ Count to infinity????
A B
C
D
41Mao F04
Link State vs. Distance Vector
Per node message complexity§ LS: O(n*e) messages; n –
number of nodes; e – number of edges
§ DV: O(d) messages; where d is node’s degree
Complexity§ LS: O(n2) with O(n*e)
messages§ DV: convergence time varies
- may be routing loops- count-to-infinity problem
Robustness: what happens if router malfunctions?
§ LS: - node can advertise incorrect
link cost- each node computes only its
own table
§ DV:- node can advertise incorrect
path cost- each node’s table used by
others; error propagate through network