Encapsulation & De-encapsulation Process in Networking
Nerd Cafe
Last updated
Nerd Cafe
Last updated
Encapsulation and de-encapsulation are fundamental concepts in networking that describe how data is packaged and transmitted across a network. These processes follow the OSI (Open Systems Interconnection) model and the TCP/IP model to ensure reliable communication between devices.
Encapsulation is the process of adding headers (and sometimes trailers) to data as it moves down the OSI or TCP/IP model layers.
Each layer of the model adds specific information needed for data transmission, such as source/destination addresses, error detection, and control information.
De-encapsulation is the reverse process, where the headers and trailers are removed as the data moves up the layers to be read by the receiving application.
The receiving device extracts useful data and forwards it to the next layer until it reaches the application layer.
Let's assume a user sends an email over a network. Here's how the data is encapsulated:
The user writes an email using an email application (e.g., Outlook, Gmail).
The email is converted into raw data by the application.
📌 Example:
Data = "Hello, how are you?"
The transport layer segments the data and adds a header with port numbers for the sender and receiver.
The header ensures that the data is delivered to the correct application on the destination system.
Protocols used: TCP (Transmission Control Protocol) or UDP (User Datagram Protocol).
📌 Example:
TCP Header: Includes source port, destination port, sequence number, and acknowledgment number.
🔹 Segmented Data Example:
The network layer encapsulates the segment into a packet by adding an IP header.
The IP header contains the source and destination IP addresses, helping the data reach the correct destination.
📌 Example:
IP Header:
Source IP: 192.168.1.10
Destination IP: 8.8.8.8
🔹 Packet Example:
The data link layer encapsulates the packet into a frame by adding a MAC (Media Access Control) header and trailer.
The MAC header contains source and destination MAC addresses, ensuring correct delivery within the local network.
📌 Example:
MAC Header:
Source MAC: 00:1A:2B:3C:4D:5E
Destination MAC: 00:2B:3C:4D:5E:6F
Frame Trailer: Contains error detection information (e.g., CRC - Cyclic Redundancy Check).
🔹 Frame Example:
The frame is converted into bits (1s and 0s) and transmitted over the network medium (e.g., Ethernet cable, Wi-Fi, fiber optics).
📌 Example:
The data is now sent to the destination computer.
Once the destination computer receives the bits, it follows the de-encapsulation process by moving up the OSI model layers:
The received bits (0s and 1s) are converted back into a frame.
The data link layer checks the MAC address. If it matches the device’s MAC address, it removes the MAC header and trailer and forwards the data to the network layer.
📌 Frame before processing:
📌 Frame after processing:
The network layer checks the IP address to ensure it matches the device’s IP.
If the IP is correct, the IP header is removed, and the data is sent to the transport layer.
📌 Packet before processing:
📌 Packet after processing:
The transport layer checks the port number to determine the correct application.
The TCP header is removed, and the data is sent to the application layer.
📌 Segment before processing:
📌 Segment after processing:
The raw data is handed over to the email application (e.g., Gmail, Outlook).
The user sees the email "Hello, how are you?"
in the inbox.
Application
Creates data (e.g., email)
Receives data (e.g., email content)
Transport
Adds TCP/UDP header (Port Numbers)
Removes TCP/UDP header
Network
Adds IP header (Source & Destination IP)
Removes IP header
Data Link
Adds MAC header & trailer
Removes MAC header & trailer
Physical
Converts to bits and sends
Converts bits back to frames
Encapsulation
, De-encapsulation
, OSI Model
, TCP/IP Model
, Data Transmission
, Network Layer
, Transport Layer
, Application Layer
, Physical Layer
, Data Link Layer
, IP Header
, MAC Address
, TCP Header
, UDP Header
, Network Packet
, Ethernet Frame
, Protocol Stack
, Bits and Bytes
, Wireshark Analysis
, Network Communication
, نتورک پلاس