UDP message reordering method, system, electronic device and storage medium

The location information of UDP fragmented messages is set through the hardware description language and arranged in the receiving buffer in chronological order, which solves the problems of data packet disorder and high CPU resource consumption in the UDP protocol, and realizes efficient fragmented message reassembly. and data transmission.

CN117118922BActive Publication Date: 2024-10-18YUSUR TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311213461.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-19
Publication Date
2024-10-18
Estimated Expiration
2043-09-19

AI Technical Summary

Technical Problem

When the UDP protocol transmits jumbo frame messages, due to the lack of a packet sorting mechanism, data packets may arrive at the receiver out of order, and CPU resources are consumed, making it unable to effectively handle the reassembly of fragmented messages.

Method used

Set the location information of fragmented messages through hardware description language and arrange them in chronological order in the receive buffer to realize the reorganization of fragmented messages, reduce CPU load and improve processing efficiency.

Benefits of technology

It effectively increases the UDP message reassembly rate, releases the occupancy rate of the CPU and kernel protocol stack, and improves data transmission efficiency and available traffic bandwidth.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117118922B_ABST
    Figure CN117118922B_ABST
Patent Text Reader

Abstract

The present invention provides a method, system, electronic device and storage medium for rearranging UDP messages. The method performed by the receiving end includes: storing the received fragmented messages of the target UDP message in a receiving buffer, wherein each of the fragmented messages contains the position information of each fragmented message in the target UDP message pre-set based on a hardware description language; arranging each fragmented message in the receiving buffer according to the position information of each fragmented message to obtain the corresponding target UDP message. The present invention can realize the reorganization of each fragmented message belonging to the same message data by hardware, can greatly improve the message reorganization rate, and can release the occupancy rate of the CPU and the kernel protocol stack at the same time, thereby improving the processing capacity of complex messages and increasing the throughput of the CPU and the kernel protocol stack.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a method, system, electronic device and storage medium for reordering UDP messages. Background Art

[0002] When transmitting jumbo frame message data, it is necessary to fragment the jumbo frame message data at the sender and reassemble the fragmented messages at the receiver due to the limitation of the transmission link MTU (maximum transmission unit). However, in the fragmentation operation of the UDP protocol (a simple message-oriented transport layer communication protocol), only the first fragment of each UDP jumbo frame message contains the UDP header, and other fragments do not, so the fragments of the jumbo frame data transmitted by the UDP protocol may arrive at the receiver in a disordered order. However, the UDP protocol is designed to achieve fast and simple data transmission, so there is no mechanism for data packet sorting in the actual data transmission process. UDP data packets may encounter different delays and packet loss during network transmission. These factors may cause data packets to arrive at the receiver in different orders, resulting in data disorder; and the UDP protocol does not perform flow control or congestion control, so it may send data packets to the network at any rate, which may cause data overlap during data packet transmission, thereby further increasing the possibility of data disorder.

[0003] In addition, the receiver of the UDP data packet transmitted through the UDP protocol needs to sort and reassemble the fragmented packets to correctly reconstruct the data packet sent by the sender. However, the current sorting and reassembly of fragmented packets consumes CPU computing power, thereby reducing the CPU's data processing capability. Summary of the invention

[0004] In view of this, embodiments of the present invention provide a method, system, electronic device and storage medium for reordering UDP packets to eliminate or improve one or more defects in the prior art.

[0005] One aspect of the present invention provides a method for reordering UDP packets that can be performed by a receiving end, comprising:

[0006] The received fragmented messages of the target UDP message are stored in a receiving buffer, wherein each of the fragmented messages includes the position information of each fragmented message in the target UDP message which is pre-set based on the hardware description language;

[0007] Arrange each of the fragmented messages in the receiving buffer according to the position information of each of the fragmented messages to obtain the corresponding target UDP message.

[0008] In some embodiments of the present invention, the step of arranging each of the fragment messages according to the position information of each of the fragment messages includes:

[0009] According to the time sequence of receiving each fragment message, each fragment message is stored in a storage position in the receiving buffer corresponding to the respective position information, wherein each storage position is used to store fragment messages with continuous position information.

[0010] In some embodiments of the present invention, storing each fragment message in a storage location in the receiving buffer corresponding to the respective position information according to the time sequence of receiving each fragment message includes:

[0011] Determining the storage step of each of the fragment messages at the storage location according to the location information of each of the fragment messages received in time sequence;

