4

I read somewhere that a fragmented ip packet can further be fragmented depending on the changes in the network.

Now how is the packet reassembled at the router. Because the identification bit can be used for one set of packets. Can someone give an example

Secondly, is the identification number randomly chosen or does it have some specific algorithm behind it.

And finally, what is the significance of the reserved bit used in the IP flag

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Aug 15 '17 at 2:55
5

The Fragmentation and reassembly section of the IPv4 Wikipedia article explains it quite well:

Fragmentation and reassembly Main article: IP fragmentation

The Internet Protocol enables networks to communicate with one another. The design accommodates networks of diverse physical nature; it is independent of the underlying transmission technology used in the Link Layer. Networks with different hardware usually vary not only in transmission speed, but also in the maximum transmission unit (MTU). When one network wants to transmit datagrams to a network with a smaller MTU, it may fragment its datagrams. In IPv4, this function was placed at the Internet Layer, and is performed in IPv4 routers, which thus only require this layer as the highest one implemented in their design.

In contrast, IPv6, the next generation of the Internet Protocol, does not allow routers to perform fragmentation; hosts must determine the path MTU before sending datagrams.

Fragmentation

When a router receives a packet, it examines the destination address and determines the outgoing interface to use and that interface's MTU. If the packet size is bigger than the MTU, and the Do not Fragment (DF) bit in the packet's header is set to 0, then the router may fragment the packet.

The router divides the packet into fragments. The max size of each fragment is the MTU minus the IP header size (20 bytes minimum; 60 bytes maximum). The router puts each fragment into its own packet, each fragment packet having following changes:

  • The total length field is the fragment size.
  • The more fragments (MF) flag is set for all fragments except the last one, which is set to 0.
  • The fragment offset field is set, based on the offset of the fragment in the original data payload. This is measured in units of eight-byte blocks.
  • The header checksum field is recomputed.

For example, for an MTU of 1,500 bytes and a header size of 20 bytes, the fragment offsets would be multiples of (1500–20)/8 = 185. These multiples are 0, 185, 370, 555, 740, ...

It is possible for a packet to be fragmented at one router, and for the fragments to be fragmented at another router. For example, consider a Transport layer segment with size of 4,500 bytes, no options, and IP header size of 20 bytes. So the IP packet size is 4,520 bytes. Assume that the packet travels over a link with an MTU of 2,500 bytes. Then it will become two fragments:

enter image description here

Note that the fragments preserve the data size: 2480 + 2020 = 4500.

Note how we get the offsets from the data sizes:

0.
0 + 2480/8 = 310.

Assume that these fragments reach a link with an MTU of 1,500 bytes. Each fragment will become two fragments:

enter image description here

Note that the fragments preserve the data size: 1480 + 1000 = 2480, and 1480 + 540 = 2020.

Also in this case, the More Fragments bit remains 1 for ALL the fragments that came with 1 in them and for the last fragment that arrives, it works as usual, that is the MF bit is set to 0 only in the last one. And of course, the Identification field continues to have the same value in all re-fragmented fragments. This way, even if fragments are re-fragmented, the receiver knows they have initially all started from the same packet.

Note how we get the offsets from the data sizes:

0.
0 + 1480/8 = 185
185 + 1000/8 = 310
310 + 1480/8 = 495

We can use the last offset and last data size to calculate the total data size: 495*8 + 540 = 3960 + 540 = 4500.

Reassembly

A receiver knows that a packet is a fragment if at least one of the following conditions is true:

  • The "more fragments" flag is set. (This is true for all fragments except the last.)
  • The "fragment offset" field is nonzero. (This is true for all fragments except the first.)

The receiver identifies matching fragments using the foreign and local internet address, the protocol ID, and the identification field. The receiver will reassemble the data from fragments with the same ID using both the fragment offset and the more fragments flag. When the receiver receives the last fragment (which has the "more fragments" flag set to 0), it can calculate the length of the original data payload, by multiplying the last fragment's offset by eight, and adding the last fragment's data size. In the example above, this calculation was 495*8 + 540 = 4500 bytes.

When the receiver has all the fragments, it can put them in the correct order, by using their offsets. It can then pass their data up the stack for further processing.

As for the reserved bit, it is reserved and must be zero and has no special significance.

  • I did read this first. But in the example, for the first fragmentation the I'd is chosen as say 10 , now each packet with I'd 10 is further fragmented with I'd 20 ,30 . Now at the host router how will the router know that 20 and 30 have to be further merged as 10 !? – john Mar 13 '17 at 16:06
  • there's no such ID as 10 / 20 / 30 (or even 1/2/3/4), the important part is the Fragment offset , combined with the "more fragment" flag. I'll try to clarify this when I have a moment – JFL Mar 13 '17 at 16:26
  • sure, I ll re frame the question a bit, in the above example, the 4500 byte packet is fragmented in to 2 packets say A and B. These both will have the same the identification number, the first packet will have the MF flag as set and the second will one will not, Now when A is further segmented(1500, 1020, 1500,560) bytes, all the 4 packets made from A will have the same ID and similarly for packet B. now at the destination router how will the packet A and B re assemble. – john Mar 13 '17 at 18:34
0

It's unlikely to have MRU different than the MTU. If fragmentation is needed on an already fragmented packet, the router treats it just like any other IP packet that needs fragmentation. The routers in the middle do not reassemble the packet. Reassembly is done at the destination. The routers simply fragment the packet and simply adjust the offset value. And for the IPID I don't think the routers change it(that's my guess), as the destination host is the one who is handling the reassembly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.