Overview of Network Layer
Forwarding — the router-local action of moving a packet from an input port to an output port (data plane, fast path, typically hardware).
Routing — the network-wide process of determining the path from source to destination (control plane, slow path, typically software).
Data plane — per-packet processing (forwarding), implemented in hardware.
Control plane — routing algorithms and protocols, implemented in software or a separate SDN controller.
Network Service Models:
- Best-effort (Internet) — no guarantees on delivery, timing, or bandwidth
- ATM CBR — constant bit rate, guaranteed
- ATM ABR — available bit rate, minimum rate guaranteed
What’s Inside a Router?
Router Architecture:
- Input ports — physical layer termination, link-layer processing, lookup and forwarding (longest prefix match using TCAM)
- Switching fabric — moves packets from input to output
- Output ports — buffering, link-layer processing, physical transmission
- Routing processor — control plane functions (routing protocols, routing table)
Switching Fabrics:
| Type | Speed | Description |
|---|---|---|
| Switching via memory | Slow | Traditional computer bus; packet copied to processor memory, then to output |
| Switching via bus | Moderate | Shared bus; input port puts packet on bus with tag, output port reads |
| Switching via crossbar | Fast | NxN interconnect; multiple packets can be forwarded simultaneously (non-blocking) |
Queuing:
- Input queuing: HOL (Head-of-Line) blocking — a packet at the head of an input queue blocks all others behind it
- Output queuing: packets queue at output when switching fabric is faster than output link; requires packet scheduling
Packet Scheduling:
- FIFO (First In First Out) — simplest, no differentiation
- Priority queuing — packets classified by priority; high-priority served first (starvation possible)
- Round Robin (RR) — cycles through classes, serving one packet from each
- WFQ (Weighted Fair Queuing) — weighted round robin; each class gets a minimum guaranteed share
The Internet Protocol (IP)
IPv4 Datagram Format
| Field | Size | Description |
|---|---|---|
| Version | 4 bits | IP version (4) |
| Header length | 4 bits | Length of header in 32-bit words (typically 5) |
| Type of service | 8 bits | Differentiated services (Diffserv) |
| Total length | 16 bits | Entire datagram length (header + data) in bytes |
| Identification | 16 bits | For fragmentation/reassembly |
| Flags | 3 bits | DF (Don’t Fragment), MF (More Fragments) |
| Fragment offset | 13 bits | Position of fragment in original datagram |
| Time-to-Live | 8 bits | Decremented at each router; dropped when 0 |
| Protocol | 8 bits | Upper-layer protocol (6=TCP, 17=UDP) |
| Header checksum | 16 bits | Error check on header only |
| Source IP address | 32 bits | Sending host’s address |
| Destination IP address | 32 bits | Receiving host’s address |
| Options | variable | Rarely used |
| Data | variable | Upper-layer segment |
IPv4 Datagram Fragmentation
- MTU (Maximum Transmission Unit) — maximum frame payload size for a link
- If IP datagram > MTU, it must be fragmented
- Each fragment is a separate IP datagram
- Reassembled at the destination host
Fragmentation calculation:
Number of fragments = ceil((Original datagram length - 20) / (MTU - 20))
Each fragment offset = (previous offset) + (fragment data length / 8)
IPv4 Addressing
CIDR (Classless InterDomain Routing):
- Address format: a.b.c.d/x, where x is the number of bits in the network prefix
- Example: 200.23.16.0/23 has a 23-bit network prefix (512 addresses)
Subnetting:
- A subnet is a network that connects hosts without an intervening router
- IP addresses within a subnet share the same prefix
DHCP (Dynamic Host Configuration Protocol):
- Host gets IP address automatically on joining a network
- DORA: Discover, Offer, Request, Acknowledge
- Also provides: subnet mask, first-hop router, DNS server
NAT (Network Address Translation)
- Private IP addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are used inside a private network
- NAT router maps (private IP, port) to (public IP, port) using a NAT translation table
- Controversial: violates end-to-end argument; workaround via NAT traversal
IPv6
- 128-bit addresses (vs IPv4’s 32 bits)
- Fixed 40-byte header (no options, no fragmentation at routers)
- No checksum at network layer
- No NAT needed (sufficient addresses)
- Tunneling — carrying IPv6 inside IPv4 to support transition
IPv6 Datagram Header:
| Field | Size | Description |
|---|---|---|
| Version | 4 bits | 6 |
| Traffic class | 8 bits | Diffserv |
| Flow label | 20 bits | Identify flows |
| Payload length | 16 bits | Data after 40-byte header |
| Next header | 8 bits | Upper-layer protocol |
| Hop limit | 8 bits | TTL equivalent |
| Source address | 128 bits | |
| Destination address | 128 bits |
Generalized Forwarding and SDN
Match-plus-Action Forwarding:
- Match: fields in packet header (IP src/dst, TCP port, etc.)
- Action: forward to port, drop, modify header, send to controller
OpenFlow:
- Open standard for SDN data plane
- Flow table entries: (match fields, priority, counters, instructions, timeouts, cookie)
- Examples: simple forwarding, load balancing, firewall, NAT
SDN Data Plane separates forwarding hardware from routing logic. The flow table (controlled by a remote SDN controller) tells the switch what to do with each packet.
Key Formulas
| Concept | Formula | Notes |
|---|---|---|
| IP addressing | Address = prefix + host | a.b.c.d/x where x = prefix bits |
| Fragmentation | fragments = ceil((total - 20) / (MTU - 20)) | Header is 20 bytes |
| Fragment offset | offset = data_in_bytes / 8 | Offset in 8-byte units |
References
- Computer Networking: A Top-Down Approach, 7th Edition — Kurose & Ross, Pearson, 2017
- RFC 791 — Internet Protocol
- RFC 8200 — Internet Protocol Version 6
- RFC 2131 — Dynamic Host Configuration Protocol
- RFC 1631 — Network Address Translator (NAT)