[0012] The step of storing each fragment message in the storage location includes:

[0013] For the fragmented messages received in the first time period, storing the fragmented messages in corresponding storage locations according to the location information of each fragmented message;

[0014] For the currently received fragmented message whose position information is continuous with the stored fragmented message, according to the relationship between the position information of the currently received fragmented message and the position information of the stored fragmented message, the currently received fragmented message is stored in the storage position of the fragmented message continuous with its position information;

[0015] For the currently received fragmented message whose location information is discontinuous with the stored fragmented message, the currently received fragmented message is stored separately in the corresponding storage location according to the relationship between the location information of the currently received fragmented message and the location information of the stored fragmented message.

[0016] In some embodiments of the present invention, the total number of fragmented messages of the target UDP message is less than or equal to a preset threshold, wherein the preset threshold is pre-determined based on the number of storage locations of the receiving buffer.

[0017] A second aspect of the present invention provides a UDP message reordering method that can be performed by a sending end, comprising:

[0018] For the fragmented messages of the target UDP message, the position information of each fragmented message is set based on the hardware description language;

[0019] Each fragment message is sent to a receiving end in the same system, so that the receiving end arranges each fragment message based on the position information of each fragment message to obtain the target UDP message.

[0020] In some embodiments of the present invention, in the fragmented messages for the target UDP message, the location information of each fragmented message is set based on the hardware description language, including:

[0021] According to the fragmentation of the target UDP message, the location information of each fragment message of the target UDP message is configured, wherein the location information includes the offset of the fragment message relative to the target UDP message and the total length of the fragment message.

[0022] In some embodiments of the present invention, before the fragmented messages of the target UDP message are respectively set with respect to the location information of each fragmented message based on the hardware description language, the method includes:

[0023] The number of fragmented messages of each target UDP message is configured according to a preset threshold, and each fragmented message of the target UDP message is generated accordingly, wherein the preset threshold is pre-determined based on the number of storage locations of the receiving buffer of the receiving end.

[0024] Another aspect of the present invention provides a UDP message reordering system, comprising:

[0025] A sending end, used to execute the above-mentioned UDP message reordering method executed by the sending end;

[0026] The receiving end is used to execute the UDP message reordering method executed by the receiving end.

[0027] Another aspect of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the UDP message reordering method executed by the receiving end as described above or the UDP message reordering method executed by the sending end as described above.

[0028] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the UDP message reordering method executed by the receiving end as described above or the UDP message reordering method executed by the sending end as described above.

[0029] The UDP message reordering method of the present invention configures the position information of each fragment message in the UDP message through a hardware description language, arranges the storage position of each fragment message, thereby realizing the fragment message reordering through hardware to obtain a target UDP message. The present invention can realize the reorganization of each fragment message of the UDP message through hardware, and can effectively improve the reorganization rate of the UDP message; at the same time, it can also release the occupancy rate of the CPU and the kernel protocol stack, thereby improving the processing capacity of complex messages, and improving the working efficiency of data transmission and the available flow bandwidth.

[0030] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.

[0031] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0033] Figure 1 The figure is a flow chart of UDP message reordering executed by a receiving end in one embodiment of the present invention.

[0034] Figure 2 This is the reordering result of the UDP fragment message in one embodiment of the present invention.

[0035] Figure 3 This is a flowchart of UDP message reordering performed by a sending end in another embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0037] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.

[0038] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.

[0039] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.

[0040] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.

[0041] In the prior art, there is TCP (a connection-oriented, reliable, byte-stream-based transport layer communication protocol) for recovering and retransmitting out-of-order messages. There is an option field (option) in the TCP message, which is used to identify whether the selective acknowledgment (SACK) feature is supported and the specific SACK information. The sender and receiver using TCP for communication need to negotiate whether to enable the SACK (selective acknowledgment) feature. If both the sender and the receiver support SACK, then in the subsequent communication process, the flag bit of the receiving end can notify the sender of the actual reception of the message at the local end through the SACK option, so that the sender can determine the lost fragmented message, and resend the corresponding fragmented message to ensure the reliability of TCP message transmission. However, there is no option field in the UDP message, so only the message header of the UDP message can be used to extract and calculate information to achieve the reordering of out-of-order messages. Based on this, the present application provides a UDP message reordering method, system, electronic device and storage medium, wherein the UDP message reordering method uses hardware implementation to reorder each fragment message based on the position information of the fragment message of the UDP message to form a completed UDP message. The present application uses hardware design instead of software to implement the disorderly reordering of UDP fragment messages, which can improve the processing capability of complex messages transmitted through the UDP protocol, while releasing the occupancy rate of the CPU and the kernel protocol stack, and increasing the information throughput.

[0042] Based on this, an embodiment provides a UDP message reordering method that can be executed by the receiving end, such as Figure 1 As shown, steps S110-S120 are included:

[0043] Step S110, storing the received fragmented messages of the target UDP message into a receiving buffer, wherein each of the fragmented messages includes position information in the target UDP message that is pre-set based on a hardware description language.

[0044] Since the message information received by the receiving end may be a complete target UDP message or a fragmented message of the target UDP message, based on this, the above step S110 also includes storing the received target UDP message into the receiving buffer.

[0045] The receiving buffer in the above step S110 includes a plurality of storage locations for storing received message information, and each of the storage locations is used to store message information with continuous location information. The message information with continuous location information includes a complete target UDP message, a fragment message of the target UDP message, or a plurality of fragment messages with continuous storage location information of the target UDP message.

[0046] In the above step S110, the receiving end determines the fragmentation of the message information according to the fragmentation mark of the IP header of the received message information. The fragmentation of the message information includes the complete target UDP message and the fragmented message of the target UDP message; the IP header of the message information includes the total length (Total Length) of the current message, the fragmentation mark (Flags) and the fragmentation offset (Fragmentation offset) and other information fields.

[0047] Correspondingly, in one or more embodiments of the present application, the fragmentation of the message information is determined according to the Flags in the IP header of the received message information, and the order of the fragmented messages of the target UPD message is determined in combination with the Fragmentation offset, specifically including:

[0048] Case 1: Flags = 2, indicating that the current message is not fragmented and is a complete target UDP message;

[0049] Case 2: Flags = 1, and Fragmentation offset = 0, indicating that the current message is a fragmented message of the target UDP message and is the first fragment packet;

[0050] Case 3: Flags = 1, and Fragmentation offset ≠ 0, indicating that the current message is a fragmented message of the target UDP message and is not the first fragment packet;

[0051] Case 4: Flags = 0, indicating that the current message is a fragmented message of the target UDP message and is the last fragment packet.

[0052] Step S120: Arrange each of the fragmented messages in the receiving buffer according to the position information of each of the fragmented messages to obtain the corresponding target UDP message.

[0053] Wherein, if the message information received by the receiving end is a complete target UDP message, the above step S120 includes: storing the target UDP message in the receiving buffer, thereby directly receiving the complete target UDP message. If the message information received by the receiving end is a fragment message of the target UDP message, the above step S120 includes, according to the time sequence of receiving each fragment message, storing each fragment message in a storage position in the receiving buffer corresponding to the respective position information, and reorganizing the fragment messages with continuous position information from the first fragment packet to the last fragment packet of the target UDP message stored in the receiving buffer to obtain a complete target UDP message.

[0054] Among them, the position information of each fragment message of the target UDP message is the position information of the data part in each fragment message in the data part of the target UDP message; correspondingly, the position information of the fragment message of the target UDP message is recorded as the (Left Edge, Right Edge] interval, wherein the Left Edge is the left edge of the fragment message, indicating the byte position of the last byte of the data part in the previous fragment message continuous with the current fragment message position information in the data part of the corresponding target UDP message, and the Right Edge is the right edge of the fragment message, indicating the byte position of the last byte of the data part in the fragment message in the data part of the corresponding target UDP message.

[0055] In one or more embodiments of the present application, for the received fragmented message of the target UDP message, the receiving end determines the position information of the fragmented message in the corresponding target UDP message according to the Fragmentation offset and Total Length in the IP header information of the fragmented message. The position information of the fragmented message includes: the offset Fragmentation offset of the current fragmented message relative to the corresponding target UDP message and the total length Total Length of the fragmented message. Among them, Fragmentation offset+1 represents the position information of the first byte of the current fragmented message in the corresponding UDP message, and the Fragmentation offset is used as the left edge (LeftEdge) of the current fragmented message; Fragmentation offset+Total Length represents the position information of the last byte of the current fragmented message in the corresponding UDP message, and the Fragmentation offset+Total Length is used as the right edge (Rigth Edge) of the current fragmented message. Then the position information of the current fragmented message relative to the corresponding UDP message is recorded as the interval (Fragmentation offset, Fragmentation offset+Total Length].

