Data encapsulation & de-encapsulation — PDU (Protocol Data Unit)

Encapsulation

Geeky much!
Networks & Security
3 min readJun 6, 2021

--

The data, as it moves from an upper layer towards the downward layers, gets a header or/and a trailer at every layer — this is referred to as data encapsulation.

Let’s look at an example →

Sender — — — — — — — — — — — — — — — — — — — — — Reciever

User data is generated at the application layer at the sender’s side. As it moves down to the presentation layer it gets encoded into a standard format, sometimes encrypted. Next the user data moves to the session layer where a session ID is added to the data. The data is still one whole data block.

Now the data is given to transport layer.

NOTE: The encapsulated data at different layers is referred to by different names.These names are called Protocol Data Unit (PDU).

At the transport layer the data is broken into several smaller blocks, to each of those, is added a header at the beginning, containing info about — destination port, source port, sequence number. The new data package is called a segment (if TCP is used) or a datagram (if UDP is used).

The segment/datagram travels to the network layer where a new IP header is added to it. IP header contains info like source IP address and destination IP. At the network layer a new PDU called IP packet is generated.

The IP packets now move to the data-link layer. A header is attached having info about source MAC address and destination MAC address to the IP packets along with a trailer at the end of the packet which contains info for error checking. The new PDU called a frame is generated at this layer.

The frame is sent to the physical layer where it is translated into some kind of signal that represents a series of 0s and 1s.

The Network Interface Card (NIC) sends these bits to the transmission medium.

De-encapsulation

At the receiver side, de-encapsulation takes place.

The physical layer gets the data as bits and converts it to a frame and delivers it to the data-link layer, where the header and trailer are checked. If the MAC address matches and there is no error, the frame header is discarded, and the IP packet is pulled out and transferred to the network layer.

At the network layer IP header is checked, and if the IP address matches, then the segment/datagram is pulled out from the IP packet which is discarded. The segment then goes to the transport layer.

At the transport layer, the segment/datagram header is examined, where the port number is looked at, and the segment is moved to the appropriate application specified by the port number.

At the session layer, session ID is used so that further transfer can take place.

Any decompression or decoding/decryption takes place at the presentation layer and the original data is restored which then gets supplied to the application layer.

--

--