7/4/21 Chapter 4 Network Layer: Data Plane • Computer Networking: A Top Down Approach Note: This class lecture is based on Chapter 3 of the textbook (Kurose and Ross) and the figures provided by the authors. 7th Edition, Global Edition Jim Kurose, Keith Ross Pearson April 2016 Network layer: our goals §understand principles behind network layer services, focusing on data plane: • • • • • • network layer service models forwarding versus routing how a router works addressing generalized forwarding Internet architecture § instantiation, implementation in the Internet • IP protocol • NAT, middleboxes Network Layer: 4-2 1 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation 4.5 Middleboxes • IPv6 Network Layer: 4-3 Network-layer services and protocols § transport segment from sending to receiving host • sender: encapsulates segments into datagrams, passes to link layer • receiver: delivers segments to transport layer protocol § network layer protocols in every Internet device: hosts, routers. § routers: • examines header fields in all IP datagrams passing through it • moves datagrams from input ports to output ports to transfer datagrams along end-end path mobile network national or global ISP application transport network link physical network link physical network link physical enterprise network network link physical network link physical network link physical datacenter network application transport network link physical Network Layer: 4-4 2 7/4/21 Two key network-layer functions network-layer functions: § forwarding: •Local decision •Inside one router •move packets from a router’s input link to appropriate router output link analogy: taking a trip § forwarding: process of getting through single interchange § routing: process of planning trip from source to destination § routing: •Global process •determine route taken by packets from source to destination •Several decisions / Several forwarding forwarding routing • routing algorithms Network Layer: 4-5 Network layer: data plane, control plane Data plane: Control plane § local, per-router function § determines how datagram arriving on router input port is forwarded to router output port § forwarding function § network-wide logic § determines how datagram is routed among routers along endend path from source host to destination host § two control-plane approaches: values in arriving packet header 1 0111 3 2 • traditional routing algorithms: implemented in routers • software-defined networking (SDN): implemented in (remote) servers Network Layer: 4-6 3 7/4/21 Interplay between routing and forwarding routing algorithm local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 value in arriving packetʼs header 1 0111 3 2 Per-router control plane Individual routing algorithm components in each and every router interact in the control plane 4.1 • OVERVIEW OF NETWORK LAYER Routing Algorithm 309 control plane Routing algorithm Control plane Data plane data plane Local forwarding table header output 0100 0110 0111 1001 3 2 2 1 Values in arriving packet’s header values in arriving packet header 1 1101 0111 3 2 1 3 Figure 4.2 ♦ 2 Routing algorithms determine values in forward tables tables. In this example, a routing algorithm runs in each and every router and both forwarding and routing functions are contained within a router. As we’ll see in Sections 5.3 and 5.4, the routing algorithm function in one router communicates with the routing algorithm function in other routers to compute the values for its forwarding table. How is this communication performed? By exchanging routing messages containing routing information according to a routing protocol! We’ll cover routing algorithms and protocols in Sections 5.2 through 5.4. The distinct and different purposes of the forwarding and routing functions can be further illustrated by considering the hypothetical (and unrealistic, but technically feasible) case of a network in which all forwarding tables are configured directly by human network operators physically present at the routers. In this case, no routing protocols would be required! Of course, the human operators would need to interact with each other to ensure that the forwarding tables were configured in such a way that packets reached their intended destinations. It’s also likely that human configuration would be more error-prone and much slower to respond to changes in the network topology than a routing protocol. We’re thus fortunate that all networks have both a forwarding and a routing function! Network Layer: 4-8 4 7/4/21 Software-Defined Networking (SDN) control plane Remote controller computes, installs forwarding tables in routers Remote Controller control plane data plane CA CA values in arriving packet header CA CA CA 1 0111 3 2 Network Layer: 4-9 Network service model Q: What service model for “channel” transporting datagrams from sender to receiver? example services for individual datagrams: example services for a flow of datagrams: § guaranteed delivery § guaranteed delivery with less than 40 msec delay § in-order datagram delivery § guaranteed minimum bandwidth to flow § restrictions on changes in interpacket spacing Network Layer: 4-10 5 7/4/21 Network Service Models Per Datagram • Guaranteed Delivery: No packets lost • Guaranteed Delivery with Bounded delay: • Maximum delay Per Flow • In-Order packet delivery: Some packets may be missing • Guaranteed minimal throughput • minimum bandwidth to flow • Guaranteed maximum jitter: Delay variation • Security Services (optional in most networks) ATM • IP offers none of these Þ Best effort service (Security is optional) Network-layer service model Network Architecture Internet ATM ATM Internet Internet Quality of Service (QoS) Guarantees ? Service Model Bandwidth Loss Order Timing best effort none no no no Constant Bit Rate Constant rate yes yes yes Internet “best effort” service model Bit Rate yes NoAvailable guarantees on: Guaranteed min no i. successful delivery to Intserv Guaranteeddatagram yes yesdestination yes (RFC ) ii. 1633 timing or order of delivery Diffserv (RFC 2475) available possible possibly iii. bandwidth to end-end flow possibly no yes no Network Layer: 4-12 6 7/4/21 Network-layer service model Network Architecture Quality of Service (QoS) Guarantees ? Service Model Bandwidth Loss Order Timing best effort none no no no ATM Constant Bit Rate Constant rate yes yes yes ATM Available Bit Rate Guaranteed min no yes no Internet Intserv Guaranteed (RFC 1633) yes yes yes yes Internet Diffserv possible possibly possibly no Internet (RFC 2475) Network Layer: 4-13 Reflections on best-effort service: § simplicity of mechanism has allowed Internet to be widely deployed adopted § sufficient provisioning of bandwidth allows performance of real-time applications (e.g., interactive voice, video) to be “good enough” for “most of the time” § replicated, application-layer distributed services (datacenters, content distribution networks) connecting close to clients’ networks, allow services to be provided from multiple locations § congestion control of “elastic” services helps It’s hard to argue with success of best-effort service model Network Layer: 4-14 7 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation • IPv6 4.5 Middleboxes Network Layer: 4-15 Router architecture overview 8 7/4/21 Router architecture overview Router architecture overview §Two key router functions: • run routing algorithms/protocol (RIP, OSPF, BGP) • forwarding datagrams from incoming to outgoing link routing processor routing, management control plane (software) operates in millisecond time frame forwarding data plane (hardware) operates in nanosecond timeframe high-speed switching fabric router input ports router output ports Network Layer: 4-18 9 7/4/21 Input port functions Input port functions line termination physical layer: bit-level reception link layer: e.g., Ethernet (chapter 6) link layer protocol (receive) lookup, forwarding switch fabric queueing decentralized switching: § using header field values, lookup output port using forwarding table in input port memory (“match plus action”) § goal: complete input port processing at ‘line speed’ § input port queuing: if datagrams arrive faster than forwarding rate into switch fabric Network Layer: 4-20 10 7/4/21 Input port functions line termination physical layer: bit-level reception link layer: e.g., Ethernet (chapter 6) link layer protocol (receive) lookup, forwarding switch fabric queueing decentralized switching: § using header field values, lookup output port using forwarding table in input port memory (“match plus action”) § destination-based forwarding: forward based only on destination IP address (traditional) § generalized forwarding: forward based on any set of header field values Network Layer: 4-21 Destination-based forwarding Q: but what happens if ranges don’t divide up so nicely? Network Layer: 4-22 11 7/4/21 Destination-based forwarding 3 Q: but what happens if ranges don’t divide up so nicely? Network Layer: 4-23 Longest prefix matching longest prefix match when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. Link interface Destination Address Range 11001000 00010111 00010*** ******** 0 11001000 00010111 00011000 ******** 1 11001000 00010111 00011*** ******** 2 3 otherwise examples: 11001000 00010111 00010110 10100001 which interface? 11001000 00010111 00011000 10101010 which interface? Network Layer: 4-24 12 7/4/21 Longest prefix matching longest prefix match when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. Link interface Destination Address Range 11001000 00010111 00010*** ******** 0 11001000 00010111 00011000 ******** 1 11001000 00010111 match! 00011*** ******** 2 3 otherwise examples: 11001000 00010111 00010110 10100001 which interface? 11001000 00010111 00011000 10101010 which interface? Network Layer: 4-25 Longest prefix matching longest prefix match when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. Link interface Destination Address Range 11001000 00010111 00010*** ******** 0 11001000 00010111 00011000 ******** 1 11001000 00010111 00011*** ******** 2 3 otherwise examples: 11001000 11001000 match! 00010111 00010110 10100001 which interface? 00010111 00011000 10101010 which interface? Network Layer: 4-26 13 7/4/21 Longest prefix matching longest prefix match when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. Link interface Destination Address Range examples: 11001000 00010111 00010*** ******** 0 11001000 00010111 00011000 ******** 1 11001000 00010111 00011*** ******** 2 otherwise match! 11001000 00010111 00010110 10100001 which interface? 11001000 00010111 00011000 10101010 which interface? 3 Network Layer: 4-27 Longest prefix matching § we’ll see why longest prefix matching is used shortly, when we study addressing § longest prefix matching: often performed using ternary content addressable memories (TCAMs) • content addressable: present address to TCAM: retrieve address in one clock cycle, regardless of table size • Cisco Catalyst: ~1M routing table entries in TCAM Network Layer: 4-28 14 7/4/21 Longest Prefix Matching: Example 4-1 Consider a datagram network using 8-bit host addresses. Suppose a router uses longest-prefix matching, and has the following forwarding table: 1. Suppose a datagram arrives at the router, with destination address 10000000. To which interface will this datagram be forwarded using longest-prefix matching? 2. Suppose a datagram arrives at the router, with destination address 00011011. To which interface will this datagram be forwarded using longest-prefix matching? 3. Suppose a datagram arrives at the router, with destination address 01001011. To which interface will this datagram be forwarded using longest-prefix matching? Prefix Match interface 00 1 11 2 001 3 111 4 100 5 otherwise 6 Longest Prefix Matching: Solution 4-1 Prefix Match interface 00 1 11 2 001 3 111 4 100 5 otherwise 6 1. Since the address is 10000000, it will go to interface 5. 2. Since the address is 00011011, it will go to interface 1. 3. Since the address is 01001011, it will go to interface 6. 15 7/4/21 Switching fabrics § transfer packet from input link to appropriate output link § switching rate: rate at which packets can be transfer from inputs to outputs • often measured as multiple of input/output line rate • N inputs: switching rate N times line rate desirable R high-speed switching fabric ... ... N input ports R (rate: NR, ideally) N output ports R R Network Layer: 4-31 Switching fabrics § transfer packet from input link to appropriate output link § switching rate: rate at which packets can be transfer from inputs to outputs • often measured as multiple of input/output line rate • N inputs: switching rate N times line rate desirable § three major types of switching fabrics: memory memory bus interconnection network Network Layer: 4-32 16 7/4/21 Types of Switching Fabrics Switching via memory first generation routers: § traditional computers with switching under direct control of CPU § packet copied to system’s memory § speed limited by memory bandwidth (2 bus crossings per datagram) input port (e.g., Ethernet) memory output port (e.g., Ethernet) system bus Network Layer: 4-34 17 7/4/21 Switching via a bus §datagram from input port memory to output port memory via a shared bus §bus contention: switching speed limited by bus bandwidth §32 Gbps bus, Cisco 5600: sufficient speed for access routers bus Network Layer: 4-35 Switching Via Interconnection Network 18 7/4/21 Switching via interconnection network § Crossbar, Clos networks, other interconnection nets initially developed to connect processors in multiprocessor § multistage switch: nxn switch from multiple stages of smaller switches § exploiting parallelism: • fragment datagram into fixed length cells on entry • switch cells through the fabric, reassemble datagram at exit 3x3 crossbar 8x8 multistage switch built from smaller-sized switches Network Layer: 4-37 Switching via interconnection network § scaling, using multiple switching “planes” in parallel: § speedup, scaleup via parallelism fabric plane 0 fabric plane 1 fabric plane 2 fabric plane 3 fabric plane 4 fabric plane 5 fabric plane 6 fabric plane 7 . . .. . . . . .. . . . . .. . . . . .. . . § basic unit: 8 switching planes § each plane: 3-stage interconnection network § up to 100’s Tbps switching capacity . . .. . . . . .. . . . . .. . . . . .. . . § Cisco CRS router: Network Layer: 4-38 19 7/4/21 Router architecture overview Input port queuing § If switch fabric slower than input ports combined -> queueing may occur at input queues • queueing delay and loss due to input buffer overflow! § Head-of-the-Line (HOL) blocking: a queued datagram waiting for service at the front of a queue prevents others in queue from moving forward in the queue switch fabric output port contention: only one red datagram can be transferred. lower red packet is blocked switch fabric one packet time later: green packet experiences HOL blocking Network Layer: 4-40 20 7/4/21 Output ports Output port queuing switch fabric (rate: NR) datagram buffer queueing link layer protocol (send) This is a really important slide line termination § Buffering required when datagrams arrive from fabric faster than link transmission rate. Drop policy: which datagrams to drop if no free buffers? § Scheduling discipline chooses among queued datagrams for transmission R Datagrams can be lost due to congestion, lack of buffers Priority scheduling – who gets best performance, network neutrality Network Layer: 4-42 21 7/4/21 Output port queuing switch fabric switch fabric at t, packets more from input to output one packet time later §buffering when arrival rate via switch exceeds output line speed §queueing (delay) and loss due to output port buffer overflow! Network Layer: 4-43 Where Does Queuing Occur? • If switching fabric is slow, packets wait on the input port. • If switching fabric is fast, packets wait for output port Queueing (Scheduling) and drop policies • Queueing: First Come First Served (FCFS) 22 7/4/21 How much buffering? § RFC 3439 rule of thumb: average buffering equal to “typical” RTT (say 250 msec) times link capacity C • e.g., C = 10 Gbps link: 2.5 Gbit buffer § more recent recommendation: with N flows, buffering equal to RTT .C N § but too much buffering can increase delays (particularly in home routers) • long RTTs: poor performance for realtime apps, sluggish TCP response • recall delay-based congestion control: “keep bottleneck link just full enough (busy) but no fuller” Destination Source ACK Network Layer: 4-45 Buffer Management switch fabric datagram buffer queueing scheduling link layer protocol (send) line R termination R queue (waiting area) drop when buffers are full • tail drop: drop arriving packet • priority: drop/remove on priority basis § marking: which packets to Abstraction: queue packet arrivals buffer management: § drop: which packet to add, packet departures mark to signal congestion (ECN, RED) link (server) Network Layer: 4-46 23 7/4/21 Scheduling mechanisms § scheduling: choose next packet to send on link § FIFO (first in first out) scheduling: send in order of arrival to queue • real-world example? • discard policy: if packet arrives to full queue: who to discard? • tail drop: drop arriving packet • priority: drop/remove on priority basis • random: drop/remove randomly • Random Early Drop (RED): Drop arriving packets even before the queue is full • Routers measure average queue and drop incoming packet with certain probability packet arrivals queue link (waiting area) (server) packet departures Packet Scheduling: FCFS packet scheduling: deciding which packet to send next on link • first come, first served • priority • round robin • weighted fair queueing FCFS: packets transmitted in order of arrival to output port § also known as: First-in-firstout (FIFO) § real world examples? Abstraction: queue packet arrivals R queue (waiting area) packet departures link (server) Network Layer: 4-48 24 7/4/21 Scheduling policies: priority Priority scheduling: § arriving traffic classified, queued by class high priority queue arrivals classify • any header fields can be used for classification § send packet from highest priority queue that has buffered packets • FCFS within priority class departures link low priority queue 2 1 3 4 5 arrivals packet in service 1 4 2 3 5 departures 1 3 2 4 5 Network Layer: 4-49 Scheduling policies: round robin Round Robin (RR) scheduling: §arriving traffic classified, queued by class • any header fields can be used for classification §server cyclically, repeatedly scans class queues, sending one complete packet from each class (if available) in turn R classify arrivals link departures Network Layer: 4-50 25 7/4/21 Scheduling policies: round robin Round Robin (RR) scheduling: § multiple classes § cyclically scan class queues, sending one complete packet from each class (if available) § real world example? 2 1 3 5 4 arrivals packet in service 1 2 3 4 5 departures 1 3 2 4 5 Scheduling policies: weighted fair queueing Weighted Fair Queuing (WFQ): § A generalized form Round Robin queuing § each class, i, has weight, wi, and gets weighted amount of service in each cycle: classify wi arrivals Sjwj § minimum bandwidth guarantee (per-traffic-class) w1 w2 w3 R link departures Network Layer: 4-52 26 7/4/21 Packet Scheduling Matching: Example 4-2 Packet Scheduling Matching: solution 4-2 1235476 27 7/4/21 Sidebar: Network Neutrality What is network neutrality? § technical: how an ISP should share/allocation its resources • packet scheduling, buffer management are the mechanisms § social, economic principles • protecting free speech • encouraging innovation, competition § enforced legal rules and policies Different countries have different “takes” on network neutrality Network Layer: 4-55 Sidebar: Network Neutrality 2015 US FCC Order on Protecting and Promoting an Open Internet: three “clear, bright line” rules: §no blocking … “shall not block lawful content, applications, services, or non-harmful devices, subject to reasonable network management.” §no throttling … “shall not impair or degrade lawful Internet traffic on the basis of Internet content, application, or service, or use of a non-harmful device, subject to reasonable network management.” §no paid prioritization. … “shall not engage in paid prioritization” Network Layer: 4-56 28 7/4/21 ISP: telecommunications or information service? Is an ISP a “telecommunications service” or an “information service” provider? § the answer really matters from a regulatory standpoint! US Telecommunication Act of 1934 and 1996: • Title II: imposes “common carrier duties” on telecommunications services: reasonable rates, non-discrimination and requires regulation • Title I: applies to information services: • no common carrier duties (not regulated) • but grants FCC authority “… as may be necessary in the execution of its functions” 4 Network Layer: 4-57 Review 1. Forwarding uses routing table to find output port for datagrams using longest prefix match. Routing protocols make the table. 2. IP provides only best effort service. 3. Routers consist of input/output ports, switching fabric, and processors. 4. Datagrams may be dropped even if the queues are not full (Random early drop). 29 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation • IPv6 4.5 Middleboxes Network Layer: 4-59 Network Layer: Internet host, router network layer functions: transport layer: TCP, UDP network layer Path-selection algorithms: implemented in • routing protocols (OSPF, BGP) • SDN controller IP protocol forwarding table • datagram format • addressing • packet handling conventions ICMP protocol • error reporting • router “signaling” link layer physical layer Network Layer: 4-60 30 7/4/21 IP Datagram format 32 bits IP protocol version number header length(bytes) “type” of service: § diffserv (0:5) § ECN (6:7) TTL: remaining max hops (decremented at each router) upper layer protocol (e.g., TCP or UDP) 6: TCP or 17: UDP overhead § 20 bytes of TCP § 20 bytes of IP § = 40 bytes + app layer overhead for TCP+IP ver head. type of len service 16-bit identifier upper time to layer live length flgs fragment offset header checksum source IP address destination IP address options (if any) payload data (variable length, typically a TCP or UDP segment) total datagram length (bytes) fragmentation/ reassembly header checksum 32-bit source IP address 32-bit destination IP address e.g., timestamp, record route taken Maximum length: 64K bytes Typically: 1500 bytes or less Network Layer: 4-61 IP Fragmentation Fields § Header length: in units of 16-bit words § Data Unit Identifier (ID) § Sending host puts an identification number in each datagram § Total length: Length of user data plus header in bytes § Fragment Offset - Position of fragment in original datagram § In multiples of 8 byte blocks § More fragments flag § Indicates that this is not the last fragment § Datagrams can be fragmented/refragmented at any router § Datagrams are reassembled only at the destination host 31 7/4/21 IP fragmentation, reassembly The maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer transaction. fragmentation: in: one large datagram out: 3 smaller datagrams … reassembly … § network links have MTU (max.transfer size) - largest possible link-level frame • different link types, different MTUs § large IP datagram divided (“fragmented”) within net • one datagram becomes several datagrams • “reassembled” only at final destination • IP header bits used to identify, order related fragments IP fragmentation, reassembly example: v v 4000 byte datagram MTU = 1500 bytes 1480 bytes in data field offset = 1480/8 offset = 2960/8 length ID fragflag =4000 =x =0 offset =0 one large datagram becomes several smaller datagrams length ID fragflag =1500 =x =1 offset =0 length ID fragflag =1500 =x =1 offset =185 length ID fragflag =1040 =x =0 offset =370 32 7/4/21 IP fragmentation, reassembly Example q 4000 byte datagram q Maximum Transmission Unit (MTU) = 1500 bytes length ID MoreFrag offset =4000 =x =0 =0 One large datagram becomes several smaller datagrams length ID MoreFrag offset =1500 =x =1 =0 1480 bytes in data field length ID MoreFrag offset =1500 =x =1 =185 offset = 1480/8 offset = (1480+1480)/8 =2960/8 length ID MoreFrag offset =1040 =x =0 =370 20 1480 20 Len=1500 1480 Len=1500 20 1020 Len=1040 Len=4000 Fragmentation : Example 4-3 § Consider sending a 1600-byte datagram into a link that has an MTU of 500 bytes. Suppose the original datagram is stamped with the identification number 291. § How many fragments are generated? What are the values in the various fields in the IP datagram(s) generated related to fragmentation? § 1600 byte datagram § Maximum Transmission Unit (MTU)= 500 bytes § Maximum size of data field in each fragment = 500 -20 = 480 bytes § The number of required fragments = !"##$%# =4 &'# § Each fragment will have Identification number 291 § Each fragment except the last one will be of size 500 bytes (including IP header) § The last datagram will be of size 160 bytes § The offset of the 4 fragments will be 0,60,120,180 § Each of the first fragments will have flag=1, the last fragment will have flag=0 33 7/4/21 HW # 4-1 § Consider sending a 2400-byte datagram into a link that has an MTU of 720 bytes. Suppose the original datagram is stamped with the identification number 422. § How many fragments are generated? What are the values in the various fields in the IP datagram(s) generated related to fragmentation? HW # 4-1: solution § 2400 byte datagram § Maximum Transmission Unit (MTU)= 720 bytes § Maximum size of data field in each fragment = 720-20 = 700 bytes § The number of required fragments = %&##$%# (## =4 § Each fragment will have Identification number 422 § Each fragment except the last one will be of size 720 bytes (including IP header) § The last datagram will be of size 2400 – 700 – 700 – 700 = 300 bytes § The offset of the 4 fragments will be 0,88,176, 264 § Each of the first fragments will have flag=1, the last fragment will have flag=0 34 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation • IPv6 4.5 Middleboxes Network Layer: 4-69 IP addressing: introduction 223.1.1.1 § IP address: 32-bit identifier associated with each host or router interface § interface: connection between host/router and physical link • router’s typically have multiple interfaces • host typically has one or two interfaces (e.g., wired Ethernet, wireless 802.11) each with a different IP address 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.3.27 223.1.1.3 223.1.2.2 223.1.3.1 223.1.3.2 dotted-decimal IP address notation: 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 1 Network Layer: 4-70 35 7/4/21 IP addressing: introduction 223.1.1.1 Q: how are interfaces actually connected? A: we’ll learn about that in chapters 6, 7 223.1.2.1 223.1.1.2 A: wired Ethernet interfaces connected by Ethernet switches 223.1.1.4 223.1.1.3 For now: don’t need to worry about how one interface is connected to another (with no intervening router) 223.1.2.9 223.1.3.27 223.1.2.2 223.1.3.1 223.1.3.2 A: wireless WiFi interfaces connected by WiFi base station Network Layer: 4-71 IP addressing: introduction § IP address: 32-bit identifier for host, router interface § interface: connection between host/router and physical link 36 7/4/21 Binary IP Addresses Dotted Decimal 37 7/4/21 IP Addresses IP Addresses 38 7/4/21 Subnet Subnets 223.1.1.1 § What’s a subnet ? • device interfaces that can physically reach each other without passing through an intervening router 223.1.2.1 223.1.1.2 223.1.1.4 223.1.1.3 223.1.2.9 223.1.3.27 223.1.2.2 § IP addresses have structure: • subnet part: devices in same subnet have common high order bits • host part: remaining low order bits 223.1.3.1 223.1.3.2 network consisting of 3 subnets Network Layer: 4-78 39 7/4/21 Subnets subnet 223.1.1.0/24 subnet 223.1.2.0/24 223.1.1.1 Recipe for defining subnets: §detach each interface from its host or router, creating “islands” of isolated networks §each isolated network is subnet called a subnet 223.1.3.0/24 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.3.27 223.1.1.3 223.1.2.2 223.1.3.2 223.1.3.1 subnet mask: /24 (high-order 24 bits: subnet part of IP address) Network Layer: 4-79 Subnets 223.1.1.2 subnet 223.1.1/24 § where are the subnets? § what are the /24 subnet addresses? 223.1.1.1 223.1.1.4 223.1.1.3 223.1.9.2 223.1.7.0 subnet 223.1.9/24 223.1.9.1 223.1.7.1 223.1.8.1 subnet 223.1.2/24 223.1.2.1 223.1.2.6 subnet 223.1.7/24 223.1.8.0 subnet 223.1.8/24 223.1.2.2 223.1.3.27 223.1.3.1 subnet 223.1.3/24 223.1.3.2 Network Layer: 4-80 40 7/4/21 Subnet Mask CIDR 41 7/4/21 IP addressing: CIDR CIDR: Classless InterDomain Routing (pronounced “cider”) • subnet portion of address of arbitrary length • address format: a.b.c.d/x, where x is # bits in subnet portion of address host part subnet part 11001000 00010111 00010000 00000000 200.23.16.0/23 Network Layer: 4-83 IP addressing: CIDR CIDR: Classless InterDomain Routing • subnet portion of address of arbitrary length • address format: a.b.c.d/x, • where x is # bits in subnet portion of address • All 1’s in the host part is used for subnet broadcast • All 0’s in the host part was meant as “subnet address” but not really used for anything. Some implementation allow it to be used as host address. Some don’t. Better to avoid it. subnet part host part 11001000 00010111 00010000 00000000 200.23.16.0/23 42 7/4/21 IP addressing: CIDR § Classless Inter-domain Routing § Improve address space utilization § Routing scalability in the Internet § For example, if an ISP owns network 172.16.0.0/16, then the ISP can offer 172.16.1.0/24, 172.16.2.0/24,and so on to customers. Yet, when advertising to other providers, the ISP only needs to advertise 172.16.0.0/16 IP Address Classes 43 7/4/21 IP Address Classes • Class A: 0 Network 1 7 Local 24 bits 10 Network Local 16 bits 2 14 110 Network Local Class C: 8 bits 3 21 1110 Host Group (Multicast) Class D: 4 28 bits 11110 Future use Class E: 5 27 bits Local = Subnet + Host (Variable length) • Class B: • • • • Router Router Subnet IP Address Classes 44 7/4/21 IP Address Classes § Class A: The first octet is the network portion. Octets 2, 3, and 4 are for subnets/hosts § Class B: The first two octets are the network portion. Octets 3 and 4 are for subnets/hosts § Class C: The first three octets are the network portion. Octet 4 is for subnets/hosts Private Address Range 45 7/4/21 Network Masks Subnetting Creates multiple logical networks that exist within a single Class A, B, or C network. If you do not subnet, you will only be able to use one network from your Class A, B, or C network, which is unrealistic Each data link on a network must have a unique network ID, with every node on that link being a member of the same network 46 7/4/21 Benefits of Subnetting Reduced network traffic 2) Optimized network performance 3) Simplified management 4) Facilitated spanning of large geographical distances 1) IP Subnet-Zero § This command allows you to use the first and last subnet in your network design. § For example, the Class C mask of 192 provides subnets 64 and 128, but with the IP subnet-zero command, you now get to use subnets 0, 64, 128, and 192 47 7/4/21 How to create subnets Determine the number of required network IDs: ØOne for each subnet ØOne for each wide area network connection Determine the number of required host IDs per subnet: ØOne for each TCP/IP host ØOne for each router interface Based on the above requirements, create the following: ØOne subnet mask for your entire network ØA unique subnet ID for each physical segment ØA range of host IDs for each subnet Subnetting a Class A/B/C Address § How many subnets does the chosen subnet mask produce? § How many valid hosts per subnet are available? § What are the valid subnets? § What’s the broadcast address of each subnet? § What are the valid hosts in each subnet? 48 7/4/21 Practice Example #1C: 255.255.255.128 (/25) Network 192.168.10.0 How many subnets? Since 128 is 1 bit on (10000000), the answer would be 21= 2. How many hosts per subnet? We have 7 host bits off (10000000), so the equation would be 27– 2 = 126 hosts. What are the valid subnets? 256 – 128 = 128. Remember, we’ll start at zero and count in our block size, so our subnets are 0, 128. What’s the broadcast address for each subnet? The number right before the value of the next subnet is all host bits turned on and equals the broadcast address. For the zero subnet, the next subnet is 128, so the broadcast of the 0 subnet is 127. What are the valid hosts? These are the numbers between the subnet and broadcast address DHCP 49 7/4/21 How does a host get an IP address? Q: How does a host get IP address? § Manually • hard-coded by system admin in a file • Windows: control-panel->network->configuration->tcp/ip->properties • UNIX: /etc/rc.config § Automagically • DHCP: Dynamic Host Configuration Protocol: dynamically get address from a server • “plug-and-play” DHCP § Dynamic Host Control Protocol § Allows hosts to get an IP address automatically from a server § Do not need to program each host manually § Each allocation has a limited “lease” time § Can reuse a limited number of addresses § Hosts broadcast “Is there a DHCP Server Here?” § Sent to 255.255.255.255 § DHCP servers respond 50 7/4/21 DHCP: Dynamic Host Configuration Protocol goal: host dynamically obtains IP address from network server when it “joins” network § can renew its lease on address in use § allows reuse of addresses (only hold address while connected/on) § support for mobile users who join/leave network DHCP overview: § host broadcasts DHCP discover msg [optional] § DHCP server responds with DHCP offer msg [optional] § host requests IP address: DHCP request msg § DHCP server sends address: DHCP ack msg Network Layer: 4-101 DHCP client-server scenario DHCP server 223.1.1.1 223.1.2.1 Typically, DHCP server will be colocated in router, serving all subnets to which router is attached 223.1.2.5 223.1.1.2 223.1.1.4 223.1.1.3 223.1.2.9 223.1.3.27 223.1.2.2 223.1.3.1 arriving DHCP client needs address in this network 223.1.3.2 Network Layer: 4-102 51 7/4/21 DHCP client-server scenario DHCP server: 223.1.2.5 DHCP discover Arriving client src : 0.0.0.0, 68 Broadcast: is there a dest.: 255.255.255.255,67 DHCPyiaddr: server 0.0.0.0 out there? transaction ID: 654 DHCP offer src: 223.1.2.5, 67 Broadcast: I’m a DHCP dest: 255.255.255.255, 68 yiaddrr:Here’s 223.1.2.4 server! an IP transaction ID: 654 address you can use lifetime: 3600 secs DHCP request src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 Broadcast: OK. I would yiaddrr: 223.1.2.4 like totransaction use this ID: IP655 address! lifetime: 3600 secs DHCP ACK src: 223.1.2.5, 67 dest: 255.255.255.255, 68 Broadcast: OK. You’ve yiaddrr: 223.1.2.4 got that IPID: address! transaction 655 lifetime: 3600 secs Network Layer: 4-103 DHCP client-server scenario DHCP server: 223.1.2.5 DHCP discover Arriving client src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0 transaction ID: 654 DHCP offer src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 654 lifetime: 3600 secs DHCP request src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 223.1.2.4 transaction ID: 655 lifetime: 3600 secs The two steps above can be skipped “if a client remembers and wishes to reuse a previously allocated network address” [RFC 2131] DHCP ACK src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 655 lifetime: 3600 secs Network Layer: 4-104 52 7/4/21 DHCP: more than IP addresses DHCP can return more than just allocated IP address on subnet: § address of first-hop router for client (Default Gateway) § name and IP address of DNS sever § network mask (indicating network versus host portion of address) Network Layer: 4-105 DHCP: example § Connecting laptop will use DHCP to get IP address, address of firsthop router, address of DNS server. DHCP UDP IP Eth Phy DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy 168.1.1.1 router with DHCP server built into router § DHCP REQUEST message encapsulated in UDP, encapsulated in IP, encapsulated in Ethernet § Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN, received at router running DHCP server § Ethernet demux’ed to IP demux’ed, UDP demux’ed to DHCP Network Layer: 4-106 53 7/4/21 DHCP: example § DCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name & IP address of DNS server DHCP UDP IP Eth Phy DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy § encapsulated DHCP server reply forwarded to client, demuxing up to DHCP at client router with DHCP server built into router § client now knows its IP address, name and IP address of DNS server, IP address of its first-hop router Network Layer: 4-107 DHCP: Wireshark output (home LAN) Message type: Boot Request (1) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 (0.0.0.0) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 0.0.0.0 (0.0.0.0) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP Request Option: (61) Client identifier Length: 7; Value: 010016D323688A; Hardware type: Ethernet Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Option: (t=50,l=4) Requested IP Address = 192.168.1.101 Option: (t=12,l=5) Host Name = "nomad" Option: (55) Parameter Request List Length: 11; Value: 010F03062C2E2F1F21F92B 1 = Subnet Mask; 15 = Domain Name 3 = Router; 6 = Domain Name Server 44 = NetBIOS over TCP/IP Name Server …… request Message type: Boot Reply (2) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 192.168.1.101 (192.168.1.101) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 192.168.1.1 (192.168.1.1) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP ACK Option: (t=54,l=4) Server Identifier = 192.168.1.1 Option: (t=1,l=4) Subnet Mask = 255.255.255.0 Option: (t=3,l=4) Router = 192.168.1.1 Option: (6) Domain Name Server Length: 12; Value: 445747E2445749F244574092; IP Address: 68.87.71.226; IP Address: 68.87.73.242; IP Address: 68.87.64.146 Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net." reply 54 7/4/21 How do organizatios get an IP address? How do organizatios get an IP address? 55 7/4/21 IP addresses: how to get one? Q: how does network get subnet part of IP address? A: gets allocated portion of its provider ISP’s address space ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20 ISP can then allocate out its address space in 8 blocks: Organization 0 Organization 1 Organization 2 ... Organization 7 11001000 00010111 00010000 00000000 11001000 00010111 00010010 00000000 11001000 00010111 00010100 00000000 ….. …. 11001000 00010111 00011110 00000000 200.23.16.0/23 200.23.18.0/23 200.23.20.0/23 …. 200.23.30.0/23 Network Layer: 4-111 Hierarchical addressing: more specific routes § Organization 1 moves from Fly-By-Night-ISP to ISPs-R-Us § ISPs-R-Us now advertises a more specific route to Organization 1 Organization 0 200.23.16.0/23 Organization 2 200.23.20.0/23 Organization 7 . . . . . . Fly-By-Night-ISP “Send me anything with addresses beginning 200.23.16.0/20” Internet 200.23.30.0/23 ISPs-R-Us Organization 1 200.23.18.0/23 “Send me anything with addresses beginning 199.31.0.0/16” “or 200.23.18.0/23” Network Layer: 4-112 56 7/4/21 IP addressing: last words ... Q: how does an ISP get block of addresses? A: ICANN: Internet Corporation for Assigned Names and Numbers http://www.icann.org/ • allocates IP addresses, through 5 regional registries (RRs) (who may then allocate to local registries) • manages DNS root zone, including delegation of individual TLD (.com, .edu , …) management Q: are there enough 32-bit IP addresses? § ICANN allocated last chunk of IPv4 addresses to RRs in 2011 § NAT (next) helps IPv4 address space exhaustion § IPv6 has 128-bit address space "Who the hell knew how much address space we needed?" Vint Cerf (reflecting on decision to make IPv4 address 32 bits long) Network Layer: 4-113 “Route Print” Command in Windows MAC: netstat -rn =========================================================================== Interface List 0x1 ........................... MS TCP Loopback interface 0x2 ...00 16 eb 05 af c0 ...... Intel(R) WiFi Link 5350 - Packet Scheduler Miniport 0x3 ...00 1f 16 15 7c 41 ...... Intel(R) 82567LM Gigabit Network Connection - Packet Scheduler Miniport 0x40005 ...00 05 9a 3c 78 00 ...... Cisco Systems VPN Adapter - Packet Scheduler Miniport =========================================================================== =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.108 10 0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.106 10 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 169.254.0.0 255.255.0.0 192.168.0.106 192.168.0.106 20 192.168.0.0 255.255.255.0 192.168.0.106 192.168.0.106 10 192.168.0.0 255.255.255.0 192.168.0.108 192.168.0.108 10 192.168.0.106 255.255.255.255 127.0.0.1 127.0.0.1 10 192.168.0.108 255.255.255.255 127.0.0.1 127.0.0.1 10 192.168.0.255 255.255.255.255 192.168.0.106 192.168.0.106 10 192.168.0.255 255.255.255.255 192.168.0.108 192.168.0.108 10 224.0.0.0 240.0.0.0 192.168.0.106 192.168.0.106 10 224.0.0.0 240.0.0.0 192.168.0.108 192.168.0.108 10 255.255.255.255 255.255.255.255 192.168.0.106 192.168.0.106 1 255.255.255.255 255.255.255.255 192.168.0.106 40005 1 255.255.255.255 255.255.255.255 192.168.0.108 192.168.0.108 1 Default Gateway: 192.168.0.1 =========================================================================== Persistent Routes: None Adr & mask = Dest Þ Match Longest Prefix match is used Metric: Lower is better Note: 127.0.0.1 = Local Host, 224.x.y.z = Multicast on local LAN 57 7/4/21 Practice Example #4: 255.255.255.224 (/27) Network 192.168.10.0 How many subnets? 224 is 11100000, so our equation would be 23 = 8. How many hosts? 25– 2 = 30. What are the valid subnets? 256 – 224 = 32. We just start at zero and count to the subnet mask value in blocks (increments) of 32: 0, 32, 64, 96, 128, 160, 192, and 224. What’s the broadcast address for each subnet (always the number right before the next subnet)? What are the valid hosts (the numbers between the subnet number and the broadcast address)? Practice Solution #4: 255.255.255.224 (/27) Network 192.168.10.0 Subnet Address 0 32 First Host 1 Last Host 30 Broadcast Address 31 …………. 192 224 33 193 225 62 222 254 63 223 255 58 7/4/21 HW # 5: 255.255.128.0 (/17) Network 172.16.0.0 Subnets? Hosts? Valid subnets? Broadcast address for each subnet? Valid hosts? HW Solution # 5: 255.255.128.0 (/17) Network 172.16.0.0 Subnets? 21 = 2 Hosts? 215– 2 = 32,766 (7 bits in the third octet, and 8 in the fourth) Valid subnets? 256 – 128 = 128. 0, 128. Remember that subnetting is performed in the third octet, so the subnet numbers are really 0.0 and 128.0, as shown in the next table Broadcast address for each subnet? Valid hosts? 59 7/4/21 Practice Solution #5: 255.255.128.0 (/17) Network 172.16.0.0 Subnet 0.0 128.0 First Host 0.1 128.1 Last Host 127.254 255.254 Broadcast 127.255 255.255 HW # 6: 255.255.240.0 (/20) Network 172.16.0.0 § Subnets? § Hosts? § Valid subnets? § Broadcast address for each subnet? § Valid hosts? 60 7/4/21 Practice Solution #6: 255.255.240.0 (/20) Network 172.16.0.0 § Subnets? 24= 16. § Hosts? 212 – 2 = 4094. § Valid subnets? 256 – 240 = 0, 16, 32, 48, etc., up to 240. § Broadcast address for each subnet? § Valid hosts? Practice Solution #6: 255.255.240.0 (/20) Network 172.16.0.0 Subnet 0.0 16.0 ……….. 240.0 First Host 0.1 16.1 240.1 Last Host 15.254 31.254 255.254 Broadcast 15.255 31.255 255.255 61 7/4/21 Packet Scheduling Matching: Example 4-7 Consider the three subnets in the diagram below. Consider the three subnets in the diagram below. What is the maximum # of interfaces in the 223.1.2/24 network? What is the maximum # of interfaces in the 223.1.3/29 network? Packet Scheduling Matching: solution 4-7 Consider the three subnets in the diagram below. What is the maximum # of interfaces in the 223.1.2/24 network? 256 What is the maximum # of interfaces in the 223.1.3/29 network? 8 Which of the following addresses can be used by an interface in the 223.1.3/29 network? 223.1.3.6 Which of the following addresses can not be used by an interface in the 223.1.3/29 network? 223.1.3.16, 223.1.2.6 62 7/4/21 Subnet Addressing: Example 4-8 Consider the router and the two attached subnets below (A and B). The number of hosts is also shown below. The subnets share the 24 high-order bits of the address space: 192.168.6.0/24 Assign subnet addresses to each of the subnets (A and B) so that the amount of address space assigned is minimal, and at the same time leaving the largest possible contiguous address space available for assignment if a new subnet were to be added. Then answer the questions below. 1. 2. 3. 4. 5. 6. Is the address space public or private? How many hosts can there be in this address space? What is the subnet address of subnet A? (CIDR notation) What is the broadcast address of subnet A? What is the starting address of subnet A? What is the ending address of subnet A? Subnet Addressing: Example 4-8(cont.) Consider the router and the two attached subnets below (A and B). The number of hosts is also shown below. The subnets share the 24 high-order bits of the address space: 192.168.6.0/24 Assign subnet addresses to each of the subnets (A and B) so that the amount of address space assigned is minimal, and at the same time leaving the largest possible contiguous address space available for assignment if a new subnet were to be added. Then answer the questions below. 7. 8. 9. 10. What is the subnet address of subnet B? (CIDR notation) What is the broadcast address of subnet B? What is the starting address of subnet B? What is the ending address of subnet B? 63 7/4/21 Subnet Addressing: Solution 4-8 1. 2. 3. 4. 5. 6. The address 192.168.6.0/24 is private. Maximum number of hosts = 2^x - 2 = 2^8 - 2 = 254. The reason we have to subtract 2 from the final number is because there are always 2 addresses allocated for each address block: the subnet ID (the first address) and the broadcast address (the last address); for example, if you have 5 bits for hosts, you can have 30 hosts, because 2 of the addresses are for the subnet ID and the broadcast address which when added equals 32, which is 2^5. Subnet A has 20 hosts, so it will need at least 22 addresses (for the subnet ID and broadcast address). The least number of bits that satisfy this is 5 bits. Knowing that, we take the prior subnet and add 32, the result of which is 192.168.6.64/27 The broadcast address of subnet A (192.168.6.64/27) is 192.168.6.95, because it is the last address in the IP range. The first IP address of subnet A (192.168.6.64/27) is 192.168.6.65, found by adding 1 to the subnet address. The last IP address of subnet A (192.168.6.64/27) is 192.168.6.94, found by subtracting 1 from the broadcast address (192.168.6.95). Subnet Addressing: Solution 4-8 (cont.) 7. Similar to the prior subnet, subnet B has 62 hosts, so it will need at least 64 addresses (for the subnet ID and broadcast address). The least number of bits that satisfy this is 6 bits. Knowing that, we take the prior subnet and add 64, the result of which is 192.168.6.0/26 8. The broadcast address of subnet B (192.168.6.0/26) is 192.168.6.63, because it is the last address in the IP range. 9. The first IP address of subnet B (192.168.6.0/26) is 192.168.6.1, found by adding 1 to the subnet address. 10. The last IP address of subnet B (192.168.6.0/26) is 192.168.6.62, found by subtracting 1 from the broadcast address (192.168.6.63). 64 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation • IPv6 4.5 Middleboxes Network Layer: 4-129 NAT: network address translation NAT: all devices in local network share just one IPv4 address as far as outside world is concerned rest of Internet 138.76.29.7 local network (e.g., home network) 10.0.0/24 10.0.0.4 10.0.0.1 10.0.0.2 10.0.0.3 all datagrams leaving local network have same source NAT IP address: 138.76.29.7, but different source port numbers datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual) Network Layer: 4-130 65 7/4/21 NAT: network address translation § all devices in local network have 32-bit addresses in a “private” IP address space (10/8, 172.16/12, 192.168/16 prefixes) that can only be used in local network § advantages: § just one IP address needed from provider ISP for all devices § can change addresses of host in local network without notifying outside world § can change ISP without changing addresses of devices in local network § security: devices inside local net not directly addressable, visible by outside world Network Layer: 4-131 NAT: network address translation implementation: NAT router must (transparently): § 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 address § 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 destination fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table Network Layer: 4-132 66 7/4/21 NAT: network address translation NAT translation table WAN side addr LAN side addr 2: NAT router changes datagram source address from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table 1: host 10.0.0.1 sends datagram to 128.119.40.186, 80 138.76.29.7, 5001 10.0.0.1, 3345 …… …… S: 10.0.0.1, 3345 D: 128.119.40.186, 80 1 2 S: 138.76.29.7, 5001 D: 128.119.40.186, 80 138.76.29.7 S: 128.119.40.186, 80 D: 138.76.29.7, 5001 3 10.0.0.4 S: 128.119.40.186, 80 D: 10.0.0.1, 3345 10.0.0.1 10.0.0.2 4 10.0.0.3 3: reply arrives, destination address: 138.76.29.7, 5001 Network Layer: 4-133 NAT: network address translation § NAT has been controversial: • • • • routers “should” only process up to layer 3 address “shortage” should be solved by IPv6 violates end-to-end argument (port # manipulation by network-layer device) NAT traversal: what if client wants to connect to server behind NAT? § but NAT is here to stay: • extensively used in home and institutional nets, 4G/5G cellular nets Network Layer: 4-134 67 7/4/21 IPv6: motivation § initial motivation: 32-bit IPv4 address space would be completely allocated § additional motivation: • speed processing/forwarding: 40-byte fixed length header • enable different network-layer treatment of “flows” Network Layer: 4-135 IPv6 datagram format priority: identify priority among datagrams in flow 128-bit IPv6 addresses 32 bits ver pri flow label hop limit payload len next hdr source address (128 bits) flow label: identify datagrams in same "flow.” (concept of “flow” not well defined). destination address (128 bits) payload (data) What’s missing (compared with IPv4): § no checksum (to speed processing at routers) § no fragmentation/reassembly § no options (available as upper-layer, next-header protocol at router) Network Layer: 4-136 68 7/4/21 Transition from IPv4 to IPv6 § not all routers can be upgraded simultaneously • no “flag days” • how will network operate with mixed IPv4 and IPv6 routers? § tunneling: IPv6 datagram carried as payload in IPv4 datagram among IPv4 routers (“packet within a packet”) • tunneling used extensively in other contexts (4G/5G) IPv4 header fields IPv4 source, dest addr IPv6 header fields IPv6 source dest addr IPv4 payload UDP/TCP payload IPv6 datagram IPv4 datagram Network Layer: 4-137 Tunneling and encapsulation Ethernet connecting two IPv6 routers: A B IPv6 IPv6 Link-layer frame Ethernet connects two IPv6 routers E F IPv6 IPv6 IPv6 datagram The usual: datagram as payload in link-layer frame Network Layer: 4-138 69 7/4/21 Tunneling and encapsulation Ethernet connecting two IPv6 routers: A B IPv6 IPv6 Link-layer frame IPv4 network connecting two IPv6 routers Ethernet connects two IPv6 routers E F IPv6 IPv6 IPv6 datagram The usual: datagram as payload in link-layer frame A B E F IPv6 IPv6/v4 IPv6/v4 IPv6 IPv4 network Network Layer: 4-139 Tunneling and encapsulation Ethernet connecting two IPv6 routers: A B IPv6 IPv6 Link-layer frame IPv4 tunnel connecting two IPv6 routers IPv4 datagram Ethernet connects two IPv6 routers E F IPv6 IPv6 IPv6 datagram The usual: datagram as payload in link-layer frame A B IPv6 IPv6/v4 IPv4 tunnel connecting IPv6 routers E F IPv6/v4 IPv6 IPv6 datagram tunneling: IPv6 datagram as payload in a IPv4 datagram Network Layer: 4-140 70 7/4/21 Tunneling logical view: physical view: IPv4 tunnel connecting IPv6 routers A B IPv6 IPv6/v4 A B C D E F IPv6 IPv6/v4 IPv4 IPv4 IPv6/v4 IPv6 flow: X src: A dest: F data A-to-B: IPv6 E F IPv6/v4 IPv6 src:B dest: E src:B dest: E src:B dest: E Flow: X Src: A Dest: F Flow: X Src: A Dest: F Flow: X Src: A Dest: F data data data B-to-C: IPv6 inside IPv4 B-to-C: IPv6 inside IPv4 flow: X src: A dest: F data B-to-C: IPv6 inside IPv4 E-to-F: IPv6 Network Layer: 4-141 Tunneling logical view: physical view: B IPv6 IPv6/v4 A B C D E F IPv6 IPv6/v4 IPv4 IPv4 IPv6/v4 IPv6 flow: X src: A dest: F Note source and destination addresses! IPv4 tunnel connecting IPv6 routers A data A-to-B: IPv6 E F IPv6/v4 IPv6 src:B dest: E src:B dest: E src:B dest: E Flow: X Src: A Dest: F Flow: X Src: A Dest: F Flow: X Src: A Dest: F data data data B-to-C: IPv6 inside IPv4 B-to-C: IPv6 inside IPv4 B-to-C: IPv6 inside IPv4 flow: X src: A dest: F data E-to-F: IPv6 Network Layer: 4-142 71 7/4/21 IPv6: adoption § Google1: ~ 30% of clients access services via IPv6 § NIST: 1/3 of all US government domains are IPv6 capable 1 https://www.google.com/intl /en/ipv6/statistics.html Network Layer: 4-143 IPv6: adoption § Google1: ~ 30% of clients access services via IPv6 § NIST: 1/3 of all US government domains are IPv6 capable § Long (long!) time for deployment, use • 25 years and counting! • think of application-level changes in last 25 years: WWW, social media, streaming media, gaming, telepresence, … • Why? 1 https://www.google.com/intl/en/ipv6/statistics.html Network Layer: 4-144 72 7/4/21 Network layer: “data plane” roadmap 4.1 Network layer: overview • data plane • control plane 4.2 What’s inside a router • input ports, switching, output ports • buffer management, scheduling 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding, SDN • datagram format • Match+action • addressing • OpenFlow: match+action in action • network address translation • IPv6 4.5 Middleboxes Network Layer: 4-145 Generalized forwarding: match plus action Review: each router contains a forwarding table (aka: flow table) § “match plus action” abstraction: match bits in arriving packet, take action values in arriving • destination-based forwarding: forward based on dest. IP address packet header 0111 • generalized forwarding: 1 2 3 • many header fields can determine action • many action possible: drop/copy/modify/log packet forwarding table (aka: flow table) Network Layer: 4-146 73 7/4/21 Flow table abstraction § flow: defined by header field values (in link-, network-, transport-layer fields) § generalized forwarding: simple packet-handling rules • match: pattern values in packet header fields • actions: for matched packet: drop, forward, modify, matched packet or send matched packet to controller • priority: disambiguate overlapping patterns • counters: #bytes and #packets Router’s flow table define router’s match+action rules Flow table match action Network Layer: 4-147 Flow table abstraction § flow: defined by header fields § generalized forwarding: simple packet-handling rules • match: pattern values in packet header fields • actions: for matched packet: drop, forward, modify, matched packet or send matched packet to controller • priority: disambiguate overlapping patterns • counters: #bytes and #packets src = *.*.*.*, dest=3.4.*.* src=1.2.*.*, dest=*.*.*.* src=10.1.2.3, dest=*.*.*.* Flow table match action * : wildcard 4 1 2 forward(2) drop send to controller 3 Network Layer: 4-148 74 7/4/21 OpenFlow: flow table entries Match Action Stats Packet + byte counters 1. 2. 3. 4. Forward packet to port(s) Drop packet Modify fields in header(s) Encapsulate and forward to controller Header fields to match: Ingress Port Src MAC Dst MAC Eth Type VLAN ID VLAN Pri IP Src IP Dst IP Proto IP ToS Network layer Link layer TCP/UDP Src Port TCP/UDP Dst Port Transport layer Network Layer: 4-149 OpenFlow: examples Destination-based forwarding: Switch MAC src Port * * MAC dst * Eth VLAN VLAN type ID Pri * * * IP Src IP Dst * 51.6.0.8 IP Src IP Dst * * IP Src IP Dst 128.119.1.1 * IP Prot IP ToS * * IP Prot IP ToS * * IP Prot IP ToS * * TCP TCP s-port d-port Action port6 * * IP datagrams destined to IP address 51.6.0.8 should be forwarded to router output port 6 Firewall: Switch MAC src Port * * MAC dst * Eth VLAN VLAN type ID Pri * * * TCP TCP s-port d-port Action drop 22 * Block (do not forward) all datagrams destined to TCP port 22 (ssh port #) Switch MAC src Port * * MAC dst * Eth VLAN VLAN type ID Pri * * * Block (do not forward) all datagrams sent by host 128.119.1.1 TCP TCP s-port d-port Action drop * * Network Layer: 4-150 75 7/4/21 OpenFlow: examples Layer 2 destination-based forwarding: Switch MAC src Port * * MAC dst 22:A7:23: 11:E1:02 Eth VLAN VLAN type ID Pri * * * IP Src IP Dst IP Prot IP ToS * * * * TCP TCP s-port d-port Action * * port3 layer 2 frames with destination MAC address 22:A7:23:11:E1:02 should be forwarded to output port 3 Network Layer: 4-151 OpenFlow abstraction § match+action: abstraction unifies different kinds of devices Router • match: longest destination IP prefix • action: forward out a link Switch • match: destination MAC address • action: forward or flood Firewall • match: IP addresses and TCP/UDP port numbers • action: permit or deny NAT • match: IP address and port • action: rewrite address and port Network Layer: 4-152 76 7/4/21 OpenFlow example Orchestrated tables can create network-wide behavior, e.g.,: Host h6 10.3.0.6 1 2 s3 controller § datagrams from hosts h5 and h6 should be sent to h3 or h4, via s1 and from there to s2 4 3 Host h5 10.3.0.5 s1 1 Host h1 10.1.0.1 2 s2 1 4 Host h4 10.2.0.4 4 2 3 3 Host h3 10.2.0.3 Host h2 10.1.0.2 Network Layer: 4-153 OpenFlow example match action Orchestrated tables can create network-wide behavior, e.g.,: Host h6 10.3.0.6 IP Src = 10.3.*.* IP Dst = 10.2.*.* forward(3) 1 2 3 s3 controller § datagrams from hosts h5 and h6 should be sent to h3 or h4, via s1 and from there to s2 4 Host h5 10.3.0.5 1 Host h1 10.1.0.1 s1 2 4 3 match ingress port = 1 IP Src = 10.3.*.* IP Dst = 10.2.*.* action forward(4) Host h2 10.1.0.2 s2 1 4 2 3 Host h3 10.2.0.3 match Host h4 10.2.0.4 action ingress port = 2 forward(3) IP Dst = 10.2.0.3 ingress port = 2 forward(4) IP Dst = 10.2.0.4 Network Layer: 4-154 77 7/4/21 Generalized forwarding: summary § “match plus action” abstraction: match bits in arriving packet header(s) in any layers, take action • matching over many fields (link-, network-, transport-layer) • local actions: drop, forward, modify, or send matched packet to controller • “program” network-wide behaviors § simple form of “network programmability” • programmable, per-packet “processing” • historical roots: active networking • today: more generalized programming: P4 (see p4.org). Network Layer: 4-155 Network layer: “data plane” roadmap 4.1 Network layer: overview 4.2 What’s inside a router 4.3 IP: the Internet Protocol 4.4 Generalized Forwarding 4.5 Middleboxes • middlebox functions • evolution, architectural principles of the Internet Network Layer: 4-156 78 7/4/21 Middleboxes Middlebox (RFC 3234) “any intermediary box performing functions apart from normal, standard functions of an IP router on the data path between a source host and destination host” Middleboxes everywhere! national or global ISP NAT: home, Firewalls, IDS: corporate, institutional, service providers, ISPs cellular, institutional Load balancers: corporate, service provider, data center, mobile nets Applicationspecific: service providers, institutional, CDN datacenter network enterprise network Caches: service provider, mobile, CDNs 79 7/4/21 Middleboxes § initially: proprietary (closed) hardware solutions § move towards “whitebox” hardware implementing open API § move away from proprietary hardware solutions § programmable local actions via match+action § move towards innovation/differentiation in software § SDN: (logically) centralized control and configuration management often in private/public cloud § network functions virtualization (NFV): programmable services over white box networking, computation, storage The IP hourglass Internet’s “thin waist”: § one network layer protocol: IP § must be implemented by every (billions) of Internet-connected devices HTTP SMTP RTP QUIC DASH TCP UDP IP Ethernet PPP … PDCP WiFi Bluetooth … many protocols in physical, link, transport, and application layers copper radio fiber 80 7/4/21 The IP hourglass, at middle age HTTP SMTP RTP QUIC DASH Internet’s middle age “love handles”? § middleboxes, operating inside the network … TCP UDP caching IP Firewalls Ethernet PPP … PDCP WiFi Bluetooth copper radio fiber Architectural Principles of the Internet RFC 1958 “Many members of the Internet community would argue that there is no architecture, but only a tradition, which was not written down for the first 25 years (or at least not by the IAB). However, in very general terms, the community believes that the goal is connectivity, the tool is the Internet Protocol, and the intelligence is end to end rather than hidden in the network.” Three cornerstone beliefs: § simple connectivity § IP protocol: that narrow waist § intelligence, complexity at network edge 81 7/4/21 The end-end argument § some network functionality (e.g., reliable data transfer, congestion) can be implemented in network, or at network edge application transport network data link physical application transport network data link physical end-end implementation of reliable data transfer application transport network data link physical hop-by-hop (in-network) implementation of reliable data transfer network link physical network link physical network link physical network link physical network link physical network link physical application transport network data link physical The end-end argument § some network functionality (e.g., reliable data transfer, congestion) can be implemented in network, or at network edge “The function in question can completely and correctly be implemented only with the knowledge and help of the application standing at the end points of the communication system. Therefore, providing that questioned function as a feature of the communication system itself is not possible. (Sometimes an incomplete version of the function provided by the communication system may be useful as a performance enhancement.) We call this line of reasoning against low-level function implementation the “endto-end argument.” Saltzer, Reed, Clark 1981 82 7/4/21 Where’s the intelligence? 20th century phone net: • intelligence/computing at network switches Internet (pre-2005) • intelligence, computing at edge Internet (post-2005) • programmable network devices • intelligence, computing, massive application-level infrastructure at edge Chapter 4: done! § Network layer: overview § What’s inside a router § IP: the Internet Protocol § Generalized Forwarding, SDN § Middleboxes Question: how are forwarding tables (destination-based forwarding) or flow tables (generalized forwarding) computed? Answer: by the control plane (next chapter) 83 7/4/21 Network Layer Data Plane: Summary 1. Forwarding consists of matching the destination address to a list of entries in a table. Routing consists of making that table. 2. IP is a forwarding protocol. IPv4 uses 32 bit addresses in dotdecimal notation. IPv6 uses 128 bit addresses in Hex-Colon notation. 3. DHCP is used to assign addresses dynamically. 4. Private addresses are used inside an enterprise network. NAT allows a single public address to be used by many internal hosts with private addresses. 5. OpenFlow separates data plane from control plane and centralizes the control plane Acronyms ACK ACM AQM ARP ATM BGP BUM CAMs CBR CCR CIDR CPU DHCP DNS Acknowledgement Automatic Computing Machinery Active Queue Management Address Resolution Protocol Asynchronous Transfer Mode Border Gateway Protocol Broadcast, Unknown, and Multicast Content Addressable Memories Constant bit rate Computer Communications Review Classless Inter-Domain Routing Central Processing Unit Dynamic Host Control Protocol Domain Name Service 84 7/4/21 Acronyms (Cont) FCAPS FCFS FTP GFR HTTP ICMP ID IP IPv4 IPv6 ISP KISS LAN MAC Fault, Configuration, Accounting, Performance and Security First Come First Served File Transfer Protocol Guaranteed Frame Rate Hyper-Text Transfer Protocol IP Control Message Protocol Identifier Inter-Network Protocol IP Version 4 IP Version 6 Internet Service Provider Keep it simple stupid Local Area Network Media Access Control Acronyms (Cont) MS MTU NAT PBX PHY QoS RED RFC RIP RTT SDN SMTP SSL TCAM Microsoft Maximum Transmission Unit Network Address Translation Private Branch Exchange Physical Layer Quality of Service Random Early Drop Request for Comment Routing Information Protocol Round Trip Time Software Defined Networking Simple Mail Transfer Protocol Secure Socket Layer Ternary Content Addressable Memory 85 7/4/21 Acronyms (Cont) TCP TLS ToS TTL UBR UPnP VBR VCI VLAN VPN WAN WiFi Transmission Control Protocol Transport Level Security Type of Service Time to live Unspecified bit rate Universal Plug and Play Variable bit rate Virtual Circuit Identifiers Virtual Local Area Network Virtual Private Network Wide Area Network Wireless Fidelity Additional Chapter 4 slides Network Layer: 4-172 86 7/4/21 IP fragmentation/reassembly fragmentation: in: one large datagram out: 3 smaller datagrams … § network links have MTU (max. transfer size) - largest possible link-level frame • different link types, different MTUs § large IP datagram divided (“fragmented”) within net reassembly … • one datagram becomes several datagrams • “reassembled” only at destination • IP header bits used to identify, order related fragments Network Layer: 4-173 IP fragmentation/reassembly example: § 4000 byte datagram § MTU = 1500 bytes 1480 bytes in data field offset = 1480/8 length ID fragflag =4000 =x =0 offset =0 one large datagram becomes several smaller datagrams length ID fragflag =1500 =x =1 offset =0 length ID fragflag =1500 =x =1 offset =185 length ID fragflag =1040 =x =0 offset =370 Network Layer: 4-174 87 7/4/21 DHCP: Wireshark output (home LAN) Message type: Boot Request (1) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 (0.0.0.0) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 0.0.0.0 (0.0.0.0) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP Request Option: (61) Client identifier Length: 7; Value: 010016D323688A; Hardware type: Ethernet Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Option: (t=50,l=4) Requested IP Address = 192.168.1.101 Option: (t=12,l=5) Host Name = "nomad" Option: (55) Parameter Request List Length: 11; Value: 010F03062C2E2F1F21F92B 1 = Subnet Mask; 15 = Domain Name 3 = Router; 6 = Domain Name Server 44 = NetBIOS over TCP/IP Name Server …… request Message type: Boot Reply (2) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 192.168.1.101 (192.168.1.101) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 192.168.1.1 (192.168.1.1) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP ACK Option: (t=54,l=4) Server Identifier = 192.168.1.1 Option: (t=1,l=4) Subnet Mask = 255.255.255.0 Option: (t=3,l=4) Router = 192.168.1.1 Option: (6) Domain Name Server Length: 12; Value: 445747E2445749F244574092; IP Address: 68.87.71.226; IP Address: 68.87.73.242; IP Address: 68.87.64.146 Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net." reply Network Layer: 4-175 Subnets 88 7/4/21 Subnets Subnets 89 7/4/21 Subnets 90