Encapsulation
Encapsulation is the process of wrapping data by adding headers as it passes through each layer. On the way down each layer stamps its own signature onto the packet; at the destination each layer peels its header back off.
01Data transformation
As data moves from the application layer down to the physical layer, it changes its name and structure:
L7 · Application
DATA
L4 · Transport
TCP
DATA → Segment
L3 · Network
IP
TCP
DATA → Packet
L2 · Data Link
ETH
IP
TCP
DATA
FCS
L1 · Physical
101010101010... → Bits
02What each layer adds
| Layer | Unit | Added |
|---|---|---|
| Application | Data | Application payload |
| Transport | Segment | TCP/UDP header (Port) |
| Network | Packet | IP header (IP address) |
| Data Link | Frame | MAC header + FCS trailer |
| Physical | Bits | Electrical signals |
03Header contents
TCP Header (Transport Layer)
TCP
Transport Control Protocol Header
The transport layer header carries everything needed to guarantee reliable delivery.
Fields
Source Port · 16 bit
Dest Port · 16 bit
Sequence No
Ack No
Flags: SYN ACK FIN
Checksum
Purpose
- Which application? → Port
- Packet lost? → Sequence No
- Connection open? → Flags
IP Header (Network Layer)
IP
Internet Protocol Header
The network layer header identifies the packet's origin, destination, and how it should be routed.
Fields
Source IP · 32 bit
Dest IP · 32 bit
TTL
Protocol (TCP=6)
Purpose
- Where to? → Destination IP
- Where from? → Source IP
- Prevent routing loops → TTL
04De-encapsulation
The reverse happens at the destination — each layer strips its own header:
L2 · Data Link
ETH
IP
TCP
DATA
FCS
L3 · Network
IP
TCP
DATA — ETH header removed
L4 · Transport
TCP
DATA — IP header removed
L7 · Application
DATA — Delivered to application
05Why encapsulation?
- Modularity — Each layer works independently
- Flexibility — Changing one layer doesn't affect the others
- Error control — Each layer checks its own errors
06Summary
- Encapsulation = Wrapping at each layer on the way down
- Each layer adds its own header
- Data → Segment → Packet → Frame → Bits
- De-encapsulation unwraps headers at the destination