IP Slicing and reassembly

Source: Internet
Author: User

Shard : When a SKB packet is longer than the MTU of the transmission device or the physical device on the link, it is cut in a certain way, so that the message can be sent out . However, it is necessary to explain that the Shard is divided into IP and TCP shards, because TCP packets have their own mechanism to Shard, do not need to rely on the IP layer shard, and for UDP or ICMP and other messages, can only rely on the IP layer to shard .

the relationship between fragmentation and recombination : The IP protocol theoretically allows the maximum IP datagram to be 65535 bytes (16 bits to represent the total length of the packet). However, because the data link layer below the protocol stack network layer generally allows longer frames than this value, such as the MTU of the Ethernet (that is, the maximum transmission unit, the maximum transmission unit) is usually around 1500 bytes. If we need to transfer a byte 4600 of the data, then we need to divide it into four pieces. Therefore, the larger IP packets are sent to the data link layer by the Shard, the IP datagram of the Shard may be transmitted to the receiving host by a different path, and the receiving host is restored to a complete IP datagram by a series of reorganization, and then submitted to the upper layer protocol processing.

IP datagram Format:

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/84/67/wKioL1ePhx-xqHOvAAD3_f14CGw877.png-wh_500x0-wm_3 -wmp_4-s_1671124133.png "title=" Oh oh. PNG "alt=" Wkiol1ephx-xqhovaad3_f14cgw877.png-wh_50 "/>


When a packet of IP data is fragmented, it is reassembled only when it arrives at the destination, where the destination refers to the next station of the IP message delivery, not the final destination, so the fragmentation and reassembly process is transparent to the transport layer .

In the IP header, the 16-bit ID, 3-bit flag, and 13-bit segment offset are used for the fragmentation and reassembly of IP packets. Where the identification field is 16 bits long and is used to identify an IP datagram. In other words, when the sending side transmits a large packet of IP packets, the identity fields of each Shard are the same, representing that the shards belong to the same number of reports. The segment offset field is 13 bits, which indicates where the slice is located in the original datagram.

The flag field has three bits, where the first bit is unused, and the second bit is used to indicate whether to fragment the datagram, called the Do not fragment (DF) bit, if the value of the bit is set to 1, the datagram cannot be fragmented. If the datagram must be segmented, and the DF bit is also set to 1, the datagram is discarded and an ICMP error message is sent to the source, and the third is used to indicate whether there are more fragments after the current segment, and if this position is 0, indicates that the current segment is the last segment of the datagram.

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/84/67/wKiom1ePhc2h6cx4AAAas_bzAXg107.png-wh_500x0-wm_3 -wmp_4-s_1729570861.png "title=" Untitled. png "alt=" wkiom1ephc2h6cx4aaaas_bzaxg107.png-wh_50 "/>

Shard function:

ip_fragment (int ip_fragment (struct sk_buff *skb, int (*output) (struct Sk_buff *)))

First of all, ip_fragment must handle the following two scenarios:

<1> must be cut into small chunks of big data, to cut big data need to allocate new buffers, and in large buffers and small buffers see the memory copy.

<2> do not need to re-shard the data linked list or array, if the allocated buffer is enough space to add the L3 header and the L2 header, then ip_fragment processing these buffers does not require a memory copy. The IP layer is going to do

Reorganization function:

int Ip_defrag (struct sk_buff *skb,u32 user)

The advantage of IP sharding is that it provides a transparent transport pipeline for the upper layer protocol, so that the upper layer protocol does not have to care about the underlying hardware technology, the disadvantage is: in the transmission process, even if the loss of one piece of data to retransmit the entire datagram.

This article is from the "11440755" blog, please be sure to keep this source http://luodn.blog.51cto.com/11440755/1828331

IP Slicing and reassembly

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.