Encapsulation in networking is the process by which each layer of a protocol stack wraps the data handed down from the layer above with its own control information, usually a header and sometimes a trailer, before passing the result to the layer below. The reverse process at the receiver, in which each layer strips and interprets its own header, is called decapsulation.
Also known as data encapsulation, the mechanism is the practical foundation of layered models such as the OSI model and the TCP/IP suite in networking fundamentals. It lets an application send a message without knowing anything about cables, radio channels or addressing, because each layer only reads the header it understands. Not to be confused with encapsulation in object-oriented programming, which concerns hiding the internal state of software objects.
How encapsulation works layer by layer
Encapsulation works by turning the output of one layer into the payload of the next. An application produces data, the transport layer adds a TCP or UDP header to form a segment or datagram, the network layer adds an IP header to form a packet, and the data link layer adds an Ethernet header and a frame check sequence trailer to form a frame. The physical layer then converts the frame into electrical, optical or radio signals.
The generic name for the unit handled at any layer is the protocol data unit (PDU). The payload a layer receives from above is its service data unit (SDU). Each layer treats that SDU as opaque bytes and never inspects its contents during normal forwarding, which is why a router can move an HTTPS packet without understanding web traffic.
The following table shows the PDU name and the control information added at each layer in a typical TCP/IP transmission over Ethernet.
| Layer | PDU name | Information added | Typical size |
|---|---|---|---|
| Application | Data or message | Application protocol fields such as HTTP headers | Variable |
| Transport | Segment or datagram | Source and destination ports, sequence numbers, checksum | 8 bytes for UDP, 20-60 bytes for TCP |
| Network | Packet | Source and destination IP addresses, TTL, protocol field | 20 bytes for IPv4 minimum, 40 bytes for IPv6 |
| Data link | Frame | Source and destination MAC addresses, EtherType, FCS trailer | 18 bytes plus 4 bytes per VLAN tag |
| Physical | Bits or symbols | Preamble, start frame delimiter, line coding | 8 bytes preamble and SFD on Ethernet |
Headers, trailers and demultiplexing fields
Every header contains a field that tells the receiver which protocol sits inside the payload. This field drives decapsulation. Without it, a receiving host would see only a stream of bytes and would not know whether to pass them to IPv4, IPv6, ARP, TCP or UDP.
The process of choosing the correct upper-layer handler is called demultiplexing. The table below lists the key identifier at each boundary and some common values.
| Boundary | Identifier field | Example values |
|---|---|---|
| Ethernet to network layer | EtherType | 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP |
| IPv4 to transport layer | Protocol number | 6 TCP, 17 UDP, 1 ICMP, 47 GRE |
| IPv6 to transport layer | Next Header | 6 TCP, 17 UDP, 58 ICMPv6 |
| Transport to application | Destination port | 443 HTTPS, 53 DNS, 22 SSH |
Trailers are less common than headers. Ethernet appends a 32-bit cyclic redundancy check in the FCS so the receiving interface can discard corrupted frames. Most higher-layer protocols place their integrity checks inside the header instead, because a header can be parsed before the full payload arrives.
Encapsulation overhead and the MTU
Encapsulation always costs capacity, because headers consume bytes that carry no user data. On standard Ethernet the maximum transmission unit (MTU) of 1,500 bytes limits the IP packet size, so a TCP segment over IPv4 without options carries at most 1,460 bytes of payload, the value known as the maximum segment size.
Small payloads suffer most. A 64-byte voice sample can carry more than 50 bytes of headers once RTP, UDP, IP and Ethernet are added, which is why voice systems use header compression on slow links. Large transfers lose only about 3 to 5 percent of capacity to headers at full-size frames.
When an additional header pushes a packet beyond the MTU of a link, the packet must be fragmented or dropped. IPv6 routers never fragment, and IPv4 packets with the DF (do not fragment) bit set are dropped too, so path MTU discovery relies on ICMP messages reaching the sender. Firewalls that block those messages cause the classic path MTU black hole, in which small requests succeed while large responses stall.
Tunneling as nested encapsulation
Tunneling is encapsulation applied out of the usual layer order: a complete packet or frame becomes the payload of another packet. The outer header carries the traffic across a network that does not need to understand the inner one. This principle underlies VPNs, overlay networks in data centers and carrier transport services.
The table compares common tunneling and labeling methods by what they carry and the overhead they add.
| Method | What is encapsulated | Outer transport | Approximate overhead |
|---|---|---|---|
| 802.1Q VLAN tag | Ethernet frame, tag inserted | Same Ethernet link | 4 bytes |
| GRE | Any network layer packet | IP | 24 bytes or more |
| IPsec ESP tunnel mode | Entire IP packet, encrypted | IP | 50-70 bytes depending on cipher |
| VXLAN | Full Ethernet frame | UDP over IP | 50 bytes |
| MPLS | IP packet or frame | Label stack over Ethernet | 4 bytes per label |
Nested encapsulation explains why overlay networks often require jumbo frames on the underlay. A VXLAN segment that must deliver standard 1,500-byte frames to virtual machines needs a physical MTU of at least 1,550 bytes, otherwise traffic fails in ways that are difficult to trace.
Limitations and common misconceptions
Real protocol stacks do not follow the layered model perfectly, and several widespread assumptions about encapsulation are inaccurate. The most frequent misunderstandings are listed below.
- Not every layer adds a header. The session and presentation layers of the OSI model rarely exist as separate headers in TCP/IP traffic; TLS, for example, combines several roles.
- Devices do inspect deeper headers. Firewalls, load balancers and NAT devices routinely read transport headers, a practice called deep packet inspection when it reaches the payload.
- Encryption changes visibility. Once a payload is encrypted, intermediate devices can read only the outer headers, which limits troubleshooting and filtering.
- Routers rewrite the data link header. At every hop the frame is decapsulated and re-encapsulated with new MAC addresses, while the IP addresses normally remain unchanged.
Packet capture tools such as protocol analyzers display each encapsulated header as a separate tree level, which makes them the most reliable way to verify what a stack actually sends rather than what a diagram suggests.
The short version
Encapsulation is like putting a letter into a series of envelopes. The writer puts the message in an envelope addressed to a department, that envelope goes into one addressed to a building, and that goes into a mail bag addressed to a city. Each handler reads only its own envelope and passes the rest along.
At the destination the envelopes are opened in reverse order until the original letter appears. Networks do the same with data: every layer adds its own label on the way out and removes it on the way in, so no single part of the system has to understand everything.
Where it makes a difference
A company moves its internal applications to virtual machines connected through a VXLAN overlay across two data center halls. After the migration, users can log in and browse small pages, but file downloads and database reports freeze partway through.
A network engineer captures traffic and sees that the virtual machines send full 1,500-byte frames, which VXLAN wraps in another 50 bytes of headers. The physical switches still use the default 1,500-byte MTU, so the oversized packets are silently dropped. Small requests fit, while large responses do not.
The team raises the underlay MTU to 9,000 bytes on every switch and host interface in the path. Downloads complete immediately, and the incident becomes a standard checklist item: account for encapsulation overhead before deploying any tunnel.