πŸ”™ Back to Index


Data Flow: Encapsulation & De-encapsulation

Encapsulation

Encapsulation is the process of wrapping data with the necessary protocol information (called headers and sometimes footers) at each OSI layer as data is prepared for transmission.

This added information helps devices:

  • Identify the sender and receiver
  • Understand how to deliver and manage the data
  • Handle errors, order, size, and addressing

Step-by-Step Encapsulation (Sender Side)

As data goes from Layer 7 down to Layer 1:

OSI LayerWhat It AddsResulting Data UnitExample Info Added
Layer 7–5 (App/Pres/Sess)Message from the appDataHTTP request, file content, email text
Layer 4 (Transport)TCP/UDP headerSegmentSource/destination ports, sequence number
Layer 3 (Network)IP headerPacketIP addresses (sender & receiver)
Layer 2 (Data Link)MAC header + trailerFrameMAC addresses, CRC (error check)
Layer 1 (Physical)Converts frame to bitsBits0s and 1s transmitted via cable/Wi-Fi

At the end of encapsulation, the message becomes raw bits sent over the network.


De-encapsulation

De-encapsulation is the reverse process: the receiving device removes the headers/trailers at each layer as data travels up the OSI stack, from Layer 1 to Layer 7.

Each layer:

  • Reads the information intended for it (e.g. IP or MAC address)
  • Removes its header/trailer
  • Passes the cleaned data up to the next layer

Step-by-Step De-encapsulation (Receiver Side)

OSI LayerWhat It DoesWhat It Extracts
Layer 1 (Physical)Receives the raw bitsConverts them back into frames
Layer 2 (Data Link)Reads/removes MAC header/trailerVerifies destination MAC, errors
Layer 3 (Network)Reads/removes IP headerChecks destination IP
Layer 4 (Transport)Reads/removes TCP/UDP headerIdentifies correct app via port
Layer 5–7 (Session–App)Delivers clean data to appHTTP message, file, email, etc

At the end of de-encapsulation, the app receives the original message exactly as it was sent.


Concrete Example – Visiting www.example.com

  1. User Action (Layer 7):
    You type www.example.com in your browser and hit Enter β†’ this creates an HTTP GET request.

  2. Encapsulation Begins:

    • Layer 4: TCP adds source/dest ports (e.g. port 443 for HTTPS)
    • Layer 3: IP adds sender & receiver IP addresses
    • Layer 2: MAC addresses are added for local delivery
    • Layer 1: The full message is converted into electrical signals (bits)
  3. Transmission:
    The bits travel over the network (Wi-Fi, cable) to the destination (Google’s server).

  4. De-encapsulation Begins:

    • The server receives bits (Layer 1), rebuilds frames (Layer 2), checks the IP and port (Layers 3–4), and finally extracts the original HTTP request (Layer 7).
  5. Server Response:
    The server sends back the requested web page using the same process in reverse.

Key Points to Remember

  • Encapsulation: Each OSI layer adds protocol info (headers/footers) β†’ prepares the data for delivery.
  • De-encapsulation: Each layer removes its header β†’ reconstructs the original message.
  • The process ensures data is delivered to the right device, to the right application, and in the correct form.

Image from : https://medium.com/@boutnaru/the-networking-journey-data-encapsulation-and-de-encapsulation-45d8057fb2e4


πŸ”™ Back to Index