Encapsulation and Decapsulation in the Transport Layer
Encapsulation and Decapsulation in the Transport Layer
Introduction
For communication between two application processes, the Transport Layer must prepare the data before transmission and recover it at the destination. This is accomplished through two important operations:
- Encapsulation – Performed at the sender.
- Decapsulation – Performed at the receiver.
These operations enable the transport layer to provide process-to-process communication by adding and removing transport-layer information such as port numbers and other control fields.
What is Encapsulation?
Encapsulation is the process of adding protocol control information (header) to the application message before sending it over the network.
The transport layer receives the message from the application layer, adds a transport-layer header, and passes the resulting packet to the network layer.
The transport-layer packet is called:
- Segment (TCP)
- User Datagram (UDP)
- Packet (general term)
Encapsulation Process
The following steps occur at the sender:
Step 1: Application Creates the Message
The application (process) generates the message to be transmitted.
Example:
Hello Bob
Step 2: Message is Passed to the Transport Layer
The application passes the following information to the transport layer:
- Application message
- Source socket address
- Destination socket address
- Other protocol-specific information
Step 3: Transport Layer Adds Header
The transport layer creates a header containing information such as:
- Source Port Number
- Destination Port Number
- Sequence Number (TCP)
- Acknowledgment Number (TCP)
- Checksum
- Control Flags
- Window Size (TCP)
The message becomes a transport-layer packet.
+-----------------------+----------------------+ | Transport Header | Application Data | +-----------------------+----------------------+
Step 4: Packet is Sent to the Network Layer
The completed transport packet is handed to the network layer, which further encapsulates it inside an IP packet.
Encapsulation Diagram
Application Layer Message │ ▼ +----------------------+ | Transport Layer | | Adds Header | +----------------------+ │ ▼ +----------------------+----------------------+ | Transport Header | Application Message | +----------------------+----------------------+ │ ▼ Network Layer
Example of Encapsulation
Suppose Alice opens a web browser and sends an HTTP request.
Application Message
GET /index.html
Transport Layer Header
Source Port = 52000 Destination Port = 80
Transport Packet
+-------------------------------------------+ | Src Port | Dest Port | Application Data | | 52000 | 80 | GET /index.html | +-------------------------------------------+
The packet is then forwarded to the network layer.
What is Decapsulation?
Decapsulation is the reverse process of encapsulation.
At the destination, the transport layer:
- Receives the transport packet.
- Removes the transport-layer header.
- Delivers the original application message to the appropriate process.
Decapsulation Process
The following steps occur at the receiver.
Step 1: Packet Arrives
The network layer delivers the transport packet.
+----------------------+----------------------+ | Transport Header | Application Message | +----------------------+----------------------+
Step 2: Header is Examined
The transport layer checks
- Destination Port Number
- Error Detection Information (Checksum)
- Sequence Number (TCP)
- Acknowledgment Number (TCP)
Step 3: Header is Removed
After processing, the transport header is discarded.
Only the application message remains.
Application Message GET /index.html
Step 4: Deliver to Correct Process
Using the destination port number, the transport layer delivers the message to the correct application.
Example
Destination Port = 80 ↓ HTTP Server
If the destination port is
25
The message is delivered to the
SMTP Server
Decapsulation Diagram
Network Layer │ ▼ +----------------------+----------------------+ | Transport Header | Application Data | +----------------------+----------------------+ │ Remove Header ▼ Application Layer Application Message
Complete Communication Process
Information Added During Encapsulation
The transport-layer header may contain:
| Field | Purpose |
|---|---|
| Source Port Number | Identifies sending process |
| Destination Port Number | Identifies receiving process |
| Sequence Number (TCP) | Orders segments |
| Acknowledgment Number (TCP) | Confirms receipt |
| Checksum | Error detection |
| Control Flags | Connection management |
| Window Size (TCP) | Flow control |
Information Removed During Decapsulation
At the receiver, the transport layer:
- Reads the destination port number.
- Verifies checksum.
- Reorders packets (TCP).
- Removes the transport header.
- Delivers the original application message.
- Passes the sender's socket address to the application if a reply is needed.
Why is Encapsulation Necessary?
Encapsulation allows the transport layer to:
- Identify the source and destination processes.
- Detect transmission errors.
- Provide reliable communication (TCP).
- Perform flow control.
- Support multiplexing and demultiplexing.
- Enable end-to-end communication.
Why is Decapsulation Necessary?
Decapsulation enables the receiver to:
- Extract the original application message.
- Identify the intended application using the destination port number.
- Verify data integrity.
- Deliver the message to the correct process.
Encapsulation vs Decapsulation
| Feature | Encapsulation | Decapsulation |
|---|---|---|
| Performed At | Sender | Receiver |
| Purpose | Add transport header | Remove transport header |
| Input | Application message | Transport packet |
| Output | Transport packet (Segment/User Datagram) | Original application message |
| Next Layer | Network Layer | Application Layer |
Summary
- Encapsulation is the process of adding a transport-layer header to the application message before transmission.
- During encapsulation, the transport layer adds information such as source and destination port numbers, checksum, and other protocol-specific fields, creating a segment (TCP) or user datagram (UDP).
- Decapsulation is the reverse process in which the transport layer receives the packet, verifies the header, removes it, and delivers the original message to the correct application process.
- These operations ensure process-to-process communication, allowing multiple applications on different hosts to communicate reliably and efficiently.

Comments
Post a Comment