Sub topic 9
Reassembly and Loss of a Single IPv4 Fragment
This chapter assumes you know IPv4 headers, MTU, binary arithmetic, and the meaning of a packet and a router. You should also know that an IPv4 datagram is the network-layer unit delivered to the destination host.
How IPv4 reassembly works
When a datagram is larger than the outgoing link's maximum transmission unit (MTU), IPv4 may split it into fragments. Each fragment receives its own IPv4 header. The headers identify fragments that belong to the same original datagram using:
- Source address
- Destination address
- Protocol
- Identification field
The fragment offset identifies where a fragment's data belongs in the original datagram. The offset is measured in units of 8 bytes, not individual bytes. The More Fragments (MF) flag is 1 on every fragment except the last one.
Routers may fragment IPv4 datagrams, but reassembly normally occurs only at the final destination. The destination stores arriving fragments in a reassembly buffer, places their data according to the offsets, and delivers the original datagram to the transport layer only after all data has arrived.
Worked example
Suppose a 4000-byte IPv4 datagram, including its 20-byte header, crosses a link with an MTU of 1500 bytes.
Each non-final fragment can carry at most:
1500 - 20 = 1480 data bytes
Because non-final data sizes must be multiples of 8, 1480 is already suitable.
| Fragment | Total length | Data bytes | Offset | MF |
|---|---|---|---|---|
| 0 | 1500 | 1480 | 0 | 1 |
| 1 | 1500 | 1480 | 185 | 1 |
| 2 | 1040 | 1020 | 370 | 0 |
The offsets are 0, 1480 / 8 = 185, and 2960 / 8 = 370. The final fragment contains the remaining 1020 data bytes. Its total length is 1040 bytes after adding its 20-byte header.
What happens when one fragment is lost?
The destination cannot deliver the original datagram if any required byte range is missing. It keeps the received fragments temporarily, waiting for the missing fragment. A reassembly timer prevents an incomplete datagram from occupying memory forever. When the timer expires, the destination discards the incomplete datagram and its fragments.
This loss affects the complete datagram, not just one fragment:
- TCP usually recovers by retransmitting the missing transport data. The retransmission may be fragmented again.
- UDP has no built-in retransmission. The application must tolerate the loss or implement recovery.
- A duplicate fragment may be ignored or handled safely.
- Overlapping fragments are problematic and can cause inconsistent interpretations, so systems validate them carefully.
Exercise
A 3000-byte datagram has a 20-byte header and crosses an MTU of 1000 bytes. What are the offsets and MF flags if every non-final fragment uses the largest possible data size?
Show answer
Each non-final fragment carries 976 bytes, because 980 is rounded down to a multiple of 8. The fragments have data sizes 976, 976, and 1028 bytes. Their offsets are 0, 122, and 244, with MF flags 1, 1, and 0.