Encapsulation: Headers, Payloads, and Protocol Stacks
What This Concept Is
Encapsulation is how the layered model is realized on the wire.
When data goes down the stack, each layer:
- takes the message from the layer above as an opaque payload
- adds its own header (and sometimes trailer) of metadata
- hands the result to the layer below
When data goes up the stack at the receiver, each layer strips its own header, inspects it, and passes the remaining payload up.
The header contains everything that layer needs to do its job: addresses, length, flags, checksums, sequence numbers, type-of-next-header hints. The payload is none of its business.
Why It Matters Here
Encapsulation explains why a single Ethernet frame on your NIC contains, in order: an Ethernet header, an IP header, a TCP header, a TLS record, an HTTP request. It also explains why tcpdump output looks the way it does: you are watching bytes that carry five layers of structure at once.
Every protocol decision downstream -- MTU, fragmentation, checksums, offload -- is an encapsulation decision.
Concrete Example
A TCP segment carrying 100 bytes of HTTP sent over Ethernet looks roughly like:
+----------------+----------------+----------------+-------------+-------------+--------+
| Ethernet hdr | IP hdr | TCP hdr | HTTP req | ... | FCS |
| 14 bytes | 20 bytes | 20 bytes | 100 bytes | | 4 bytes|
| src/dst MAC | src/dst IP | src/dst port | "GET / ..." | | |
| type=0x0800 | proto=6 (TCP) | seq, ack, flags| | | |
+----------------+----------------+----------------+-------------+-------------+--------+
^ ^
| frame on the wire (~158 bytes total) |
The type field in the Ethernet header says "next is IP." The proto field in the IP header says "next is TCP." Each header points to the one above it.
Common Confusion / Misconception
"The payload is just the user's message." No. From the perspective of the IP layer, the entire TCP segment -- TCP header plus HTTP bytes -- is payload. From the perspective of the link layer, the entire IP packet is payload. Payloads nest.
Related trap: MTU is a link-layer property, but it constrains all the upper layers because they all have to fit inside one frame (or fragment).