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:

  1. Input ports — physical layer termination, link-layer processing, lookup and forwarding (longest prefix match using TCAM)
  2. Switching fabric — moves packets from input to output
  3. Output ports — buffering, link-layer processing, physical transmission
  4. Routing processor — control plane functions (routing protocols, routing table)

Switching Fabrics:

TypeSpeedDescription
Switching via memorySlowTraditional computer bus; packet copied to processor memory, then to output
Switching via busModerateShared bus; input port puts packet on bus with tag, output port reads
Switching via crossbarFastNxN 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

FieldSizeDescription
Version4 bitsIP version (4)
Header length4 bitsLength of header in 32-bit words (typically 5)
Type of service8 bitsDifferentiated services (Diffserv)
Total length16 bitsEntire datagram length (header + data) in bytes
Identification16 bitsFor fragmentation/reassembly
Flags3 bitsDF (Don’t Fragment), MF (More Fragments)
Fragment offset13 bitsPosition of fragment in original datagram
Time-to-Live8 bitsDecremented at each router; dropped when 0
Protocol8 bitsUpper-layer protocol (6=TCP, 17=UDP)
Header checksum16 bitsError check on header only
Source IP address32 bitsSending host’s address
Destination IP address32 bitsReceiving host’s address
OptionsvariableRarely used
DatavariableUpper-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:

FieldSizeDescription
Version4 bits6
Traffic class8 bitsDiffserv
Flow label20 bitsIdentify flows
Payload length16 bitsData after 40-byte header
Next header8 bitsUpper-layer protocol
Hop limit8 bitsTTL equivalent
Source address128 bits
Destination address128 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

ConceptFormulaNotes
IP addressingAddress = prefix + hosta.b.c.d/x where x = prefix bits
Fragmentationfragments = ceil((total - 20) / (MTU - 20))Header is 20 bytes
Fragment offsetoffset = data_in_bytes / 8Offset 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)