Sub topic 6
The IPv4 Header Fields That Matter
Assume you know binary and decimal conversion, the basic network layers, packets, routers, hosts, and weighted-graph terminology. This chapter focuses on the IPv4 header fields used in fragmentation and routing questions.
IPv4 header structure
An IPv4 packet contains a header followed by payload data. The header is at least 20 bytes and can be as large as 60 bytes when options are present.
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | Identifies IPv4; its value is 4 |
| IHL | 4 bits | Header length in 32-bit words |
| Total Length | 16 bits | Header plus payload, in bytes |
| Identification | 16 bits | Labels fragments belonging to one original datagram |
| Flags | 3 bits | Includes DF and MF fragmentation controls |
| Fragment Offset | 13 bits | Fragment position in 8-byte units |
| TTL | 8 bits | Limits a packet's lifetime |
| Protocol | 8 bits | Identifies the next protocol, such as TCP or UDP |
| Header Checksum | 16 bits | Checks errors in the IPv4 header |
| Source and Destination | 32 bits each | Identify the sender and receiver |
The IHL value is not a byte count. For example, IHL = 5 means 5 × 4 = 20 bytes. The total length includes both the header and the payload.
Fields used for fragmentation
The maximum transmission unit (MTU) is the largest IP packet that a link accepts. If a datagram is larger than the next link's MTU and the Don't Fragment (DF) flag is clear, an IPv4 router can split it into fragments.
Every fragment receives its own IPv4 header. The fragments share:
- The same Identification value.
- The same source and destination addresses.
- The same protocol value.
- Different Fragment Offset values.
The Fragment Offset counts payload positions in units of 8 bytes. Therefore, every non-final fragment normally carries a payload whose size is a multiple of 8 bytes.
The More Fragments (MF) flag is 1 on every fragment except the last one. The last fragment has MF = 0. The destination uses the identification, offsets, and lengths to reassemble the original datagram. If one fragment is lost, the complete datagram usually cannot be delivered.
Other fields that affect forwarding
TTL decreases by at least one at every router. When it changes, the router recomputes the IPv4 header checksum. The checksum covers only the IPv4 header, not the payload.
The Protocol field tells the receiving host how to interpret the payload. For example, TCP is 6 and UDP is 17. Routers normally use the destination address and their forwarding table to choose the next hop; they do not use the Protocol field to choose the network path.
Exercise
An IPv4 fragment has IHL = 6, Total Length = 1000, and Fragment Offset = 125. How many header bytes does it have, how many payload bytes does it have, and where does its payload begin in the original datagram?
Show answer
The header is 6 × 4 = 24 bytes. The payload is 1000 − 24 = 976 bytes. Its payload begins at 125 × 8 = 1000 bytes.