Presentation is loading. Please wait.

Presentation is loading. Please wait.

Katz, Stoica F04 EECS 122: Introduction to Computer Networks Link State and Distance Vector Routing Computer Science Division Department of Electrical.

Similar presentations


Presentation on theme: "Katz, Stoica F04 EECS 122: Introduction to Computer Networks Link State and Distance Vector Routing Computer Science Division Department of Electrical."— Presentation transcript:

1 Katz, Stoica F04 EECS 122: Introduction to Computer Networks Link State and Distance Vector Routing Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley Berkeley, CA 94720-1776

2 Katz, Stoica F04 2 Today’s Lecture: 7 Network (IP) Application Transport Link Physical 2 7, 8, 9 10, 11 17, 18, 19 14, 15, 16 21, 22, 23 25 6

3 Katz, Stoica F04 3 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

4 Katz, Stoica F04 4 What is Routing? Routing is the core function of a network It ensures that information accepted for transfer at a source node is delivered to the correct set of destination nodes, at reasonable levels of performance.

5 Katz, Stoica F04 5 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

6 Katz, Stoica F04 6 Example AS-1 AS-2 AS-3 Interior router BGP router

7 Katz, Stoica F04 7 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

8 Katz, Stoica F04 8 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 E D CB F 2 2 1 3 1 1 2 5 3 5

9 Katz, Stoica F04 9 Outline  Link State  Distance Vector

10 Katz, Stoica F04 10 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

11 Katz, Stoica F04 11 Link State Flooding Example 6 7 8 5 4 3 1 2 12 10 13 11

12 Katz, Stoica F04 12 Link State Flooding Example 6 7 8 5 4 3 1 2 12 10 13 11

13 Katz, Stoica F04 13 Link State Flooding Example 6 7 8 5 4 3 1 2 12 10 13 11

14 Katz, Stoica F04 14 Link State Flooding Example 6 7 8 5 4 3 1 2 12 10 13 11

15 Katz, Stoica F04 15 Dijsktra’s Algorithm 1 Initialization: 2 S = {A}; 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A,v); 6 else D(v) = ; 7 8 Loop 9 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;

16 Katz, Stoica F04 16 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A 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 E D CB F 2 2 1 3 1 1 2 5 3 5 1 Initialization: 2 S = {A}; 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A,v); 6 else D(v) = ; …

17 Katz, Stoica F04 17 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A AD D(B),p(B) 2,A D(C),p(C) 5,A 4,D D(D),p(D) 1,A D(E),p(E) 2,D D(F),p(F) A E D CB F 2 2 1 3 1 1 2 5 3 5 … 8 Loop 9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11update 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;

18 Katz, Stoica F04 18 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A AD ADE D(B),p(B) 2,A D(C),p(C) 5,A 4,D 3,E D(D),p(D) 1,A D(E),p(E) 2,D D(F),p(F) 4,E A E D CB F 2 2 1 3 1 1 2 5 3 5 … 8 Loop 9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11update 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;

19 Katz, Stoica F04 19 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A AD ADE ADEB D(B),p(B) 2,A D(C),p(C) 5,A 4,D 3,E D(D),p(D) 1,A D(E),p(E) 2,D D(F),p(F) 4,E A E D CB F 2 2 1 3 1 1 2 5 3 5 … 8 Loop 9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11update 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;

20 Katz, Stoica F04 20 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A AD ADE ADEB ADEBC D(B),p(B) 2,A D(C),p(C) 5,A 4,D 3,E D(D),p(D) 1,A D(E),p(E) 2,D D(F),p(F) 4,E A E D C B F 2 2 1 3 1 1 2 5 3 5 … 8 Loop 9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11update 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;

21 Katz, Stoica F04 21 Example: Dijkstra’s Algorithm Step 0 1 2 3 4 5 start S A AD ADE ADEB ADEBC ADEBCF D(B),p(B) 2,A D(C),p(C) 5,A 4,D 3,E D(D),p(D) 1,A D(E),p(E) 2,D D(F),p(F) 4,E A E D CB F 2 2 1 3 1 1 2 5 3 5 … 8 Loop 9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11update 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;

22 Katz, Stoica F04 22 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(n 2 ) -More efficient implementations possible: O(n*log(n))

23 Katz, Stoica F04 23 Oscillations  Assume link cost = amount of carried traffic A D C B 1 1+e e 0 e 1 1 0 0 initially A D C B 2+e 0 0 0 1+e 1 … recompute routing A D C B 0 2+e 1+e 1 0 0 … recompute A D C B 2+e 0 e 0 1+e 1 … recompute  How can you avoid oscillations?

24 Katz, Stoica F04 24 Outline  Link State  Distance Vector

