Determine if IPv4 packet is fragmented

7.4k Views Asked by At

What is the right way to test if IP packet is a fragment?
Currently I only look at MF (More Fragments) bit in the IPv4 header. Is it sufficient?

1

There are 1 best solutions below

0
Ron Maupin On BEST ANSWER

That is insufficient because the last packet fragment will not have the MF flag set. You must also look at the Fragment offset field, but that by itself is not sufficient because the first packet fragment will have that field set to 0.

If the Fragment Offset field > 0 then it is a packet fragment, or if the Fragment Offset field = 0 and the MF flag is set then it is a fragment packet.