Internet Technolog 08. Routing Paul Kranoski Rutgers Universit Spring 06 March, 06 CS 0-06 Paul Kranoski
Routing algorithm goal st hop router = source router last hop router = destination router router router sitch LAN LAN Routing algorithm: given routers connected ith links, hat is a good (best?) path a source to a destination router good = least cost cost = time or mone March, 06 CS 0-06 Paul Kranoski
Routing graphs, neighbors, and cost v u Graph G = (N, E) N = set of nodes (routers) E = set of edges (links) Each edge = pair of connected nodes in N Node is a neighbor of node if (, ) E Cost Each edge has a value representing the cost of the link c(, ) = cost of edge beteen nodes & if (, ) E, then c(, ) = We ill assume c(, ) = c(, ) March, 06 CS 0-06 Paul Kranoski
Path cost, least-cost path, & shortest path v u A path in a graph G = (N, E) is a sequence of nodes (,,, p ) such that each of the pairs (, ), (, ),, ( p-, p ) are edges in E. The cost of a path is the sum of edge costs: c(, ), c(, ),, c( p-, p ) There could be multiple paths beteen to nodes, each ith a different cost. One or more of these is a least-cost path. Eample: the least-cost path beteen u and is (u,,, ) c(u,,, ) = If all edges have the same cost, then least-cost path = shortest path March, 06 CS 0-06 Paul Kranoski 4
Algorithm classifications Global routing algorithms Compute the least-cost path using complete knoledge of the netork The algorithm knos the connectivit beteen all nodes & costs Centralied algorithm These are link-state (LS) algorithms Decentralied routing algorithms No node has complete information about the costs of all links A node initiall knos onl its direct links Iterative process: calculate & echange info ith neighbors Eventuall calculate the least-cost path to a destination Distance-Vector (DV) algorithm March, 06 CS 0-06 Paul Kranoski
Additional algorithm classifications Static routing algorithms Routes change ver slol over time Dnamic routing algorithms Change routing paths as netork traffic loads or topolog change Load-sensitive algorithms Link costs var to reflect the current level of congestion Load-insensitive algorithms Ignore current or recent levels of congestion March, 06 CS 0-06 Paul Kranoski 6
Link-State (LS): Dijkstra s Algorithm Assumption: Entire netork topolog & link costs are knon Each node broadcasts link-state packets to all other nodes All nodes have an identical, complete vie of the netork Compute least-cost path one node to all other nodes in the netork Iterative algorithm After k iterations, least-cost paths are knon to k nodes March, 06 CS 0-06 Paul Kranoski 7
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Initialie: N = current node N = { u } for all nodes v if v is a neighbor of u D(v) = c(u, v) else D(v) = u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u March, 06 CS 0-06 Paul Kranoski 8
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Loop until N = N: Find a node n not in N such that D(n) is a minimum Node has minimum D(n) add n to N N = {u, } for each neighbor m of n not in N : for each neighbor of node D(m) = min( D(m), D(n) + c(n, m) ) ne cost = old cost or cost through if D(m) changed, set p(m) = n u Skip: u N v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() Least cost path 0 u,u,u,u u,u 4,, Cost to v is not better through Cost to is better through Ignore ; it is in N We no have a path to March, 06 CS 0-06 Paul Kranoski 9
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Loop until N = N: find n not in N such that D(n) is a minimum Nodes v & have minimum D(n) Pick an one: e choose add n to N N = {u,, } for each neighbor m of n not in N : for each neighbor of node D(m) = min( D(m), D(n) + c(n, m) ) ne cost = old cost or cost through if D(m) changed, set p(m) = n u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u u,u 4,, u,u, 4, Cost to is even better through Least cost path Skip: and are in N We no have a path to March, 06 CS 0-06 Paul Kranoski 0
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Loop until N = N: find n not in N such that D(n) is a minimum Node v has minimum D(n) add n to N N = {u,,, v} for each neighbor m of n not in N : for each neighbor of node v D(m) = min( D(m), D(n) + c(n,m) ) ne cost = old cost or cost through if D(m) changed, set p(m) = n u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u u,u 4,, u,u, 4, uv, 4, No improvement (+) No change: is not a neighbor March, 06 CS 0-06 Paul Kranoski
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Loop until N = N: find n not in N such that D(n) is a minimum Node has minimum D(n) add n to N N = {u,,, v, } for each neighbor m of n not in N : for each neighbor of node D(m) = min( D(m), D(n) + c(n,m) ) ne cost = old cost or cost through if D(m) changed, set p(m) = n u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u u,u 4,, u,u, 4, uv, 4, 4 uv 4, No improvement (+) 4 March, 06 CS 0-06 Paul Kranoski
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path Loop until N = N: find n not in N such that D(n) is a minimum Node is the onl one left! u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u add n to N N = {u,,, v,, } for each neighbor m of n not in N : There are no neighbors not in N! We re done u,u 4,, u,u, 4, uv, 4, 4 uv 4, uv March, 06 CS 0-06 Paul Kranoski
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path N = N: All nodes are in N u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() () u is s predecessor For each node, e have the total cost the source and the predecessor along that path. We can look up the predecessor to find its predecessor E.g., least-cost path u is u 0 u,u,u,u u,u 4,, u,u, 4, uv, () is s 4, predecessor 4 uv 4, uv () is s predecessor March, 06 CS 0-06 Paul Kranoski 4
Dijkstra s Algorithm D(v): cost of least-cost path source to v p(v): previous node (neighbor of v) along the least-cost path to v N : subset of nodes for hich e found the least-cost path We can create a forarding table that stores the net hop on the least-cost route Forarding table for node u Destination v Link uv u u u u u v step N D(v), p(v) D(), p() D(),p() D(),p() D(),p() 0 u,u,u,u u,u 4,, u,u, 4, uv, 4, 4 uv 4, uv March, 06 CS 0-06 Paul Kranoski
Dijkstra s Algorithm Computational cost st iteration: search n nodes to find the minimum cost node nd iteration: search n- nodes rd iteration: search n- nodes n th iteration: search node n Total of n iterations = n + (n - ) + (n - ) + = i=0 (n i) We need to search n(n+)/ nodes Compleit = O(n ) March, 06 CS 0-06 Paul Kranoski 6
Oscillations ith congestion-based routing If link cost = load carried on the link Link costs are not smmetric c(u, v) = c(v, u) onl if the same load flos in both directions Eample loads Load of comes into for Load of comes into for Load of e comes into for When LS is run determines ( ) cost is compared to ( ) cost, hich is +e determines that is a loer-cost path +e 0 0 e 0 Initial routing e March, 06 CS 0-06 Paul Kranoski 7
Oscillations ith congestion-based routing After route updates, LS is run again,, and detect 0-cost path counterclockise +e 0 0 +e +e 0 0 0 0 e e Clockise routing Counterclockise routing March, 06 CS 0-06 Paul Kranoski 8
Oscillations ith congestion-based routing After route updates, LS is run et again,, and no detect 0-cost path clockise 0 +e +e 0 0 0 +e 0 0 e e Counterclockise routing Clockise routing March, 06 CS 0-06 Paul Kranoski 9
Avoiding oscillations Ensure that not all routers run the LS algorithm at the same time Avoid snchronied routers b randomiing the time hen a router advertises its link state March, 06 CS 0-06 Paul Kranoski 0
Distance-Vector Routing Algorithm Initial assumption Each router (node) knos the reach its directl-connected neighbors Iterative, asnchronous, distributed algorithm Multiple iterations Each iteration caused b local link cost change or distance vector update message neighbor Asnchronous Does not require lockstep snchroniation Distributed Each node receives information one or more directl attached neighbors Notifies neighbors onl hen its distance-vector changes March, 06 CS 0-06 Paul Kranoski
Bellman-Ford Equation What it sas If is not directl connected to, it needs to first hop to some neighbor v The loest cost is (the cost of the first hop to v) + (the loest cost v to ) = c(, v) + d v () the least cost path to, d (), is the minimum of the loest cost of all of s neighbors d () = min v { c(, v) + d v () } The value of v that satisfies the equation is the forarding table entr in s router for destination v' d v () c(,v ) c(,v ) v d v () March, 06 CS 0-06 Paul Kranoski
Distance-Vector Routing Algorithm At each node e store: c(, v) = cost for the direct link to v for each neighbor v D () = estimate of the cost of the least-cost path to Distance Vector is the set of D () for all nodes in N D = [ D (): N ] Least-cost estimates to all other nodes Distance vectors received its neighbors D v = [ D v (): N ] Set of least-cost estimates each neighbor v to each node Each node v periodicall sends its distance vector, D v to its neighbors When a node receives a distance vector, it saves it and updates its on distance vector using the Bellman-Ford equation D () = min v { c(, v) + D v () } for each node N If this results in a change to s DV, it sends the ne DV to its neighbors Each cost estimate D () converges to the actual least-cost D () March, 06 CS 0-06 Paul Kranoski
Distance-Vector Eample Node DV table Node DV table Node DV table 0 7 7 0 7 0 March, 06 CS 0-06 Paul Kranoski 4
Distance-Vector Eample Node DV table Node DV table Node DV table 0 7 7 0 7 0 Node sends its DV {0,, 7} to nodes and Node DV table 0 7 Node DV table 0 7 0 Node DV table 0 7 7 0 c(, ) = c(, ) = 7 March, 06 CS 0-06 Paul Kranoski
Distance-Vector Eample Node DV table Node DV table Node DV table 0 7 0 7 0 7 7 0 7 0 Node sends its DV {, 0, } to nodes and Node sends its DV {7,, 0} to nodes and Node DV table 0 0 7 0 Node DV table 0 7 0 7 0 Node DV table 0 7 0 0 c(, ) = From : c(,) is c(, ) = c(, ) + c(,) = c(, ) = = + = Less than old value, 7 Ever update to a node s DV also updates the forarding table From : c(,) is c(, ) = c(,) + c(,) = = + = Less than old value, 7 March, 06 CS 0-06 Paul Kranoski 6
Distance-Vector Eample Node DV table Node DV table Node DV table 0 0 7 0 7 7 0 0 0 7 0 7 0 0 Node DV table 0 0 0 Node DV table 0 0 0 Node DV table Node sends its DV {0,, 7} to nodes and Node s vector did not change it stas quiet Node sends its DV {, 0, } to nodes and 0 0 0 We converged. Everone has the same vie of the netork. Nobod has updates to send. March, 06 CS 0-06 Paul Kranoski 7
Link cost changes The DV algorithm remains quiet once it converges until some link cost changes If a node detects link cost change beteen itself and a neighbor It updates its distance vector If there is a change in the cost of an least-cost path it informs its neighbors of the ne distance vector Each neighbor computes a ne least cost If the value changed its previous value, it sends its DV to its neighbors Recompute until values converge March, 06 CS 0-06 Paul Kranoski 8
Link loss Distance to C = Distance to C = A B C We created a Routing Loop Suppose e lose the link to C: c(b,c) = B ill send an update to A but A thinks its C is B ill think there is a route to C: B A C ith a cost of (c(b,a) + ) = 4 Distance to C = Distance to C =4 A B C Update (A,C)= Distance to C = Distance to C =4 A B C Update (B,C)=4 This continues ad infinitum! March, 06 CS 0-06 Paul Kranoski 9
Mitigation: Poison Reverse If A routes through B to get to C A ill advertise to B that its distance is infinit B ill then never attempt to route through A This does not ork ith loops involving or more nodes! Other approaches Limit sie of netork b setting a hop (cost) limit Send full path information in route advertisement Perform eplicit queries for loops March, 06 CS 0-06 Paul Kranoski 0
The end March, 06 CS 0-06 Paul Kranoski