Analysis of fragmentation and recombination of IP datagram

Source: Internet
Author: User

This article is reproduced from http://soft.chinabyte.com/339/9020339.shtml


In the previous article, we learned about the role of the TTL field for IP datagrams in network analysis and how to analyze network failures through TTL. In fact, in the IP protocol header, in addition to the TTL field, there are several fields are very important, this is what we are discussing today, the identifier, flag bit and offset, these 3 fields in the IP datagram Shard and reorganization, is very important field.


We all know that different types of networks, their MTU (Maximum transmission unit) are not the same, such as Ethernet, the maximum transmission frame is 1518 bytes, FDDI is 4500 bytes, Token ring frame between 4500 bytes to 17800 bytes, and an important function of IP protocol, is the ability to segment the transmitted data over the MTU of the hardware interface. That is, a datagram larger than the MTU will be divided into 2 or more appropriate sizes to be transmitted. A shard may also continue to be fragmented in the path to the receiving host, so that the Shard's IP datagram may be transferred to the receiving host with a different path, and the receiving host is restored to a full IP datagram through a series of reorganizations, which are then submitted to the upper layer protocol processing.

IP identifier IP identifier, flag, offset 3 fields are located in the IP header as shown in Figure 1 below:


Figure 1


Before sending the datagram, the sending host gives each datagram an ID value, placed in the 16-bit identifier field. This ID is used to identify a unique datagram or data stream. The receiving host uses this ID to reorganize the received datagrams. As mentioned earlier, when the IP datagram of a shard is sent from the source address to the destination, due to network latency or a different transmission path, these shard datagrams are not always ordered, but are in an unordered state when the destination host is reached. The receiving host uses this ID to determine whether the received Shard datagrams belong to the same data stream and then regroup (the reorganization will be discussed in the offset).



Sign

The flag field occupies 3 bits in the IP header, 1th place as a reservation, set 0, 2nd bit, segmented, there are two different values: the position 0, indicating that it can be segmented; the position 1 means that it cannot be segmented; 3rd bit, more segments, and two values: the position 0, which is the last segment in the data flow, the position 1, Indicates that the data flow is not complete, and that there are further fragments, when a datagram has no fragmentation, the position is 0, indicating that this is the only segment. See Figure 2 below:




Figure 2

When the destination host receives an IP datagram, it first looks at the datagram identifier, and checks that the 3rd bit of the flag bit is set to 0 or 1 to determine if there are more segments, and if there are subsequent messages, the receiving host puts the received message in the cache until all the datagrams with the same identifier are received. Then the reorganization.


More segments allow the receiving host to determine whether the datagram of the Shard is sent, and in addition to the segmentation of the datagram, but also to achieve another purpose, in some cases, can be used to dynamically find the network end-to-end MTU size. If the router is configured with this bit at 0, when the host attempts to send a frame that is larger than the datagram on the transmission path, the router does not forward the frame, but discards it and sends an ICMP message to the source host indicating that the datagram is too large for the source host to resize the datagram and resend it.


The


Offset

13-bit offset field is used to represent the position of the segmented datagram across the entire data stream, which is equivalent to the sequential number of the Shard datagram. The sending host offsets the first datagram by 0, and the subsequent Shard datagram offsets are assigned to the network's MTU size. Offset this is a key field when the receiver is reorganizing the data. The data segment (in bytes) for a shard must be an integer multiple of 8, otherwise the IP cannot express its offset. As shown in Figure 3 below:


Figure 3

Ethernet, if the source host needs to transfer 3000 bytes of data through UDP to the destination host, then the segmentation situation as shown in Figure 4 (on the same network segment):

Figure 4

Here Note that for the header of the Shard 1, the header cost of the 8-byte UDP protocol is more than the header of the other two shards, so when calculating the actual transmitted data payload, Shard 1 subtracts the 8-byte UDP header. Finally, the receiving host reorganizes the data into a full datagram by this offset value.

Summary

The IP protocol is a common protocol, but for its header structure, the meaning of each field in the header requires that we continue to learn to truly understand the essence of the IP protocol. In this, I hope that all of you brothers to exchange, we learn together.

        Original from "Bit network", reproduced please keep the original link: http://soft.chinabyte.com/339/9020339.shtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.