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 Name | Size | Description |
|---|---|---|
| Version | 4 bits | Indicates the IP version. Fixed at 4 for IPv4. |
| IHL (Internet Header Length) | 4 bits | Expresses 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 bits | Controls 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 Length | 16 bits | The total size in bytes of the packet, including the IP header and data. Can express up to 65535 bytes. |
| Identification | 16 bits | A value used to identify fragments that originated from the same packet when the packet is split (fragmented). |
| Flags | 3 bits | A 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 Offset | 13 bits | Indicates, in units of 8 bytes, how far the fragmented data is positioned from the start of the original packet. |
| TTL (Time To Live) | 8 bits | The 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. |
| Protocol | 8 bits | Indicates the type of upper-layer protocol carried in the data portion. |
| Header Checksum | 16 bits | An error-detection checksum covering only the IP header. Since the TTL changes at every router, it is recalculated each time. |
| Source Address | 32 bits | The source IP address of the packet. |
| Destination Address | 32 bits | The destination IP address of the packet. |
| Options | Variable 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 length | The 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 Value | Protocol |
|---|---|
1 | ICMP |
2 | IGMP |
6 | TCP |
17 | UDP |
41 | IPv6 (IPv6 encapsulation) |
47 | GRE |
50 | ESP (IPsec) |
51 | AH (IPsec) |
89 | OSPF |
132 | SCTP |
Protocol numbers are managed by IANA, and the full list of assigned values is published here.
Header Length and Fragmentation
| Item | Size | Notes |
|---|---|---|
| IP header (without options) | 20 bytes | The case when IHL = 5. The most common configuration. |
| IP header (with options) | 24–60 bytes | The case when IHL = 6–15. Increases in increments of 4 bytes. |
| Entire IP packet | Up to 65535 bytes | The 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
| RFC | Title | Summary |
|---|---|---|
| RFC 791 | Internet Protocol | The original specification for IPv4. Defines the basic format including header structure, fragmentation, and TTL. |