Chapter 4 Network Layer
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 4 Network Layer A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). Computer They’re in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your needs. Networking: A Top They obviously represent a lot of work on our part. In return for use, we only ask the following: Down Approach v If you use these slides (e.g., in a class) that you mention their source th (after all, we’d like people to use our book!) 6 edition v If you post any slides on a www site, that you note that they are adapted Jim Kurose, Keith Ross from (or perhaps identical to) our slides, and note our copyright of this Addison-Wesley material. March 2012 Thanks and enjoy! JFK/KWR All material copyright 1996-2012 J.F Kurose and K.W. Ross, All Rights Reserved Network Layer 4-1 Chapter 4: outline 4.1 introduction 4.5 routing algorithms 4.2 virtual circuit and § link state datagram networks § distance vector 4.3 what’s inside a router § hierarchical routing 4.4 IP: Internet Protocol 4.6 routing in the Internet § datagram format § RIP § IPv4 addressing § OSPF § BGP § ICMP § IPv6 4.7 broadcast and multicast routing Network Layer 4-2 Interplay between routing, forwarding routing algorithm determines routing algorithm end-end-path through network forwarding table determines local forwarding table local forwarding at this router dest address output link address-range 1 3 address-range 2 2 address-range 3 2 address-range 4 1 IP destination address in arriving packet’s header 1 3 2 Network Layer 4-3 Graph abstraction 5 v 3 w 2 5 u 2 1 z 3 1 x y 2 graph: G = (N,E) 1 N = set of routers = { u, v, w, x, y, z } E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) } aside: graph abstraction is useful in other network contexts, e.g., P2P, where N is set of peers and E is set of TCP connections Network Layer 4-4 Graph abstraction: costs 5 c(x,x’) = cost of link (x,x’) v 3 w e.g., c(w,z) = 5 2 5 u cost could always be 1, or 2 1 z 3 inversely related to bandwidth, 1 x y 2 or inversely related to 1 congestion cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp) key question: what is the least-cost path between u and z ? routing algorithm: algorithm that finds that least cost path Network Layer 4-5 Routing algorithm classification Q: global or decentralized Q: static or dynamic? information? static: global: v routes change slowly over v all routers have complete time topology, link cost info dynamic: v “ ” link state algorithms v routes change more decentralized: quickly v router knows physically- § periodic update connected neighbors, link § in response to link costs to neighbors cost changes v iterative process of computation, exchange of info with neighbors v “distance vector” algorithms Network Layer 4-6 Chapter 4: outline 4.1 introduction 4.5 routing algorithms 4.2 virtual circuit and § link state datagram networks § distance vector 4.3 what’s inside a router § hierarchical routing 4.4 IP: Internet Protocol 4.6 routing in the Internet § datagram format § RIP § IPv4 addressing § OSPF § BGP § ICMP § IPv6 4.7 broadcast and multicast routing Network Layer 4-7 A Link-State Routing Algorithm Dijkstra’s algorithm notation: v net topology, link costs v c(x,y): link cost from known to all nodes node x to y; = ∞ if not § accomplished via “link state direct neighbors broadcast” v D(v): current value of § all nodes have same info cost of path from source v computes least cost paths to dest. v from one node (‘source”) v p(v): predecessor node to all other nodes along path from source to § gives forwarding table for v that node v N': set of nodes whose v iterative: after k least cost path definitively iterations, know least cost known path to k dest.’s Network Layer 4-8 Dijsktra’s Algorithm 1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞ 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' Network Layer 4-9 Dijkstra’s algorithm: example D(v) D(w) D(x) D(y) D(z) Step N' p(v) p(w) p(x) p(y) p(z) 0 u 7,u 3,u 5,u ∞ ∞ 1 uw 6,w 5,u 11,w ∞ 2 uwx 6,w 11,w 14,x 3 uwxv 10,v 14,x 4 uwxvy 12,y 5 uwxvyz x 9 notes: 5 7 v construct shortest path tree by 4 tracing predecessor nodes 8 v ties can exist (can be broken u 3 w y z arbitrarily) 2 3 7 4 v Network Layer 4-10 Dijkstra’s algorithm: another 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 5 v 3 w 2 5 u 2 1 z 3 1 x y 2 1 Network Layer 4-11 Dijkstra’s algorithm: example (2) resulting shortest-path tree from u: v w u z x y resulting forwarding table in u: destination link v (u,v) x (u,x) y (u,x) w (u,x) z (u,x) Network Layer 4-12 Dijkstra’s algorithm, discussion algorithm complexity: n nodes v each iteration: need to check all nodes, w, not in N v n(n+1)/2 comparisons: O(n2) v more efficient implementations possible: O(nlogn) oscillations possible: v e.g., support link cost equals amount of carried traffic: A 1 1+e A A A 2+e 0 0 2+e 2+e 0 D B D B D B D B 0 0 1+e 1 0 0 1+e 1 0 e 0 0 C C 0 1 C 1+e C 0 1 1 e given these costs, given these costs, given these costs, initially find new routing…. find new routing…. find new routing…. resulting in new costs resulting in new costs resulting in new costs Network Layer 4-13 Chapter 4: outline 4.1 introduction 4.5 routing algorithms 4.2 virtual circuit and § link state datagram networks § distance vector 4.3 what’s inside a router § hierarchical routing 4.4 IP: Internet Protocol 4.6 routing in the Internet § datagram format § RIP § IPv4 addressing § OSPF § BGP § ICMP § IPv6 4.7 broadcast and multicast routing Network Layer 4-14 Distance vector algorithm Bellman-Ford equation (dynamic programming) let dx(y) := cost of least-cost path from x to y then d (y) = min {c(x,v) + d (y) } x v v cost from neighbor v to destination y cost to neighbor v min taken over all neighbors v of x Network Layer 4-15 Bellman-Ford example 5 clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3 v 3 w 2 5 u B-F equation says: 2 1 z 3 1 d (z) = min { c(u,v) + d (z), x y 2 u v 1 c(u,x) + dx(z), c(u,w) + dw(z) } = min {2 + 5, 1 + 3, 5 + 3} = 4 node achieving minimum is next hop in shortest path, used in forwarding table Network Layer 4-16 Distance vector algorithm v Dx(y) = estimate of least cost from x to y § x maintains distance vector Dx = [Dx(y): y є N ] v node x: § knows cost to each neighbor v: c(x,v) § maintains its neighbors’ distance vectors. For each neighbor v, x maintains Dv = [Dv(y): y є N ] Network Layer 4-17 Distance vector algorithm key idea: v from time-to-time, each node sends its own distance vector estimate to neighbors v when x receives new DV estimate from neighbor, it updates its own DV using B-F equation: Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N v under minor, natural conditions, the estimate Dx(y) converge to the actual least cost dx(y) Network Layer 4-18 Distance vector algorithm iterative, asynchronous: each node: each local iteration caused by: wait for (change in local link v local link cost change cost or msg from neighbor) v DV update message from neighbor distributed: recompute estimates v each node notifies neighbors only when its DV changes if DV to any dest has § neighbors then notify their changed, notify neighbors neighbors if necessary Network Layer 4-19 Dx(z) = min{c(x,y) + Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 node x cost to cost to table x y z x y z x 0 2 7 x 0 2 3 y y 2 0 1 ∞ ∞ ∞ from from z ∞ ∞ ∞ z 7 1 0 node y cost to table x y z y 2 1 x ∞ ∞ ∞ x z y 2 0 1 7 from z ∞ ∞ ∞ node z cost to table x y z x ∞ ∞ ∞ y from ∞ ∞ ∞ z 7 1 0 time Network Layer 4-20 Dx(z) = min{c(x,y) + Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 node x cost to cost to cost to table x y z x y z x y z x 0 2 7 x 0 2 3 x 0 2 3 y y 2 0 1 ∞ ∞ ∞ from y from 2 0 1 z z from ∞ ∞ ∞ 7 1 0 z 3 1 0 node y cost to cost to cost to table x y z x y z x y z y 2 1 x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z y 2 0 1 y 2 0 1 y 7 from 2 0 1 from z ∞ ∞ ∞ z 7 1 0 from z 3 1 0 node z cost to cost to cost to table x y z x y z x y z x ∞ ∞ ∞ x 0 2 7 x 0 2 3 y y 2 0 1 y from 2 0 1 from from ∞ ∞ ∞ z z z 7 1 0 3 1 0 3 1 0 time Network Layer 4-21 Distance vector: link cost changes link cost changes: 1 v node detects local link cost change y 4 1 v updates routing info, recalculates x z distance vector 50 v if DV changes, notify neighbors “good t0 : y detects link-cost change, updates its DV, informs its news neighbors.