[0075] Example 3: The serial numbers of the packet fragments received by the network device are 2, 1, 4, 3, 6, and 5. According to the above method, the fragment receiving process is as follows Figure 4 shown.
[0076] Specifically, as Figure 4As shown, after receiving the packet fragment with the sequence number 2, the network device stores the packet fragment in the storage unit R[2], and after receiving the packet fragment with the sequence number 1, it stores the packet fragment in the storage unit R[2]. The message fragment is appended to the header of the fragment chain in the storage unit R[2], and the reorganized fragment chain is recorded in the storage unit R[2]. After receiving the message fragment with the sequence number 4 Then, the message fragment is stored in the storage unit R[4]. After receiving the message fragment with the sequence number 3, since the adjacent storage units before and after the storage unit R[3] are not empty, then Integrate the message fragment, the fragment chain of the storage unit R[2], and the fragment chain of the storage unit R[4], merge the integrated fragment chain into a new fragment chain, and store it in the storage In unit R[4], after receiving the tail piece message fragment with sequence number 6, the tail piece message fragment is stored in the storage unit R[6] to create a corresponding fragment chain, and after receiving After the packet with sequence number 5 is fragmented, since the adjacent storage units before and after storage unit R[5] are non-empty, the packet, the fragment chain of storage unit R[4], and storage unit R are fragmented. The shard chain of [6] is integrated into the shard chain of the storage unit R[6], and a new shard chain is obtained. Since the new shard chain has the first packet fragment and the last packet fragment flag, then integrate and submit the new shard chain.
[0077] In the packet reassembly method provided by the embodiment of the present invention, after receiving any packet fragment, the network device obtains the sequence number of the packet fragment, and determines its corresponding target storage unit according to the sequence number. If there is a shard chain in the adjacent storage unit of the target storage unit corresponding to the message fragment, any message fragment will be merged into the shard chain. If there is no shard chain in the adjacent storage unit, Then, in the target storage unit, create a fragmentation chain containing any of the message fragments, and finally, according to the fragmentation chain including the last fragment and the first fragment of the target message corresponding to the any of the message fragments, obtain the fragmentation chain. The target packet, so that in the process of receiving the packet fragmentation of the target packet, the packet reassembly can be realized, so that the network device can directly obtain all the packet fragments of the target packet. The fragmented chain of the target packet, and then the target packet is obtained, which not only improves the overall reassembly efficiency, but also reduces the packet transmission delay.
[0078] An embodiment of the present invention provides a network device, where the network device includes a plurality of continuous storage units for buffering packet fragments, such as Figure 5 As shown, the network device includes: a receiving module 21, an executing module 22 and an obtaining module 23, wherein:
[0079] The receiving module 21 is configured to obtain the serial number of the packet fragment after receiving any packet fragment, and determine the corresponding target storage unit according to the serial number of the packet fragment.
[0080] The execution module 22 is configured to merge any message fragment into the fragment chain if there is a fragment chain in the adjacent storage unit of the target storage unit corresponding to any message fragment received by the receiving module 21 , if there is no shard chain in the adjacent storage unit, then in the target storage unit, create a shard chain containing any of the packet shards.
[0081] The obtaining module 23 is configured to obtain the target packet according to the fragment chain including the last fragment and the first fragment of the target packet corresponding to any of the packet fragments.
[0082] Optionally, the above-mentioned adjacent memory cells include front adjacent memory cells and rear adjacent memory cells.
[0083] Optionally, in the case that any packet fragment is a non-tail packet packet fragment of the target packet, execute the module 22, which is specifically configured to: if any packet fragment corresponds to the previous adjacent storage of the target storage unit There is a first fragment chain in the unit, and a second fragment chain is stored in the adjacent storage unit, then the first fragment chain, the any packet fragment and the second fragment chain are reorganized, and Record the reorganized fragmentation chain in the next adjacent storage unit; if the previous adjacent storage unit is empty and there is a second fragmented chain in the next adjacent storage unit, any packet will be fragmented Append to the header of the second shard chain, and record the reorganized shard chain in the next adjacent storage unit; if the first shard chain exists in the former adjacent storage unit, and the latter adjacent storage unit is If it is empty, then any packet fragment is appended to the end of the first fragment chain, and the reorganized fragment chain is recorded in the target storage unit.
[0084] Optionally, in the case that any of the message fragments is the tail piece of the target message, the execution module 22 is specifically configured to: in the target storage unit, create a third fragment that includes the tail piece of the target message. Chain; determine whether there is a fourth shard chain in the preceding adjacent storage unit of the target storage unit corresponding to the tail piece of the target message, if so, append the fourth shard chain to the header of the third shard chain.
[0085] Optionally, the execution module 22 is further configured to: when the merged fragment chain includes the tail fragment of the target message, perform the following steps cyclically until the first fragment of the target message exists in the merged fragment chain Or the fifth shard chain is empty: According to the number of shards in the current merged shard chain, check whether there is a fifth shard chain in the storage unit offset by the corresponding amount forward, if so, then the fifth shard The chain is appended to the header of this merged shard chain.
[0086] In the network device provided by the embodiment of the present invention, after receiving any packet fragment, the network device obtains the sequence number of the packet fragment, and determines its corresponding target storage unit according to the sequence number. If there is a shard chain in the adjacent storage unit of the target storage unit corresponding to the shard, any packet shard will be merged into the shard chain. In the target storage unit, create a fragmentation chain including the fragmentation of any message, and finally obtain the target fragmentation chain according to the fragmentation chain including the tail fragment and the first fragment of the target message corresponding to the fragmentation of any message. Therefore, in the process of receiving the packet fragmentation of the target packet, packet reassembly can be realized, so that the network device can directly obtain the target packet after obtaining all the packet fragments of the target packet. The fragmentation chain of the message, and then the target message is obtained, which not only improves the overall reassembly efficiency, but also reduces the transmission delay of the message.
[0087] An embodiment of the present invention provides a schematic diagram of a hardware structure of a network device, such as Image 6 As shown, the network device 30 includes: a processor 31 , a communication interface 32 , a memory 33 and a bus 34 .
[0088] The communication interface 32 is used to obtain the serial number of the message fragment after receiving any packet fragment, and determine the corresponding target storage unit according to the serial number of the packet fragment. The processor 31 is configured to merge any packet fragment into a fragment if there is a fragment chain in the adjacent storage unit of the target storage unit corresponding to any packet fragment received by the communication interface 32 If there is no shard chain in the adjacent storage unit, then in the target storage unit, create a shard chain containing any of the packet shards. The target packet is obtained according to the fragmentation chain including the tail fragment and the first fragment of the target packet corresponding to any packet fragment.
[0089] In the network device provided by the embodiment of the present invention, after receiving any packet fragment, the network device obtains the sequence number of the packet fragment, and determines its corresponding target storage unit according to the sequence number. If there is a shard chain in the adjacent storage unit of the target storage unit corresponding to the shard, any packet shard will be merged into the shard chain. In the target storage unit, create a fragmentation chain including the fragmentation of any message, and finally obtain the target fragmentation chain according to the fragmentation chain including the tail fragment and the first fragment of the target message corresponding to the fragmentation of any message. Therefore, in the process of receiving the packet fragmentation of the target packet, packet reassembly can be realized, so that the network device can directly obtain the target packet after obtaining all the packet fragments of the target packet. The fragmentation chain of the message, and then the target message is obtained, which not only improves the overall reassembly efficiency, but also reduces the transmission delay of the message.
[0090] In the embodiment of the present invention, in Image 6 The bus may include any number of interconnected buses and bridges, in particular one or more processors represented by processor 31 and various circuits of memory represented by memory 33 linked together. It should be noted that, in the specific implementation process, the above figure 1 The steps performed by the network device in the shown method flow can be implemented by the processor 31 in the form of hardware executing computer-executed instructions in the form of software stored in the memory 33 , which are not repeated here to avoid repetition.
[0091] The programs corresponding to the actions performed by the above network device may be stored in the memory of the network device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0092] The above memory may include volatile memory (volatile memory), such as random-access memory (random-access memory, RAM); may also include non-volatile memory (non-volatile memory), such as read-only memory (read only memory) -only memory, ROM), flash memory (flash memory), hard disk drive (HDD) or solid-state drive (solid-state drive, SSD); a combination of the above types of memories may also be included.
[0093] The processor in the network device provided above may be one processor, or may be a general term for multiple processing elements. For example, the processor may be a central processing unit (CPU); other general-purpose processors, digital signal processors (digital signal processing, DSP), application specific integrated circuits (ASIC), field programmable Field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor, etc. ; It can also be a special-purpose processor, and the special-purpose processor can include at least one of a baseband processing chip, a radio frequency processing chip, and the like.
[0094] Those skilled in the art can clearly understand that, for the convenience and brevity of description, for the specific working process of the above-described devices and modules, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.