How Data Encapsulation & De-encapsulation Works?
Data Encapsulation :
Encapsulation is the process of adding additional information when data is traveling in OSI or TCP/IP model. The additional information has been added on sender’s side, starting from Application layer to Physical layer.
working of Encapsulation :
- There will be no additional information added in the user’s data in the Application layer in TCP/IP model or Application, Presentation, Session layers in OSI model.
- Then Session layer sends data to Transport layer.
- In the Transport layer, the data broken up into different pieces. It adds the header in each of the broken data, which contains information like source port, destination port, sequence number, etc. Now, everything combined to a new form.
- The encapsulated data in Transport layer is called Segments or Datagrams. If the transmission uses TCP, then it is called Segments, or UDP is called Datagrams.
- Now, the data will travel down and reach Network layer. Here, layer 3 header is added. That contains information like source IP, destination IP, and so on. This information combines into a new form. The encapsulated data in the network layer is called Packets.
- Now, network layer sends packet to Data Link layer When it enters into data link layer, a new header(Layer 2) is added.
- Also, a trailer is added. It contains information like source MAC address, destination MAC address, and so on. The trailer is used for error checking. The encapsulated data in the data link layer is called Frames.
- The physical layer takes frames from Data Link layer. The encapsulated data in the physical layer is called Bits.
- That is how encapsulation takes place.
Protocol Data Unit (PDU) :
The encapsulated data is called by different names when it travels down following layers. Those names are called Protocol Data Unit. The following table shows the name of encapsulated data in each layer.
Protocol Data Unit (PDU)
De-encapsulation is the exact reverse process of encapsulation. The additional information added on the sender’s side(during encapsulation) gets removed when it travels on the receiver’s side from the Physical layer to the Application layer.
Working of De-encapsulation :
- The Physical layer gets the bits and de-encapsulates them into frames and sends them to the upper layer.
- The Data Link layer receives the frames and checks MAC address whether it is matching or not. If everything matched and also no error is found. Then layer 2 header and layer 2 trailer are removed. It de-encapsulates the data and packet sent to upper layer.
- The Network layer receives the packet from Data Link layer. It checks for IP addresses. If it matched then, the header in layer 3 is removed. Now the de-encapsulated data packet is delivered to the Transport layer.
- Now, the Transport layer gets the data segments/ datagrams from the Network layer and removes the layer 4 header.
- After traveling through Session, Presentation, and Application layer, the de-encapsulated data is sent to the receiver.
- That is how the de-encapsulation takes place.
Encapsulation & De-encapsulation
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation
Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation