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). 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. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) that you mention their source (after all, we’d like people to use our book!) If you post any slides on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material. Computer Networking: A Top Down Approach 6th edition Jim Kurose, Keith Ross Addison-Wesley 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: network layer chapter goals: understand principles behind network layer services: forwarding versus routing how a router works routing (path selection) instantiation, implementation in the Internet Network Layer 4-2 Chapter 4: outline 4.1 introduction 4.2 virtual circuit and datagram networks 4.3 what’s inside a router 4.4 IP: Internet Protocol datagram format IPv4 addressing ICMP IPv6 4.5 routing algorithms link state distance vector hierarchical routing 4.6 routing in the Internet RIP OSPF BGP 4.7 broadcast and multicast routing Network Layer 4-3 Two key network-layer functions forwarding: The process of moving packets from input to output based on: 1. The forwarding table 2. Information in the packet routing: Process by which the forwarding table is built and maintained. 1. One or more routing protocols 2. Algorithms to convert routing info to forwarding tables Network Layer 4-4 Example Routing Table Image coutesy of http://www.hill2dot0.com/wiki/index.php?title=Routing_table Network Layer 4-5 Chapter 4: outline 4.1 introduction 4.2 virtual circuit and datagram networks 4.3 what’s inside a router 4.4 IP: Internet Protocol datagram format IPv4 addressing ICMP IPv6 4.5 routing algorithms link state distance vector hierarchical routing 4.6 routing in the Internet RIP OSPF BGP 4.7 broadcast and multicast routing Network Layer 4-6 Router architecture overview two key router functions: run routing algorithms/protocol (RIP, OSPF, BGP) forwarding datagrams from incoming to outgoing link forwarding tables computed, pushed to input ports routing processor routing, management control plane (software) forwarding data plane (hardware) high-seed switching fabric router input ports router output ports Network Layer 4-7 Chapter 4: outline 4.1 introduction 4.2 virtual circuit and datagram networks 4.3 what’s inside a router 4.4 IP: Internet Protocol datagram format IPv4 addressing ICMP IPv6 4.5 routing algorithms link state distance vector hierarchical routing 4.6 routing in the Internet RIP OSPF BGP 4.7 broadcast and multicast routing Network Layer 4-8 A Link-State Routing Algorithm Dijkstra’s algorithm net topology, link costs known to all nodes accomplished via “link state broadcast” all nodes have same info computes least cost paths from one node (‘source”) to all other nodes gives forwarding table for that node notation: c(x,y): link cost from iterative: after k iterations, know least cost path to k dest.’s node x to y; = ∞ if not direct neighbors D(v): current value of cost of path from source to dest. v p(v): predecessor node along path from source to v N': set of nodes whose least cost path definitively known Network Layer 4-9 Dijkstra’s algorithm: building a forwarding table (1) Step 0 1 2 3 4 5 N' u ux uxy uxyv uxyvw uxyvwz D(v),p(v) D(w),p(w) 2,u 5,u 2,u 4,x 2,u 3,y 3,y D(x),p(x) 1,u D(y),p(y) ∞ 2,x D(z),p(z) ∞ ∞ 4,y 4,y 4,y 5 v 3 w 2 u 2 1 x 3 5 z 1 y 2 1 Network Layer 4-10 Dijkstra’s algorithm: building a forwarding table (2) resulting shortest-path tree from u: v w u z x y resulting forwarding table in u: destination link v x (u,v) (u,x) y (u,x) w (u,x) z (u,x) Network Layer 4-11 Link-State Walkthrough (1) 1. 2. 3. Each router sends a “Router Discovery (ICMP)” message to 224.0.0.2. (“All Routers” multicast address) Each router makes a list of its adjacent neighbors. Each router sends its list of adjacent neighbors to ALL other routers in the AS, using 224.0.0.9 (RIP address) 4. Each router builds a complete map of the network. 5. Each router uses Dykstra’s to build forwarding table. 6. Repeat every 30 seconds. Network Layer 4-12 Link-State Walkthrough (2) (Step 1) From: 10.10.1.1 To: 224.0.0.2 Data: What routers can hear this request? (Do not forward.) (Step 2) From: 10.10.1.3 To: 10.10.1.1 Data: I am a router From: To: Data: 10.10.1.5 10.10.1.1 I am a router Network Layer 4-13 Link-State Walkthrough (3) (Step 3) From: 10.10.1.1 To: 224.0.0.9 Data: These routers are adjacent to me. (Please forward.) Origin: 10.10.1.1 Neighbors (10.10.1.3, 10.10.1.5) Each router receives the complete collection of messages sent by all routers: Origin: 10.10.1.1 Neighbors (10.10.1.3, 10.10.1.5) Origin: 10.10.1.3 Neighbors (10.10.1.1, 10.10.1.5, 10.10.1.7) Origin: 10.10.1.5 Neighbors (10.10.1.1, 10.10.1.3, 10.10.1.9) Origin: 10.10.1.7 Neighbors (10.10.1.3, 10.10.1.9) Origin: 10.10.1.9 Neighbors (10.10.1.5, 10.10.1.7) (Step 4) Exercise – Draw the network map yourself Network Layer 4-14 Link-State Walkthrough (4) (Step 4) Solution: 10.10.1.3 10.10.1.7 10.10.1.5 10.10.1.9 10.10.1.1 (Step 5) Each router has the complete network map, can construct complementary forwarding tables. Network Layer 4-15 Link-State Walkthrough (4) 10.10.1.3 10.10.1.7 10.10.1.5 10.10.1.9 10.10.1.1 (Step 6) If a network link goes down, each router will know after 30 seconds when the next update gets sent. Network Layer 4-16 Link-State Questions Is this practical on the Internet backbone? Q1: Is it scalable to large numbers of routers? Q2: Is cost always a function of hop-count or time? Q2: Do all router owners have the same incentives? Network Layer 4-17 Chapter 4: outline 4.1 introduction 4.2 virtual circuit and datagram networks 4.3 what’s inside a router 4.4 IP: Internet Protocol datagram format IPv4 addressing ICMP IPv6 4.5 routing algorithms link state distance vector hierarchical routing 4.6 routing in the Internet RIP OSPF BGP 4.7 broadcast and multicast routing Network Layer 4-18 Distance vector algorithm Bellman-Ford equation (dynamic programming) let dx(y) := cost of least-cost path from x to y then dx(y) = min {c(x,v) + d (y) } v v cost from neighbor v to destination y cost to neighbor v min taken over all neighbors v of x Network Layer 4-19 Distance vector: link cost changes link cost changes: node detects local link cost change updates routing info, recalculates distance vector if DV changes, notify neighbors “good news travels fast” 1 x 4 y 1 50 z t0 : y detects link-cost change, updates its DV, informs its neighbors. t1 : z receives update from y, updates its table, computes new least cost to x , sends its neighbors its DV. t2 : y receives z’s update, updates its distance table. y’s least costs do not change, so y does not send a message to z. Network Layer 4-20 Distance-Vector Walkthrough (1) 1. Each router sends an “Open Shortest Path First (OSPF)” Hello message to 224.0.0.5. (OSPF multicast address) 2. Each router finds direct cost to its adjacent neighbors 3. Each router updates its estimated cost to all known routers 4. 5. Each router collates its complete list of forwarding costs to all known routers and then mails the list to its adjacent neighbors only (no forwarding). Repeat every 30 seconds. Network Layer 4-21 Distance-Vector Walkthrough (2) *** Assume that 10.10.1.1 is entering an established network *** (Step 1) From: 10.10.1.1 To: 224.0.0.5 Data: What routers can hear this request? (Do not forward.) (Step 2) From: 10.10.1.3 To: 10.10.1.1 Data: I am a router, COST==5 From: To: Data: 10.10.1.5 10.10.1.1 I am a router, COST==3 Network Layer 4-22 Distance-Vector Walkthrough(3) (Step 3) Build forwarding table: Destination Cost NIC 10.10.1.3 5 A 10.10.1.5 3 B (Step 4) From: 10.10.1.1 To: 224.0.0.5 Data: These are all of my known routes. (Do not forward.) 10.10.1.1 -> 10.10.1.3 (cost 5) 10.10.1.1 -> 10.10.1.5 (cost 3) Network Layer 4-23 Distance-Vector Walkthrough(4) (Step 4 cont) Messages received from the group of routers: From 10.10.1.3 Known routes: 10.10.1.3 -> 10.10.1.1 (cost 5) 10.10.1.3 -> 10.10.1.5 (cost 1) 10.10.1.3 -> 10.10.1.7 (cost 2) 10.10.1.3 -> 10.10.1.9 (cost 4) From 10.10.1.5 Known routes: 10.10.1.5 -> 10.10.1.1 (cost 3) 10.10.1.5 -> 10.10.1.3 (cost 1) 10.10.1.5 -> 10.10.1.7 (cost 3) 10.10.1.5 -> 10.10.1.9 (cost 5) Network Layer 4-24 Distance-Vector Walkthrough(5) *** SECOND ROUND *** (Step 3) Build your new forwarding table yourself as an exercise: Destination 10.10.1.3 10.10.1.5 10.10.1.7 Cost NIC Neighbors: NIC A: 10.10.1.3 (cost 5) NIC B: 10.10.1.5 (cost 3) From 10.10.1.3 Known routes: 10.10.1.3 -> 10.10.1.1 (cost 5) 10.10.1.3 -> 10.10.1.5 (cost 1) 10.10.1.3 -> 10.10.1.7 (cost 2) 10.10.1.3 -> 10.10.1.9 (cost 4) 10.10.1.9 From 10.10.1.5 Known routes: 10.10.1.5 -> 10.10.1.1 (cost 3) 10.10.1.5 -> 10.10.1.3 (cost 1) 10.10.1.5 -> 10.10.1.7 (cost 3) 10.10.1.5 -> 10.10.1.9 (cost 5) Network Layer 4-25 Distance-Vector Walkthrough(6) *** SECOND ROUND *** (Step 3) ANSWERS: Destination Cost NIC 10.10.1.3 4 B 10.10.1.5 3 B 10.10.1.7 6 B 10.10.1.9 8 B Q: Is it possible to draw the network topology from this information? Neighbors: NIC A: 10.10.1.3 (cost 5) NIC B: 10.10.1.5 (cost 3) From 10.10.1.3 Known routes: 10.10.1.3 -> 10.10.1.1 (cost 5) 10.10.1.3 -> 10.10.1.5 (cost 1) 10.10.1.3 -> 10.10.1.7 (cost 2) 10.10.1.3 -> 10.10.1.9 (cost 4) From 10.10.1.5 Known routes: 10.10.1.5 -> 10.10.1.1 (cost 3) 10.10.1.5 -> 10.10.1.3 (cost 1) 10.10.1.5 -> 10.10.1.7 (cost 3) 10.10.1.5 -> 10.10.1.9 (cost 5) Network Layer 4-26 Distance-Vector Walkthrough(7) 10.10.1.3 2 10.10.1.7 5 1 10.10.1.1 2 3 10.10.1.5 10.10.1.9 10 A: No. This is a drawing of the actual network with costs. You cannot reproduce this from what you know. Network Layer 4-27 Distance-Vector Walkthrough(8) 10.10.1.3 2 10.10.1.7 5 3 1 10.10.1.1 4 3 10.10.1.5 5 10.10.1.9 You can produce a map that looks like this • It shows the cost to each node from your neighbors • The map has a max of two edges from you to any other node Network Layer 4-28 Comparison of LS and DV algorithms message complexity LS: with n nodes, E links, O(nE) msgs sent DV: exchange between neighbors only convergence time varies speed of convergence O(n2) LS: algorithm requires O(nE) msgs may have oscillations DV: convergence time varies may be routing loops count-to-infinity problem robustness: what happens if router malfunctions? LS: node can advertise incorrect link cost each node computes only its own table DV: DV node can advertise incorrect path cost each node’s table used by others • error propagate thru network Network Layer 4-29 Hierarchical routing “autonomous systems” (AS) aggregate routers into regions routers in same AS run same routing protocol “intra-AS” routing protocol routers in different AS can run different intra-AS routing protocol gateway router: at “edge” of its own AS has link to router in another AS Network Layer 4-30 Chapter 4: outline 4.1 introduction 4.2 virtual circuit and datagram networks 4.3 what’s inside a router 4.4 IP: Internet Protocol datagram format IPv4 addressing ICMP IPv6 4.5 routing algorithms link state distance vector hierarchical routing 4.6 routing in the Internet RIP OSPF BGP 4.7 broadcast and multicast routing Network Layer 4-31 Intra-AS Routing also known as interior gateway protocols (IGP) most common intra-AS routing protocols: RIP: Routing Information Protocol OSPF: Open Shortest Path First Network Layer 4-32 RIP (Routing Information Protocol) included in BSD-UNIX distribution in 1982 distance vector algorithm distance metric: # hops (max = 15 hops), each link has cost 1 DVs exchanged with neighbors every 30 sec in response message (aka advertisement) each advertisement: list of up to 25 destination subnets (in IP addressing sense) u v A z C B w x D y from router A to destination subnets: subnet hops u 1 v 2 w 2 x 3 y 3 z 2 Network Layer 4-33 RIP: link failure, recovery if no advertisement heard after 180 sec --> neighbor/link declared dead routes via neighbor invalidated new advertisements sent to neighbors neighbors in turn send out new advertisements (if tables changed) link failure info quickly (?) propagates to entire net poison reverse used to prevent ping-pong loops (infinite distance = 16 hops) Network Layer 4-34 OSPF (Open Shortest Path First) “open”: publicly available uses link state & distance vector algorithms LS packet dissemination topology map at each node route computation using Dijkstra’s algorithm OSPF advertisement carries one entry per neighbor advertisements flooded to entire AS carried in OSPF messages directly over IP (rather than TCP or UDP IS-IS routing protocol: nearly identical to OSPF Network Layer 4-35 Hierarchical OSPF boundary router backbone router backbone area border routers area 3 internal routers area 1 area 2 Network Layer 4-36 Summary of Protocols Protocol Type of routing (LS/DV/Other) Common Usage RIP LS Lower-tier ISPs and enterprise networks OSPF LS & DV Upper-tier ISPs Hierarchical • LS for smaller ASs • DV for collections of ASs BGP DV & Policy Network Layer 4-37 Internet inter-AS routing: BGP BGP (Border Gateway Protocol): the de facto inter-domain routing protocol “glue that holds the Internet together” BGP provides each AS a means to: eBGP: obtain subnet reachability information from neighboring ASs. iBGP: propagate reachability information to all ASinternal routers. determine “good” routes to other networks based on reachability information and policy. allows subnet to advertise its existence to rest of Internet: “I am here” Network Layer 4-38 BGP basics BGP session: two BGP routers (“peers”) exchange BGP messages: advertising paths to different destination network prefixes (“path vector” protocol) exchanged over semi-permanent TCP connections when AS3 advertises a prefix to AS1: AS3 promises it will forward datagrams towards that prefix AS3 can aggregate prefixes in its advertisement 3c 3b other networks 3a BGP message AS3 2c 1c 1a AS1 1d 2a 1b 2b other networks AS2 Network Layer 4-39 BGP basics: distributing path information using eBGP session between 3a and 1c, AS3 sends prefix reachability info to AS1. 1c can then use iBGP do distribute new prefix info to all routers in AS1 1b can then re-advertise new reachability info to AS2 over 1b-to2a eBGP session when router learns of new prefix, it creates entry for prefix in its forwarding table. 3c 3b other networks eBGP session 3a AS3 iBGP session 2c 1c 1a AS1 1d 2a 1b 2b other networks AS2 Network Layer 4-40 BGP routing policy legend: B W provider network X A customer network: C Y A,B,C are provider networks X,W,Y are customer (of provider networks) X is dual-homed: attached to two networks X does not want to route from B via X to C .. so X will not advertise to B a route to C Network Layer 4-41 BGP routing policy (2) legend: B W provider network X A customer network: C Y A advertises path AW to B B advertises path BAW to X Should B advertise path BAW to C? No way! B gets no “revenue” for routing CBAW since neither W nor C are B’s customers B wants to force C to route to w via A B wants to route only to/from its customers! Network Layer 4-42 Why different Intra-, Inter-AS routing ? policy: inter-AS: admin wants control over how its traffic routed, who routes through its net. intra-AS: single admin, so no policy decisions needed scale: hierarchical routing saves table size, reduced update traffic performance: intra-AS: can focus on performance inter-AS: policy may dominate over performance Network Layer 4-43