Detailed Description
In order to better understand the technical solutions in the embodiments of the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which are derived by a person skilled in the art based on the embodiments of the present application, shall fall within the scope of protection of the embodiments of the present application.
Fig. 1 is a schematic flow chart of a data slicing method based on a DPU according to an embodiment of the present application. The data slicing method based on the DPU provided by the embodiment of the application can be applied to a standard network card, an intelligent network card, a DPU (Data Processing Unit, data processor) chip and the like for executing slicing operation by supporting hardware. When the hardware supports IP fragmentation unloading, the software can directly send the ultralong packet to the hardware for processing, because of pipelining processing of the hardware, processing delay can be greatly reduced, CPU resources are released, meanwhile, because the hardware has a filtering function, all data messages can be sent through the hardware, the CPU processes the messages which cannot be processed by the hardware, and the CPU which can be processed by the hardware directly transfers the big packet to hardware processing.
The DPU-based data slicing method comprises the following steps:
S101, obtaining a maximum data message capacity value set by a data transmission unit through which the data message is to pass.
In the embodiment of the present application, the maximum transmission unit MTU (Maximum Transmission Unit, MTU) refers to the maximum packet size that can be transmitted by the network, and is in bytes. The size of the MTU determines the maximum number of bytes that the sender can send a message at a time. If the MTU exceeds the maximum value that can be borne by the receiving end, or exceeds the maximum value that can be borne by a certain device routed on the transmission path, the message fragments and even drops. The value of the data transmission unit, namely the value of the MTU, can be set, and the maximum data message capacity value set by the data transmission unit through which the data message passes is obtained, so that a reference is provided for the subsequent judgment of the fragmentation of the data packet.
S102, if the data message uses the first protocol version and the data message accords with the slicing condition, determining a target data message capacity according to the maximum data message capacity value and the IP header length of the Internet protocol corresponding to the data message, and slicing the data message based on the target data message capacity value to obtain the sliced data message.
In the embodiment of the present application, the protocol version used by the data packet may be internet protocol version 4 (Internet Protocol version, IPV 4) and internet protocol version 6 (Internet Protocol version, IPV 6), and the protocol version used by the data packet is determined, and when the protocol version is the first protocol version, i.e., IPV4 international protocol version, whether the data packet meets the data slicing condition is further determined. If the data message is a slicing message, a message which does not allow slicing to be executed or the message length is insufficient for MTU, the data message does not accord with the slicing condition, otherwise, the data message accords with the slicing condition. Because the payload content of the fragmented message is to be rounded in eight bytes when the data message is fragmented, the MTU value for unloading, i.e. the target data message capacity value, is determined according to the maximum data message capacity and the IP header length which are currently set.
If the data message uses the first protocol version, that is, if the data message is an IPV4 message, the IP fragment offset flag, the IP layer header information length, the four-layer protocol type, the total message length, etc. corresponding to the IPV4 message are parsed, and whether the data message meets the fragment condition is determined according to the parsing result.
In the embodiment of the application, the type of the transport layer protocol corresponding to the data message is judged, if the type is a first preset protocol, namely a transmission control protocol (Transmission Control Protocol, TCP)/user datagram protocol (User Datagram Protocol, UDP), the number of fragments of the data message is determined according to the capacity value of the target data message, and the fragmented data message is obtained.
If the transport layer protocol type corresponding to the data message is not the first preset protocol, the data message is directly fragmented based on the target data message capacity value, and the fragmented data message is obtained.
In an embodiment of the present application, when IP fragment offload is turned on, the default is to turn on checksum offload.
And S103, if the data message uses the second protocol version and the protocol header resolved from the header of the data message is the first preset protocol, determining a target data message capacity value according to the total length of the extension header resolved from the header and the maximum data message capacity, and slicing the data message based on the target data message capacity value to obtain the sliced data message.
In the embodiment of the application, the protocol version used by the data message is judged, when the protocol version is the second protocol version, namely the IPV6 international protocol version, the protocol type carried by the packet header of the data message is analyzed, when the carried protocol type is a protocol header, such as a four-layer protocol header, is a first preset protocol, such as a TCP/UDP protocol, the total length of all the extension headers carried by the packet header is obtained, the target data message capacity value is determined according to the total length of the extension headers and the maximum data message capacity, and finally the number of fragments of the data message is determined according to the target data message capacity value, so that the fragmented data message is obtained.
When the packet head of the data message carries the protocol type, if the protocol type is an extension head, continuing to analyze until four layers of protocol heads are analyzed, obtaining all extension heads before analyzing the four layers of protocol heads, and summing the obtained extension heads to obtain the total length of the extension heads. If the fragmentation extension header is resolved in the process of resolving the protocol type carried by the packet header, the data message is characterized to be fragmented before the message fragmentation can not be performed any more, and the resolution is not performed any more.
In the embodiment of the present application, as shown in fig. 2, fig. 2 is a system block diagram of IP fragmentation offloading provided in the embodiment of the present application. In fig. 2, the method includes a checksum calculation module (packet_checksum), a generation descriptor module (packet_packet), a buffer pool storage module (packet_memory), and a data burst module (packet_fragment), and after a data packet is transmitted through a data stream interface, the checksum calculation is performed, and at the same time, the generation descriptor module generates a corresponding descriptor, including supporting hardware unloading function, checksum unloading, a maximum data transmission unit, an extended header length, and a TCP/UDP result. When the MTU value for unloading is determined based on the maximum transmission unit in the descriptor, the data message is stored in a buffer pool storage module, after unloading capacity is confirmed and TCP/UDP checksum is calculated, the data packet is read from the buffer pool, data slicing is carried out in a data slicing module according to the unloading capacity, sliced data is obtained, checksum calculation is carried out on the sliced data again, the calculation can be carried out on IP layer checksum, the IP layer checksum and the TCP/UDP checksum are filled in the data message after slicing, and finally the data message filled with the checksum is transmitted through a data flow interface.
It can be understood that in the embodiment of the application, the maximum data message capacity value set by the output unit of the data message is obtained, if the data message uses the first protocol version and accords with the slicing condition, the target data message capacity value is determined according to the maximum data message capacity value and the IP header length of the data message, the sliced data message is obtained based on the target data message capacity value, and if the data message uses the second protocol version and the protocol header resolved by the packet header of the data message is the first preset protocol, the target data message capacity value is determined according to the total length of the resolved extension header and the maximum data message capacity value, and the sliced data message is obtained based on the target data message capacity value. In the process, on one hand, aiming at the problem of weak capability of a plurality of CPUs, the CPU is replaced to judge the protocol version used by the data message, whether the data message is fragmented or not is judged, if the two conditions are not met, different fragmentation measures are carried out according to different protocol versions, CPU resources are released, and the fragmentation technology is optimized. On the other hand, if the CPU capability of the user is strong, the message processing delay can be reduced by turning off the hardware function.
In some embodiments of the present application, S102 may be implemented through S1021 to S103, which are described by the following steps.
S1021, when the data message uses the first protocol version, acquiring key fields of the data message in the transmission process.
In some embodiments of the present application, the key fields may be an IP fragment offset flag, an IP layer header information length, a four layer protocol type, and a total message length. The four-layer protocol type mainly comprises an application layer, a transmission layer, a network layer and a network interface layer or a data link layer, and the four layers work together to ensure the integrity and the correctness of data, so that various application programs can communicate and exchange data through a network. The total length of the message refers to the total length of the message, including the sum of the length of the header and the payload. The IP layer header information length generally refers to the length of the IPv4 or IPv6 packet header. The header structures of IPv4 and IPv6 are different, and thus their header lengths are also different.
And S1022, when the data message accords with the slicing condition through the key field, determining a target data message capacity value according to the maximum data message capacity and the IP header length corresponding to the data message.
In some embodiments of the present application, whether the data packet is a fragmented packet, a packet that does not allow fragmentation to be performed, or a packet with a packet length less than the MTU is determined according to key fields of the data packet, such as an IP fragment offset flag, an IP layer header information length, a four layer protocol type, and a packet total length. When the data message accords with the slicing condition through the key word, the target data message capacity value is further determined according to the maximum data message capacity and the IP header length corresponding to the data message.
S1023, when the key field judges that the data message does not accord with the slicing condition, the slicing processing is not carried out on the data message.
In some embodiments of the present application, when it is determined by the key field that the data packet does not meet the fragmentation condition, the data packet is a fragmented packet, a packet that is not allowed to be fragmented, or a packet with a packet length less than the MTU, the fragmentation process is not performed on the data packet. If the data message is a slicing message or a message which does not allow slicing to be executed and the data message length is larger than the MTU, discarding the packet and returning an ICMP error message.
It can be understood that in some embodiments of the present application, when the data packet uses the first protocol version, a key field of the data packet in the transmission process is obtained, and when the data packet meets the fragmentation condition through the key field, a target data packet capacity value is determined according to the maximum data packet capacity and the IP header length corresponding to the data packet. And when judging that the data message does not accord with the slicing condition through the key field, not carrying out slicing processing on the data message. Judging whether the data message can be fragmented or not through the keywords corresponding to the data message, and improving the accuracy of data fragmentation.
In some embodiments of the present application, S10 is further included before S102, which is specifically described by the following steps.
S10, analyzing the Ethernet type value corresponding to the data message to obtain a protocol version used by the data message.
In some embodiments of the present application, the data message transmitted by the bus is parsed, the ethernet type is parsed first, and the international protocol version used by the data message is determined by reading the ethernet frame, extracting the type field, and checking the value of the type field. The protocol version used by the data message can be an IPV4 version and an IPV6 version, and whether the protocol version used by the data message is the IPV4 version or the IPV6 version is determined.
It can be understood that in some embodiments of the present application, when the data packet is fragmented, whether the data packet is IPv4 or IPv6 is determined according to the ethernet type, and different protocol versions are suitable for different network environments and requirements, so that accuracy, efficiency and compatibility of network communication are improved.
In some embodiments of the present application, S20 to S22 are further included before S104, which is specifically described by the following steps.
And S20, if the data message uses the second protocol version, analyzing the protocol type carried by the packet header to obtain an analysis result.
In some embodiments of the present application, if the second protocol version, i.e. the IPV6 protocol version, is used for the data packet, the protocol type carried by the packet header is parsed, and it is determined whether the protocol type is an extension header or a preset protocol header, i.e. a four-layer protocol header.
S21, if the analysis result represents that the protocol type is an extension header, acquiring the protocol type indicated by the next header field of the extension header.
And S22, if the protocol type indicated by the next header field is an extension header, continuing to analyze the extension header until a preset protocol header is obtained.
In some embodiments of the present application, when the field of the IPV6 header is read, the "next header" field will show the next header type, if the "next header" field value corresponds to a certain extension header type, then the next header will be the extension header, when the analysis result indicates that the protocol type is the extension header, the extension header is continuously read and analyzed, and the "next header" field in the extension header is checked to determine the type of the next header until the preset protocol header, that is, the four-layer protocol header, is analyzed.
It can be understood that in some embodiments of the present application, if the data packet uses the second protocol version, the protocol type carried by the header corresponding to the data packet is parsed to obtain a parsing result, if the parsing result characterizes the protocol type as an extension header, the protocol type indicated by the next header field of the extension header is obtained, and if the protocol type indicated by the next header field is an extension header, the parsing of the extension header is continued until a preset protocol header is obtained. By analyzing the protocol type of the packet header of the data message, judging whether the packet header is an extension header or a preset protocol header, improving the processing efficiency, ensuring the data integrity, supporting the realization of network functions and enhancing the network security, and by the steps, the IPV4 header option field and the IPV6 extension header field can be correctly identified according to the processing modes of the IPV4 header carrying option and the IPV6 extension header carrying option and the non-carrying.
In some embodiments of the present application, S201 to S202 are further included after S104, and are described by the following steps.
S201, analyzing the fragmented data message to obtain respective corresponding hop-by-hop extension heads or route extension heads.
In some embodiments of the present application, hop-by-Hop Extensions (Hop-by-Hop Extensions) are an important component of the IPv6 protocol that allows additional processing of data packets at the IP layer without affecting upper layer protocols. The hop-by-hop extension header immediately follows the IPv6 base header, allowing the intermediate node to perform the necessary processing on the data packet without having to pass it to a higher network layer. The route extension header is an optional extension header defined in the IPv6 protocol, and uses routing addresses arranged in sequence to identify the entire route, so that the user can configure the header to achieve the purpose of allowing packets to travel along the same path.
In some embodiments of the present application, a plurality of fragmented data messages are obtained after the data message is fragmented, and the fragmented data messages are continuously parsed to obtain a piece-by-piece extension header or a route extension header corresponding to each fragmented data message.
S202, adding the fragmented extension header corresponding to the fragmented data message to the hop-by-hop extension header or the route extension header.
In some embodiments of the present application, the fragmented extension header corresponding to each fragmented data packet is added behind the hop-by-hop extension header or behind the route extension header, and if these two extension headers are not present, the fragmented extension header follows the IPV6 basic packet header.
It can be understood that in some embodiments of the present application, the fragmented data packet is parsed to obtain a corresponding hop-by-hop extension header or a route extension header, and the fragmented extension header corresponding to the fragmented data packet is added to the hop-by-hop extension header or the route extension header. By adding the fragmentation expansion header behind the hop-by-hop expansion header or the route expansion header, whether the fragmented data message is a fragmentation message or not is determined, and in the process of transmitting the subsequent data message, the accuracy of whether the data message is the fragmentation message or not is improved.
In some embodiments of the present application, if the data packet uses the first protocol version and meets the fragmentation condition in S103, S301 to S304 are further included after determining the target data packet capacity value according to the maximum data packet capacity value and the internet protocol IP header length of the data packet, and if the data packet uses the second protocol version and the protocol header resolved by the packet header of the data packet in S104 is the first preset protocol, the following steps are described.
S301, if the transmission layer protocol of the data message is a first preset protocol, calculating a first checksum, and obtaining the calculated first checksum.
In some embodiments of the present application, if the transport layer protocol of the data packet is a first preset protocol, i.e. a TCP/UDP protocol, a TCP/UDP checksum is calculated, i.e. a first checksum is calculated, so as to obtain a calculated first checksum. If the transmission layer protocol of the data message is not TCP/UDP protocol, the checksum calculation is not carried out, and the data slicing is directly carried out.
S302, performing checksum calculation based on a first preset protocol to obtain a calculated first checksum.
In some embodiments of the present application, if the data packet uses the second protocol version and the header of the data packet is a first preset protocol (i.e., a TCP/UDP protocol), the checksum is calculated, so as to obtain the calculated first checksum, and if the parsed header is not the first preset protocol, i.e., is not the TCP/UDP protocol, the fragmentation of the data is directly performed.
It can be understood that in some embodiments of the present application, whether to perform checksum calculation is determined by determining whether a transport layer protocol of a data packet is a first preset protocol or a protocol header parsed by a packet header of the data packet is the first preset protocol, so that integrity in a data transmission process is ensured. And the application covers the checksum offloading of TCP messages and UDP messages of IPV4 and IPV 6.
In some embodiments of the present application, in S102, the data message is fragmented based on the target data message capacity value, so as to obtain a fragmented data message, and in S103, the data message is fragmented based on the target data message capacity value, so that the fragmented data message may be implemented in S401 to S403, and the following steps are specifically described.
S401, respectively recalculating the network layer checksums of the fragmented data messages to obtain second checksums corresponding to the fragmented data messages.
In some embodiments of the present application, the network layer checksum, i.e., the IP layer checksum, is a field of the IP packet header that is used to detect any corruption or alteration of the IP packet header during transmission. And respectively recalculating the network layer checksums of the fragmented data messages to obtain second checksums, namely IP layer checksums, corresponding to the fragmented data messages.
S402, filling the first checksums of the second checksums into the corresponding first data messages respectively to obtain filled first data messages.
S403, respectively filling the second checksums into the corresponding second data messages to obtain filled second data messages.
In some embodiments of the present application, after slicing a data packet to obtain a sliced data packet, a first checksum, i.e. a TCP/UDP checksum, and a second checksum, i.e. an IP layer checksum, are filled into a first piece of data packet, i.e. a first data packet, in the sliced data packet, so as to obtain a filled first data packet. And respectively filling the second checksum into other data messages except the first data message to obtain a filled second data message.
Illustratively, the IPV4 packet is fragmented, resulting in a first packet, a second packet, a third packet, and so on. The TCP/UDP checksum and the IP layer checksum are filled into the first data packet, and the IP layer checksum is filled into the second data packet, the third data packet and other data packets except the first data packet.
S304, transmitting the filled first data message and the filled second data message through a data transmission unit.
In some embodiments of the present application, if the message length of the first data message after filling and the second data message after filling is less than the set MTU, the first data message after filling and the second data message after filling are transmitted through the data transmission unit.
It can be appreciated that in some embodiments of the present application, the first checksum and the second checksum obtained by calculation are filled into the first data packet, and the second checksum is filled into other data packets, so that the integrity and accuracy of the fragmented data packet in the subsequent transmission process are ensured.
In some embodiments of the present application, S101 further includes S401, which will be specifically described by the following steps.
S401, when calculating the target data message capacity value, storing the data message in a cache pool.
In some embodiments of the present application, when calculating the MTU value, the data packet is stored in the buffer pool for waiting, and if it is the TCP/UDP protocol, the TCP/UDP checksum is calculated, and the other protocol messages do not calculate any checksum. After confirming the unloading capacity and calculating the TCP/UDP checksum, reading the data packet from the buffer pool and carrying out IP fragmentation according to the unloading capacity.
In combination with the above steps, as shown in fig. 3, fig. 3 is a schematic diagram of an IP fragment unloading state jump according to an embodiment of the present application. In fig. 3, an idle state (state_idle) is included, indicating one state in which the system is in a stationary or waiting state. I.e. the system is not performing any specific task or operation at this time, but rather is waiting for an external event or trigger to change its state, an ethernet Internet Protocol (IP) state (i.e. state_eth_ip) indicating the state of processing an ethernet frame and extracting an IP packet, i.e. the system is parsing the header of the ethernet frame and preparing to process the IP packet contained therein, determining whether to perform IP fragmentation by processing the ethernet frame and extracting the state of the IP packet, jumping to an ignore state when data fragmentation is not needed, and jumping to an Internet Protocol (IP) option state (i.e. state_ip_option) indicating the state of the system parsing an IPv6 extension header or processing an IPv6 option when data fragmentation is needed. I.e., the system is processing an extension header or option field in an IPv6 packet, and a transport layer header state (i.e., state_tp_header) indicating that the system is parsing the state of the transport layer protocol header. I.e. the system is handling header information of TCP (transmission control protocol), UDP (user datagram protocol) or other transport layer protocol, and the payload status (i.e. state_payload) indicates the status that the system is handling the payload. I.e. the system has completed parsing of the packet header and is ready to process the actual data in the packet, an ethernet Internet Protocol (IP) fragmentation state (i.e. state_fragment_eth_ip) indicating the state in which the system is processing the fragmented IP packets contained in an ethernet frame, i.e. the system is processing an ethernet frame containing one or more fragmented IP packets, an IP fragmentation processing option state (i.e. state_fragment_ip_option) indicating the state in which the system is processing fragmented IPv6 packets and the extension header in these fragmented packets is being parsed or processed. The fragmentation load status (i.e., state_frag_payload) is used to describe a particular stage in processing a fragmented packet, indicating that the device is processing the payload portion in the fragment.
It can be appreciated that in some embodiments of the present application, when calculating the target data message capacity value, the data message is stored in the buffer pool, so that the processor can perform the processing of the data slice, thereby reducing the waiting time and improving the performance of the system.
The application also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method provided by any of the above embodiments when executing the program.
The application also provides a computer readable medium having stored thereon a computer program which when executed by a processor implements the method provided by any of the above embodiments.
Referring to fig. 4, a schematic structural diagram of an electronic device according to an embodiment of the present application is shown, and the specific embodiment of the present application is not limited to the specific implementation of the electronic device.
As shown in FIG. 4, the electronic device may include a processor 1002, a communication interface (Communications Interface) 1004, a memory 1006, and a communication bus 1008.
Wherein:
the processor 1002, communication interface 1004, and memory 1006 communicate with each other via a communication bus 1008.
Communication interface 1004 is used to communicate with other electronic devices or servers.
The processor 1002 is configured to execute the program 1010, and may specifically perform relevant steps in the method embodiments described above.
In particular, program 1010 may include program code including computer operating instructions.
The processor 1002 may be a central processing unit CPU, or an Application-specific integrated Circuit ASIC (Application SPECIFIC INTEGRATED Circuit), or one or more integrated circuits configured to implement embodiments of the present application. The one or more processors included in the smart device may be the same type of processor, such as one or more CPUs, or different types of processors, such as one or more CPUs and one or more ASICs.
Memory 1006 for storing programs 1010. The memory 1006 may include high-speed RAM memory or may further include non-volatile memory (non-volatile memory), such as at least one magnetic disk memory.
The program 1010 may be specifically configured to cause the processor 1002 to perform operations corresponding to the methods described in the above method embodiments.
The specific implementation of each step in the program 1010 may refer to the corresponding steps and corresponding descriptions in the units in the above method embodiments, which are not repeated herein. It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus and modules described above may refer to corresponding procedure descriptions in the foregoing method embodiments, which are not repeated herein.
It should be noted that, according to implementation requirements, each component/step described in the embodiments of the present application may be split into more components/steps, or two or more components/steps or part of operations of the components/steps may be combined into new components/steps, so as to achieve the objects of the embodiments of the present application.
The above-described methods according to embodiments of the present application may be implemented in hardware, firmware, or as software or computer code storable in a recording medium such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk, or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium and to be stored in a local recording medium downloaded through a network, so that the methods described herein may be stored on such software processes on a recording medium using a general purpose computer, special purpose processor, or programmable or special purpose hardware such as an ASIC or FPGA. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code that, when accessed and executed by a computer, processor, or hardware, performs the methods described herein. Furthermore, when a general purpose computer accesses code for implementing the methods illustrated herein, execution of the code converts the general purpose computer into a special purpose computer for performing the methods illustrated herein.
Those of ordinary skill in the art will appreciate that the elements and method steps of the examples described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
The above embodiments are only for illustrating the embodiments of the present application, but not for limiting the embodiments of the present application, and various changes and modifications may be made by one skilled in the relevant art without departing from the spirit and scope of the embodiments of the present application, so that all equivalent technical solutions also fall within the scope of the embodiments of the present application, and the scope of the embodiments of the present application should be defined by the claims.