Network Layer Goals: Overview: � understand principles � last time behind network layer � network layer services services: � virtual circuit and datagram � forwarding networks � routing (path selection) � what’s inside a router? � dealing with scale � IP: Internet Protocol � how a router works � today � advanced topics: IPv6, � routing algorithms multicast • Link state � instantiation and • Distance Vector implementation in the • Hierarchical routing Internet � routing in the Internet • RIP • OSPF • BGP � broadcast and multicast routing 23/4-07 Datakommunikation - Jonny Pettersson, UmU Interplay between routing and forwarding routing algorithm local forwarding table header value output link 0100 3 0101 2 0111 2 1001 1 value in arriving packet’s header 1 0111 2 3 23/4-07 1
Graph abstraction 5 3 v w 5 2 u z 2 1 3 1 2 x y 1 Graph: G = (N,E) N = set of routers = { u, v, w, x, y, z } E = set of links ={ (u,v), (u,x), (u,w), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) } Remark: Graph abstraction is useful in other network contexts Example: P2P, where N is set of peers and E is set of TCP connections 23/4-07 Datakommunikation - Jonny Pettersson, UmU Graph abstraction: costs 5 • c(x,x’) = cost of link (x,x’) 3 v w 5 - e.g., c(w,z) = 5 2 u z 2 1 3 • cost could always be 1, or 1 inversely related to bandwidth, 2 x y 1 or inversely related to congestion Cost of path (x 1 , x 2 , x 3 ,…, x p ) = c(x 1 ,x 2 ) + c(x 2 ,x 3 ) + … + c(x p-1 ,x p ) Question: What’s the least-cost path between u and z ? Routing algorithm: algorithm that finds least-cost path 23/4-07 Datakommunikation - Jonny Pettersson, UmU 2
Routing Algorithm classification Global or decentralized Static or dynamic? information? Static: Global: � routes change slowly � all routers have complete over time topology, link cost info Dynamic: � “link state” algorithms � routes change more Decentralized: � router knows physically- quickly connected neighbors, link � periodic update costs to neighbors � in response to link � iterative process of cost changes computation, exchange of info with neighbors � “distance vector” algorithms 23/4-07 Datakommunikation - Jonny Pettersson, UmU Link State � Förutsättning � Varje nod kan kolla om närmsta granne är uppe/nere och kan kostnaden för varje länk � Basidé � Alla noder vet hur de ska nå närmsta granne, låt alla veta det (alla får komplett bild) � Beror av två mekanismer • Tillförlitlig spridning av link-state information • Beräkning av vägar från summan av all ackumulerad information 23/4-07 Datakommunikation - Jonny Pettersson, UmU 3
A Link-State Routing Algorithm Dijkstra’s algorithm Notation: � net topology, link costs � c(x,y): link cost from node known to all nodes x to y; = ∞ if not direct � accomplished via “link neighbors state broadcast” � D(v): current value of cost � all nodes have same info of path from source to � computes least cost paths dest. v from one node (‘source”) to � p(v): predecessor node all other nodes along path from source to v � gives forwarding table � N': set of nodes whose for that node least cost path definitively � iterative: after k known iterations, know least cost path to k dest.’s 23/4-07 Datakommunikation - Jonny Pettersson, UmU Dijsktra’s Algorithm 5 1 Initialization: 3 2 N' = {u} v w 5 2 3 for all nodes v u z 4 if v adjacent to u 2 1 3 5 then D(v) = c(u,v) 1 2 x y 6 else D(v) = ∞ 1 7 8 Loop 9 find w not in N' such that D(w) is a minimum 10 add w to N' 11 update D(v) for all v adjacent to w and not in N' : 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N' 23/4-07 Datakommunikation - Jonny Pettersson, UmU 4
Forward Search Algorithm � Två listor – bekräftade (C) och möjliga (T) 1. Confirm = {s} 2. Kalla senaste till C adderade nod NEXT 3. För varje granne till NEXT beräkna kostnaden som summan av kostnaden från s till NEXT och NEXT till granne (a) Om grannen ej finns i C eller T, lägg i T (b) Om grannen finns i T och den nya kostnaden är lägre, uppdatera 4. Om T är tom avbryt, annars ta den med lägst kostnad i T och flytta till C samt hoppa till 2 Exempel på tavlan 23/4-07 Datakommunikation - Jonny Pettersson, UmU Dijkstra’s algorithm, discussion Algorithm complexity: n nodes � each iteration: need to check all nodes, w, not in N � n(n+1)/2 comparisons: O(n 2 ) � more efficient implementations possible: O(nlogn) Oscillations possible: � e.g., link cost = amount of carried traffic A A A A 1 1+e 2+e 0 0 2+e 2+e 0 D B D D B B D 0 B 0 1+e 1 0 0 1+e 1 e 0 0 0 1 1+e e 0 C C C C 1 1 e … recompute … recompute … recompute initially routing 23/4-07 Datakommunikation - Jonny Pettersson, UmU 5
Distance Vector Algorithm (1) Bellman-Ford Equation Define d x (y) := cost of least-cost path from x to y Then d x (y) = min {c(x,v) + d v (y) } where min is taken over all neighbors of x 23/4-07 Datakommunikation - Jonny Pettersson, UmU Bellman-Ford example (2) 5 Clearly, d v (z) = 5, d x (z) = 3, d w (z) = 3 3 v w 5 2 B-F equation says: u z 2 1 3 d u (z) = min { c(u,v) + d v (z), 1 2 x y c(u,x) + d x (z), 1 c(u,w) + d w (z) } = min {2 + 5, 1 + 3, 5 + 3} = 4 Node that achieves minimum is next hop in shortest path ➜ forwarding table 23/4-07 Datakommunikation - Jonny Pettersson, UmU 6
Distance Vector Algorithm (3) � D x (y) = estimate of least cost from x to y � Distance vector: D x = [D x (y): y є N ] � Node x knows cost to each neighbor v: c(x,v) � Node x maintains D x = [D x (y): y є N ] � Node x also maintains its neighbors’ distance vectors � For each neighbor v, x maintains D v = [D v (y): y є N ] 23/4-07 Datakommunikation - Jonny Pettersson, UmU Distance vector algorithm (4) Basic idea: � Each node periodically sends its own distance vector estimate to neighbors � When a node x receives new DV estimate from neighbor, it updates its own DV using B-F equation: D x (y) ← min v {c(x,v) + D v (y)} for each node y ∊ N � Under minor, natural conditions, the estimate D x (y) converge to the actual least cost d x (y) 23/4-07 Datakommunikation - Jonny Pettersson, UmU 7
Distance Vector Algorithm (5) Iterative, asynchronous: Each node: each local iteration caused by: � local link cost change wait for (change in local link cost or msg from neighbor) � DV update message from neighbor Distributed: recompute estimates � each node notifies neighbors only when its DV changes if DV to any dest has � neighbors then notify changed, notify neighbors their neighbors if necessary Exempel på tavlan 23/4-07 Datakommunikation - Jonny Pettersson, UmU Distance Vector: link cost changes Link cost changes: 1 � node detects local link cost change y 4 1 � updates routing info, recalculates x z distance vector 50 � if DV changes, notify neighbors At time t 0 , y detects the link-cost change, updates its DV, and informs its neighbors. “good news At time t 1 , z receives the update from y and updates its table. It computes a new least cost to x and sends its neighbors its DV. travels fast” At time t 2 , 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 . 23/4-07 Datakommunikation - Jonny Pettersson, UmU 8
Distance Vector: link cost changes Link cost changes: � good news travels fast 60 y � bad news travels slow - 4 1 “count to infinity” problem! x z 50 � 44 iterations before algorithm stabilizes: see text Poissoned 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 completely solve count to infinity problem? 23/4-07 Datakommunikation - Jonny Pettersson, UmU Comparison of LS and DV algorithms Message complexity Robustness: what happens if router malfunctions? � LS: with n nodes, E links, O(nE) msgs sent LS: � DV: exchange between � node can advertise neighbors only incorrect link cost � convergence time varies � each node computes only its own table Speed of Convergence DV: � LS: O(n 2 ) algorithm requires O(nE) msgs � DV node can advertise incorrect path cost � may have oscillations � each node’s table used by � DV: convergence time varies others � may be routing loops • error propagate thru � count-to-infinity problem network 23/4-07 Datakommunikation - Jonny Pettersson, UmU 9
Distance Vector - Link State � Link State � Alla pratar med alla � Berättar bara om sina egna länkar � Distance Vector � Varje nod pratar endast med närmsta granne � Berättar allt den vet 23/4-07 Datakommunikation - Jonny Pettersson, UmU Hierarchical Routing Our routing study thus far - idealization � all routers identical � network “flat” … not true in practice scale: with 200 million administrative autonomy destinations: � internet = network of networks � can’t store all dest’s in routing tables! � each network admin may want to control routing in its � routing table exchange own network would swamp links! 23/4-07 Datakommunikation - Jonny Pettersson, UmU 10
Recommend
More recommend