Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 Routing Algorithm in Networks. How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth.

Similar presentations


Presentation on theme: "Chapter 5 Routing Algorithm in Networks. How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth."— Presentation transcript:

1 Chapter 5 Routing Algorithm in Networks

2 How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth (path) 2) Message-switching : using routing table share link bandwidth concept, 同一 msg 用 同一 path 3) Packet-switching : 不同路徑 for every packet out of order.

3 Routing Algorithm in Networks 24 1 6 35 6 5 4 3 2 1 1 1 1 1 1 Out of order Re-assembly problem Virtual circuit – msg delivered in the order transmitted – sharing, i.e. no dedicated paths. Implementation centralized ─ distributed Vulnerable to failure Comm. Of control infomation

4 Shortest Path Algorithm -Graph G = (V, A) d ij is the src weight of (i, j)  A. d ij =  if (i, j)  A. Source node is node 1 Set of nodes Set of Direct arcs # of nodes |V|=N

5 §5.2.3 Shortest Path P.396 §Bellman-Ford Alg. (can handle negative weights but not negative cycles) Let D i (h) be the length of a shortest path from 1 to i using h or fewer arcs (or links) Initially D 1 (0) = 0 D i (0) = , i  1 For each h = 0, 1, 2, …, N-2

6

7 §5.2.3 Shortest Path [Thm] : The alg. Finds the correct shortest path lengths proof by induction. are the lengths of the shortest path using 1 or fewer links.

8 §5.2.3 Shortest Path Induction step : suppose D i (h) are the correct length of shortest paths using h or fewer links. k1k1 ik1k1 k1k1 d k1i d k2i d k3i

9 §5.2.3 Shortest Path Complexity: 1) The alg. Requires at most N-1 iterations. 2) For each iteration, the recursion is performed by N-1 nodes. 3) Each application of the recursion requires no more than N-1 addition & comparisons  O(N 3 ) complexity. Example : see P.397. Fig 5.31

10 §Dijkstra ’ s Algorithm.(position arc weights only.) Let p be the set of nodes that are permanently labeled. Step 0 : set P={1}, D 1 = 0, and D j = d 1j,  j  1 Step 1 : Find i  P, s.t.

11 §Dijkstra ’ s Algorithm.(position arc weights only.) Step 2 :

12

13 §Dijkstra ’ s Algorithm.(position arc weights only.) After k iterations of the algorithm. P contains the k+1 nodes that are closest to node 1 and their permanent labels are the correct shortest path lengths from node 1. 24 1 6 35 1 1 1 1 1 2 2

14 §Dijkstra ’ s Algorithm.(position arc weights only.) Proof by inductions: True for k=1: Inductive step: suppose statement is true for any k. P={1, i 1,i 2, …,i k } are (k+1) closest nodes to 1. D k is length of the shortest path from 1 to k,  k  P.

15 §Dijkstra ’ s Algorithm.(position arc weights only.) i k-1 i1i1 ikik i i k+1

16 §Dijkstra ’ s Algorithm.(position arc weights only.) By construction, i k+1 is at least as close to 1 as any other node in Complexity: 1) The algorithm requires N-1 iterations. 2) For each iteration: 1) Step 1 : requires at most N comparison 2) Step 2 : requires at most N addition & comparisons.  complexity is O(N 2 )

17 §Floyd-Warshall algorithm Finds shortest path between every pair of nodes O(N 3 ) Negative arc weights(but no negative cycle) Note: every pair Bellman-Ford O(N 4 ) Dijkstra O(N 3 )

18 §Floyd-Warshall algorithm D ij (n) = shortest path length between nodes I and j using only nodes 1,2,3 … n as intermediate nodes on paths. Initially, D ij (0) = d ij For n=0,1,2, …,N-1 D ij (n+1) = min[D ij (n+1), D i,n+1 (n+1) +d n+1,j ] for all i  j

19

20 §Floyd-Warshall algorithm Example see fig.? Proof by induction : Complexity : 1. N iterations 2. Each iteration require N(N-1) comparisons & additions  O(N 3 )

21 Centralized, synchronous Bellmen-Ford Algorithm Let D i (h) be the shortest (<=h) path length from node 1 to node I Initially, D 1 (h) = 0 for all h D i (0) =  for i = 1

22 Centralized, synchronous Bellmen-Ford Algorithm => h is an index for iteration # (the # of links allowed in paths) ← synchronous => 有困難 h 必須 all the same

23 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm Let D i be the shortest path length from node i to 1. Let N(i) = { j|(i,j)  A }

24 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm Let Di be the shortest path length from node i to 1. Let N(i) = { j|(i,j)  A } Neighbor At each time t, each node i  1 has available: D j i (t) : i ’ s latest estimate (sent by node i) of the shortest distance from node j  N(i) to node 1. D i (t) : i ’ s latest estimate (computed by node i) of the shortest distance from node i to 1

25 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm At each point in time, each node. i  1 is doing one of the followings : 1. Node i update D i (t) by And leaves the estimate D j i (t), j  N(i) unchanged & sends D i, j  N(i) 2. Node i receives from one or more neighbors D i, j  N(i) computed by j at an earlier time. Node i update D j i (t) and leaves other estimate unchanged. 3. Node i is idle.

26 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm  Prove convergence of the distributed asyn. B-F Alg. Let T i be the set of times at which node i update D i (t) Let T j i be the set of times at which node i update D j (t) Let {t 0, t 1 … } be the ordering of

27 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm Assumptions: 1. nodes never stop updateing their estimate D i (t) and receiving msg. from all their neighbors D j i (t), j  N(i), T i, T j i have  # of elements. 2. All estimates D i (t), D j i (t),  i  V, j  N(i) are non-negative. 3. Old distance information is eventually purged from the system.

28 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm Let D i k be the k-th iteration of Bellman- Ford (k=0,1,2 … ) for node i = 1,2, … N when Let D i k be the k-th iteration of Bellman- Ford when D i (0) = 0, i = 1,2, … N

29 § 5.2.4 Distributed Asynchronous Bellman-Ford Algorithm

30

31

32


Download ppt "Chapter 5 Routing Algorithm in Networks. How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth."

Similar presentations


Ads by Google