IP Fragmentation and MTU Explained: IPv4 Formula, Worked Examples and Exam Traps
Learn how IPv4 fragmentation works, calculate fragment sizes and offsets step by step, and catch the alignment and MF mistakes that commonly spoil correct answers.
KnowledgeGate Team
Exam prep & CS education

IPv4 fragmentation becomes mechanical once Total Length, payload length and eight-byte Fragment Offset units stay separate. A fragment can split again on a smaller-MTU link, but every new offset still points into the original payload. The GATE CS Exam Preparation hub places this calculation in the wider network-layer sequence.
1. MTU and fragmentation: build the packet-level picture
The maximum transmission unit, or MTU, is the largest IP packet a link can carry without fragmentation. The path MTU is the smallest MTU on the end-to-end route.
An IPv4 packet's Total Length includes its header and data. When it exceeds an outgoing link's MTU, a router can fragment it only if fragmentation is allowed. Every fragment is a separate IP packet with its own header. For the addressing foundation, revise IP Addressing and Subnetting Explained.
For a 1500-byte MTU and a 20-byte IPv4 header, the apparent data capacity is 1480 bytes. That value must also satisfy the 8-byte alignment rule before it can be used for a non-final fragment.
2. The IPv4 fields and formula that control the split
Track four header fields:
Total Length is the fragment's header plus data.
Identification is copied to every fragment so the destination can associate the pieces.
MF, or More Fragments, is 1 when more original data follows and 0 only on the final piece.
Fragment Offset is the start position within the original payload, in units of 8 bytes.
The reusable formula is:
maximum non-final fragment data = floor((MTU - header bytes) / 8) x 8
Subtract the header because MTU limits the whole fragment. Round down because the next start must be representable in 8-byte units. Only non-final payloads require this alignment.
Assume IPv4, no header options, a 20-byte header, no existing fragmentation and byte units. A larger IHL leaves less room for data.
3. Worked example: 4000-byte IPv4 datagram over MTU 1500
The IPv4 and Network Layer Protocols guide connects fragmentation to the rest of the header, addressing, ARP, ICMP, DHCP and NAT. The same 4000-byte baseline continues through byte conservation, extra-header overhead and re-fragmentation on a second link.
Suppose the original Total Length is 4000, the header is 20, DF is 0 and Identification is 4242. The original payload is:
4000 - 20 = 3980 bytes
The largest aligned non-final payload is:
floor((1500 - 20) / 8) x 8 = floor(1480 / 8) x 8 = 185 x 8 = 1480 bytes
The fragment count is ceil(3980 / 1480) = 3.
Fragment | Original payload bytes | Data length | Header | Total Length | Fragment Offset | MF | Identification |
|---|---|---|---|---|---|---|---|
1 | 0-1479 | 1480 | 20 | 1500 | 0 | 1 | 4242 |
2 | 1480-2959 | 1480 | 20 | 1500 | 185 | 1 | 4242 |
3 | 2960-3979 | 1020 | 20 | 1040 | 370 | 0 | 4242 |
Fragment 2 begins after 1480 original data bytes, so its offset is 1480 / 8 = 185. Fragment 3 begins after 2960 bytes, so its offset is 2960 / 8 = 370.
Now check conservation: 1480 + 1480 + 1020 = 3980 data bytes. The transmitted IP bytes total 1500 + 1500 + 1040 = 4040. That is 40 bytes above the original 4000 because fragmentation introduced two extra 20-byte headers.

4. Re-fragmentation on a smaller-MTU link
An outgoing link later in the route may have a smaller MTU. This is a link constraint, not something caused by the routing algorithm itself.
Take Fragment 1 above, which contains 1480 data bytes, and send it onto a link with MTU 620. Its new maximum aligned data size is:
floor((620 - 20) / 8) x 8 = 600 bytes
It splits into data lengths 600, 600 and 280. Their Total Length values are 620, 620 and 300. Their offsets are 0, 600 / 8 = 75 and 1200 / 8 = 150.
These offsets still refer to the original 3980-byte payload, not to a new local payload. All three pieces have MF = 1 because their incoming fragment had MF = 1. Even after byte 1479, more data from the original datagram still follows.