[0056] Correspondingly, the out-of-order reordering of the fragmented messages of the target UDP message received by the receiving end is implemented based on the position information of the IP header in each fragmented message of the target UDP message, and storing each fragmented message in a storage position in the receiving buffer corresponding to the respective position information according to the time sequence of receiving each fragmented message, including: determining the storage step of each fragmented message in the storage position according to the position information of each fragmented message received in time sequence; the storage step of each fragmented message in the storage position specifically includes:

[0057] For the fragmented messages received in the first time period, the position information of each fragmented message is stored in a corresponding storage position; including: for multiple segments of the fragmented messages received with continuous position information, the multiple segments of the fragmented messages with continuous position information are stored in the same storage position of the receiving buffer; for multiple segments of the fragmented messages received with discontinuous position information, the multiple segments of the fragmented messages with continuous position information are stored in different storage positions of the receiving buffer according to the sequence of the position information.

[0058] For the currently received fragmented message whose position information is continuous with the position information of the stored fragmented message, according to the relationship between the position information of the currently received fragmented message and the position information of the stored fragmented message, the currently received fragmented message is stored in the storage position of the fragmented message continuous with its position information; including: for the currently received fragmented message whose position information is continuous with the fragmented message stored in a storage position of the receiving buffer, the currently received fragmented message is stored in the storage position of the fragmented message storage continuous with its position information, and each fragmented message stored in the storage position is reorganized according to the sequence relationship of the position information of each fragmented message; for the currently received fragmented message whose position information is continuous with the fragmented messages stored in two storage positions of the receiving buffer, the currently received fragmented message is stored between the two fragmented messages continuous with their position information, and the fragmented messages stored in the two storage positions and the currently received fragmented message are stored in the same storage position, and at the same time, they are reorganized according to the sequence relationship of the position information of each fragmented message stored in the storage position.

[0059] For the currently received fragmented message whose location information is discontinuous with the stored fragmented message, the currently received fragmented message is stored separately in the corresponding storage location according to the relationship between the location information of the currently received fragmented message and the location information of the stored fragmented message.

[0060] Correspondingly, in one or more embodiments of the present application, the receiving end reassembles the fragmented messages of the target UDP message received successively out of order based on the storage position in the receiving buffer. Figure 2 As shown, A', B' and C' of each state respectively correspond to A, B and C of the previous state corresponding to the state. In the first period of the target UDP message communication, the fragment message received by the receiving end includes three fragment messages whose position information is not continuous. Then the storage state of the three fragment messages in the storage position of the receiving buffer is Figure 2 The current state in the receiving buffer is that the storage locations where the three fragmented messages are stored in the receiving buffer are marked as A, B and C in order from left to right. On this basis, the fragmented messages received in the next period are stored and arranged in the storage locations of the receiving buffer, including the following arrangements:

[0061] Storage status 1 of the fragmented message in the storage position of the receiving buffer in the next period: If the Left Edge of a fragmented message received in the next period is greater than the Rigth Edge of the fragmented message in the current storage position A, and the Rigth Edeg of a fragmented message received in the next period is less than the Left Edeg of the stored message in the current storage position B, then the fragmented message received in the next period is stored in the storage position between the current storage positions A and B, that is, the storage status of a total of four fragmented messages in the storage position of the receiving buffer in the next period is Figure 2 As shown in the next state 1 in , the storage locations where the four fragment messages are stored in the receiving buffer are marked as A, B, C and D in order from left to right. Among them, the current storage location A is still the storage location A of the next period, the storage location where the fragment message received in the next period is stored is the storage location B of the next period, the current storage location B is updated to the storage location C of the next period, and the current storage location C is updated to the storage location D of the next period.

[0062] Storage status 2 of the fragmented message in the storage position of the receiving buffer in the next time period: If the Left Edge of a fragmented message received in the next time period is greater than the Rigth Edge of the fragmented message in the current storage position A, and the Rigth Edeg of a fragmented message received in the next time period is equal to the Left Edeg of the message stored in the current storage position B, then the fragmented message received in the next time period is stored in the current storage position B, and is located in front of the fragmented message stored in the current storage position B, and is recombined with the fragmented message stored in the current storage position B, that is, the storage status of a total of four fragmented messages in the storage position of the receiving buffer in the next time period is Figure 2 As shown in the next state 2 in , the storage positions where the four fragmented messages are stored in the receiving buffer are marked as A, B and C in order from left to right. Among them, the current storage position A is still the storage position A of the next time period, the Left Edeg of the fragmented message stored in the current storage position B is updated to the Left Edeg of the fragmented message received in the next time period as the storage position B of the next time period, and the fragmented message stored in the next storage position B includes the fragmented message received in the next time period and the currently stored fragmented message from left to right, and the current storage position C is still the storage position C of the next time period.

[0063] Storage status 3 of the fragmented message in the storage position of the receiving buffer in the next time period: If the Left Edge of a fragmented message received in the next time period is equal to the Rigth Edge of the fragmented message in the current storage position B, and the Rigth Edeg of a fragmented message received in the next time period is less than the Left Edeg of the message stored in the current storage position C, then the fragmented message received in the next time period is stored in the current storage position B, and is located behind the fragmented message stored in the current storage position B, and is reorganized with the fragmented message stored in the current storage position B, that is, the storage status of a total of four fragmented messages in the storage position of the receiving buffer in the next time period is Figure 2 As shown in the next state 3 in the figure, the storage positions where the four fragment messages are stored in the receiving buffer are marked as A, B and C in order from left to right. Among them, the current storage position A is still the storage position A of the next time period, the Rigth Edeg of the fragment message stored in the current storage position B is updated to the Rigth Edeg of the fragment message received in the next time period as the storage position B of the next time period, and the fragment message stored in the next storage position B includes the currently stored fragment message and the fragment message received in the next time period from left to right, and the current storage position C is still the storage position C of the next time period.

[0064] Storage status 4 of the fragmented message in the storage position of the receiving buffer in the next time period: If the Left Edge of a fragmented message received in the next time period is equal to the Rigth Edge of the fragmented message in the current storage position A, and the Rigth Edge of a fragmented message received in the next time period is equal to the Left Edge of the message stored in the current storage position C, then the fragmented message received in the next time period is stored between the fragmented message stored in the current storage position B and the fragmented message stored in the current storage position C, and is reorganized with the fragmented message stored in the current storage position B and the fragmented message stored in the current storage position C, that is, the storage status of a total of four fragmented messages in the storage position of the receiving buffer in the next time period is Figure 3 As shown in the next state 4 in the figure, the storage positions where the four fragmented messages are stored in the receiving buffer are marked as A and B in order from left to right. Among them, the current storage position A is still the storage position A of the next period, and the Rigth Edeg of the fragmented message stored in the current storage position B is updated to the Rigth Edeg of the fragmented message stored in the current storage position C as the storage position B of the next period, and the fragmented messages stored in the next storage position B are, from left to right, the fragmented messages stored in the current storage position B, the fragmented messages received in the next period, and the fragmented messages stored in the current storage position C, and the current storage position C is cancelled during the update process of the next period.

[0065] Based on the above storage arrangement method for the fragmented messages received in the next time period in the storage position of the receiving buffer, the fragmented messages of the target UDP message received in time sequence are stored and arranged in sequence, and according to the Flags and Fragmentation offset of the fragmented messages stored in the receiving buffer, it is judged whether the reassembled message of the fragmented messages received by the receiving end is a complete target UDP message. Correspondingly, the judgment standard that the reassembled message of the fragmented messages received by the receiving end is a complete target UDP message is: the reassembled message is stored in the same storage position in the receiving buffer, and the fragmented messages in the reassembled message include the first fragment packet and the last fragment packet of the target UDP message.

[0066] Based on the arrangement and reorganization method of the above-mentioned fragmented messages in the receiving buffer, it can be known that the total number of fragmented messages that the receiving buffer can arrange and reorganize for the fragmented messages belonging to the same target UDP message is limited by the number of storage locations in the receiving buffer. The total number of each fragmented message of the target UDP message is less than or equal to a preset threshold, wherein the preset threshold is determined in advance based on the number of storage locations in the receiving buffer, and correspondingly, the total number of fragmented messages of the target UDP message that the receiving buffer can arrange and reorganize is equal to twice the number of storage locations in the receiving buffer.

