03/08/2026
IPv4 Datagram Header
Introduction to IPv4
Internet Protocol Version 4 (IPv4) is the fourth version of the Internet Protocol and the most widely used protocol for communication across computer networks. Introduced in 1983 as part of the ARPANET project, IPv4 provides logical addressing and packet routing, allowing devices to communicate over local networks and the Internet.
An IPv4 address consists of 32 bits (4 bytes) and is written in dotted-decimal notation, where four decimal numbers (octets) are separated by periods. For example:
192.168.1.1
Every IPv4 packet contains a header followed by the data (payload). The header stores important control information that enables routers and destination devices to deliver packets correctly and efficiently.
IPv4 Packet Structure
An IPv4 packet is divided into two main parts:
Header – Contains control information required for routing and delivery.
Payload (Data) – Contains the actual information being transmitted.
The IPv4 header has a minimum size of 20 bytes and can increase to 60 bytes if optional fields are included.
Key Features of IPv4
IPv4 provides several important networking capabilities:
Uses 32-bit addressing, allowing approximately 4.29 billion unique addresses (2³²).
Operates as a connectionless protocol, meaning each packet is routed independently.
Supports communication across LANs, WANs, and the Internet.
Provides logical addressing for network devices.
Supports both static and dynamic IP address assignment (such as through DHCP).
Supports Unicast, Broadcast, and Multicast communication.
Allows packet fragmentation when packets exceed the Maximum Transmission Unit (MTU).
Supports subnetting using Variable Length Subnet Masking (VLSM).
Uses the Address Resolution Protocol (ARP) to map IPv4 addresses to physical (MAC) addresses.
IPv4 Address Classes
Traditionally, IPv4 addresses were divided into five classes:
ClassPurposeClass ALarge networks with many hostsClass BMedium-sized networksClass CSmall networksClass DMulticast communicationClass EExperimental and research purposes
Although modern networks primarily use Classless Inter-Domain Routing (CIDR), understanding address classes remains useful for learning networking fundamentals.
Characteristics of IPv4
IPv4 has the following characteristics:
Uses 32-bit numerical addresses.
Addresses are written in dotted-decimal format.
The standard header contains 12 main fields.
The header size ranges from 20 to 60 bytes.
Supports Unicast, Broadcast, and Multicast communication.
Allows routers to fragment packets when necessary.
Supports subnetting through VLSM.
Uses ARP for resolving IP addresses to MAC addresses.
Can be configured manually (Static IP) or automatically using DHCP.
Compatible with many routing protocols, including RIP, OSPF, and BGP.
IPv4 Datagram Header Fields
The IPv4 header contains several fields that help deliver packets accurately across a network.
Header FieldSizeDescriptionVersion4 bitsIdentifies the IP version. The value is always 4 for IPv4.Header Length (IHL)4 bitsSpecifies the size of the IPv4 header in 32-bit words. Minimum value is 5 (20 bytes) and maximum is 15 (60 bytes).Type of Service (ToS) / DSCP8 bitsIndicates packet priority and quality of service requirements, such as low delay or high reliability.Total Length16 bitsSpecifies the total size of the packet, including both the header and payload. Maximum packet size is 65,535 bytes.Identification16 bitsUniquely identifies a packet so fragmented pieces can be reassembled correctly.Flags3 bitsControls fragmentation. Includes Reserved, Don't Fragment (DF), and More Fragments (MF) flags.Fragment Offset13 bitsIndicates the position of each fragment within the original packet.Time to Live (TTL)8 bitsLimits how many routers (hops) a packet can pass through before being discarded, preventing routing loops.Protocol8 bitsIdentifies the transport protocol carried in the payload, such as TCP (6), UDP (17), or ICMP (1).Header Checksum16 bitsDetects errors in the IPv4 header during transmission.Source IP Address32 bitsThe IPv4 address of the sending device.Destination IP Address32 bitsThe IPv4 address of the receiving device.Options (Optional)VariableStores optional information used for diagnostics, testing, routing, or network management.PaddingVariableAdds extra bits so the header length remains a multiple of 32 bits.
How an IPv4 Datagram Is Processed
When a device sends data over a network, IPv4 performs the following steps:
Creates an IPv4 packet by adding a header to the data.
Assigns the source and destination IP addresses.
Calculates the header checksum.
Sets the TTL value to prevent endless routing loops.
Sends the packet to the next router.
Each router decreases the TTL by one and forwards the packet toward its destination.
If the packet is larger than the network's MTU, it may be fragmented and later reassembled by the receiving device.
Why the IPv4 Header Is Important
The IPv4 header contains all the information needed for successful packet delivery. Network devices use the header to:
Identify the sender and receiver.
Determine the best routing path.
Detect transmission errors.
Control packet fragmentation.
Prevent packets from circulating indefinitely.
Identify the transport-layer protocol carrying the data.
Without the IPv4 header, routers and computers would be unable to deliver data reliably across networks.
Key Takeaway
The IPv4 Datagram Header is the control section of every IPv4 packet. It contains essential information such as IP addresses, packet size, routing details, fragmentation information, protocol type, and error-checking data. Understanding each header field is fundamental for learning networking, troubleshooting communication problems, and analyzing network traffic in cybersecurity.