Term encapsulation is used to describe a process of adding headers and trailers around some data. One can explain this process with the four-layer TCP/IP model, with each step describing the role of the layer. For example, here is what happens when you send an email using your favourite email program (such as Outlook or Thunderbird):
- The Application layer sends email to the Transport layer.
- The Transport layer encapsulates the data and adds its own header with its own information, such as which port will be used and passes the data to the Internet layer
- The Internet layer encapsulates the received data and adds its own header, usually with information about the source and destination IP addresses. The Internet layer than passes the data to the Network Access layer
- The Network Access layer is the only layer that adds both a header and a trailer. It then sends the data through a physical network link.
Here is a graphical representation of how each layer add its own information:
Each packet (header + encapsulated data) defined by a particular layer has a specific name:
- Frame – encapsulated data defined by the Network Access layer. A frame can have both a header and a trailer.
- Packet – encapsulated data defined by the Network layer. A header contains the source and destination IP addresses.
- Segment – encapsulated data as defined by the Transport layer. It also includes information such as the source and destination ports or sequence and acknowledgment numbers.
The term decapsulation refers to the process of removing headers and trailers as data passes from lower to upper layers. This process happens on the computer that is receiving data.
Data encapsulation in the OSI model
Just like with the TCP/IP layers, each OSI layer asks for services from the next lower layer. The lower layer encapsulates the higher layer’s data between a header (Data Link protocols also add a trailer).
While the TCP/IP model uses terms like segment, packet and frame to refer to a data packet defined by a particular layer, the OSI model uses a different term: protocol data unit (PDU). A PDU represents a unit of data with headers and trailers for the particular layer, as well as the encapsulated data. Since, OSI model has 7 layers and we number PDUs from 1 to 7, where the Physical layer is the first layer. For example, the term Layer 3 PDU refers to the data encapsulated at the Network layer of the OSI model.
Here is a graphical representation of all the PDUs in the OSI model:
That’s some useful information about Encapsulation!