IP fragmentation is an Internet Protocol (IP) process that breaks packets into smaller pieces (fragments), so that the resulting pieces can pass through a link with MTU (maximum transmission unit) smaller than the original packet size. Fragmentation is done by intermediary devices such as routers and the reassembly of fragments is done at the destination. Reassembly is not done at the routers because:
- Fragmented data units may reach the destination through independent paths.
- There may be a need for further fragmentation.
IP Packet fields used in Fragmentation:
Identification field: The receiver of the fragments uses the identification field (16 bit) to ensure that fragments of different packets are not mixed. Fragments belonging to the same packet have the same identification number.
Fragment offset field: The fragment offset field (13 bits) tells the receiver the position of a fragment in the original packet. It indicates the number of data bytes ahead of the given fragment.
FO = (the number of data bytes ahead of the given fragment)/8
1: MF flag (1 bit): More fragment bit tells if more fragments are ahead of this fragment i.e. if MF = 1, more fragments are ahead of this fragment and if MF = 0, it is the last fragment.
2: DF flag (1 bit): Don’t fragment bit is used to decide whether to fragment a given packet or not. When we don’t want the packet to be fragmented then DF is set (i.e. DF = 1). Any packet so marked is not to be fragmented under any circumstances. If packet with DF set as 1 cannot be delivered to its destination without fragmention, it is to be discarded instead.
Case 1: Size of the packet ≤ MTU:
If size of the packet is found to be smaller than or equal to MTU then in this case the router will transmit the packet without any fragmentation.
Case 2: Size of the packet > MTU:
- When DF = 1
If size of the packet is found to be greater than MTU and DF bit is set to 1 then in this case the router will discard the packet.
- When DF = 0
If size of the packet is found to be greater than MTU and DF bit is set to 0 then in this case the router will divide the packet into fragments of size less than or equal to MTU. The amount of data sent in one fragment is chosen such that:
- It is as large as possible but less than or equal to MTU.
- It is a multiple of 8 so that pure decimal value can be obtained for the fragment offset field.
- It is not compulsory for the last fragment to contain the amount of data that is a multiple of 8.
Fragmentation of a packet increases the overhead. This is because after fragmentation, IP header has to be attached with each fragment.
Overhead= (Total number of fragments — 1) x size of IP header
Efficiency = actual data bytes / Total bytes transferred