← Back to list

I Watched a Message Get Wrapped and Unwrapped — And Finally Understood Encapsulation

You send a message to your friend.

Anas · 2026-06-01 23:28 · 0 claps · 4.5 min read
#encapsulation #de-encapsulation #ccna-preparation #networking-fundamental #tcp-header
Open on Medium ↗

I Watched a Message Get Wrapped and Unwrapped — And Finally Understood Encapsulation

You send a message to your friend.

“Hey, wanna grab coffee?”

Simple, right?

But behind the scenes, that message gets wrapped in layers — like putting a letter in an envelope, then that envelope in a shipping box, then that box on a truck.

That’s encapsulation.

Then your friend receives it and unwraps everything.

That’s de-encapsulation.

Let me show you exactly how it works.

What Is Encapsulation?

Encapsulation is the process of adding headers (wrappers) to data as it moves down the OSI or TCP/IP model.

Each layer adds its own information so the receiving device knows how to handle it.

Think of it like mailing a gift:

Step 1 — You write a letter. That’s the actual data at the Application layer.

Step 2 — You put the letter in an envelope. That’s the Transport layer adding port numbers (TCP/UDP).

Step 3 — You write the address on the envelope. That’s the Network layer adding source and destination IPs.

Step 4 — You put the envelope inside a shipping box. That’s the Data Link layer adding source and destination MACs.

Step 5 — You hand the box to the delivery driver. That’s the Physical layer sending the bits as signals.

That last step is the actual transmission — the truck on the road.

Step-by-Step: How Encapsulation Works

Let’s say PC1 (192.168.1.1) sends a ping to PC2 (192.168.1.2).

Step 1 — Application Layer (Layer 7) The ping command creates the raw data. Just the message “hey, are you there?”

Step 2 — Transport Layer (Layer 4) The data gets wrapped with a TCP or UDP header. This header contains:

  • Source port (random number like 50000)
  • Destination port (for ping, it’s usually port 7 or 8)

Now we call it a segment.

Step 3 — Network Layer (Layer 3) The segment gets wrapped with an IP header. This header contains:

  • Source IP: 192.168.1.1
  • Destination IP: 192.168.1.2

Now we call it a packet.

Step 4 — Data Link Layer (Layer 2) The packet gets wrapped with an Ethernet header (MAC addresses). This header contains:

  • Source MAC: AA:BB:CC:DD:EE:11
  • Destination MAC: AA:BB:CC:DD:EE:22

Now we call it a frame.

Step 5 — Physical Layer (Layer 1) The frame (just 0s and 1s now) gets sent as electrical signals, light pulses, or radio waves through the cable.

The Big Picture of Encapsulation

Data (Layer 7)
    ↓
[TCP/UDP header + Data]  ← Segment (Layer 4)
    ↓
[IP header + TCP/UDP header + Data]  ← Packet (Layer 3)
    ↓
[MAC header + IP header + TCP/UDP header + Data + MAC trailer]  ← Frame (Layer 2)
    ↓
Bits sent as signals (Layer 1)

Each layer adds something to the front (header) and sometimes the end (trailer).

The data keeps growing as it goes down.

What Is De-Encapsulation?

De-encapsulation is the reverse process.

When the receiving device gets the bits, it works from Layer 1 up to Layer 7, removing each header as it goes.

Think of it like opening that gift:

Step 1 — The delivery driver hands you the box. That’s the Physical layer receiving signals.

Step 2 — You look at the shipping label. It has the MAC addresses. That’s the Data Link layer reading and removing the MAC header.

Step 3 — You open the box and find an envelope inside. On the envelope are the IP addresses. That’s the Network layer reading and removing the IP header.

Step 4 — You open the envelope and find a letter. The letter has port numbers on it. That’s the Transport layer reading and removing the TCP/UDP header.

Step 5 — You read the letter. That’s the Application layer getting the original data.

Step-by-Step: How De-Encapsulation Works

PC2 receives the bits from PC1.

Step 1 — Physical Layer (Layer 1) PC2 receives electrical signals. It converts them back into 0s and 1s (a frame).