25 Katz, Stoica F04 25 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

26 Katz, Stoica F04 26 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 only when 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 dest has changed, notify neighbors Each node:

27 Katz, Stoica F04 27 Distance Vector Algorithm (cont’d) 1 Initialization: 2 for all neighbors V do 3 if V adjacent to A 4 D(A, V) = c(A,V); 5 else D(A, V) = ∞; loop: 8 wait (until A sees a link cost change to neighbor V 9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do 12 D(A,Y) = D(A,Y) + d 13 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

28 Katz, Stoica F04 28 Example: Distance Vector Algorithm A C 1 2 7 B D 3 1 Dest.CostNextHop B2B C7C D∞- Node A Dest.CostNextHop A2A C1C D3D Node B Dest.CostNextHop A7A B1B D1D Node C Dest.CostNextHop A∞- B3B C1C Node D 1 Initialization: 2 for all neighbors V do 3 if V adjacent to A 4 D(A, V) = c(A,V); 5else 6 D(A, V) = ∞; …

29 Katz, Stoica F04 29 Dest.CostNextHop B2B C7C D8C Node A Example: 1 st Iteration (C  A) A C 1 2 7 B D 3 1 Dest.CostNextHop A2A C1C D3D Node B Dest.CostNextHop A7A B1B D1D Node C Dest.CostNextHop A∞- B3B C1C Node D D(A, D) = D(A, C) + D(C,D) = 7 + 1 = 8 (D(C,A), D(C,B), D(C,D)) 7loop: … 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

30 Katz, Stoica F04 30 Dest.CostNextHop B2B C3B D5B Node A Example: 1 st Iteration (B  A, C  A) A C 1 2 7 B D 3 1 Dest.CostNextHop A2A C1C D3D Node B Dest.CostNextHop A7A B1B D1D Node C Dest.CostNextHop A∞- B3B C1C Node D D(A,D) = D(A,B) + D(B,D) = 2 + 3 = 5D(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

31 Katz, Stoica F04 31 Example: End of 1 st Iteration A C 1 2 7 B D 3 1 Dest.CostNextHop B2B C3B D5B Node A Dest.CostNextHop A2A C1C D2C Node B Dest.CostNextHop A3B B1B D1D Node C Dest.CostNextHop A5B B2C C1C Node 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

32 Katz, Stoica F04 32 Example: End of 2 nd Iteration A C 1 2 7 B D 3 1 Dest.CostNextHop B2B C3B D4B Node A Dest.CostNextHop A2A C1C D2C Node B Dest.CostNextHop A3B B1B D1D Node C Dest.CostNextHop A4C B2C C1C Node 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

33 Katz, Stoica F04 33 Example: End of 3 rd Iteration A C 1 2 7 B D 3 1 Dest.CostNextHop B2B C3B D4B Node A Dest.CostNextHop A2A C1C D2C Node B Dest.CostNextHop A3B B1B D1D Node C Dest.CostNextHop A4C B2C C1C 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

34 Katz, Stoica F04 34 Distance Vector: Link Cost Changes A C 1 4 50 B 1 “good news travels fast” DCN A4A C1B Node B DCN A5B B1B Node C DCN A1A C1B DCN A5B B1B DCN A1A C1B DCN A2B B1B DCN A1A C1B DCN A2B B1B Link cost changes here time 7 loop: 8 wait (until A sees a link cost change to neighbor V 9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do 12 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 Algorithm terminates

35 Katz, Stoica F04 35 Distance Vector: Count to Infinity Problem A C 1 4 50 B 60 “bad news travels slowly” DCN A4A C1B Node B DCN A5B B1B Node C DCN A6C C1B DCN A5B B1B DCN A6C C1B DCN A7B B1B DCN A8C C1B DCN A2B B1B Link cost changes here; recall from slide 24 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 V 9 or until A receives update from neighbor V) 10 if (D(A,V) changes by d) 11 for all destinations Y through V do 12 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 …

36 Katz, Stoica F04 36 Distance Vector: Poisoned Reverse A C 1 4 50 B 60  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? DCN A4A C1B Node B DCN A5B B1B Node C DCN A60A C1B DCN A5B B1B DCN A50A B1B Link cost changes here; B updates D(B, A) = 60 as C has advertised D(C, A) = ∞ time DCN A60A C1B DCN A50A B1B DCN A51C C1B DCN A50A B1B DCN A51C C1B Algorithm terminates

37 Katz, Stoica F04 37 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(n 2 ) 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


Download ppt "Katz, Stoica F04 EECS 122: Introduction to Computer Networks Link State and Distance Vector Routing Computer Science Division Department of Electrical."

Similar presentations


Ads by Google