Routing Algorithm lassification Global or decentralied information? Global: All routers have complete topolog, link cost info Link state algorithms Decentralied: Router knows phsicallconnected neighbors, link costs to neighbors Iterative process of computation, echange of info with neighbors Distance vector algorithms Static or dnamic? Static: Routes change slowl over time Dnamic: Routes change more quickl Periodic update In response to link cost changes A Link-State Routing Algorithm Net topolog, link costs known to all nodes Accomplished via link state broadcast All nodes have same info omputes least cost paths one node ( source ) to all other nodes Gives routing table for that node Eample: Dijkstra s algorithm Iterative: after k iterations, know least cost path to k dest. s Notation: Dijkstra s algorithm c(i,j): link cost node i to j. cost infinite if not direct neighbors D(v): current value of cost of path source to dest. v p(v): predecessor node along path source to v N : set of nodes whose least cost path definitivel known
Dijsktra s Algorithm Initialiation for A: N = {A} for all nodes v if v adjacent to A 5 then D(v) = c(a,v) 6 else D(v) = 7 Dijsktra s Algorithm (.) 8 Loop 9 find w not in N such that D(w) is a minimum 0 add w to N update D(v) for all v adjacent to w and not in N : D(v) = min( D(v), D(w) + c(w,v) ) /* new v is either old v or known shortest path w plus cost w to v */ 5 until all nodes in N
Dijkstra s Algorithm: Eample Step 0 5 start N A AD ADE ADEB ADEB ADEBF D(B),p(B),A,A,A D(),p() 5,A,D,E,E D(D),p(D),A D(E),p(E) infinit,d D(F),p(F) infinit infinit,e,e,e 5 A B D E 5 F 6 Dijkstra s Algorithm: Eample () Resulting shortest-path tree A: B A F D E Resulting forwarding table at A: destination B D E F link (A,B) (A,D) (A,D) (A,D) (A,D) 7
Dijkstra s Algorithm, Discussion Algorithm compleit: n nodes Each iteration: need to check all nodes, w, not in N n*(n+)/ comparisons: O(n ) More efficient implementations possible: O(n logn) Oscillations possible: E.g., link cost = amount of carried traffic A +e D 0 0 B 0 e e initiall A +e 0 D B 0 +e 0 recompute routing 0 A +e D 0 0 B +e recompute +e A 0 D B 0 +e e recompute 8 A Distance Vector Routing Algorithm Decentralied algorithm: Router knows its neighbors and link costs to neighbors Iterative computation, echange of info with neighbors Bellman-Ford Equation (dnamic programming) Define d () := cost of least-cost path to Then d () = min {c(,v) + d v ()} v where min is taken over all neighbors v of 9
Bellman-Ford Eample u 5 v w 5 learl, d v () = 5, d () =, d w () = Bellman-Ford equation sas: d u () = min { c(u,v) + d v (), c(u,) + d (), c(u,w) + d w () } = min { + 5, +, 5 + } = Node that ields minimum is net hop in shortest path forwarding table 0 Distance Vector Algorithm Iterative, asnchronous: Each local iteration caused b: Local link cost change DV update message neighbor Distributed: Each node notifies neighbors onl when its Distance Vector changes Neighbors then notif their neighbors if necessar Each node: wait for (change in local link cost of msg neighbor) recompute estimates if Distance Vector to an dest has changed, notif neighbors 5
Distance Vector Algorithm (.) D () = estimate of least cost to Distance vector: D = [D (): є N ] Node knows each neighbor v: c(,v) Node maintains D = [D (): є N ] Node also maintains its neighbors distance vectors For each neighbor v, maintains D v = [D v (): є N ] Distance Vector Algorithm (.) Basic idea: Each node periodicall sends its own distance vector estimate to neighbors When a node receives new DV estimate neighbor, it updates its own DV using B-F equation: D () min v {c(,v) + D v ()} for each node N Under natural conditions the estimates of D () converge to the actual least cost d () 6
node table 0 7 node table 0 node table 7 0 D () = min{c(,) + D (), c(,) + D ()} = min{+0, 7+} = 0 0 7 0 0 7 0 7 0 0 7 0 0 0 0 0 0 0 0 0 0 0 time D () = min{c(,) + D (), c(,) + D ()} = min{+, 7+0} = 7 Distance Vector Algorithm: At each node, : Initialiation: for all destinations in N: D () = if is not a neighbor D () = c(,) if is a neighbor 5 for each neighbor w 6 D w () = for all destinations in N 7 for each neighbor w 8 send distance vector D = [D (): in N] to w 5 7
Distance Vector Algorithm (cont.): 9 loop 0 wait (until I see a link cost change to neighbor w or until I receive update neighbor w) for each in N: D () = min v {c(, v) + D v ()} 5 6 if D () changed for an destination 7 send DV D = [D ()]: in N] to all neighbors 8 9 forever 6 Distance Vector Algorithm (Summar) Iterative, asnchronous: Each local iteration caused b: Local link cost change DV update message neighbor Distributed: Each node notifies neighbors onl when its Distance Vector changes Neighbors then notif their neighbors if necessar Each node: wait for (change in local link cost of msg neighbor) recompute estimates if Distance Vector to an dest has changed, notif neighbors 7 8
Distance Vector (DV): Link ost hanges Link cost changes: Node detects local link cost change Updates routing info, recalculates distance vector If DV changes, notif neighbors 50 good news travels fast At time t 0, detects link-cost change, updates its DV, and informs its neighbors. At time t, receives update and updates its table, computes a new least and sends its neighbors its DV At time t, receives s update and updates its distance table. As s least costs do not change does not send updates to. 8 50 node table 0 5 0 0 5 0 0 0 node table 0 5 0 0 5 0 0 0 time 9 9
Distance Vector: Link ost hanges Link cost changes: Good news travels fast Bad news travels slow 60 50 0 60 50 D () = min{c(,) + D (), c(,) + D ()} = min{60 + 0, + 5} = 6 D () = min{c(,) + D (), c(,) + D ()} = min{60 + 0, + 7} = 8 node table 6 0 5 0 6 0 5 0 68 0 7 0 node table 0 5 0 6 0 5 7 0 6 0 7 0 time 0
Distance Vector: Link ost hanges Link cost changes: Good news travels fast Bad news travels slow count to infinit problem! E.g., iterations before algorithm stabilies 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) Will this completel solve count to infinit problem? 60 50 omparison of LS and DV Algorithms Message compleit LS: with n nodes, E links, O(nE) msgs sent each DV: echange between neighbors onl onvergence time varies Speed of onvergence LS: O(n log n) algorithm requires O(nE) msgs Ma have oscillations DV: convergence time varies Ma be routing loops ount-to-infinit problem Robustness: What happens if router malfunctions? LS: Node can advertise incorrect link cost Each node computes onl its own table DV: DV node can advertise incorrect path cost Each node s table used b others Error propagate thru network
Hierarchical Routing Our routing stud thus far idealiation All routers identical Network flat not true in practice Scale: With 00 million destinations: an t store all dest s in routing tables! Routing table echange would swamp links! Administrative autonom Internet = network of networks Each network admin ma want to control routing in its own network Hierarchical Routing Aggregate routers into regions, autonomous sstems (AS) Routers in same AS run same routing protocol Inter-AS routing protocol Routers in different AS can run different inter- AS routing protocol Gatewa router Direct link to router in another AS 5
Interconnected ASes c a b AS a c d b Intra-AS Routing algorithm AS Forwarding table Inter-AS Routing algorithm a c b AS Forwarding table is configured b both intra- and inter-as routing algorithm Intra-AS sets entries for internal dests Inter-AS & Intra-As sets entries for eternal dests 6