Step 2 — Data Link Layer (Layer 2) PC2 reads the MAC header. It checks:

  • “Is this MAC address mine?”
  • If yes → removes the MAC header and trailer
  • Passes the remaining data (packet) up to Layer 3

Step 3 — Network Layer (Layer 3) PC2 reads the IP header. It checks:

  • “Is this IP address mine?”
  • If yes → removes the IP header
  • Passes the remaining data (segment) up to Layer 4

Step 4 — Transport Layer (Layer 4) PC2 reads the TCP/UDP header. It checks:

  • “Which application should get this data?”
  • Removes the TCP/UDP header
  • Passes the remaining data (raw data) up to Layer 7

Step 5 — Application Layer (Layer 7) PC2 gets the original data: “hey, are you there?”

PC2 responds with a reply, and the whole process repeats.

The Big Picture of De-Encapsulation

Bits received from cable (Layer 1)
    ↓
Frame → MAC header removed (Layer 2)
    ↓
Packet → IP header removed (Layer 3)
    ↓
Segment → TCP/UDP header removed (Layer 4)
    ↓
Data (Layer 7) ← Original message

Each layer removes its own header and passes the rest up.

The data keeps shrinking as it goes up.

Encapsulation + De-Encapsulation = Communication

Here’s the full cycle:

PC1                                    PC2
Data (Hi!)                             
    ↓                                   
Segment (adds ports)                   
    ↓                                   
Packet (adds IPs)                      
    ↓                                   
Frame (adds MACs)                      
    ↓                                   
Bits (sent over cable)  ──────────→   Bits (received)
                                       ↓
                                    Frame (remove MAC)
                                       ↓
                                    Packet (remove IP)
                                       ↓
                                    Segment (remove ports)
                                       ↓
                                    Data (Hi!)

See It Yourself in Packet Tracer

  1. Open Packet Tracer
  2. Put two PCs on a switch
  3. Give them IPs: 192.168.1.1 and 192.168.1.2
  4. Go to Simulation mode (bottom right)
  5. Ping from PC1 to PC2
  6. Click on the envelope as it travels

You will see:

  • On PC1: Data → Segment → Packet → Frame → Bits (data gets bigger)
  • On the wire: The frame traveling
  • On PC2: Bits → Frame → Packet → Segment → Data (data gets smaller)

That’s Encapsulation and De-encapsulation live.

Quick Reference:

Encapsulation (Sender):

Data → Segment → Packet → Frame → Bits

De-encapsulation (Receiver):

Bits → Frame → Packet → Segment → Data

Remember:

  • Going DOWN = ADDING wrappers (Encapsulation)
  • Going UP = REMOVING wrappers (De-encapsulation)

What This Taught Me

1. Data doesn’t travel alone. It carries instructions with it — like a package with shipping labels. Every router and switch reads only the layer it needs.

2. Encapsulation and de-encapsulation happen every time. Every single packet you send — a Google search, a YouTube video, a text message — goes through this process.

3. The OSI model is a roadmap. Encapsulation shows you how the layers actually work together, not just their names.

4. Packet Tracer makes it visible. You can literally watch the data grow and shrink. That’s the best way to learn it.

Final thought:

Encapsulation is just wrapping gifts for shipment.

De-encapsulation is just unwrapping them at the door.

The internet works because every device agrees on how to wrap and unwrap.

Next time your message reaches someone in seconds — remember the invisible wrapping and unwrapping happening behind the scenes.

What was your “aha” moment with encapsulation? Drop it in the comments.


메타데이터
post_id
d1ee2e785888
slug
i-watched-a-message-get-wrapped-and-unwrapped-and-finally-understood-encapsulation-d1ee2e785888
url
https://medium.com/@0x9z/i-watched-a-message-get-wrapped-and-unwrapped-and-finally-understood-encapsulation-d1ee2e785888
canonical_url
https://medium.com/@0x9z/i-watched-a-message-get-wrapped-and-unwrapped-and-finally-understood-encapsulation-d1ee2e785888
author_url
https://medium.com/@0x9z
status
ok
fetched_at
2026-07-10 07:28:19