The word encapsulation refers to the method of wrapping data in headers and trailers. The four-layer TCP/IP model can be used to describe this method, with each stage explaining the position of the layer. For example, consider what happens when you send an email from your preferred email client (such as Outlook or Thunderbird):
- From the Application layer to the Transport layer, the email is sent.
- The Transport layer encapsulates the data and adds its own header with details such as which port will be used before passing it to the Internet layer
- The Internet layer encapsulates the received data and adds its own header, which usually includes the source and destination IP addresses.
- The data is then passed from the Internet layer to the Network Access layer, which is the only layer that adds both a header and a trailer.
- The data is then transmitted over a physical network connection.
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 – The Network Access layer defines encapsulated data. A frame may have a header as well as a trailer.
- Packet – Encapsulated data specified by the network layer A header includes the source and destination IP addresses.
- Segment – The Transport layer defines encapsulated data. The header contains information such as the source and destination ports, as well as sequence and acknowledgment numbers.
As mentioned above, the method of removing headers and trailers as data moves from lower to upper layers is referred to as decapsulation. This procedure is carried out on the device that is receiving data.
Data Encapsulation in the OSI Reference Model
Each OSI layer, like the TCP/IP layers, requests resources from the next lower layer. Between a header and a footer, the lower layer encapsulates the data of the higher layer (Data Link protocols also add a trailer).
While the TCP/IP model employs terms such as segment, packet, and frame to refer to a data packet specified by a specific layer, the OSI model employs a different term: protocol data unit (PDU). A PDU is a data unit that includes headers and trailers for the specific layer as well as the encapsulated data. Since the OSI model has seven layers, PDUs are numbered one through seven, with the Physical layer being the first. For example, the term Layer 3 PDU refers to data encapsulated at the OSI model’s Network layer.
Here is a graphical representation of all the PDUs in the OSI model: