Encapsulation and Decapsulation in Protocol Layering

 

Encapsulation and Decapsulation in Protocol Layering

Introduction

In the TCP/IP protocol suite, data moves through different layers before transmission.
During this process, each layer adds its own control information to the data.

This process is called:

Encapsulation

At the receiving side, each layer removes its corresponding information.

This process is called:

Decapsulation


Encapsulation

Definition

Encapsulation is the process of adding headers (and sometimes trailers) to data as it moves down through the protocol layers at the sender side.

Each layer treats the data received from the upper layer as:

Payload

and adds its own control information.


Steps of Encapsulation at the Source Host

1. Application Layer

  • The user creates data called a message
  • The message is passed to the transport layer
Message

2. Transport Layer

The transport layer:

  • Takes the message as payload
  • Adds a transport-layer header

The header contains:

  • Source port number
  • Destination port number
  • Flow/error control information

The resulting packet is called:

  • Segment (TCP)
  • User Datagram (UDP)
[Transport Header | Message]

3. Network Layer

The network layer:

  • Takes the segment as payload
  • Adds a network-layer header

The header contains:

  • Source IP address
  • Destination IP address
  • Routing information

The resulting packet is called:

Datagram

[Network Header | Transport Header | Message]

4. Data-Link Layer

The data-link layer:

  • Takes the datagram as payload
  • Adds its own header

The header contains:

  • MAC address of sender
  • MAC address of next hop

The resulting packet is called:

Frame

[Data-Link Header | Network Header | Transport Header | Message]

5. Physical Layer

The frame is converted into:

Bits/Signals

and transmitted through the communication medium.

101010101...

Encapsulation Flow

Message

Segment / User Datagram

Datagram

Frame

Bits




Decapsulation

Definition

Decapsulation is the process of removing headers and extracting the original data as it moves upward through the layers at the receiver side.

Each layer:

  • Removes its corresponding header
  • Passes the payload to the upper layer

Steps of Decapsulation at the Destination Host

1. Physical Layer

  • Receives bits/signals
  • Passes frame to data-link layer

2. Data-Link Layer

  • Removes data-link header
  • Extracts datagram
  • Performs error checking

3. Network Layer

  • Removes network header
  • Extracts segment/user datagram

4. Transport Layer

  • Removes transport header
  • Extracts original message

5. Application Layer

  • Receives the final message for the application/user

Decapsulation Flow

Bits

Frame

Datagram

Segment

Message

Encapsulation and Decapsulation at a Router

A router performs:

  • Decapsulation
  • Encapsulation

because it connects multiple links.


At the Router

Step 1: Decapsulation

  • Router receives a frame
  • Removes the data-link header
  • Extracts the datagram

Step 2: Network Layer Processing

  • Router examines destination IP address
  • Chooses the next hop using routing table

Step 3: Re-Encapsulation

  • Datagram is encapsulated into a new frame
  • New link-layer header is added
  • Frame is sent to the next link

Important Point

The:

  • Transport header
  • Application data

normally remain unchanged during routing.

Only:

  • Data-link headers change at each hop.

Why Encapsulation is Important

1. Modular Communication

Each layer performs independent tasks.

2. Proper Routing and Delivery

Headers provide addressing and control information.

3. Error and Flow Control

Control information helps reliable communication.

4. Interoperability

Different networks and devices can communicate efficiently.


Real-Life Analogy

Sending a letter through postal service:

Networking LayerReal-Life Analogy
Application    Writing the letter
Transport    Putting the letter in an inner envelope
Network    Adding destination address
Data-Link    Packing for local delivery
Physical    Physical transportation

At the receiver side, each covering is removed step by step.


Summary

Encapsulation is the process of adding protocol information to data as it moves down the TCP/IP layers at the sender side. Decapsulation is the reverse process, where each layer removes its corresponding header at the receiver side to retrieve the original message. Routers perform both decapsulation and re-encapsulation while forwarding packets between networks.

Comments

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

Introduction to Local Area Network (LAN)