Understanding the Basics of an IPv4 Header
The IPv4 header is a fundamental component of internet communication, acting as the packaging for data as it travels across networks. It contains essential information that helps route data packets from the sender to the receiver.
In this guide, we'll explore the structure and purpose of each field within an IPv4 header, making it easier to understand how data is efficiently managed and transmitted over the internet. Whether you're a tech enthusiast or just curious about how the internet works, this introduction will provide you with a clear and straightforward overview.
So what is IPv4 header? Every time data is sent using IPv4, it comes with something called an IPv4 header. Think of it like the envelope of a letter, it holds important information about where the data is coming from, where it's going, and how it should be handled. This header sits at the beginning of every packet and helps routers and devices understand what to do with the data inside.

Now that we know the IPv4 header is like an envelope for network data, let’s go over what’s inside it. The header is made up of different parts, and each one has a job to do. These parts help routers and devices figure out how to handle the packet.
Here are the main parts of the IPv4 header:
Version (4 bits)
Tells which version of IP is being used. For IPv4, this value is always 4.
IHL – Internet Header Length (4 bits)
Shows how long the IPv4 header is. The minimum is 20 bytes, but it can be longer if extra options are added.
DSCP – Differentiated Services Code Point (6 bits)
Used to mark packets based on priority or type of service (like video, voice, or regular traffic). Helps routers decide how to treat each packet.
ECN – Explicit Congestion Notification (2 bits)
Used to signal network congestion without dropping packets. Lets the sender slow down to avoid making the congestion worse.
Total Length (16 bits)
Shows the full size of the packet, including both the header and the data. Maximum size is 65,535 bytes.
Identification (16 bits)
A unique number assigned to each packet. Helps when large packets are split (fragmented) into smaller ones and need to be put back together later.
Flags (3 bits)
Controls fragmentation. It includes:
A bit that says “don’t fragment,” and
A bit that says “more fragments coming.”
Fragment Offset (13 bits)
Tells the position of a fragment so it can be reassembled properly at the destination.
Time to Live (TTL) (8 bits)
Limits how long a packet can travel. Each router that forwards the packet reduces the TTL by 1. If TTL hits 0, the packet is discarded to avoid looping forever.
Protocol (8 bits)
Tells what kind of data is inside the packet so the receiving device knows how to handle it. Common values:
6 for TCP
17 for UDP
1 for ICMP (used in ping)
Header Checksum (16 bits)
Used to detect errors in the IPv4 header. If something goes wrong during transmission, the packet can be dropped.
Source IP Address (32 bits)
The IP address of the sender.
Destination IP Address (32 bits)
The IP address of the receiver.
Options (variable length, optional)
This field is optional. It can be used for testing, security, or specific routing needs. Not commonly used in regular traffic.
Padding (variable, optional)
If the Options field doesn’t end on a 32-bit boundary, padding is added to make the header size correct.
All of these parts work together to make sure the data gets where it needs to go, safely and correctly.
Wrapping It Up
The IPv4 header might seem technical at first, but it’s really just a set of instructions that helps data get to the right place. Each field plays a role in making sure packets are delivered accurately, efficiently, and safely.
If you’ve made it this far, great job. Understanding these basics gives you a strong foundation in how networks actually work. I’m not an expert, just someone learning and sharing along the way. Thanks for reading, and keep going. There's always more to learn.