Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

What are encapsulation and de-encapsulation in networking?

Hafiza Farwa Mahmood

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

When we send data in a network, various protocols are added to the data by the sender. Then they are deciphered at the receiver's end to read the actual message. Protocols are added along with the message for the reliability and security of the message between sender and receiver.

These protocols depend on the type of model being used for data transfer. OSIOpen Systems Interconnection (OSI) model is used to understand how data is transmitted across devices that are connected via a network model uses encapsulation and de-encapsulation for data transmission across two ends.

Encapsulation

Encapsulation is adding extra protocols along with data to send it from one point to another via a network. Encapsulation always takes place at the sender's side to send data properly.

Data encapsulation

Working

Each OSI model layer adds more information, encapsulating the received data from the previous layer. Here's how encapsulation takes place.

  1. Segment header: The upper layers of the OSI model "application," "presentation," and "session layer" create a stream of data received by the transport layer. The transport layer divides this data stream into multiple pieces, known as segmentation. Afterward, the header is added to each piece of data. The header contains information like sequence number, port numbers of source and destination, and so on. These data pieces, along with headers, are known as segments.
  2. Packet header: The network layer receives data segments sent by the transport layer. It creates a packet header for each segment. Now, this header contains routing information related to the IP, like source IP and destination IP. After encapsulating segments with a packet header, they are sent to the next layer, the data link layer.
  3. Frame header: Data link layer gets encapsulated packets from the network layer. It adds frame headers in packets with information related to the switching, such as MAC address. The frame header is inserted to transfer packets to the hardware components properly.
  4. Bits: The last layer of the OSI model physical layer converts the encapsulated frames into bits or data signals. These bits are in the form of zero's and one's, which are acceptable by physical media for data transmission.

De-encapsulation

The process of removing all the extra protocols from encapsulated data to get the actual data is known as de-encapsulation. It works the same as encapsulation does but in a reverse manner. The receiver performs de-encapsulation to perceive original data.

Data de-encapsulation

Working

Each OSI model layer removes its protocols while de-encapsulating the received data from the previous layer. Here's how de-encapsulation occurs at the receiver's end.

  1. At the receiver end, the physical layer receives bits. It de-encapsulates them and sends them to the data link layer for further processing.
  2. The data link layer gets frames and checks all the information after matching all instructions, such as MAC address. It removes the frames and sends packets to the next layer.
  3. The network layer receives packets and de-encapsulates them after confirming all required IP addresses.
  4. The transport layer removes all the segment headers from the data.
  5. After transmitting through the session, presentation, and application layers, data is sent to the receiver.

RELATED TAGS

CONTRIBUTOR

Hafiza Farwa Mahmood
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring