Encapsulation & De-encapsulation Process in Networking
Nerd Cafe
Introduction
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.
1. Understanding Encapsulation & De-encapsulation
Encapsulation
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
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.
2. Step-by-Step Encapsulation Process (Sending Data)
Let's assume a user sends an email over a network. Here's how the data is encapsulated:
Step 1: Application Layer (Layer 7)
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?"
Step 2: Transport Layer (Layer 4)
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:
[ TCP Header | "Hello, how are you?" ]
Step 3: Network Layer (Layer 3)
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:
[ IP Header | TCP Header | "Hello, how are you?" ]
Step 4: Data Link Layer (Layer 2)
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:
[ MAC Header | IP Header | TCP Header | "Hello, how are you?" | Trailer ]
Step 5: Physical Layer (Layer 1)
The frame is converted into bits (1s and 0s) and transmitted over the network medium (e.g., Ethernet cable, Wi-Fi, fiber optics).
📌 Example:
101101011010010110110101010...
The data is now sent to the destination computer.
3. Step-by-Step De-encapsulation Process (Receiving Data)
Once the destination computer receives the bits, it follows the de-encapsulation process by moving up the OSI model layers:
Step 1: Physical Layer (Layer 1)
The received bits (0s and 1s) are converted back into a frame.
Step 2: Data Link Layer (Layer 2)
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:
[ MAC Header | IP Header | TCP Header | "Hello, how are you?" | Trailer ]
📌 Frame after processing:
[ IP Header | TCP Header | "Hello, how are you?" ]
Step 3: Network Layer (Layer 3)
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:
[ IP Header | TCP Header | "Hello, how are you?" ]
📌 Packet after processing:
[ TCP Header | "Hello, how are you?" ]
Step 4: Transport Layer (Layer 4)
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:
[ TCP Header | "Hello, how are you?" ]
📌 Segment after processing:
"Hello, how are you?"
Step 5: Application Layer (Layer 7)
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.
Summary Table: Encapsulation vs. De-encapsulation
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
Keywords
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
, نتورک پلاس
Last updated