CSC 40 Data and Computer Communications Networks Network Layer NAT, Routing, Link State, Distance Vector Prof. Lina Battestilli Fall 07
Chapter 4 Outline Network Layer: Data Plane 4. Overview of Network layer data plane control plane 4. What s inside a router 4.3 Internet Protocol (IP) datagram format, IPv4 addressing, DHCP, IPv6, NAT 4.4 Generalized Forward and SDN
Private IPv4 address spaces A private network is a network that uses private IP address space, following RFC 98 Used for home, office, and enterprise local area networks (LANs) If you have a local IP address then you need a NAT http://en.wikipedia.org/wiki/private_network
NAT: network address translation rest of Internet 38.76.9.7 0.0.0.4 local network (e.g., home network) 0.0.0/4 0.0.0. 0.0.0. 0.0.0.3 all datagrams leaving local network have same single source NAT IP address: 38.76.9.7,different source port numbers datagrams with source or destination in this network have 0.0.0/4 address for source, destination (as usual)
NAT: network address translation motivation: local network uses just one IP address as far as outside world is concerned: range of addresses not needed from ISP: just one IP address for all devices can change addresses of devices in local network without notifying outside world can change ISP without changing addresses of devices in local network devices inside local net not explicitly addressable, visible by outside world (a security plus)
NAT: network address translation implementation: NAT router must: outgoing datagrams: replace (source IP address, port #)of every outgoing datagram to (NAT IP address, new port #)... remote clients/servers will respond using (NAT IP address, new port #) as destination addr remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair incoming datagrams: replace (NAT IP address, new port #) in dest fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table
NAT: network address translation : NAT router changes datagram source addr from 0.0.0., 3345 to 38.76.9.7, 500, updates table NAT translation table WAN side addr LAN side addr 38.76.9.7, 500 0.0.0., 3345 S: 38.76.9.7, 500 D: 8.9.40.86, 80 0.0.0.4 S: 0.0.0., 3345 D: 8.9.40.86, 80 : host 0.0.0. sends datagram to 8.9.40.86, 80 0.0.0. 0.0.0. 38.76.9.7 S: 8.9.40.86, 80 D: 38.76.9.7, 500 3 3: reply arrives dest. address: 38.76.9.7, 500 S: 8.9.40.86, 80 D: 0.0.0., 3345 4 4: NAT router changes datagram dest addr from 38.76.9.7, 500 to 0.0.0., 3345 0.0.0.3
NAT Example 7
NAT :RFC 3489, 538, 4687 NAT 0.39.64.96 (5.7.4.6) 64.33.77.00 64.33.77.00 0.39.64.96 5.7.4.6 64.33.77.00 0.39.64.96 43 554 5.7.4.6 80 43 80 554 Q: What packets does a NAT allow to traverse this mapping? Q: How are the Mapping Assigned? Q: When are mappings deleted? 8
9 NAT Static Configuration client wants to connect to server with address 0.0.0. server address 0.0.0. local to LAN (client can t use it as destination addr) visible NATed address: 38.76.9.7 client 0.0.0. Port 5000 38.76.9.7 NAT router 0.0.0.4 server Statically configure NAT to forward incoming connection requests at given port to server e.g., (3.76.9.7, port 500) always forwarded to 0.0.0. port 5000
NAT Automate Configuration Universal Plug and Play (UPnP) Internet Gateway Device (IGD) Protocol. Allows NATed host to: learn public IP address (38.76.9.7) add/remove port mappings (with lease times) IGD 0.0.0. NAT router automated static NAT port map configuration 0
NAT Implications 6-bit port-number field: ~65K simultaneous connections with a single WAN-side address! NAT is controversial: routers should only process up to layer 3 violates end-to-end argument NAT possibility must be taken into account by app designers, e.g., PP applications address shortage should instead be solved by IPv6 Developing Apps is hard Proliferation of middleboxes: NAT, load balancers, firewalls, Intrusion Detection/Prevention Systems, etc.
The New Hourglass http smtp ssh ftp TCP IP UDP Network Layer And Transport Layers Ethernet WiFi DSL 3G
Chapter 5 Outline Network Layer: Control Plane 5. Introduction 5. Routing protocols: Link State, Distance Vector 5.3 intra-as routing in the Internet: OSPF 5.4 routing among the ISPs: BGP 5.5 The SDN control plane 5.6 ICMP: The Internet Control Message Protocol 5.7 Network management and SNMP
Network-layer functions Data Plane Control Plane forwarding: move packets from router s input to appropriate router output routing: determine route taken by packets from source to destination Two approaches to structuring network control plane: per-router control (traditional) logically centralized control (Software Defined Networking)
Routing protocols Routing protocol goal: determine good paths (equivalently, routes), from sending hosts to receiving host, through network of routers path: sequence of routers packets will traverse in going from given initial source host to given final destination host good : least cost, fastest, least congested top-0 list of important networking topics!
Graph Abstraction 5 u v x 3 3 w y 5 z graph: G = (N,E) 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., PP, where N is set of peers and E is set of TCP connections
Graph abstraction: costs of links 5 c(x,x ) = cost of link (x,x ) u v x 3 3 w y 5 z e.g., c(w,z) = 5 cost could always be, or inversely related to bandwidth, or inversely related to congestion cost of path (x, x, x 3,, x p ) = c(x,x ) + c(x,x 3 ) + + c(x p-,x p ) key question: what is the least-cost path between u and z? routing algorithm: algorithm that finds that least cost path What If all the edges have the same cost?
Routing algorithm classification Q: global or decentralized information? global: all routers have complete topology, link cost info link state algorithms decentralized: router knows physically-connected neighbors, link costs to neighbors exchange info with neighbors distance vector algorithms Q: static or dynamic? static: routes change slowly over time dynamic: routes change more quickly periodic update in response to link cost changes Q: Load sensitive?
Chapter 5 Outline Network Layer: Control Plane 5. Introduction 5. Routing protocols: Link State Distance Vector 5.3 Intra-AS routing in the Internet: OSPF 5.4 Routing among the ISPs: BGP 5.5 The SDN control plane 5.6 ICMP: The Internet Control Message Protocol 5.7 Network management and SNMP
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 results in a forwarding table for that node iterative: after k iterations, know least cost path to k destinations Example: Internet s OSPF protocol
A Link-State Routing Algorithm x 9 5 4 7 8 u source 3 w 3 7 4 y z v
Dijkstra s algorithm: example Step 0 3 4 5 N' D(v) p(v) D(w) p(w) D(x) p(x) D(y) p(y) D(z) p(z) u 7,u 3,u 5,u uw 6,w 5,u,w uwx 6,w,w 4,x uwxv 0,v 4,x uwxvy,y uwxvyz x notation: c(x,y): link cost from 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 9 Computed at node u construct shortest path tree by tracing predecessor nodes ties can exist (can be broken arbitrarily) u 5 3 w 4 8 7 3 7 4 y z v
source: node u Initialization: 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 Dijsktra s Algorithm notation: c(x,y): link cost from 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 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) ) 3 /* new cost to v is either old cost to v or known 4 shortest path cost to w plus cost from w to v */ 5 until all nodes in N'
Dijkstra s algorithm: Example SOLUTION Step 0 3 4 5 N' u ux uxy uxyv uxyvw uxyvwz D(v),p(v),u,u,u D(w),p(w) 5,u 4,x 3,y 3,y D(x),p(x),u D(y),p(y),x D(z),p(z) 4,y 4,y 4,y u 5 v x 3 3 w y 5 z figure out path from u to z u x y z 37
Dijkstra s algorithm: Example resulting shortest-path tree from u: v w u x y z path from u to z u x y z resulting forwarding table in u: destination v x y w z link (u,v) (u,x) (u,x) (u,x) (u,x)
Dijkstra s algorithm Complexity algorithm complexity: n nodes each iteration: need to check all nodes, w, not in N Iteration Comparisons n (n-) 3 (n-) n n(n+)/ comparisons: O(n ) more efficient implementations possible using a heap: O(nlogn) What happens when link cost changes or routers/link fail? 39
Dijkstra s algorithm Oscillations oscillations possible: link cost equals amount of carried traffic: Arpanet did this in the 80 s D A +e 0 0 0 e C initially e B D A +e 0 0 +e C B given these costs, find new routing. resulting in new costs 0 D A 0 +e 0 0 C +e B given these costs, find new routing. resulting in new costs D A +e 0 0 +e C B given these costs, find new routing. resulting in new costs 0 What can be done to prevent such oscillations? 40
Chapter 5 Outline Network Layer: Control Plane 5. Introduction 5. Routing protocols: Link State Distance Vector 5.3 Intra-AS routing in the Internet: OSPF 5.4 Routing among the ISPs: BGP 5.5 The SDN control plane 5.6 ICMP: The Internet Control Message Protocol 5.7 Network management and SNMP
Distance vector algorithm Bellman-Ford Equation (dynamic programming) Important relationship that exists among the costs of least-cost paths Let d x (y) := cost of least-cost path from x to y then d x (y) = min {c(x,v) + d v (y) } v cost from neighbor v to destination y cost to neighbor v min taken over all neighbors v of x 4
Bellman-Ford example source u v x neighbors: v, x, w 5 d v (z) = 5, d x (z) = 3, d w (z) = 3 3 3 w y 5 z path to z from u s neighbors B-F equation says: d u (z) = min { c(u,v) + d v (z), c(u,x) + d x (z), c(u,w) + d w (z) } = min { + 5, + 3, 5 + 3} = 4 node achieving minimum is next hop in shortest path, used in forwarding table Gives us un idea of the neighbor-to-neighbor communication needed for DV 43
Distance Vector Algorithm D x (y) is the estimate of least cost from x to y x maintains its own Distance Vector D x = [D x (y): y є N ] Node x determines its Distance Vector by: Knowing the cost to each of its neighbors v: c(x,v) Also maintaining its neighbors Distance Vectors. for each neighbor v, x has D v = [D v (y): y є N ]
Distance Vector Algorithm Key Idea: from time-to-time, each node sends its own distance vector estimate to neighbors when x receives new DV estimate from neighbor, it updates its own DV using Bellman-Ford equation: D x (y) min v {c(x,v) + D v (y)} for each node y N The estimate D x (y) converges to the actual least cost dx(y)
Distance Vector Algorithm iterative, asynchronous: each local iteration caused by: local link cost change DV update message from neighbor distributed: each node notifies neighbors only when its DV changes neighbors then notify their neighbors if necessary each node: wait for (change in local link cost or msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Internet s RIP, BGP and original ARPAnet 4-46
from from from from from from D x (y) = min{c(x,y) + D y (y), c(x,z) + D z (y)} = min{+0, 7+} = node x table x y z node y table x y z cost to x y z 0 7 cost to x y z 0 x y z x y z x y z 0 cost to 3 0 7 0 x y z 0 cost to 7 0 7 0 D x (z) = min{c(x,y) + D y (z),c(x,z) + D z (z)} = min{+, 7+0} = 3 x y 7 z node z table cost to x y z x y z 7 0 x y z x y z 0 cost to 7 0 3 0 Quiescent State until link cost changes time 47
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 x 4 y 50 z good news travels fast t 0 : y detects link-cost change, updates its DV, informs its neighbors. t : z receives update from y, updates its table, computes new least cost to x, sends its neighbors its DV. iterations needed to get to quiescent state t : 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. 4-48
Distance vector: link cost changes link cost changes: node detects local link cost change 44 iterations before algorithm stabilizes Why? 60 x 4 y 50 z bad news travels slow - count to infinity problem! Before link cost changes at node y c y, x = 4 and c y, z = D x x = 0 and D z x = 5 at node z c z, x = 50 and c z, y = D x x = 0 and D y x = 4 t 0 : y detects the link cost change D y x = min{c y, x + D x (x), c y, z + D z x } = min{ 60, 6} = 6 t : y informs z of it s new cost to x t : z computes its new cost to x via y to be D z x = 6+=7 t 3 : z informs y of it s new cost to x t 4 : y computes its new cost to x via z to be D y x =7+=8 wrong! Routing Loop
Distance vector: link cost changes link cost changes: node detects local link cost change 44 iterations before algorithm stabilizes at node y c y, x = 4 and c y, z = D x x = 0 and D z x = 5 60 x 4 y 50 at node z c z, x = 50 and c z, y = D x x = 0 and D y x = 4 z 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)
Comparison both used in Internet Number of messages Link State with n nodes, E links, O(nE) messages sent Distance Vector exchange messages between neighbors only speed of convergence O(n ) algorithm may have oscillations convergence time varies may be routing loops count-to-infinity problem robustness what happens if router malfunctions? node can advertise incorrect link cost each node computes only its own table DV node can advertise incorrect path cost each node s table used by others - > error propagates through the network e.g in 997 a router caused large portions of the internet to be disconnected for hours 5
References Some of the slides are identical or derived from. Slides for the 7 th edition of the book Kurose & Ross, Computer Networking: A Top-Down Approach,. Computer Networking, Nick McKeown and Philip Levis, 04 Stanford University