Introduction

Every link has a maximum transmission unit (MTU): the largest IP datagram, header included, that one link-layer frame can carry. Ethernet's is 1500 bytes; other links have larger or smaller ones. A datagram crossing several links may meet one whose MTU is smaller than the datagram. IPv4 then lets the router fragment it: split the data into pieces, give each piece its own IP header, and send the pieces as separate datagrams. They travel independently and are reassembled only at the destination host.

Three header fields make this work: identification (which datagram a fragment belongs to), the MF flag (more fragments follow) and the fragment offset (where this fragment's data starts, in 8-byte units). The DF flag forbids fragmentation; a router that would need to fragment a DF datagram drops it and reports back. The tasks are to find the number of fragments, each fragment's length, offset and MF bit, and the reverse: what a given fragment says about the original datagram.

Prerequisites

Core concepts

What each fragment carries

FieldIn each fragment
IdentificationCopied from the original: the same in all fragments
Source, destination, protocolCopied
Total lengthThis fragment's header plus its own data
MF1 in every fragment except the one holding the end of the original data; that one copies the original's MF
Fragment offsetOriginal offset plus (this fragment's first data byte) / 8
Header checksumRecomputed

The two size rules

  1. Fits the MTU: header plus data ≤\le MTU, so data ≤\le MTU −- header length.
  2. Multiple of 8: every fragment except the last carries a multiple of 8 data bytes, because the next fragment's offset must be a whole number of 8-byte units.

So the largest data per fragment is

dmax⁡=8⌊MTU−H8⌋,d_{\max} = 8 \left\lfloor \frac{\text{MTU} - H}{8} \right\rfloor,

with H=20H = 20 bytes for a header without options. The last fragment is exempt from rule 2, so it may carry up to MTU−H\text{MTU} - H bytes, which exceeds dmax⁡d_{\max} when MTU−H\text{MTU} - H is not a multiple of 8. Only the data is split; the original header is not part of any fragment's data.

Reassembly

The destination collects fragments with the same (source, destination, protocol, identification), places each fragment's data at byte 8×offset8 \times \text{offset}, knows the total size once it has the fragment with MF = 0, and delivers the datagram when every byte is present. If any fragment is lost, a reassembly timer expires and the whole datagram is discarded: IP never retransmits a single fragment.

Don't fragment and path MTU

If DF = 1 and the datagram exceeds the next link's MTU, the router discards it and returns ICMP Destination Unreachable with code 4, "fragmentation needed and DF set". Path MTU discovery (RFC 1191) uses this: the source sends with DF set and lowers its datagram size whenever such a message comes back, so that it never needs fragmentation.

How it works: fragmenting a datagram

A datagram of total length 5140 bytes (20-byte header, 5120 data bytes, identification 777) meets a link with MTU 1420. Then dmax⁡=8⌊1400/8⌋=1400d_{\max} = 8 \lfloor 1400 / 8 \rfloor = 1400.

FragmentData bytesData rangeTotal lengthOffsetMF
114000 to 1399142001
214001400 to 279914201751
314002800 to 419914203501
49204200 to 51199405250

Number of fragments ⌈5120/1400⌉=4\lceil 5120 / 1400 \rceil = 4. The four fragments put 4×20=804 \times 20 = 80 header bytes on the link instead of 20, so 60 extra bytes.

A 5140-byte datagram drawn as a bar with a 20-byte header and 5120 data bytes, entering a router whose outgoing link has MTU 1420. Four fragments leave: each with its own 20-byte header; data sizes 1400, 1400, 1400 and 920; offsets 0, 175, 350 and 525; MF bits 1, 1, 1 and 0; total lengths 1420, 1420, 1420 and 940; all with identification 777. A second stage shows fragment 4 meeting an MTU of 620 and splitting into data 600 at offset 525 with MF 1, and data 320 at offset 600 with MF 0.
Figure 1. Fragmenting 5120 data bytes for MTU 1420: offsets 0, 175, 350, 525 and MF 1, 1, 1, 0; fragment 4 is split again at MTU 620 into offsets 525 and 600.

Mathematical explanation

For DD data bytes, header HH and MTU MM:

k=1+⌈D−(M−H)dmax⁡⌉  for D>M−H,offseti=(i−1) dmax⁡8,last data=D−(k−1) dmax⁡.k = 1 + \left\lceil \frac{D - (M - H)}{d_{\max}} \right\rceil \ \text{ for } D > M - H, \qquad \text{offset}_i = \frac{(i - 1)\, d_{\max}}{8}, \qquad \text{last data} = D - (k - 1)\, d_{\max} .

The first k−1k - 1 fragments carry dmax⁡d_{\max} each and the last carries the rest, which may be up to M−HM - H. The shortcut ⌈D/dmax⁡⌉\lceil D / d_{\max} \rceil gives the same count except when D>dmax⁡D > d_{\max} and DD exceeds a multiple of dmax⁡d_{\max} by 1 to s=(M−H)−dmax⁡s = (M - H) - d_{\max} bytes (the 0 to 7 bytes of slack the last fragment may use), where it counts one fragment too many; so the two always agree when M−HM - H is a multiple of 8 (s=0s = 0, as for MTU 1500 or 1420), and Example 1 shows a case where they differ.

Extra header bytes =(k−1)H= (k - 1) H.

Reading a fragment backwards. A fragment with offset ff, total length TT and header 4×IHL4 \times \text{IHL} holds data bytes 8f8f to 8f+(T−4 IHL)−18f + (T - 4\,\text{IHL}) - 1. It is the first fragment exactly when f=0f = 0 and MF = 1, the last when MF = 0 and f>0f > 0, and a middle one when f>0f > 0 and MF = 1. From the last fragment, the original data length is 8f+(T−4 IHL)8f + (T - 4\,\text{IHL}).

Loss. If each fragment is lost independently with probability pp, the datagram survives with probability (1−p)k(1 - p)^k: fragmentation multiplies the loss rate roughly by kk for small pp.

Worked examples

Example 1: an MTU that is not 20 plus a multiple of 8

3000 data bytes, MTU 1006. 1006−20=9861006 - 20 = 986, and dmax⁡=8⌊986/8⌋=984d_{\max} = 8 \lfloor 986 / 8 \rfloor = 984, not 986.

FragmentDataTotal lengthOffsetMF
1984100401
298410041231
398410042461
448683690

Using 986 would give offsets of 123.25, which cannot be written.

With 2954 data bytes instead, the fragments are 984, 984 and 986 (RFC 791 cuts off dmax⁡d_{\max} bytes only while the rest does not fit): the last may use all 986 bytes the MTU allows, so k=1+⌈(2954−986)/984⌉=3k = 1 + \lceil (2954 - 986)/984 \rceil = 3. The shortcut ⌈2954/984⌉=4\lceil 2954 / 984 \rceil = 4 is wrong here.

Example 2: fragmenting a fragment

Fragment 1 of the main example (1400 data bytes, offset 0, MF 1) and fragment 4 (920 data bytes, offset 525, MF 0) meet a link with MTU 620, so dmax⁡=600d_{\max} = 600.

FromPieces (data, offset, MF)
Fragment 1(600, 0, 1), (600, 75, 1), (200, 150, 1)
Fragment 4(600, 525, 1), (320, 600, 0)

Offsets stay relative to the original datagram. Every piece of fragment 1 has MF = 1, including its last, because more of the original follows; only the last piece of fragment 4 has MF = 0.

Example 3: from one fragment to the original

A fragment arrives with IHL 5, total length 420, offset 300 and MF 0. Its data is 400 bytes, bytes 2400 to 2799. It is the last fragment, so the original carried 2800 data bytes and had total length 2820 (with a 20-byte header).

Example 4: loss amplification

With p=0.01p = 0.01 per fragment and k=4k = 4 fragments, the datagram is lost with probability 1−0.994≈0.03941 - 0.99^4 \approx 0.0394, almost four times the per-fragment rate.

Example 5: a header with options

A datagram with IHL 6 (a 24-byte header) carries 3000 data bytes to a link with MTU 1500. If every fragment carries the 24-byte header, dmax⁡=8⌊1476/8⌋=1472d_{\max} = 8 \lfloor 1476 / 8 \rfloor = 1472: data 1472, 1472 and 56 bytes, offsets 0, 184 and 368, MF 1, 1 and 0, total lengths 1496, 1496 and 80. RFC 791 copies an option into every fragment only if the option's copied flag is set. If it is not set, only the first fragment has the 24-byte header and the later ones have 20 bytes, which gives data 1472, 1480 and 48 with offsets 0, 184 and 369. A question with options must say which case applies.

Example 6: total length is not data length

A datagram of total length 4000 bytes (20-byte header) meets MTU 1500. Its data is 3980 bytes: fragments of 1480, 1480 and 1020 data bytes, total lengths 1500, 1500 and 1040, offsets 0, 185 and 370. Treating 4000 as the data length gives a wrong last fragment of 1040 data bytes.

Important properties and observations

  • Routers fragment, hosts reassemble. No router reassembles; fragments may take different paths.
  • Any fragment can be fragmented again; offsets always refer to the original data.
  • The header is replicated, not split. Each fragment's total length includes its own header.
  • Identification groups fragments, together with source, destination and protocol.
  • Minimum sizes. Every IPv4 module must forward a datagram of 68 bytes without further fragmentation, and every host must accept a reassembled datagram of 576 bytes (RFC 791).

Common misconceptions.

  • "Offset counts bytes." It counts 8-byte units.
  • "Fragment data is MTU minus 20." Only if that is a multiple of 8; otherwise round down to one, except in the last fragment.
  • "The last piece of any fragment has MF = 0." Only if that piece ends the original datagram.
  • "Lost fragments are retransmitted." The whole datagram is lost; any recovery is up to TCP.
  • "The original header is counted as data." The data excludes the header.

Related material. IPv6 routers never fragment; only the source may, using a fragment extension header, after path MTU discovery.

GATE examination perspective

  • Fragment table. Compute dmax⁡d_{\max} first, rounding down to a multiple of 8; then sizes, offsets (bytes / 8), total lengths (data + 20) and MF bits.
  • Reverse questions. From offset, total length and MF: data range, position (first, middle, last), original length.
  • Two-stage fragmentation. Offsets relative to the original; MF inherited by the last sub-fragment.
  • Count of fragments and overhead. k=⌈D/dmax⁡⌉k = \lceil D / d_{\max} \rceil when MTU−20\text{MTU} - 20 is a multiple of 8; otherwise remember the last fragment may hold up to MTU−20\text{MTU} - 20 bytes. Extra bytes (k−1)×20(k - 1) \times 20.
  • DF set. Discard plus ICMP type 3 code 4, not fragmentation.
  • Total length or data? Subtract the header first when the question gives the datagram's total length (Example 6).

Summary

Sources

  1. A. S. Tanenbaum, D. J. Wetherall, Computer Networks, 5th ed., Pearson, 2011: Sections 5.5.5 (Packet Fragmentation) and 5.6.1 (The IP Version 4 Protocol).
  2. B. A. Forouzan, Data Communications and Networking, 5th ed., McGraw-Hill, 2013: Chapter 19 (Network-Layer Protocols).
  3. J. Postel (Ed.), RFC 791, Internet Protocol, 1981, Sections 2.3 (Function Description: fragmentation), 3.1 (Internet Header Format, including the copied flag of options) and 3.2 (Discussion: fragmentation and reassembly, the 68-byte and 576-byte minimums), (consulted 2026-11-11).
  4. J. Postel, RFC 792, Internet Control Message Protocol, 1981 (Destination Unreachable, code 4), (consulted 2026-11-11).
  5. J. Mogul, S. Deering, RFC 1191, Path MTU Discovery, 1990, Section 2 (Protocol overview), (consulted 2026-11-11).

Next steps