Skip to main content
  1. Network Articles/
  2. IPv4 Articles/

IPv4 Packet Header Structure

Table of Contents

IPv4 Packet Header Structure

An IPv4 (Internet Protocol version 4) packet consists of a header attached at the front, followed by data (the payload). The header is defined as a stack of 32-bit (4-byte) rows; the basic portion is 20 bytes, and up to 60 bytes when options are included. This article explains the role of each field.

Description of Each Field

Field NameSizeDescription
Version4 bitsIndicates the IP version. Fixed at 4 for IPv4.
IHL (Internet Header Length)4 bitsExpresses the header length in units of 32 bits (4 bytes). The minimum value without options is 5 (= 20 bytes), and the maximum is 15 (= 60 bytes).
Type of Service (DSCP + ECN)8 bitsControls packet priority and congestion notification. The upper 6 bits are used as DSCP (Differentiated Services Code Point) and the lower 2 bits as ECN (Explicit Congestion Notification).
Total Length16 bitsThe total size in bytes of the packet, including the IP header and data. Can express up to 65535 bytes.
Identification16 bitsA value used to identify fragments that originated from the same packet when the packet is split (fragmented).
Flags3 bitsA bit sequence used for fragment control. Bit 0 is reserved (fixed at 0), bit 1 is DF (Don’t Fragment), and bit 2 is MF (More Fragments, indicating whether further fragments follow).
Fragment Offset13 bitsIndicates, in units of 8 bytes, how far the fragmented data is positioned from the start of the original packet.
TTL (Time To Live)8 bitsThe maximum number of router hops the packet may traverse. Decremented by 1 at each router, and discarded once it reaches 0. A mechanism to prevent looping packets from persisting forever.
Protocol8 bitsIndicates the type of upper-layer protocol carried in the data portion.
Header Checksum16 bitsAn error-detection checksum covering only the IP header. Since the TTL changes at every router, it is recalculated each time.
Source Address32 bitsThe source IP address of the packet.
Destination Address32 bitsThe destination IP address of the packet.
OptionsVariable length (0–40 bytes)An optional field used to specify additional functionality such as security or timestamp recording. When present, padding is added to align to a 32-bit boundary. Only present when IHL is greater than 5.
Data (Payload)Variable lengthThe data body passed from an upper-layer protocol (TCP, UDP, ICMP, etc.).

Common Protocol Values

The value of the Protocol field indicates the type of upper-layer protocol carried in the data portion. Common values are as follows.

Protocol ValueProtocol
1ICMP
2IGMP
6TCP
17UDP
41IPv6 (IPv6 encapsulation)
47GRE
50ESP (IPsec)
51AH (IPsec)
89OSPF
132SCTP

Protocol numbers are managed by IANA, and the full list of assigned values is published here.

Header Length and Fragmentation

IHL only represents the header length; the length of the entire packet is expressed separately by the Total Length field.
ItemSizeNotes
IP header (without options)20 bytesThe case when IHL = 5. The most common configuration.
IP header (with options)24–60 bytesThe case when IHL = 6–15. Increases in increments of 4 bytes.
Entire IP packetUp to 65535 bytesThe upper limit expressible by the Total Length field.

If the packet size is larger than the MTU (Maximum Transmission Unit) of a link along the path, the packet is fragmented by the source or a router. Fragmented packets are reassembled at the receiving end using the Identification, Flags, and Fragment Offset fields. However, if the DF bit is set, fragmentation is prohibited, and a packet exceeding the MTU is discarded, with an ICMP Destination Unreachable message returned to the source.

Related RFCs

RFCTitleSummary
RFC 791Internet ProtocolThe original specification for IPv4. Defines the basic format including header structure, fragmentation, and TTL.