William Stallings Data and Computer Communications 7 th

  • Slides: 15
Download presentation
William Stallings Data and Computer Communications 7 th Edition Chapter 12 Routing

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

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

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

Packet Switched Network example

Packet Switched Network example

Least Cost Algoritm • Routing decision —Number of hops —link cost reflects capacity •

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

Dijkstra Algorithm Definitions • Searches the least cost path from a source node to

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

Dijkstra Algorithm Method • Step 1 [Initialization] — T = {s} Source Node —

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

Algoritm Dijkstra Observations • At finish, value L(x) asociated to each node x is

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

Example Algorithm Dijkstra

Example Algorithm Dijkstra

Results for Dijkstra Algorithm Ite rat ion T L(2) Path L(3) Path L(4) Path

Results for Dijkstra Algorithm Ite rat ion T L(2) Path L(3) Path L(4) Path L(5) Path L(6) Path 1 {1} 2 1– 2 5 1 -3 1 1– 4 - - 2 {1, 4} 2 1– 2 4 1 -4 -3 1 1– 4 2 1 -4– 5 - 3 {1, 2, 4} 2 1– 2 4 1 -4 -3 1 1– 4 2 1 -4– 5 - 4 {1, 2, 4, 5} 2 1– 2 3 1 -4 -5– 3 1 1– 4 2 1 -4– 5 4 1 -4 -5– 6 5 {1, 2, 3, 4, 5} 2 1– 2 3 1 -4 -5– 3 1 1– 4 2 1 -4– 5 4 1 -4 -5– 6 6 {1, 2, 3, 4, 5, 6} 2 1 -2 3 1 -4 -5 -3 1 1 -4 2 1 -4– 5 4 1 -4 -5 -6

Algoritm Bellman-Ford Definitions • Find shortest paths from source node such that paths contain

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 • Lh(n) =cost of least-cost path from s to n such that no more than h links

Algorithm Bellman-Ford [Initialization] step 1 L 0(n) = , for all n s Lh(s)

Algorithm Bellman-Ford [Initialization] step 1 L 0(n) = , for all n s Lh(s) = 0, for all h [Update] step 2 For each successive h 0: For each n ≠ s, compute Lh+1(n)=minj[Lh(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

Observaţii Algoritm Bellman. Ford • At each iteration of step 2 for h=K and

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

Bellman-Ford Ex.

Bellman-Ford Ex.

Bellman-Ford Results h Lh(2) Path Lh(3) Path Lh(4) Path Lh(5) Path Lh(6) Path 0

Bellman-Ford Results h Lh(2) Path Lh(3) Path Lh(4) Path Lh(5) Path Lh(6) Path 0 - - - 1 2 1 -2 5 1 -3 1 1 -4 - - 2 2 1 -2 4 1 -4 -3 1 1 -4 2 1 -4 -5 10 1 -3 -6 3 2 1 -2 3 1 -4 -5 -3 1 1 -4 2 1 -4 -5 4 1 -4 -5 -6 4 2 1 -2 3 1 -4 -5 -3 1 1 -4 2 1 -4 -5 4 1 -4 -5 -6

B. -F. vs. Dijkstra • Dijkstra — Each node must know link costs of

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. , Lh(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