Understanding the IPv4 Packet Structure is essential for anyone learning networking or cybersecurity. In this article, we break down each header field of an IPv4 packet with clear examples, helping you grasp how data travels across the internet efficiently and securely.

1. Introduction
Every time you browse a website, send an email, or stream a video, your data is broken into smaller pieces called packets. These packets travel across multiple networks before reaching their destination.
In the world of networking, IPv4 (Internet Protocol version 4) is still the most widely used protocol to deliver these packets. But how does a packet carry both the data and instructions on where to go? The answer lies in its structure — more specifically, the IPv4 header fields.
In this article, we’ll break down the IPv4 packet format, explain each header field in detail, and show how it all comes together in real-world communication.
2. What is an IPv4 Packet?
An IPv4 packet is the basic data unit transmitted across an IPv4 network. It has two main parts:
- Header – contains control and routing information (like source IP, destination IP, TTL, etc.).
- Payload – the actual data being delivered (e.g., part of an email, video stream, or web page).
👉 Think of it like a postal envelope:
– The header = sender’s and receiver’s addresses + delivery instructions.
– The payload = the actual letter inside.
3. IPv4 Packet Structure Overview
An IPv4 packet is structured as follows:

– The header is between 20 and 60 bytes, depending on options.
– The payload is the actual data from higher-layer protocols (TCP, UDP, ICMP, etc.).
At a high level:
– Routers only look at the header to make forwarding decisions.
– The payload is untouched until it reaches the destination.
4. IPv4 Header Fields (Detailed Breakdown)
The IPv4 header contains multiple fields, each with a specific role:

1. Version (4 bits)
– Indicates the IP version.
– For IPv4, this value is always 4.
– Ensures routers know they’re handling an IPv4 packet (not IPv6).
2. IHL (Internet Header Length) (4 bits)
– Specifies the length of the header in 32-bit words.
– Minimum = 20 bytes, maximum = 60 bytes.
– Example: If IHL = 5 → header length = 5 × 4 = 20 bytes.
3. Type of Service (TOS) / DSCP (8 bits)
– Used for Quality of Service (QoS).
– Helps prioritize traffic (e.g., video call packets over file downloads).
– Example: In VoIP calls, routers may give higher priority to minimize delay.
4. Total Length (16 bits)
– Defines the total packet size (header + payload).
– Maximum size = 65,535 bytes.
– Example: If header = 20 bytes, payload = 1480 bytes → total length = 1500 bytes.
5. Identification (16 bits)
– Unique ID for each packet.
– Used when packets are fragmented into smaller pieces.
– Helps the receiver reassemble fragments into the original packet.
6. Flags (3 bits)
– Control fragmentation.
– Important bits:
• DF (Don’t Fragment) – prevents fragmentation.
• MF (More Fragments) – indicates more fragments are coming.
7. Fragment Offset (13 bits)
– Indicates the position of a fragment in the original packet.
– Example: If a packet is split into 3 fragments, this field tells the receiver how to put them back together.
8. Time to Live (TTL) (8 bits)
– Maximum number of hops (routers) a packet can cross.
– Decremented by 1 at each hop.
– If TTL reaches 0 → packet is discarded.
– Prevents packets from looping forever in the network.
9. Protocol (8 bits)
– Specifies which protocol the payload belongs to.
– Examples:
• 6 → TCP
• 17 → UDP
• 1 → ICMP
– Helps the destination system know how to process the data.
10. Header Checksum (16 bits)
– Used for error detection in the header.
– If the checksum doesn’t match → packet is dropped.
11. Source Address (32 bits)
– IP address of the sender.
– Example: 192.168.1.10
.
12. Destination Address (32 bits)
– IP address of the receiver.
– Example: 142.250.72.14
(Google server).
13. Options (Variable length, optional)
– Rarely used.
– Allows testing, debugging, or security features.
14. Padding
– Ensures the header length is a multiple of 32 bits.
5. Example: IPv4 Packet in Action
Let’s say you ping Google.com from your computer.
- Source Address = your system’s IP (
192.168.1.10
). - Destination Address = Google’s IP (
142.250.72.14
). - Protocol = ICMP (1).
- TTL = 64 (default on Linux systems).
- Identification = 12345 (unique ID for this packet).
Each router on the way will decrease TTL by 1 until it reaches Google.
6. Why IPv4 Header Matters
- Routing – Routers forward packets based on destination address.
- Reliability – TTL and checksum help avoid errors and loops.
- Efficiency – Fragmentation ensures large data fits into smaller network frames.
7. IPv4 vs. IPv6 Header (Quick Comparison)
Feature | IPv4 Header | IPv6 Header |
---|---|---|
Size | 20–60 bytes | Fixed 40 bytes |
Address Length | 32-bit | 128-bit |
Checksum | Present | Removed (handled by other layers) |
Options | Variable | Extension headers |
Simplicity | Complex (many fields) | Simplified |
8. Common Interview/Exam Questions
- Q: What is the minimum size of an IPv4 header?
A: 20 bytes. - Q: Which field prevents infinite loops?
A: TTL (Time to Live). - Q: Difference between Identification and Fragment Offset?
A: Identification = packet ID, Fragment Offset = fragment’s position.
9. Conclusion
The IPv4 packet structure is the backbone of how data moves across the internet. Each header field plays a crucial role — from addressing and routing to fragmentation and error checking.
Understanding these fields not only helps in networking basics, but also in firewall configuration, troubleshooting, and certifications like CCNA, Network+, or Palo Alto PCNSE.
Next in the series, we’ll cover IPv4 Fragmentation and how packets are split and reassembled across networks.
10. FAQs
Q1: What is the minimum size of an IPv4 header?
→ 20 bytes.
Q2: Which IPv4 field is used for Quality of Service (QoS)?
→ Type of Service (TOS) / DSCP field.
Q3: How does TTL prevent routing loops?
→ Each router decreases TTL by 1. If it reaches 0, the packet is discarded.
Q4: What’s the difference between header and payload?
→ Header = control/routing info, Payload = actual user data.
Read More
Explore related topics to deepen your understanding of IPv4 networking:
References / Outside Sources
-
RFC 791 – Internet Protocol (IPv4)
Official specification of IPv4, detailing the packet header fields and structure.
Read RFC 791 -
RFC 1122 – Requirements for Internet Hosts – Communication Layers
Provides detailed information on IP header processing and network layer behavior.
Read RFC 1122

Cybersecurity blogger with a focus on firewalls, network security, and tech trends making security simple for everyone, from IT pros to curious minds.