Presentation is loading. Please wait.

Presentation is loading. Please wait.

William Stallings Data and Computer Communications 7 th Edition Chapter 12 Routing.

Similar presentations


Presentation on theme: "William Stallings Data and Computer Communications 7 th Edition Chapter 12 Routing."— Presentation transcript:

1 William Stallings Data and Computer Communications 7 th Edition Chapter 12 Routing

2 Performance Criteria Used for path selection —Minimum hop count —Minimum cost

3 Packet Switched Network example

4 Least Cost Algoritm Routing decision —Number of hops —link cost reflects capacity Network with bidirectional links Each link has a cost associated in both directions Path cost equal to sum of link costs Least cost path searched for each pair of nodes Costs can be different on diff. directions

5 Dijkstra Algorithm Definitions Searches the least cost path from a source node to all other nodes by examining paths of increasing length or number of hops N =set of nodes of the network s = source node T =setul of nodes incorporated in the algorithm w(i, j) = cost of link from node i to node j —w(i, i) = 0 —w(i, j) =  if not directly connected —w(i, j)  0 if directly connected L(n) = least cost path from node s to n known —At finish, L(n) is the least cost from s to all n

6 Dijkstra Algorithm Method Step 1 [Initialization] —T = {s} Source Node —L(n) = w(s, n) for n ≠ s —Initialy only link costs Step 2 [Next Node] —Searches neighbour node not incorporated in T with minimum cost to s —Incorporate nod in T Step 3 [Update least cost path] —L(n) = min[L(n), L(x) + w(x, n)] for all n  T —If second term is min. update path by concatenation [Finish ] Algorithm ends when all nodes incorporated in T

7 Algoritm Dijkstra Observations At finish, value L(x) asociated to each node x is the cost (lenght) of least cost path from s to x. T defines the least cost path from s to every other node One iteration of steps 2 and 3 adds a new node to T

8 Example Algorithm Dijkstra

9 Results for Dijkstra Algorithm Ite rat ion TL(2)PathL(3)PathL(4)PathL(5)PathL(6 ) Path 1{1}21–251-311–4  -  - 2{1,4}21–241-4-311–421-4–5  - 3{1, 2, 4}21–241-4-311–421-4–5  - 4{1, 2, 4, 5} 21–231-4-5–311–421-4–541-4-5–6 5{1, 2, 3, 4, 5} 21–231-4-5–311–421-4–541-4-5–6 6{1, 2, 3, 4, 5, 6} 21-231-4-5-311-421-4–541-4-5-6

10 Algoritm Bellman-Ford Definitions Find shortest paths from source node such that paths contain at most one link Find shortest paths such that paths have at most two links And so on s = source node w(i, j) = link cost from node i to node j w(i, i) = 0 w(i, j) =  if nodes are directly connected w(i, j)  0 if nodes directly connected h = maximum number of links in path at current stage L h (n) =cost of least-cost path from s to n such that no more than h links

11 Algorithm Bellman-Ford [Initialization] step 1 L 0 (n) = , for all n  s L h (s) = 0, for all h [Update] step 2 For each successive h  0: For each n ≠ s, compute L h+1 (n)= min j [L h (j)+w(j,n)] Connect n with predecessor node j that achieves minimum Eliminate any connection of n with different predecessor node formed during an earlier iteration Path from s to n terminates with link from j to n

12 Observaţii Algoritm Bellman- Ford At each iteration of step 2 for h=K and each destination node n, the algorithm compares paths from source s to n of length K+1 with the path from previous iteration The path with lesser cost is maintained as best cost path

13 Bellman-Ford Ex.

14 Bellman-Ford Results hL h (2)PathL h (3)PathL h (4)PathL h (5)PathL h (6)Path 0  -  -  -  -  - 121-251-311-4  -  - 221-241-4-311-421-4-5101-3-6 321-231-4-5-311-421-4-541-4-5-6 421-231-4-5-311-421-4-541-4-5-6

15 B.-F. vs. Dijkstra Dijkstra —Each node must know link costs of all links —Information must be exchanged with all other nodes Both converge under static conditions to same solution If costs change algorithm will attempt to catch up If cost depends on traffic Depends on routes chosen then feedback condition exists Bellman-Ford —Link cost to all neighboring nodes to node n [i.e., w(j, n)] plus total path cost to those neighboring nodes from a particular source node s [i.e., L h (j)] —Each node can maintain set of costs and associated paths for every other node and exchange information with direct neighbors —Each node can use Bellman-Ford based only on information from neighbors and knowledge of its link costs —Instabilities may result


Download ppt "William Stallings Data and Computer Communications 7 th Edition Chapter 12 Routing."

Similar presentations


Ads by Google