Sub topic 3
Decapsulation: Unwrapping at the Receiver
Assume you know basic IP addressing, bytes, hexadecimal notation, and terminal commands. This chapter follows a received frame backward through the network stack.
Removing Each Layer
Decapsulation is the reverse of encapsulation. The receiver removes headers in order:
- The link layer checks the Ethernet frame and removes its header.
- The network layer reads the IPv4 header and removes it.
- The transport layer reads the TCP header and delivers the application data to the correct port.
The Ethernet header identifies the next device on the local link. The IP header identifies the end hosts. The TCP header identifies the application conversation.
Finding the Next MAC Address with ARP
An IP address is not enough to send an Ethernet frame. The sender needs the next device's MAC address, which identifies a network interface on the local link.
With ARP, a host broadcasts, “Who has this IP address?” The owner replies with its MAC address. For a remote destination, the host resolves the default gateway's MAC address, not the remote host's MAC address.
What Changes at Each Router
At every router, the old Ethernet frame is removed and a new frame is built for the next link. The source and destination MAC addresses therefore change at each hop.
The IP source and destination normally remain end-to-end. A router decreases the IPv4 TTL, and fields such as the link-layer header and checksum change.
| Field | Usually changes at each hop? |
|---|---|
| Ethernet MAC addresses | Yes |
| IPv4 source and destination | No |
| IPv4 TTL | Yes |
| TCP ports and sequence numbers | No |
MTU, MSS, and Fragmentation
The MTU is the largest frame payload a link accepts. MSS is the largest TCP application segment, excluding TCP and IP headers. TCP usually negotiates MSS to avoid fragmentation.
If an IP packet exceeds a path's MTU, it may be fragmented, dropped when fragmentation is forbidden, or handled by a smaller TCP MSS. Fragmentation adds overhead and complicates reassembly.
Seeing the Layers
A packet capture shows these nested layers. For example:
sudo tcpdump -i eth0 -e -nn -v -c 5 tcp port 80The Ethernet details appear first, followed by IP addresses, TTL, TCP ports, flags, and payload information.
Tunneling
Tunneling encapsulates one packet inside another packet. The outer packet carries the inner packet across an intermediate network. At the tunnel endpoint, the outer header is removed and the original packet continues processing.
Exercise
A packet crosses two routers. Which addresses normally change at each router: MAC addresses, IP addresses, or TCP ports?
Show answer
The MAC addresses change at every link. The IP addresses and TCP ports normally remain end to end.