[0067] In one or more embodiments of the present application, the hardware logic of the UDP message reordering method that can be executed by the receiving end is implemented through Verilog (hardware description language), and the hardware logic of the UDP message reordering method executed by the receiving end is compiled into a program code and burned into an FPGA chip (an integrated chip mainly composed of digital circuits) to implement the logic circuit of the UDP message reordering method that can be executed by the receiving end.

[0068] The present invention also provides a receiving end for executing all or part of the contents of the above-mentioned UDP message reordering method executed by the receiving end. The embodiment of the receiving end can be specifically used to execute the processing flow of the embodiment of the UDP message reordering method executed by the receiving end in the above-mentioned embodiment. Its functions will not be repeated here, and reference can be made to the detailed description of the embodiment of the above-mentioned UDP message reordering method executed by the receiving end.

[0069] Corresponding to the above-mentioned method for reordering UDP packets that can be executed by the receiving end, another embodiment also provides a method for reordering UDP packets that can be executed by the sending end, such as Figure 3 As shown, steps S210-S220 are included:

[0070] Step S210: for the fragmented messages of the target UDP message, the location information of each fragmented message is set based on the hardware description language.

[0071] The message information sent by the sender may be a complete target UDP message or a fragment message of the target UDP message; based on this, the above step S210 also includes, for the target UDP message, setting the location information of the target UDP message based on the hardware description language. The location information of each fragment message of the target UDP message includes the offset (Fragmentation offset) of the fragment message relative to the target UDP message and the total length (TotalLength) of the fragment message; the location information of the target UDP message includes the offset (Fragmentationoffset) of the target UDP message and the total length (TotalLength) of the target UDP message.

[0072] Correspondingly, the above step S210 also includes: setting the fragmentation flag (Flags) of the target UDP message and / or the fragmentation flag (Flags) of each fragment message of the target UDP message based on the hardware description language.

[0073] In one or more embodiments of the present application, for each fragment message of the target UDP message, according to the fragmentation of the target UDP message, the location information and fragmentation flags (Flags) of each fragment message of the target UDP message are configured. Wherein, configuring the fragmentation flag (Flags) in the IP header of the fragment message of the target UDP message and the offset (Fragmentationoffset) of the fragment message relative to the header of the target UDP message according to the fragmentation of the target UDP message specifically includes:

[0074] Case 1: The current message is not fragmented and is a complete target UDP message, so the Flags of the current message is configured to be 2;

[0075] Case 2: The current message is a fragmented message of the target UDP message and is the first fragment packet, so the Flags of the current message is configured to be 1, and the Fragmentation offset is configured to be 0;

[0076] Case 3: If the current message is a fragmented message of the target UDP message and is not the first fragment packet, then the Flags of the current message is configured to be 1, and the Fragmentation offset is ≠ 0, wherein the Fragmentation offset is configured according to the offset of the first byte of the current message compared to the first byte of the corresponding target UDP message;

[0077] Case 4: The current message is a fragmented message of the target UDP message and is the last fragment packet, so the Flags of the current message is configured to be 0.

[0078] For the fragmentation messages of the target UDP message corresponding to the fragmentation flag Flags=1 or Flags=0 in the IP header of the message information, the position information of each fragmentation message is recorded as the interval of (Fragmentation offset, Fragmentationoffset+Total Length]. Among them, Fragmentation offset+1 represents the position information of the first byte of the data part in the corresponding fragmentation message in the target UDP message, and Fragmentation offset is used as the left edge (Left Edge) of the fragmentation message; Fragmentation offset+Total Length represents the position information of the last byte of the data part in the corresponding fragmentation message in the target UDP message, and Fragmentationoffset+Total Length is used as the right edge (Rigth Edge) of the fragmentation message.

[0079] Step S220, sending each fragment message to a receiving end in the same system, so that the receiving end arranges each fragment message based on the position information of each fragment message to obtain the target UDP message.

[0080] Since the total number of fragmented messages that the receiving end can arrange and reassemble belonging to the same target UDP message is limited by the number of storage locations in the receiving buffer of the receiving end, the preset threshold value of the number of fragmented messages for the target UDP message fragments of the sending end is determined based on the number of storage locations in the receiving buffer of the receiving end corresponding to the sending end.

[0081] Correspondingly, in one or more embodiments of the present application, before the fragmented messages for the target UDP message set the location information of each fragmented message based on the hardware description language, the sending end configures the number of fragmented messages of each of the target UDP messages according to a preset threshold, and generates each of the fragmented messages of the target UDP message accordingly, wherein the preset threshold is determined in advance based on the number of storage locations in the receiving buffer of the receiving end corresponding to the sending end.

