What is encapsulation and how is it used in a layered model?

In the previous lesson we have learned that the term encapsulation describes the process of putting headers (and sometimes trailers) around some data. 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 represent a unit of data with headers and trailers for the particular layer, as well as the encapsulated data. Since the OSI model has 7 layers, PDUs are numbered from 1 to 7, with the Physical layer being the first one. 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 the PDUs in the OSI model:

What is encapsulation and how is it used in a layered model?

Encapsulation is a process by which a lower-layer protocol receives data from a higher-layer protocol and then places the data into the data portion of its frame.

What is Encapsulation (in networking)?

Generally, Encapsulation is a process by which a lower-layer protocol receives data from a higher-layer protocol and then places the data into the data portion of its frame. Thus, encapsulation is the process of enclosing one type of packet using another type of packet.

Encapsulation at the lowest levels of the Open Systems Interconnection (OSI) reference model is sometimes referred to as framing.

Examples:

What is encapsulation and how is it used in a layered model?
Encapsulation and Decapsulation

The data-link layer (layer 2) of the OSI model for networking is responsible for encapsulation or framing of data for transmission over the physical medium. In local area network (LAN) technologies, this is usually Carrier Sense Multiple Access with Collision Detection (CSMA/CD) for Ethernet networks. For wide area network (WAN) technologies, the data-link protocols used depend on whether the communications are point-to-point or multipoint:

  • For point-to-point communications, possible WAN data-link protocols include Point-to-Point Protocol (PPP) and High-level Data Link Control (HDLC) protocol.
  • For multipoint communications, possible WAN data-link protocols include frame relay, ATM, Switched Multimegabit Data Services (SMDS), and X.25.

https://youtu.be/ucUgi24oTf0

link to Power Over Ethernet (PoE)
link to PoE Device Roles and Type Parameters

This tutorial explains how the OSI model and TCP/IP model encapsulate and de-encapsulate the data when it passes through the layers.

In a networking model, the term encapsulation refers to a process in which protocol information is added to the data. The term de-encapsulation refers to a process in which information added through the encapsulation process is removed.

Protocol information can be added before and after the data. If the information is added before the data, it is known as a header. If the information is added after the data, it is known as a trailer.

The following image explains the data encapsulation and de-encapsulation process.

The header and trailer added by a layer on the sending computer can only be removed by the peer layer on the receiving computer. For example, the header and trailer added by the Transport layer on the sending computer can only be removed by the Transport layer on the receiving computer.

Data encapsulated by a layer on the sending computer is de-encapsulated by the same layer on the receiving computer. This process is known as the same layer interaction.

The encapsulation process takes place on the sending computer. The de-encapsulation process takes place on the receiving computer. After doing the encapsulation, each layer uses a specific name or term to represent the encapsulated data.

The following table lists the terms used by the layers in both models to represent the encapsulated data.

Term OSI layer TCP/IP layer
Data Application Application
Data Presentation
Data Session
Segment Transport Transport
Packet Network Network
Frame Data Link Data Link
Bits Physical Physical

Let’s understand each term and the data encapsulation process in detail.

Data

The upper layer (the Application layer in the TCP/IP model) or the layers (the Application, Presentation, and Session layers in the OSI model) create a data stream and transfer it to the Transport layer.

The upper layers do not attach headers and trailers to the data. But if required, the application that initiates the connection can add a header and trailer to the data. For example, browsers use the HTTP protocol to fetch websites from webservers. The HTTP protocol uses a header to transfer the data.

The encapsulation process describes the headers and trailers that are added by the layers. It does not describe application-specific headers and trailers. Since the upper layers do not add any header or trailer to the data, the encapsulation process does not use any particular term to refer to the encapsulated data in the upper layers.

Segment

The Transport layer receives the data stream from the upper layers. It breaks the received data stream into smaller pieces. This process is known as segmentation. After segmentation, it creates a header for each data piece and attaches that header to the data piece. Headers contain the information that the remote host needs to reassemble all data pieces. Once the header is attached, a data piece is known as the segment. The Transport layer transfers segments to the Network layer for further processing.

Packet

The Network layer creates a header for each received segment from the Transport layer. This header contains the information that is required for addressing and routing, such as the source software address and destination software address. Once the header is attached, a segment is known as the packet. Packets are handed down to the Data link layer.

In the original TCP/IP model, the term packet is mentioned as the term datagram. Both terms are identical and interchangeable. A packet or a datagram contains a network layer header and an encapsulated segment.

Frame

The Data link layer receives packets from the Network layer. Unlike the Transport layer and Network layer which only create a header, it also creates a trailer along with the header for each received packet. The header contains information that is required for the switching, such as the source hardware address and destination hardware address. The trailer contains information that is required to detect and drop the corrupt data packages in the earliest stage of the de-encapsulation. Once the header and trailer are attached, a packet is known as the frame. Frames are passed down to the Physical layer.

Bits

The Physical layer receives frames from the Data link layer and converts them into a format that the attached media can carry. For example, if the host is connected through a copper wire, the Physical layer converts frames into voltages. And if the host is connected through a wireless network, the physical layer converts them into radio signals.

De-encapsulation

De-encapsulation takes place on the receiving computer. The de-encapsulation process is the opposite of the encapsulation process. In this process, the headers and trailers that are attached by the encapsulation process are removed.

The Physical layer picks encoded signals from the media and converts them into frames and hands them over to the Data link layer.

The Data-link layer reads the trailer of the frame and confirms that the received frame is in the correct shape. If the frame is in the correct shape, it reads the destination hardware address of the frame to determine whether the fame is intended for it.

If the frame is not intended for it, it will discard the frame. If the frame is intended for it, it will remove the header and the trailer from the frame. Once the data link layer’s header and trailer are removed from the frame, it becomes the packet. Packets are handed over to the Network layer.

The Network layer checks the destination software address in the header of each packet. If the packet is not intended for it, it will discard the packet. If the packet is intended for it, it will remove the header. Once the network layer’s header is removed, the packet becomes the segment. Segments are handed over to the Transport layer.

The Transport layer receives segments from the Network layer. From segment headers, it collects all necessary information, and based on that information it arranges all segments back to the correct order. Next, it removes the segment header from all segments and reassembles them in the original data stream. The data stream is handed over to the upper layers.

Upper layers convert the data stream in such a format that the target application can understand.

The following figure shows the encapsulation and de-encapsulation process in the OSI model.

The following figure shows the encapsulation and de-encapsulation process in the TCP/IP model.

That’s all for this article. If you like this article, please don’t forget to share it with friends through your favorite social site.