Home/Learn/Computer Networks/Packets, Frames & Encapsulation

Packets, Frames & Encapsulation

Beginner
Fundamentals

Data is broken into packets at Layer 3 and frames at Layer 2. Encapsulation wraps data with headers at each layer; MTU limits frame size and drives IP fragmentation.

Overview

When an application sends data, it does not travel as one continuous stream over the physical network. It is broken into chunks at different layers, each with its own header. At Layer 4 (Transport), TCP splits data into segments. At Layer 3 (Network), IP wraps each segment into a packet with IP header. At Layer 2 (Data Link), each packet is wrapped in a frame with MAC addresses. The Maximum Transmission Unit (MTU) — typically 1500 bytes for Ethernet — limits the payload of each frame. If an IP packet exceeds the path MTU, it is fragmented into multiple smaller packets, each reassembled at the destination. Modern networks often use PMTU Discovery to avoid fragmentation entirely. Understanding this is essential for diagnosing network issues like black holes caused by oversized packets.

Packet and Frame Structure

Each layer adds its own header. IP packets carry source/destination IP addresses. Ethernet frames carry source/destination MAC addresses. A MAC address identifies a network interface on a LAN; an IP address identifies a host globally.

Ethernet frame and IPv4 packet structure
// Ethernet Frame structure (Layer 2):
// ┌──────────────┬──────────────┬──────┬──────────────────────┬─────┐
// │ Dst MAC (6B) │ Src MAC (6B) │ Type │ Payload (IP Packet)  │ FCS │
// └──────────────┴──────────────┴──────┴──────────────────────┴─────┘
// Max payload = 1500 bytes (standard Ethernet MTU)
// Jumbo frames = up to 9000 bytes (datacenter NICs)

// IPv4 Packet structure (Layer 3):
// ┌────────────────────────────────────────────────────────────────┐
// │ Version │ IHL │ DSCP │ Total Length │ ID │ Flags │ Fragment   │
// │ TTL     │ Protocol  │ Checksum     │ Source IP (4B)          │
// │ Destination IP (4B) │ Options (variable)                      │
// │ Payload (TCP Segment / UDP Datagram)                          │
// └────────────────────────────────────────────────────────────────┘

// Protocol field identifies Layer 4 protocol:
// 6 = TCP, 17 = UDP, 1 = ICMP

MTU and Fragmentation

The MTU is the largest payload a network link can carry. Ethernet MTU is 1500 bytes. If an IP packet exceeds the MTU of any link in the path, routers fragment it. Fragmentation is expensive — modern stacks use Path MTU Discovery (PMTUD) to send packets that fit the smallest MTU on the path.

MTU, fragmentation, and PMTUD
// MTU impact on TCP:
// Ethernet MTU = 1500 bytes
// IP header    =   20 bytes
// TCP header   =   20 bytes (minimum)
// ─────────────────────────
// Max TCP payload per segment (MSS) = 1460 bytes

// If a 4000-byte IP packet is sent over Ethernet (MTU=1500):
// Fragment 1: bytes  0–1479 (1480 byte payload + 20B IP header = 1500)
// Fragment 2: bytes 1480–2959
// Fragment 3: bytes 2960–3999
// All fragments reassembled only at destination

// Path MTU Discovery (PMTUD):
// Sender sets DF (Don't Fragment) bit in IP header
// If a router can't forward without fragmenting → sends ICMP "Fragmentation Needed"
// Sender reduces packet size and retries

// Practical: VPNs add overhead (IPSec header ~50B) so effective MTU drops to ~1450
// This is why some VPN configs set TCP MSS clamping to avoid black holes

Key Points to Remember

  • 1Packets (Layer 3) carry IP addresses; frames (Layer 2) carry MAC addresses.
  • 2Ethernet MTU is 1500 bytes — the maximum IP packet payload per frame.
  • 3TCP MSS = MTU − IP header (20B) − TCP header (20B) = 1460 bytes.
  • 4IP fragmentation splits oversized packets; reassembly happens only at the destination.
  • 5Path MTU Discovery avoids fragmentation by probing the minimum MTU on the path.
  • 6VPNs add header overhead, reducing effective MTU — MSS clamping compensates.

Interview Questions

Sign in to ask Aria
1

What is the difference between a packet and a frame?

EasyInfosys
2

What is MTU and why is it important?

EasyWipro
3

What is IP fragmentation and why should it be avoided?

MediumIBM
4

How does Path MTU Discovery work?

MediumAmazon
5

Why might a VPN connection experience connectivity issues with certain applications?

HardThoughtWorks

Ask Aria about Packets, Frames & Encapsulation

Your personal AI tutor — ask anything about this concept

Revision Status

Personal Notes

Sign in to save personal notes for this topic.

Discussion

Sign in to join the discussion.

Loading discussion…