[0082] The present invention also provides a receiving end for executing all or part of the contents of the above-mentioned UDP message reordering method executed by the sending end. The embodiment of the receiving end can be specifically used to execute the processing flow of the embodiment of the UDP message reordering method executed by the sending end in the above-mentioned embodiment. Its functions will not be repeated here, and reference can be made to the detailed description of the embodiment of the above-mentioned UDP message reordering method executed by the sending end.

[0083] The present invention also provides a UDP message reordering system, comprising: a sending end and a receiving end; the sending end is used to execute the above-mentioned UDP message reordering method executed by the sending end; the receiving end is used to execute the above-mentioned UDP message reordering method executed by the receiving end. The sending end and the receiving end are communicated via the UDP protocol. The embodiment of the UDP message reordering system can be specifically used to execute the processing flow of the embodiment of the UDP message reordering method executed by the sending end and the embodiment of the UDP message reordering method executed by the receiving end in the above-mentioned embodiment. Its functions will not be repeated here, and reference can be made to the detailed description of the above-mentioned embodiment of the UDP message reordering method executed by the sending end and the embodiment of the UDP message reordering method executed by the receiving end.

[0084] Corresponding to the above method, the present invention also provides an electronic device, which includes a computer device, the computer device includes a processor and a memory, the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the electronic device implements the UDP message reordering method executed by the receiving end as mentioned above or the UDP message reordering method executed by the sending end as mentioned above.

[0085] The embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the UDP message reordering method executed by the receiving end or the UDP message reordering method executed by the sending end. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.

[0086] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.

[0087] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0088] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.

[0089] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for reordering UDP packets, characterized in that: include: Determine a target UDP message and fragment messages of the target UDP message according to a fragment mark in an IP header of the received message information; The received fragmented messages of the target UDP message are stored in a receiving buffer, wherein each of the fragmented messages includes respective position information in the target UDP message that is pre-set based on a hardware description language, and the position information of each fragmented message of the target UDP message includes: an offset of the fragmented message relative to the target UDP message and a total length of the fragmented message; Wherein, if the value of the fragmentation mark is 2, it means that the current target UDP message is not fragmented, and the fragmented message of the target UDP message is a complete target UDP message; If the value of the fragmentation mark is 1 and the value of the offset in the position information of the current fragmentation message is 0, it means that the current fragmentation message is the fragmentation message of the first fragment packet of the target UDP message; If the value of the fragmentation mark is 1 and the value of the offset in the position information of the current fragmentation message is not 0, it means that the current fragmentation message is a fragmentation message that is not the first fragment packet of the target UDP message; If the value of the fragmentation mark is 0, it means that the current fragmentation message is a fragmentation message of the tail packet of the target UDP message; Arrange each of the fragmented messages in the receiving buffer according to the offset of the fragmented messages relative to the target UDP message in the position information of each of the fragmented messages and the total length of the fragmented messages to obtain a reassembled message, and judge whether the reassembled message is stored in the same storage position in the receiving buffer and the fragmented messages in the reassembled message include the first fragment packet and the last fragment packet of the target UDP message according to the fragmentation mark and the offset corresponding to each of the fragmented messages stored in the receiving buffer, and if so, judge that the current reassembled message is a complete target UDP message to obtain the corresponding target UDP message; Arranging each of the fragment messages in the receiving buffer includes: According to the time sequence of receiving each fragment message, each fragment message is stored in a storage position in the receiving buffer corresponding to the respective position information, wherein each storage position is used to store message information with continuous position information; The storing each fragment message in a storage position in the receiving buffer corresponding to the respective position information according to the time sequence of receiving each fragment message comprises: Determining the storage step of each of the fragment messages at the storage location according to the location information of each of the fragment messages received in time sequence; The step of storing each fragment message in the storage location includes: For the fragmented messages received in the first time period, storing the fragmented messages in corresponding storage locations according to the location information of each fragmented message; For the currently received fragmented message whose position information is continuous with the stored fragmented message, according to the relationship between the position information of the currently received fragmented message and the position information of the stored fragmented message, the currently received fragmented message is stored in the storage position of the fragmented message continuous with its position information; For the currently received fragmented message whose location information is discontinuous with the stored fragmented message, the currently received fragmented message is stored separately in the corresponding storage location according to the relationship between the location information of the currently received fragmented message and the location information of the stored fragmented message.