5. DF, reassembly and a lost fragment
With DF = 0, the original 4000-byte packet can split for the 1500-byte link as calculated. With DF = 1, a router cannot fragment it. The router drops the packet and normally returns an ICMP message indicating that fragmentation was needed, allowing the source to use a smaller packet as part of Path MTU Discovery.
IPv4 reassembly happens at the destination, not at each intermediate router. The destination groups fragments using matching header information and places their data using the offsets. If any piece is unavailable, it cannot reconstruct and deliver the complete original datagram upward. Any recovery beyond that depends on the transport protocol or application design, not on IPv4 fragmentation itself.
IPv6 routers do not fragment packets in transit. When IPv6 fragmentation is needed, the source handles it.
6. Fragmentation traps to catch before submitting
Correct these common wrong moves:
Divide MTU by 8: subtract the IPv4 header first.
Write the offset in bytes: divide the original-data start position by 8.
Give every fragment MF = 1: the final piece of the original datagram has MF = 0.
Force the final payload to a multiple of 8: only non-final payloads need that alignment.
Treat MTU as a data limit: it limits each fragment's Total Length.
Forget headers: every fragment carries its own IP header.
Reset offsets during re-fragmentation: they remain relative to the original payload.
Do not assume a 20-byte header unless the question gives no options or supplies an IHL that confirms it. Before accepting an answer, verify that every Total Length is within the MTU, every non-final data length is divisible by 8, the offsets describe contiguous byte ranges and all data lengths sum to the original payload.
7. How exams turn these rules into questions
Common exam-style constructions ask you to find fragment count and sizes, fill Total Length, Offset and MF, infer a byte position from an offset, calculate header overhead or re-fragment an existing fragment.
Drill A: Total Length 2020, header 20 and MTU 700 give a payload of 2000. Maximum non-final data is floor(680 / 8) x 8 = 680, so the split is 680, 680 and 640. Total Length values are 700, 700 and 660; offsets are 0, 85 and 170; MF values are 1, 1 and 0.
Drill B: Fragment Offset 125 means that the fragment starts at original payload byte 125 x 8 = 1000. It does not mean byte 125.
After solving these without notes, the GATE Test Series is an optional way to practise similar calculations under time pressure.
8. The short version and next step
Subtract the header before finding data capacity. Round non-final data down to an 8-byte multiple. Measure every offset from the original payload. Set MF = 0 only on the final piece of that original datagram.
For the 4000-byte datagram and MTU 1500, the three Total Length values are 1500, 1500 and 1040, with offsets 0, 185 and 370.
Recompute that table without looking. Then change the MTU from 1500 to 1000 and rebuild it. If you want a broader guided study plan, GATE Guidance by Sanchit Sir is an optional next step; the GATE catalogue linked at the beginning provides the wider route.
Keep learning
Fragmentation & MTU MCQs: 12 Solved IPv4 Questions with Explanations
Solve 12 IPv4 fragmentation questions covering MTU capacity, fragment offset, re-fragmentation, loss and IP overhead. Each answer shows the working.
IPv4 Header and Fragmentation for GATE: Offset, MTU and TTL Numericals Solved
Decode the IPv4 header, split a 4000-byte datagram across a 1500-byte MTU, and verify every offset, flag and fragment length.
IP Options and Padding Explained: IHL, Alignment and a Worked IPv4 Header
Learn to locate the IPv4 options area, calculate padding, decode a Record Route option byte by byte, and find the payload boundary without guessing.
IPv4 Basics Explained: Header Fields, Checksum and Packet Forwarding
Decode a complete IPv4 header, verify its checksum with one's-complement arithmetic, and follow the datagram from Host A through two routers. See exactly what changes at each hop and what remains end to end.





