Breaking Down IPv4 Address Headers
22,768 Total views across this article’s versions; includes the historical baseline where available.
Every IP packet includes metadata that describes the data payload it is carrying to its destination. This metadata information has evolved over time as the Internet has matured. This article explains the contents and purpose of metadata found in IPv4 headers - the portion of an IP packet that precedes the data payload.
An IPv4 packet begins with a header that describes the packet: where it is going, where it came from, and how it should be handled. The basic header is 20 bytes; options and padding can extend it to 60 bytes.
Each octet is an 8-bit byte. The chart below lays out the fixed header in 32-bit rows. The final row represents a variable-length options and padding area, which can add up to 40 bytes.
| Offsets | Octet | 0 | 1 | 2 | 3 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | Version | IHL | DSCP | ECN | Total Length | |||||||||||||||||||||||||||
| 4 | 32 | Identification | Flags | Fragment Offset | |||||||||||||||||||||||||||||
| 8 | 64 | Time To Live | Protocol | Header Checksum | |||||||||||||||||||||||||||||
| 12 | 96 | Source IP Address | |||||||||||||||||||||||||||||||
| 16 | 128 | Destination IP Address | |||||||||||||||||||||||||||||||
| 20 onward | 160 onward | Options and padding (optional; 0–40 bytes when IHL > 5) | |||||||||||||||||||||||||||||||
Version
The IP version. Always equal to 4 for IPv4 packets.
Internet Header Length (IHL)
The Internet Header Length (IHL) field gives the header size in 32-bit words. Valid values run from 5 through 15, corresponding to 20 through 60 bytes. A value of 5 describes the basic header without options.
Differentiated Services Code Point (DSCP)
The six-bit DSCP field identifies a differentiated-services codepoint. It shares the former eight-bit Type of Service field with the two ECN bits. A network’s configured policy determines the forwarding treatment associated with a codepoint; a larger number does not universally mean higher priority. See RFC 2474 and its terminology clarification.
Explicit Congestion Notification (ECN)
This field is defined in RFC 3168 and allows end-to-end notification of network congestion without dropping packets. ECN is an optional feature that is only used when both endpoints support it and are willing to use it. It is effective only when supported by the underlying network.
What Happened to ToS?
The original IPv4 Type of Service octet was redefined as the Differentiated Services field in December 1998 by RFC 2474. RFC 3168 assigned the two remaining bits to ECN in 2001. These definitions apply to the corresponding fields in both IPv4 and IPv6.
Some tools still call the octet “ToS.” That historical name does not mean the old precedence and service-bit interpretation remains the current one. DSCP treatment depends on policy, while ECN signals congestion; neither supplies a universal numerical packet-priority ranking.
Total Length
The 16-bit Total Length field gives the entire IPv4 packet size, including header and payload, in bytes. It is a length, not a checksum. The maximum is 65,535 bytes; the minimum is the header length, which is at least 20 bytes. Each fragment has its own Total Length.
Identification
The 16-bit Identification field helps associate fragments of one original datagram, together with its source address, destination address, and protocol. It is not a globally unique packet number, and the ID alone does not indicate that a packet is fragmented.
RFC 6864 limits its purpose to fragmentation and reassembly. An atomic datagram has DF set, MF clear, and a zero fragment offset; its ID has no meaning and may be any value. Non-atomic datagrams still require suitable IDs, including packets that have not yet been fragmented but permit fragmentation. The RFC explains a theoretical rate limit from the old uniqueness requirement; it does not establish that adding the field to packets generally caused observed connection slowdowns.
Flags
The three flag bits are reserved (must be zero), DF (Don’t Fragment), and MF (More Fragments). DF prohibits fragmentation. MF indicates that more fragments follow; the last fragment has MF clear, and its offset can still be nonzero. Do not infer that MF clear alone means the packet was never fragmented.
Fragment Offset
The 13-bit fragment offset locates this fragment’s payload within the original datagram’s payload, in units of eight bytes. The destination uses the offset during reassembly. The first fragment has offset zero.
Time to Live (TTL)
TTL limits a packet’s lifetime and prevents it from circulating indefinitely. Although historically defined in seconds, forwarding routers must reduce it by at least one at every hop, so in practice it works as a hop limit. A router discards a packet whose TTL expires in transit and normally sends ICMP Time Exceeded, subject to the rules limiting ICMP error responses.
TTL is not a separate timer for fragment reassembly. Updating the IPv4 header checksum after decrementing TTL preserves error detection; it does not authenticate the packet or make the checksum a security mechanism. See RFC 1812, section 5.3.1.
Protocol
The IP protocol type (e.g. TCP), identified by a unique 8-bit number that correlates with the official list published by the Internet Assigned Numbers Authority (IANA). The registry includes assigned, experimental, reserved, and unassigned values; consult it for the current assignments.
The most common protocols are TCP (6), UDP (17), and ICMP (1).
Header Checksum
The header checksum detects errors in the IPv4 header only, including any options. It does not cover the payload and is not cryptographic authentication. A header change, such as a TTL decrement, requires a corresponding checksum update. Transport protocols have separate checksum rules for their own data.
Source Address
The originating or sending host. Note this can be altered via Network Address Translation (NAT) devices.
Destination Address
The receiving host. Note this can be altered via Network Address Translation (NAT) devices.
Options
Options and any padding occupy the area after the fixed 20-byte header. Padding makes the total header length a multiple of four bytes; IHL includes both the fixed portion and this optional area.
References
RFC 791. INTERNET PROTOCOL: DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION. September 1981. Official HTML.
RFC 2474. Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers. December 1998. Official HTML. Return to Type of Service.
RFC 3168. The Addition of Explicit Congestion Notification (ECN) to IP. September 2001. Official HTML. Return to ECN.
RFC 3260. New Terminology and Clarifications for Diffserv. April 2002. Official HTML.
RFC 6864. Updated Specification of the IPv4 ID Field. February 2013. Official HTML.