2. The UDP message reordering method according to claim 1, characterized in that: The total number of fragmented messages of the target UDP message is less than or equal to a preset threshold, wherein the preset threshold is pre-determined based on the number of storage locations of the receiving buffer.

3. A method for reordering UDP packets, characterized in that: include: For the fragmented messages of the target UDP message, the position information of each fragmented message is set based on the hardware description language; The location information of each fragment message of the target UDP message includes: the offset of the fragment message relative to the target UDP message and the total length of the fragment message; Send each fragment message of the target UDP message to a receiving end in the same system, so that the fragment mark in the IP header of the message information corresponding to the target UDP message at the receiving end determines the target UDP message and the fragment message of the target UDP message, arrange each fragment message in a receiving buffer based on the offset of the fragment message relative to the target UDP message in the position information of each fragment message and the total length of the fragment message to obtain a reassembled message, and judge whether the reassembled message is stored in the same storage position in the receiving buffer and the fragment message in the reassembled message includes the first fragment packet and the last fragment packet of the target UDP message according to the fragment mark and the offset corresponding to each fragment message stored in the receiving buffer, and if so, judge that the current reassembled message is a complete target UDP message to obtain the target UDP message; Wherein, if the value of the fragmentation mark is 2, it means that the current target UDP message is not fragmented, and the fragmented message of the target UDP message is a complete target UDP message; If the value of the fragmentation mark is 1 and the value of the offset in the position information of the current fragmentation message is 0, it means that the current fragmentation message is the fragmentation message of the first fragment packet of the target UDP message; If the value of the fragmentation mark is 1 and the value of the offset in the position information of the current fragmentation message is not 0, it means that the current fragmentation message is a fragmentation message that is not the first fragment packet of the target UDP message; If the value of the fragmentation mark is 0, it means that the current fragmentation message is a fragmentation message of the tail packet of the target UDP message; The receiving end arranges each of the fragment messages in the receiving buffer, including: According to the time sequence of receiving each fragment message, each fragment message is stored in a storage position in the receiving buffer corresponding to the respective position information, wherein each storage position is used to store message information with continuous position information; The step of storing each fragment message in a storage location in the receiving buffer corresponding to the respective position information according to the time sequence of receiving each fragment message comprises: Determining the storage step of each of the fragment messages at the storage location according to the location information of each of the fragment messages received in time sequence; The step of storing each fragment message in the storage location includes: For the fragmented messages received in the first time period, storing the fragmented messages in corresponding storage locations according to the location information of each fragmented message; For the currently received fragmented message whose position information is continuous with the stored fragmented message, according to the relationship between the position information of the currently received fragmented message and the position information of the stored fragmented message, the currently received fragmented message is stored in the storage position of the fragmented message continuous with its position information; For the currently received fragmented message whose location information is discontinuous with the stored fragmented message, the currently received fragmented message is stored separately in the corresponding storage location according to the relationship between the location information of the currently received fragmented message and the location information of the stored fragmented message.

4. The method for reordering UDP packets according to claim 3, characterized in that: In the fragmented messages for the target UDP message, the location information of each fragmented message is set based on the hardware description language, including: According to the fragmentation of the target UDP message, the location information of each fragment message of the target UDP message is configured.

5. The method for reordering UDP packets according to claim 3, characterized in that: Before the fragmented messages of the target UDP message are respectively set with respect to the location information of each fragmented message based on the hardware description language, the method includes: The number of fragmented messages of each target UDP message is configured according to a preset threshold, and each fragmented message of the target UDP message is generated accordingly, wherein the preset threshold is pre-determined based on the number of storage locations of the receiving buffer of the receiving end.

6. A UDP message reordering system, characterized in that: include: A sending end, used to execute the UDP message reordering method described in any one of claims 3 to 5; A receiving end, used to execute the UDP message reordering method described in claim 1 or 2.

7. An electronic device, comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the UDP message reordering method as described in claim 1 or 2 or the UDP message reordering method as described in any one of claims 3 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the UDP message reordering method as described in claim 1 or 2 or the UDP message reordering method as described in any one of claims 3 to 5.

Citation Information

Patent Citations

  • File transmission method, device and system and electronic equipment

    CN111211878A