IPv4 datagram fragmentation mechanism: working principle and application considerations

When the length of an IP datagram exceeds the MTU of the frame, it will be transmitted in fragments. This process may happen on the sending end or on the transit router, and may be fragmented multiple times during the transmission process, but only on the final target machine, these fragments will be reassembled by the IP module in the kernel. This kind of fragmentation transmission allows datagrams to be transmitted in the network without being unable to transmit because the MTU is exceeded.

The three fields in the IP header: datagram identifier, flag and slice offset provide enough information for IP fragmentation and reassembly. The datagram identifier is a 16-bit field used to identify a datagram. When a datagram must be fragmented because its length exceeds the network MTU, this value will be copied to the identifier field of all datagram fragments. In this way, during reassembly, datagram fragments with the same identifier will be reassembled into a complete datagram.

548d56412430c9b7dd6005f39518a168.jpeg

The flag field is a 3-bit field, the lowest bit of which is called MF, MF=1 means that there are several datagram fragments behind, and MF=0 means that this is the last datagram fragment. The middle bit is called DF, and DF means that fragmentation cannot be performed, and only when DF=0 can fragmentation be performed. These two flag fields provide enough information for fragmentation and reassembly of IP datagrams.

The slice offset field is a 13-bit field that indicates the relative position of a slice in the original datagram. The length of each fragment is an integer multiple of 8 bytes, and the last fragment is filled if it is less than 8 bytes. Therefore, each fragment of an IP datagram has its own IP header with the same identification value but different fragment offsets. All but the last shard will have the MF flag set. Additionally, the total length field of each fragment's IP header will be set to the length of that fragment.

2a5192e28a75f7becbaedd2e04ffe8e6.jpeg

Although the IP fragmentation mechanism can allow datagrams to be transmitted in the network, it will also bring certain problems. Fragmentation may increase the delay of network transmission and also increase the risk of network congestion. Therefore, in practical applications, it is necessary to rationally use the IP fragmentation mechanism according to network conditions and transmission requirements.

In addition, it should be noted that the IP fragmentation mechanism is only applicable to the IPv4 protocol, and the IP fragmentation mechanism has been canceled in the IPv6 protocol. Instead, the datagram is divided into data blocks that meet the MTU size for transmission at the sending end, so IPv6 The transmission efficiency of the protocol is higher, and the delay is smaller.

In short, the three fields of datagram identifier, flag and fragment offset in the IP header provide enough information for IP fragmentation and reassembly, so that IP datagrams can be fragmented and transmitted in the network, and can also be fragmented. The IP blocks in the kernel are reassembled. For network and computer-related staff, understanding the IP fragmentation mechanism is an essential knowledge point. At the same time, it is also necessary to use the IP fragmentation mechanism reasonably according to the actual situation to improve network transmission efficiency and reduce the risk of network congestion.

Guess you like

Origin blog.csdn.net/qq_40427481/article/details/132725012