Personal tools

Data Encapsulation and De-encapsulation

TCP/IP Data Encapsulation and De-encapsulation_061120A
(TCP/IP Data Encapsulation and De-encapsulation - Oracle)

 

- Packets and Encapsulation

Data travels on a network in the form of packets, bursts of data with a maximum length imposed by the link layer. Each packet consists of a header and a payload. The header tells where the packet came from and where it is going. It can also include checksums, protocol-specific information, or other handling instructions. 

The payload is the data to be transferred. The name of the primitive data unit depends on the layer of the protocol. At the link layer it is called a frame, at the IP layer it is called a packet, and at the TCP layer it is called a segment. We will use the term packet as a generic term that encompasses all of these cases. As a packet travels down the protocol stack in preparation for being sent, each protocol adds its own header information. Each protocol’s finished packet becomes the payload part of the packet generated by the next protocol. This nesting is known as encapsulation. On the receiving machine, the encapsulation is reversed as the packet travels back up the protocol stack. 

For example, a UDP packet being transmitted over Ethernet contains three different wrappers or envelopes. On the Ethernet wire, it is framed with a simple header that lists the source and next-hop destination hardware addresses, the length of the frame, and the frame’s checksum (CRC). The Ethernet frame’s payload is an IP packet, the IP packet’s payload is a UDP packet, and the UDP packet’s payload is the actual data being transmitted.

A protocol stack, today usually provided by the operating system (rather than as a separate library, for instance), is a set of services that allow processes to communicate over a network using the protocols that the stack implements. The operating system forwards the payload of incoming IP packets to the corresponding application by extracting the socket address information from the IP and transport protocol headers and stripping the headers from the application data.

 

TCP_IP_Header_IPv4_070320A
[TCP/IP Packet (IPv4) - Wikipedia]

- Header and Trailer

In networking model, the terms encapsulation and de-encapsulation refer to a process in which protocol information is added to the data and removed from the data when it passes through the layers. Protocol information can be added before and after the data. If information is added before the data, it is known as header. If information is added after the data, it is known as trailer.

Header and trailer added by a layer in the sending computer (Host A) can be removed only by the peer layer in the receiving computer (Host B). For example, header and trailer added by the transport layer in the sending computer can be removed only by the transport layer in the receiving computer. When data encapsulated by a layer of sending computer is processed by the same layer of receiving computer, it is known as the same layer interaction. 

Encapsulation process takes place in the sending computer (Host A) while the de-encapsulation process takes place in the receiving computer (Host B). After encapsulation, each layer uses a specific name or term to represent the encapsulated data.

Actually, the encapsulation of data at various layers of the implementing model (OSI or TCP/IP) adds various functionalities and features to the data transmission. The most important feature that it adds is the security and reliability of data transmission between two nodes in a network.

 

- Data Encapsulation

The data is encapsulated on the sender’s side, starting from the application layer to the physical layer. Each layer takes the encapsulated data from the previous layer and adds some more information to encapsulate it and some more functionalities with the data. These functionalities may include proper data sequencing, error detection and control, flow control, congestion control, routing information, etc..

First, you must convert the data into segments. At times, data is too large to be sent as one piece. For example, a file transfer might require the file to be broken into several pieces and sent as such. Each segment encapsulates some data, but it also has a header that identifies the sending application on one device (source) and the receiving application on its counterpart device (destination). The sending and receiving applications are usually identified using source and destination port numbers. Next, you add a header that includes network address information to each segment, effectively converting each segment into a packet (packet encapsulates segment). From there, you encapsulate each packet into a frame. The frame header includes physical addressing information (frame encapsulates packet). Finally, you are ready to transmit the frame as bits.

 

- Data De-encapsulation

Data De-encapsulation is the reverse process of data encapsulation. The encapsulated information is removed from the received data to obtain the original data. This process takes place at the receiver’s end. The data is de-encapsulated at the same layer at the receiver’s end to the encapsulated layer at the sender’s end. The added header and trailer information are removed from the data in this process.

End system Host B receives the data from the physical medium, removes the data control information, and converts the data as needed for use with the target application. After frames enter Host B's network interface card, the network interface card discovers that the frames' destination MAC address matches the MAC address. The network interface card generates an interrupt to the CPU and the frame is copied from the network interface card's buffer to the main memory of Host A. Each frame's packet is decapsulated (the frame header and check sequence are removed), each packet's segment is decapsulated (the packet header and cyclic redundancy check are removed), and the data encapsulated in each segment is decapsulated and passed to the destination application based on the destination port number of the segments.

 

 

[More to come ...]

 

Document Actions