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.

KnowledgeGate Team

Exam prep & CS education

Updated 3 Sep 20265 min read

IPv4 fragmentation numericals usually fail because three fields use three different units. Fragment Offset counts 8-byte blocks, Total Length counts bytes and includes the header, while IHL counts 32-bit words. Keep those units visible and a long-looking datagram question becomes a short calculation.

The IPv4 header, field by field

An IPv4 header is at least 20 bytes when no options are present and can grow to 60 bytes with options. These are the fields most often tested:

Field

Width

What it tells you

Version

4 bits

The IP version, 4 for IPv4

IHL

4 bits

Header length in 32-bit words

Total Length

16 bits

Header plus data, in bytes

Identification

16 bits

The common identifier carried by all fragments

Flags

3 bits

Reserved, DF and MF

Fragment Offset

13 bits

Data position in units of 8 bytes

TTL

8 bits

Remaining router-hop allowance

Protocol

8 bits

Encapsulated upper-layer protocol

Header Checksum

16 bits

Check over the IPv4 header

Source Address

32 bits

Sender's IPv4 address

Destination Address

32 bits

Receiver's IPv4 address

Two conversions deserve a permanent place in your rough work:

Header length = IHL x 4 bytes

Data length = Total Length - Header length

For example, IHL = 5 means 5 x 4 = 20 header bytes. IHL = 7 means 28 header bytes, not 7.

Diagram of the IPv4 header in 32-bit rows, with the Identification, Flags and Fragment Offset fields marked for fragmentation.

The fragmentation rules

An IPv4 router may fragment a datagram when it is larger than the outgoing link's maximum transmission unit, or MTU, provided DF is 0. If DF is 1, fragmentation is forbidden.

For a fixed header size, calculate the normal fragment payload as:

payload = floor((MTU - header) / 8) x 8

Rounding down matters because every non-last fragment must carry a multiple of 8 data bytes. The final fragment may carry the remainder.

Fragment Offset is not a byte address. It is the position of that fragment's first data byte in the original payload, divided by 8. MF, or More Fragments, is 1 on every fragment except the last. All fragments from the same original datagram keep the same Identification value.

Reassembly happens only at the final destination. An intermediate router can fragment an IPv4 fragment again if required, but it does not reassemble fragments on the way.

Fully worked fragmentation numerical

Take an original IPv4 datagram with Total Length = 4000 bytes. It has a 20-byte header, so its data is:

4000 - 20 = 3980 bytes

The next link has MTU = 1500 bytes. The maximum data in a normal fragment is:

1500 - 20 = 1480 bytes

Check the required unit: 1480 / 8 = 185 exactly, so no further rounding is needed. The number of fragments is:

ceil(3980 / 1480) = ceil(2.689...) = 3

Now fill every fragment from the data position, not by guessing the offset:

Fragment

Original data bytes

Data length

Offset

MF

Total Length

F1

0 to 1479

1480

0 / 8 = 0

1

1480 + 20 = 1500

F2

1480 to 2959

1480

1480 / 8 = 185

1

1480 + 20 = 1500

F3

2960 to 3979

1020

2960 / 8 = 370

0

1020 + 20 = 1040

Verify the payload first: 1480 + 1480 + 1020 = 3980 bytes, exactly the original data. Verify the byte ranges independently: 0 to 1479 contains 1480 bytes, 1480 to 2959 contains 1480, and 2960 to 3979 contains 1020. There is no gap and no overlap.

A 4000-byte datagram split into three fragments over a 1500-byte MTU link, showing each fragment offset, MF flag and length.

Do not add the three Total Length values to recover 4000. Each fragment carries its own 20-byte header, so fragmentation adds header overhead. Reconstruct the original by adding only their data lengths.

When MTU minus header is not a multiple of 8

Change the outgoing link to MTU = 576 bytes and the rounding rule starts to bite. The space left for data is:

576 - 20 = 556 bytes

But 556 / 8 = 69.5, which is not a whole number of 8-byte blocks, so a non-last fragment may carry only:

floor(556 / 8) x 8 = 69 x 8 = 552 bytes

The same 3980 data bytes now need ceil(3980 / 552) = ceil(7.21...) = 8 fragments. Seven of them carry 552 bytes each, which accounts for 7 x 552 = 3864 bytes, so the eighth carries 3980 - 3864 = 116 bytes.

That last fragment has Offset = 3864 / 8 = 483, MF = 0 and Total Length = 116 + 20 = 136 bytes. The 4 bytes per fragment you gave up to rounding (556 minus 552) are unused link capacity, not a mistake in the arithmetic.

TTL and the hop count, quickly

Every router handling an IPv4 datagram decreases TTL by 1. If the decrement makes TTL zero, the router discards the datagram and normally sends an ICMP Time Exceeded message to the source. Traceroute uses this behaviour by sending probes with TTL values 1, 2, 3 and so on.

Suppose a datagram starts with TTL = 64 on a path containing 65 routers. Router 1 reduces it from 64 to 63. Following the same pattern, router 63 reduces it from 2 to 1. Router 64 reduces it from 1 to 0 and discards it. It never crosses router 65.

The traps GATE plants

  • Writing a byte offset into the field. A fragment beginning at data byte 1480 carries Offset = 1480 / 8 = 185.

  • Forgetting the 8-byte rule. Round the non-last payload down to a multiple of 8, even if MTU minus header is not divisible by 8.

  • Treating Total Length as data length. Subtract IHL x 4 before splitting the payload.

  • Mixing IHL and offset units. IHL uses 4-byte words; Fragment Offset uses 8-byte blocks.

  • Reversing MF. MF is 1 when more data follows and 0 only on the last fragment.

  • Changing Identification. Fragments belonging to one original datagram share it.

  • Reassembling at a router. Only the destination reassembles.

A compact scratch-work header helps: write HL, payload, offset unit and MF before calculating.

How the exam tests IPv4 fragmentation

Common formats ask for the number of fragments, the kth fragment's offset, MF and DF values, the last fragment's Total Length, TTL behaviour or a decoded field from a hexadecimal header. Confirm the current Computer Networks scope on the organising institute's official GATE 2027 syllabus page.

If the field layout still feels detached from addressing, revisit IP Addressing and Subnetting: Worked Example, Exam Angle. Then use Computer Networks Subnetting MCQs to practise unit-sensitive network-layer questions.

The short version and next step

Use payload = MTU minus header, rounded down to a multiple of 8 for non-last fragments. Divide the starting data byte by 8 for Offset. Set MF to 1 except on the last fragment, and remember that Total Length includes the header.

KnowledgeGate has about 2,400 Computer Networks questions available for practice, including IP and fragmentation. Drill the numericals in the GATE Test Series, build the surrounding network-layer theory with GATE Guidance by Sanchit Sir, and use the GATE preparation category to connect this topic to the rest of your plan.