Computer Networking Notes - Chapter 4 Data Plane
Network Layer: Data Plane
Goals
- Understand the principles behind network layer services, focusing on the data plane:
- Network layer service models.
- Forwarding versus routing.
- How a router works.
- Addressing.
- Generalized forwarding.
- Internet architecture.
- Instantiation and implementation in the Internet:
- IP protocol.
- NAT, middleboxes.
Data Plane Roadmap
- Network layer overview:
- Data plane.
- Control plane.
- What’s inside a router:
- Input ports, switching, output ports.
- Buffer management, scheduling.
- IP: The Internet Protocol:
- Datagram format.
- Addressing.
- Network address translation.
- IPv6.
- Generalized Forwarding, SDN
- Match+action
- OpenFlow: match+action in action
- Middleboxes
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 the end-end path.
Data Plane vs. Control Plane
Data Plane:
- Local, per-router function.
- Determines how a datagram arriving on a router input port is forwarded to a router output port.
Control Plane:
- Network-wide logic.
- Determines how a datagram is routed among routers along the end-to-end path from source host to destination host.
- Two control-plane approaches:
- Traditional routing algorithms: implemented in routers.
- Software-Defined Networking (SDN): implemented in (remote) servers.
Network-Layer Service Model
| Feature | Internet (Best Effort) | ATM (CBR) | ATM (ABR) | Internet (Intserv) | Internet (Diffserv) |
|---|
| Bandwidth | None | Constant | Guaranteed Min | Guaranteed | Possible |
| Loss | No | Yes | No | Yes | Possibly |
| Order | No | Yes | Yes | Yes | Possibly |
| Timing | No | Yes | No | Yes | No |
- Internet "Best Effort" Service Model: No guarantees on:
- Successful datagram delivery to destination.
- Timing or order of delivery.
- Bandwidth available to end-to-end flow.
- Quality of Service (QoS) Guarantees:?
Destination-Based Forwarding
- Forwarding Table:
- Maps destination address ranges to link interfaces.
Example
| Destination Address Range | Link Interface |
|---|
| 11001000 00010111 00010000 00000000 through 11001000 00010111 00010000 00000111 | 3 |
| 11001000 00010111 00011000 00000000 through 11001000 00010111 00011001 11111111 | 2 |
| 11001000 00010111 00011010 00000000 through 11001000 00010111 00011111 11111111 | 3 |
| Otherwise | 3 |
- Question: What happens if ranges don't divide up so nicely?
Longest Prefix Matching
- When looking for a forwarding table entry for a given destination address, use the longest address prefix that matches the destination address.
- Examples:
- Destination Address:
11001000 00010111 00011000 10101010 matches prefix 11001000 00010111 00011000, use interface 2. - Destination Address:
11001000 00010111 00010110 10100001 matches prefix 11001000 00010111 00010, use interface 0.
Router Internals
- Input ports, switching fabric, output ports.
- Buffer management, scheduling.
IP: The Internet Protocol
- Datagram format.
- Addressing.
- Network address translation.
- IPv6.
IP Protocol
- Datagram format
- Addressing
- Packet handling conventions
- ICMP protocol
- Error reporting
- Router "signaling"
- Transport Layer: TCP, UDP
- Link Layer
- Physical Layer
- Forwarding Table
- Path-selection algorithms: Implemented in
- Routing protocols (OSPF, BGP)
- SDN controller
\begin{verbatim}
ver length type of service total length
32 bits head. len flgs fragment offset
time to live upper layer header checksum
source IP address
destination IP address
options (if any)
payload data (variable length, typically a TCP or UDP segment)
\end{verbatim}
- Version (ver): IP protocol version number.
- Header Length (head. len): Length of header in bytes.
- Type of Service: DiffServ and ECN.
- Total Length: Total datagram length (bytes).
- Identifier, flags, fragmentation offset: Used for fragmentation/reassembly.
- TTL (Time To Live): Remaining max hops (decremented at each router).
- Upper Layer: Indicates upper layer protocol (e.g., TCP or UDP).
- Header Checksum: Used for error detection in the header.
- Source IP Address: 32-bit source IP address.
- Destination IP Address: 32-bit destination IP address.
- Options: Optional headers (e.g., timestamp, record route taken).
- Data/Payload: variable length; typically a TCP or UDP segment
- Overhead: 20 bytes of TCP + 20 bytes of IP = 40 bytes
- Maximum length: 64K bytes.
- Typically: 1500 bytes or less.
IP Addressing: Introduction
- IP address: 32-bit identifier associated with each host or router interface.
- Interface: connection between host/router and physical link.
- A router typically has multiple interfaces.
- A host typically has one or two interfaces (e.g., wired Ethernet, wireless 802.11).
- Dotted-decimal IP address notation:
Example: 223.1.1.1=11011111 00000001 00000001 00000001
IP Addressing: CIDR
- CIDR (Classless InterDomain Routing):
- Subnet portion of address of arbitrary length.
- Address format:
a.b.c.d/x, where x is the number of bits in the subnet portion of the address. - Example:
200.23.16.0/23
Subnet Mask
- It is a 32-bit address used to distinguish between a network address and a host address in an IP address.
- A subnet mask identifies which part of an IP address is the network address and the host address.
Connecting Interfaces
- Wired Ethernet interfaces connected by Ethernet switches.
- Wireless WiFi interfaces connected by WiFi base stations.
Subnets
- Subnet: Device interfaces that can physically reach each other without passing through an intervening router.
- IP addresses have structure:
- Subnet part: devices in the same subnet have common high order bits.
- Host part: remaining low order bits.
Recipe for Defining Subnets
- Detach each interface from its host or router, creating “islands” of isolated networks.
- Each isolated network is called a subnet.
- Example:
- Subnet mask:
/24 (high-order 24 bits: subnet part of IP address). - Subnets:
223.1.1.0/24, 223.1.2.0/24, 223.1.3.0/24.
Finding Subnets
- Identify where the subnets are.
- Determine the
/24 subnet addresses.
IPv4 Special Addresses
- Network Address
- The first IP in any block is known as the “network address”.
- It defines where the block of IPs begins.
- The entire host portion of the address is populated with binary zeros
- Directed broadcast address
- A directed broadcast address is used by hosts to send data to all devices on the specific subnet or specific network.
- The entire host portion of the address is populated with binary ones.
- Example:
172.31.0.0/16- Broadcast address:
172.31.255.255 - Network Address:
172.31.0.0
Subnetting Knowledge
- Given an IP address, be able to find out:
- What subnet is this host on?
- What is the first host in this subnet?
- What is the last host in this subnet?
- What is the broadcast address?
Binary Method Rules
- Network/Subnet Address:
- Fill the host portion of the address with binary 0’s.
- Broadcast address:
- Fill the host portion of the address with binary 1’s.
- First host in the subnet:
- Fill the host portion of the address with binary 0's except for the very last bit which is set to a binary 1.
- Last host in the subnet:
- Fill the host portion of the address with binary 1's except for the last bit which is set to binary 0.
Example 1: Subnetting
- IP Address:
192.168.1.18/24 or 192.168.1.18 255.255.255.0 - The red octet is the host portion of the IP address
- Calculations:
- Subnet:
192.168.1.0 - 1st Host:
192.168.1.1 - Last Host:
192.168.1.254 - Broadcast:
192.168.1.255
Example 2: Subnetting
- IP Address:
172.16.35.123/20 or 172.16.35.123 255.255.240.0 - The network and host portion lies somewhere in the third octet.
172.16.00100011.01111011 - Calculations:
- Subnet:
172.16.32.0 - 1st Host:
172.16.32.1 - Last Host:
172.16.47.254 - Broadcast:
172.16.47.255
Create Multiple Subnets - Why?
- Subnet a network into a number of subnets.
- Subnet a network into subnets each having a required number of hosts on them.
- Reasons:
- Less Network Congestion
- Easier Network Administration
- Better Security
Subnetting – Binary Method
- Take bits away from the host portion of address
- Allocate those stolen bits to the network portion of a new address
- Rules:
- When asked for the number of hosts: HOSTS=2n−2
- count the host bits from right to left
- when asked for the number of networks: NETWORKS=2n
- count network bits from left to the right
Example 1: Subnetting (cont.)
- A company has been allocated the subnet of
10.1.1.0/24 for a small office and the network administrator needs to split this subnet into smaller subnets where each subnet supports 14 hosts or machines. - Step 1: Work out the number of bits that are required to support the number of hosts
- 24−2=14. We need to steal 4 bits from the host portion of the address and assign them to the network address
- Step 2: convert the host portion of the original network into binary
10.1.1.0/24 -> 10.1.1.00000000
- Step 3: work out the new subnet mask
- Step 4: work out the various subnets
- 1st:
10.1.1.0/28 - 2nd:
10.1.1.16/28 - 3rd:
10.1.1.32/28 - last:
10.1.1.240/28
IP Addresses: How to Get One?
- Two questions:
- How does a host get an IP address within its network (host part of address)?
- How does a network get an IP address for itself (network part of address)?
- How does a host get an IP address?
- Hard-coded by sysadmin in config file (e.g.,
/etc/rc.config in UNIX). - DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server
DHCP: Dynamic Host Configuration Protocol
- Goal: host dynamically obtains IP address from the network server when it "joins" the network:
- Can renew its lease on the 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.
DHCP Client-Server Scenario
- DHCP Server:
223.1.2.5 - Arriving DHCP client needs address in this network
- Typically, DHCP server will be co-located in router, serving all subnets to which router is attached.
DHCP Client-Server Message Sequence
- DHCP Discover:
- Source:
0.0.0.0, 68 - Destination:
255.255.255.255, 67 - yiaddr:
0.0.0.0 - Transaction ID:
654 - Broadcast: is there a DHCP server out there?
- DHCP Offer:
- Source:
223.1.2.5, 67 - Destination:
255.255.255.255, 68 - yiaddr:
223.1.2.4 - Transaction ID:
654 - lifetime:
3600 secs - Broadcast: I'm a DHCP server! Here's an IP address you can use.
- DHCP Request:
- Source:
0.0.0.0, 68 - Destination:
255.255.255.255, 67 - yiaddr:
223.1.2.4 - Transaction ID:
655 - lifetime:
3600 secs - Broadcast: OK. I would like to use this IP address!
- DHCP ACK:
- Source:
223.1.2.5, 67 - Destination:
255.255.255.255, 68 - yiaddr:
223.1.2.4 - Transaction ID:
655 - lifetime:
3600 secs - Broadcast: OK. You've got that IP address!
- The two steps above can be skipped “if a client remembers and wishes to reuse a previously allocated network address” [RFC 2131]
DHCP: More Than IP Addresses
- DHCP can return more than just allocated IP address on subnet:
- Address of first-hop router for client.
- Name and IP address of DNS server.
- Network mask (indicating network versus host portion of address).
DHCP: Example
- Connecting laptop will use DHCP to get IP address, address of first-hop router, address of DNS server.
- 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
DHCP: Example (cont.)
- DCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name & IP address of DNS server
- encapsulated DHCP server reply forwarded to client, demuxing up to DHCP at client
- client now knows its IP address, name and IP address of DNS server, IP address of its first-hop router
IP Addresses: How to Get One? (cont.)
- Q: How does a network get a subnet part of the IP address?
- A: Gets allocated portion of its provider ISP’s address space
Example
- ISP's block:
200.23.16.0/20 - ISP can then allocate out its address space in 8 blocks:
- Organization 0:
200.23.16.0/23 - Organization 1:
200.23.18.0/23 - Organization 2:
200.23.20.0/23 - Organization 7:
200.23.30.0/23
IP Addressing: Last Words
- Q: How does an ISP get a block of addresses?
- A: ICANN: Internet Corporation for Assigned Names and Numbers
- 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.
NAT: Network Address Translation
- All devices in the local network share just one IPv4 address as far as the outside world is concerned
- Datagrams with source or destination in this network have
10.0.0/24 addresses for source and destination (as usual). - All datagrams leaving the local network have the same source NAT IP address:
138.76.29.7, but different source port numbers.
NAT: Advantages
- All devices in the 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 the local network. - Advantages:
- Just one IP address is needed from provider ISP for all devices.
- Can change addresses of hosts in the local network without notifying the outside world.
- Can change ISP without changing addresses of devices in the local network.
- Security: Devices inside the local net are not directly addressable, visible by the outside world.
NAT: 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 the 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 the corresponding (source IP address, port #) stored in the NAT table.
NAT: Example
- Host
10.0.0.1 sends a datagram to 128.119.40.186, 80 - NAT router changes datagram source address from
10.0.0.1, 3345 to 138.76.29.7, 5001, and updates the table - A reply arrives with the destination address:
138.76.29.7, 5001
NAT Translation Table
| WAN Side Address | LAN Side Address |
|---|
| 138.76.29.7, 5001 | 10.0.0.1, 3345 |
NAT: Controversy
- NAT has been controversial:
- Routers “should” only process up to layer 3.
- The address “shortage” should be solved by IPv6.
- Violates end-to-end argument (port # manipulation by network-layer device).
- NAT traversal: what if a client wants to connect to a server behind NAT?
- But NAT is here to stay:
- Extensively used in home and institutional nets, 4G/5G cellular nets. 29.7, 5001