IP Fragmentation – Calculating Total Length and Payload of IP Datagram

datafragmentationipv4mturouting

I do not understand how to fragment a IP datagram.

Let's say the original datagram has a total size of 302 (20bytes header and 282 bytes payload). My datagram needs to be fragmented since it goes through a network of 128MTU. I have to fragment it and add 20 header for each new fragments.

  • Fragment 1 124 total length (104 bytes payload)

  • Fragment 2 124 total length (104 bytes payload)

  • Fragment 3 94 total length (74 bytes payload)

If I addition that it gives me indeed the original payload. I do not understand how to find those numbers…

Why couldn't it be

  • Fragment 1 114 total length (94 bytes payload)
  • Fragment 2 114 total length (94 bytes payload)
  • Fragment 3 114 total length (94 bytes payload)

(282/128(MTU)) > 2 so I need 3 fragments. 3Fragments = 60 bytes header added
60 +282 = 342 342/3 = 114 total lenght for each fragments.

My question is…

How and why should I get 124 124 and 94?

Best Answer

The IP fragmentation and reassembly is described by the RFCs. You must fragment on 64-bit boundaries. There are RFCs dealing with this, and other sites which will describe the fragmentation and reassembly process in depth; you can do a search to find them

Start with RFC 791, INTERNET PROTOCOL:

To fragment a long internet datagram, an internet protocol module
(for example, in a gateway), creates two new internet datagrams and
copies the contents of the internet header fields from the long
datagram into both new internet headers. The data of the long
datagram is divided into two portions on a 8 octet (64 bit) boundary
(the second portion might not be an integral multiple of 8 octets,
but the first must be). Call the number of 8 octet blocks in the
first portion NFB (for Number of Fragment Blocks). The first
portion of the data is placed in the first new internet datagram,
and the total length field is set to the length of the first

Related Topic