200 likes | 312 Views
TCP/IP Network Layer (1). 5. 3. v. w. 2. 5. u. 2. 1. z. 3. 1. 2. x. y. 1. Routing. Routing protocol Goal: determine “good” path (sequence of routers) through network from source to destination. Graph abstraction for routing algorithms: graph nodes are routers
E N D
5 3 v w 2 5 u 2 1 z 3 1 2 x y 1 Routing • Routing protocol • Goal: determine “good” path (sequence of routers) through network from source to destination. • Graph abstraction for routing algorithms: • graph nodes are routers e.g. N={u,v,w,x,y,z} • graph edges are physical links e.g. E={(u,v), (u,x)…..(y,z)} • link cost: delay, $ cost, or congestion level • 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) • “good” path: • typically means minimum cost path • other definitions possible
Global or decentralized information? Global: all routers have complete topology, link cost information “link state” algorithms Decentralized: router knows physically-connected neighbors, link costs to neighbors iterative process of computation, exchange of information with neighbors “distance vector” algorithms Routing Algorithm Classification Static or dynamic? Static: • routes change slowly over time Dynamic: • routes change more quickly • periodic update • in response to link cost changes
Dijkstra’s algorithm net topology, link costs known to all nodes accomplished via “link state broadcast” all nodes have same information computes least cost paths from one node (‘source”) to all other nodes gives forwarding table for that node iterative: after k iterations, know least cost path to k destinations A Link-State Routing Algorithm Notation: • c(x,y): link cost from node x to y; = ∞ if not direct neighbors • D(v): current value of least cost of path from source to node v • p(v): immediate predecessor node along path from source to v • N: set of nodes whose least cost path definitively known
Dijsktra’s Algorithm Initialization: 2 N = {i} 3 for all nodes j 4 if j adjacent to i 5 then D(j) = c(i,j) 6 else D(j) = ∞ 7 8 Loop 9 find k not in N such that D(k) is a minimum 10 add k to N 11 update D(j) for all j adjacent to k and not in N : 12 D(j) = min( D(j), D(k) + c(k,j) ) 13 /* new cost to j is either old cost to j or known 14 shortest path cost to k plus cost from k to j */ 15 until all nodes in N
5 3 v w 2 5 u 2 1 z 3 1 2 x y 1 Dijsktra’s Algorithm (Example) Step N D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z) 0 u 2,u 5,u 1,u ∞ ∞ 1 ux 2,u 4,x 2,x ∞ 2 uxy 2,u 3,y 4,y 3 uxyv 3,y 4,y 4 uxyvw 4,y 5 uxyvwz Initialization: 2 N = {i} 3 for all nodes j 4 if j adjacent to i 5 then D(j) = c(i,j) 6 else D(j) = ∞ 7 8 Loop 9 find k not in N such that D(k) is a minimum 10 add k to N 11 update D(j) for all j adjacent to k and not in N : 12 D(j) = min( D(j), D(k) + c(k,j) ) 13 /* new cost to j is either old cost to j or known 14 shortest path cost to k plus cost from k to j */ 15 until all nodes in N
A A A A D D D D B B B B C C C C 1 1+e 2+e 0 2+e 0 2+e 0 0 0 1 1+e 0 0 1 1+e e 0 0 0 e 1 1+e 0 1 1 e … recompute … recompute routing … recompute initially Link-State Routing - Discussion Algorithm complexity: n nodes • each iteration: need to check all nodes, k, not in N • n + (n-1) + … + 1 = n(n+1)/2 comparisons, i.e. O(n2) • more efficient implementations possible: O(nlogn) Weakness of Link State Routing • Oscillations may arise, e.g., consider link cost = amount of carried traffic • Remedy: don’t allow all the routers to run LSR at the same time
= distance from X to Y, via Z as next hop = Distance Vector Routing Algorithm • distributed: • each node communicates only with directly-attached neighbors • iterative: • continues until no nodes exchange information. • self-terminating: no “signal” to stop • asynchronous: • nodes need not exchange information/iterate in lock step! • Distance Table data structures • each node has its own distance table (leads to routing table) • row for each possible destination • column for each directly-attached neighbor to node • consider node X, for destination. Y via neighbor Z, distance table entry is given by the equation:
wait for (change in local link cost of msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Distance Vector Routing Algorithm Iterative, asynchronous: each local iteration caused by: • local link cost change • DV update message from neighbor Distributed: • each node notifies neighbors only when its DV changes • neighbors then notify their neighbors if necessary Each node:
Distance Vector Algorithm: Example 1 Initialization: 2 for all adjacent nodes v: 3 DX(*,v) = infty /* the * operator means "for all rows" */ 4 DX(v,v) = c(X,v) 5 for all destinations, y 6 send minwD(y,w) to each neighbor /* w over all X's neighbors */ 7 8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive update from neighbor V) 11 12 if (c(X,V) changes by d) 13 /* change cost to all dest's via neighbor v by d */ 14 /* note: d could be positive or negative */ 15 for all destinations y: DX(y,V) = DX(y,V) + d 16 17 else if (update received from V wrt destination Y) 18 /* shortest path from V to some Y has changed */ 19 /* V has sent a new value for its minw DV(Y,w) */ 20 /* call this received new value is "newval" */ 21 for the single destination y: DX(Y,V) = c(X,V) + newval 22 23 if we have a new minw DX(Y,w)for any destination Y 24 send new value of minw DX(Y,w) to all neighbors 25 26 forever
1 4 1 50 x z y Distance Vector : link cost changes • node detects local link cost change • updates routing info, recalculates distance vector • if cost change in least cost path, notify neighbors • At time t0, y detects the link-cost change, updates its DV, and • informs its neighbors. • At time t1, z receives the update from y and updates its table. It computes a • new least cost to x and sends its neighbors its DV. • At time t2, y receives z’s update and updates its distance table. • y’s least costs do not change and hence y does not send any message to z.
60 4 1 50 x z y Distance Vector : link cost changes • good news travels fast • bad news travels slow - “count to infinity” problem!
60 4 1 50 x z y Distance Vector : Poisoned Reverse • If Z routes through Y to get to X : • Z tells Y its (Z’s) distance to X is infinite • (so Y won’t route to X via Z)