What is encapsulation, and what is the data unit called at each layer?
MediumConceptOSI & TCP/IP Models
Answer
Encapsulation means that each layer wraps the data it receives from the layer above with its own header (and sometimes a trailer) before passing it down. The receiver does the reverse, called decapsulation: each layer reads and removes its own header and hands the rest up. The unit of data at each layer is called a PDU (protocol data unit).
| Layer | PDU name | Header adds |
|---|---|---|
| Application | data (message) | for example an HTTP request line |
| Transport | segment (TCP) or datagram (UDP) | source and destination ports |
| Network | packet | source and destination IP addresses, TTL |
| Data Link | frame | MAC addresses, plus a CRC trailer for error detection |
| Physical | bits | none |
- Each layer reads only its own header, which keeps the layers independent.
- A router decapsulates up to the network layer, chooses the next hop, then builds a new frame, so MAC addresses change at every hop while IP addresses stay the same.
Example: A browser sends GET /index.html over plain HTTP:
[HTTP GET /index.html] data
[TCP 51000 -> 80][HTTP ...] segment
[IP 192.168.1.5 -> 203.0.113.10][TCP ...][HTTP ...] packet
[Eth laptop MAC -> router MAC][IP ...][TCP ...][HTTP ...][CRC] frame