Tcp packet encapsulation method and device, electronic equipment and storage medium

By segmenting TCP packets and optimizing redundant fields, the problem of low TCP data transmission rate was solved, achieving more efficient data transmission.

CN119324947BActive Publication Date: 2025-11-25SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411151694.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2025-11-25
Estimated Expiration
2044-08-21

AI Technical Summary

Technical Problem

The low TCP data transmission rate in existing technologies is mainly due to the excessive overhead caused by the repeated transmission of redundant fields during the TCP segmentation and offloading process.

Method used

After receiving TCP packets sent by the local CPU and establishing a communication connection with the other end, the packets are segmented into at least two first-segment packets. Redundant fields in each first-segment packet are optimized, the first encapsulated packet is determined, and the second encapsulated packet is determined based on the local verification status data, thereby reducing the transmission of redundant fields.

Benefits of technology

It effectively reduces the overhead of TCP packet headers, improves the efficiency of real-time data transmission, reduces the repeated transmission of redundant fields, and enhances the performance of network communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119324947B_ABST
    Figure CN119324947B_ABST
Patent Text Reader

Abstract

The application provides a TCP message encapsulation method and device, electronic equipment and storage medium, and relates to the technical field of data transmission. The method comprises the following steps: receiving a TCP message sent by a CPU at a local end, and segmenting the TCP message into at least two first segment messages under the condition that a communication connection is established between a peer end and the local end; optimizing a redundant field in each first segment message to determine each first encapsulation message; for each first encapsulation message, determining a second encapsulation message corresponding to the first encapsulation message based on corresponding check state data of the local end; and the check state data is used to indicate whether the first encapsulation message enables check and unloads. The application can effectively reduce the head cost and improve the transmission rate of data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data transmission, and particularly relates to a TCP message encapsulation method and device, electronic equipment and a storage medium. BACKGROUND

[0002] TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer protocol. TCP can ensure the integrity and accuracy of data through its own series of characteristics. TCP is widely used in network communication that requires reliability, but these characteristics of TCP also bring additional performance overhead and complexity, which limits its real-time communication and high-efficiency transmission. For example, TCP needs to perform three-way handshake when connecting and four-way handshake when disconnecting. Although this constraint ensures the stability of data transmission, it greatly reduces the speed of real-time communication.

[0003] In the prior art, TSO (TCP Segment Offload) technology is generally used to dynamically adjust the size of the data packet to adapt to the MTU (Maximum Transmission Unit) of different network segments, reduce the performance loss caused by IP (Internet Protocol) layer fragmentation, reduce delay, and improve the overall performance of network communication.

[0004] However, when segmenting and offloading TCP data packets, the IP header and the complete TCP header are saved. As shown in Figure 1 , a complete TCP data packet is segmented into multiple smaller segment messages according to the MSS (Maximum Segment Size). The TCP frame header of each segment message is as shown in Figure 2 . The TCP frame header shown in Figure 2 is retransmitted when each segment message is sent, which greatly reduces the data transmission rate. SUMMARY

[0005] The present application provides a TCP message encapsulation method, device, electronic equipment and storage medium, which effectively reduces the header overhead and improves the data transmission rate to solve the problem of low data transmission rate in the prior art.

[0006] The present application provides a TCP message encapsulation method, comprising:

[0007] receiving a TCP message sent by a CPU at a local end, and segmenting the TCP message into at least two first segment messages under the condition that a communication connection is established between a peer end and the local end.

[0008] optimizing the redundant fields in each of the first segmented packets to determine each first encapsulation packet;

[0009] for each of the first encapsulation packets, determining a second encapsulation packet corresponding to the first encapsulation packet based on the check state data corresponding to the local end, the check state data being used to indicate whether the first encapsulation packet enables check and offload.

[0010] According to the TCP packet encapsulation method provided by the application, the redundant fields include a source port and a destination port.

[0011] The optimization of the redundant fields in each of the first segmented packets to determine each first encapsulation packet comprises:

[0012] obtaining the source port and the destination port confirmed by the opposite end and the local end in the communication process;

[0013] for each of the first segmented packets, deleting the source port and the destination port in the TCP frame header of the first segmented packet to determine a second segmented packet, and determining the first encapsulation packet based on the segment type corresponding to the second segmented packet, the segment type being used to represent the position of the second segmented packet in the TCP packet.

[0014] According to the TCP packet encapsulation method provided by the application, the redundant fields further include a sequence number.

[0015] The determination of the first encapsulation packet based on the segment type corresponding to the second segmented packet comprises:

[0016] in the case that the segment type corresponding to the second segmented packet is a first segment packet, the second segmented packet is determined as the first encapsulation packet;

[0017] in the case that the segment type corresponding to the second segmented packet is a non-first segment packet, the sequence number is deleted in the TCP frame header of the second segmented packet to obtain the first encapsulation packet.

[0018] The determination of the second encapsulation packet corresponding to the first encapsulation packet based on the check state data corresponding to the local end comprises:

[0019] in the case that the check state data indicates that the local end enables check and offload, the check sum corresponding to the first encapsulation packet is determined, and the TCP frame header of the first encapsulation packet is updated based on the check sum to obtain a second encapsulation packet;

[0020] In a case that the check state data indicates that the local end does not enable check and offload, the first encapsulation packet is determined as the second encapsulation packet.

[0021] According to the TCP packet encapsulation method provided in the application, the determination of the check sum corresponding to the first encapsulation packet comprises:

[0022] The check sum corresponding to the first encapsulation packet is determined based on the pseudo header corresponding to the first encapsulation packet.

[0023] According to the TCP packet encapsulation method provided in the application, the method further comprises:

[0024] The second encapsulation packets are sequentially sent to the opposite end according to the segment order of the second encapsulation packets.

[0025] The application further provides a TCP packet encapsulation device, comprising:

[0026] The receiving module is configured to receive a TCP packet sent by a CPU of a local end, and in a case that a communication connection is established between the opposite end and the local end, segment the TCP packet into at least two first segment packets.

[0027] The optimization module is configured to, in a case that a communication connection is established between the opposite end and the local end, optimize a redundant field in each first segment packet, and determine each first encapsulation packet.

[0028] The determination module is configured to, for each first encapsulation packet, determine a second encapsulation packet corresponding to the first encapsulation packet based on check state data corresponding to the local end, wherein the check state data is used to indicate whether the first encapsulation packet enables check and offload.

[0029] The application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the TCP packet encapsulation method of any of the above when executing the computer program.

[0030] The application further provides a non-transitory computer readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the TCP packet encapsulation method of any of the above.

[0031] The application further provides a computer program product comprising a computer program, wherein the computer program is executable on a processor to implement the TCP packet encapsulation method of any of the above.

[0032] The application provides a TCP message encapsulation method and device, electronic equipment and a storage medium. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.

[0034] Figure 1 is a schematic diagram of segmenting and offloading TCP data packets provided by the prior art.

[0035] Figure 2 is a schematic diagram of a TCP frame header of a segment message provided by the prior art.

[0036] Figure 3 is a flowchart of a TCP message encapsulation method provided by an embodiment of the application.

[0037] Figure 4 is a flowchart of data transmission provided by an embodiment of the application.

[0038] Figure 5 is a schematic diagram of a TCP frame header enabling checksum offloading provided by an embodiment of the application.

[0039] Figure 6 is a schematic diagram of a second encapsulation message enabling checksum offloading provided by an embodiment of the application.

[0040] Figure 7 is a schematic diagram of a second encapsulation message not enabling checksum offloading provided by an embodiment of the application.

[0041] Figure 8 is a structural diagram of a TCP message encapsulation device provided by an embodiment of the application.

[0042] Figure 9 is a structural diagram of an electronic equipment provided by an embodiment of the application. DETAILED DESCRIPTION

[0043] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below in combination with the drawings in the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.

[0044] In order to solve the problem of low transmission rate of data in the prior art, the present application provides a TCP message encapsulation method, Figure 3 is a flowchart of the TCP message encapsulation method provided by the present application, as shown in Figure 3 The TCP message encapsulation method comprises the following steps 310 to 330.

[0045] Step 310, receiving a TCP message sent by a CPU in the local end, and segmenting the TCP message into at least two first segmented messages in the case that a communication connection is established between the opposite end and the local end.

[0046] Specifically, after receiving the TCP message sent by the CPU in the local end and the communication connection is established between the opposite end and the local end, if the TCP message exceeds the MTU (Maximum Transmission Unit) of the network segment, the electronic device can segment the TCP message by the MSS (Maximum Segment Size) negotiated in the communication process between the opposite end and the local end to obtain at least two first segmented messages. The MSS can be understood as the most suitable data block size in the data transmission process. The segmentation can better adapt to the network environment, reduce the load of the transmission of the single first segmented message, improve the network throughput, and realize the reliable transmission of data.

[0047] It should be noted that the TCP message encapsulation method provided by the present application is applied to an electronic device in the local end. The electronic device can comprise a network interface card or other hardware devices, and the electronic device is in communication connection with the CPU in the local end. The local end can be a client or a server. When the local end is a client, the opposite end is a server, and vice versa, when the local end is a server, the opposite end is a client.

[0048] Figure 4 is a flowchart of data transmission provided by the present application, as shown in Figure 4 Before the TCP message is segmented in the local end, the data transmission comprises the following steps.

[0049] S1, the application layer issues an instruction, the CPU in the local end executes the application program to issue an instruction, and prepares to send data.

[0050] S2, the to-be-sent data is delivered to the transport layer after being encapsulated by the presentation layer and the session layer, and the transport layer encapsulates the to-be-sent data by TCP (Transmission Control Protocol), adds necessary TCP header information to the to-be-sent data, and the TCP header information can include: source port number, destination port number, sequence number and length information. Then the to-be-sent data with the added TCP header information is transmitted to the network layer.

[0051] S3, the network layer adds IP (Internet Protocol) header information to the TCP header information of the to-be-sent data delivered, to form a TCP message. The IP header information can include: source IP address and destination IP address information. Then the network layer delivers the TCP message to the link layer. In the link layer, the electronic device adds a MAC (Media Access Control Address) frame header to the IP header information of the delivered TCP message, and the MAC frame header can include source MAC address, destination MAC address, type field and CRC (Cyclic Redundancy Check) field information. Then the TCP message with the added MAC frame header is delivered to the physical layer and communicates with the opposite end on the Ethernet medium.

[0052] S4, the communication connection between the local end and the opposite end is established by the "three-way handshake" in TCP. During the "three-way handshake", the opposite end and the local end will negotiate some communication parameters, which at least include part of the fields in the redundancy field and the MSS. The three-way handshake actually provides a parameter basis for subsequent data segmentation.

[0053] Step 320, optimizing the redundancy field in each of the first segment messages to determine each first encapsulated message.

[0054] Specifically, since the redundancy fields in each of the first segment messages are the same, by optimizing the redundancy fields in each of the first segment messages, each first encapsulated message is obtained, and by reducing the header overhead in each of the first segment messages, the repeated transmission of the redundancy field is avoided.

[0055] Further, the redundancy field includes a source port and a destination port.

[0056] The optimization of the redundancy field in each of the first segment messages to determine each first encapsulated message includes:

[0057] obtaining the source port and the destination port confirmed by the opposite end and the local end during the communication process;

[0058] For each first segmented packet, the source port and the destination port in the TCP frame header of the first segmented packet are deleted to determine a second segmented packet; the first encapsulated packet is determined based on a segment type corresponding to the second segmented packet, wherein the segment type is used to represent a position of the second segmented packet in the TCP packet.

[0059] Specifically, since the source port and the destination port of the peer and the local end are obtained during the "three-way handshake", to avoid repeated transmission of the source port and the destination port, the source port and the destination port in the TCP frame header of each first segmented packet can be deleted to obtain the second segmented packet with the optimized TCP frame header. Then, according to the segment type of each second segmented packet, i.e., according to the position of each second segmented packet in the TCP packet, the TCP frame header of each second segmented packet is further optimized to obtain each first encapsulated packet.

[0060] Further, the redundant field further includes an acknowledgement number.

[0061] The first encapsulated packet is determined based on a segment type corresponding to the second segmented packet, and the segment type is used to represent a position of the second segmented packet in the TCP packet.

[0062] In a case where the segment type corresponding to the second segmented packet is a first segment packet, the second segmented packet is determined as the first encapsulated packet.

[0063] In a case where the segment type corresponding to the second segmented packet is a non-first segment packet, the acknowledgement number in the TCP frame header of the second segmented packet is deleted to obtain the first encapsulated packet.

[0064] Specifically, since each second segmented packet belongs to the same TCP packet, the acknowledgement numbers of the second segmented packets are the same, which can be the response to the previous request. Therefore, for each second segmented packet, if the second segmented packet is a first segment packet of the TCP packet, the acknowledgement number in the TCP frame header of the first segment packet can be retained, i.e., the second segmented packet is directly determined as the first encapsulated packet. If the second segmented packet is a non-first segment packet of the TCP packet, the acknowledgement number in the TCP frame header of the non-first segment packet can be deleted, and the acknowledgement number of the first segment packet is shared, so that the same acknowledgement number does not need to be repeatedly sent in the transmission process of each non-first segment packet.

[0065] For example, as shown in the TCP frame header, Figure 2 After the source port, the destination port and the acknowledgement number are deleted, the TCP frame header can be optimized from a fixed 20 bytes to 12 bytes, reducing the overhead of the TCP frame header by 40%.

[0066] Step 330, for each first encapsulation packet, determining a second encapsulation packet corresponding to the first encapsulation packet based on the corresponding check state data of the local end; the check state data is used to indicate whether the first encapsulation packet enables check and offloading.

[0067] Specifically, after determining each first encapsulation packet, the check state data configured in the local end can be determined, and through the check state data, it can be determined whether the check and offloading is supported in the local end. Through the check state data, the TCP frame header of each first encapsulation packet can be further optimized to obtain the second encapsulation packet of the optimized user.

[0068] It should be noted that the check and offloading is an effective technology to improve network performance, which transfers the check and calculation and verification tasks of the data packet from the CPU to the electronic device, uses hardware acceleration to quickly complete the generation and verification of the check sum, reduces the delay in the data transmission process, effectively reduces the burden of the CPU, and improves the communication efficiency of the network.

[0069] Further, the determination of the second encapsulation packet corresponding to the first encapsulation packet based on the corresponding check state data of the local end comprises:

[0070] In the case that the check state data indicates that the local end enables check and offloading, the check sum corresponding to the first encapsulation packet is determined, and the TCP frame header of the first encapsulation packet is updated based on the check sum to obtain the second encapsulation packet;

[0071] In the case that the check state data indicates that the local end does not enable check and offloading, the first encapsulation packet is determined as the second encapsulation packet.

[0072] Specifically, if it is determined according to the check state data that the local end supports check and offloading, the electronic device calculates the check sum of the first encapsulation packet and verifies it, and inserts the value of the check sum into the check sum field in the TCP frame header of the first encapsulation packet to obtain the second encapsulation packet after optimization. If it is determined according to the check state data that the local end does not support check and offloading, the first encapsulation packet does not need to be further optimized, and the first encapsulation packet can be directly determined as the second encapsulation packet.

[0073] Further, the determination of the check sum corresponding to the first encapsulation packet comprises:

[0074] Based on the pseudo header corresponding to the first encapsulation packet, the check sum corresponding to the first encapsulation packet is determined.

[0075] Specifically, if checksum offload is supported at the local end, a pseudo header corresponding to each first encapsulated packet can be obtained, the pseudo header can include a source IP address, a destination IP address, a padding field, a protocol number, and a TCP packet length, etc. Each first encapsulated packet belongs to the same TCP packet, and thus the pseudo headers of the first encapsulated packets are the same. After determining the pseudo headers of the first encapsulated packets, the checksum of each first encapsulated packet can be calculated according to the pseudo header.

[0076] For example, Figure 5 is a schematic diagram of a TCP frame header enabling checksum offload provided by an embodiment of the present application, Figure 6 is a schematic diagram of a second encapsulated packet enabling checksum offload provided by an embodiment of the present application. If checksum offload is enabled at the local end, a redundant field is deleted, and a TCP frame header of the second encapsulated packet after insertion of the checksum is as shown in Figure 5 , and a complete second encapsulated packet is as shown in Figure 6 . In the figures, EH represents an Ethernet frame header, IPH represents an IP frame header, CRC represents an Ethernet checksum, TPi represents the i-th segment of TCP payload segment data, the TCP payload segment data of all second encapsulated packets can constitute TCP payload data of a TCP packet, i is a positive integer less than n, n represents the number of all second encapsulated packets, and THLC represents a TCP frame header enabling checksum offload.

[0077] In addition, if checksum offload is not enabled at the local end, the TCP frame header of the second encapsulated packet is different from the TCP frame header as shown in Figure 5 , in that the checksum field is empty. Figure 7 is a schematic diagram of a second encapsulated packet without enabling checksum offload provided by an embodiment of the present application, and a complete second encapsulated packet obtained is as shown in Figure 7 , in which THL represents a TCP frame header without enabling checksum offload.

[0078] It should be noted that the checksum is used to detect whether an error occurs in each first encapsulated packet during transmission, and the checksum is determined based on the pseudo header and the TCP payload data. Therefore, although the pseudo headers of the first encapsulated packets are the same, the TCP payload data in the first encapsulated packets are different, and thus the values of the checksums of the first encapsulated packets calculated are different.

[0079] Further, the method further includes:

[0080] According to the segment order of each second encapsulated packet, each second encapsulated packet is sequentially sent to the opposite end.

[0081] Specifically, after determining each second encapsulated packet, the electronic device can sequentially send each second encapsulated packet to the opposite end according to the segment order of each second encapsulated packet, to realize network communication between the local end and the opposite end.

[0082] The TCP packet encapsulation method provided in this embodiment of the invention segments the TCP packets sent by the local CPU to obtain at least two first segment packets. When a communication connection is established between the local and the remote end, redundant fields in each first segment packet are optimized to obtain an optimized first encapsulated packet. At the same time, based on the verification status data configured on the local end to enable or disable verification and offloading, the encapsulation method of each first encapsulated packet is optimized to obtain an optimized second encapsulated packet. This reduces the header overhead in each second encapsulated packet, avoids the repeated transmission of redundant fields, and thus improves the real-time data transmission efficiency.

[0083] The TCP packet encapsulation apparatus provided by the present invention is described below. The TCP packet encapsulation apparatus described below can be referred to in correspondence with the TCP packet encapsulation method described above.

[0084] This invention also provides a TCP packet encapsulation device. Figure 8 This is a schematic diagram of the TCP packet encapsulation device provided in an embodiment of the present invention, as shown below. Figure 8 As shown, the TCP packet encapsulation device 800 includes: a receiving module 810, an optimization module 820, and a determination module 830.

[0085] The receiving module 810 is used to receive TCP packets sent by the CPU of the local end, and, when a communication connection is established between the peer end and the local end, to segment the TCP packets into at least two first segment packets.

[0086] Optimization module 820 is used to optimize redundant fields in each of the first segmented messages and determine each of the first encapsulated messages when a communication connection is established between the peer end and the local end.

[0087] The determining module 830 is used to determine the second encapsulated message corresponding to each of the first encapsulated messages based on the verification status data corresponding to the local end; the verification status data is used to indicate whether the first encapsulated message enables verification and offloading.

[0088] The TCP packet encapsulation device provided in this embodiment of the invention segments the TCP packets sent by the local CPU to obtain at least two first segment packets. When a communication connection is established between the local and the remote end, the device optimizes the redundant fields in each first segment packet to obtain an optimized first encapsulated packet. At the same time, based on the verification status data configured on the local end to enable or disable verification and offloading, the device optimizes the encapsulation method of each first encapsulated packet to obtain an optimized second encapsulated packet. This reduces the header overhead in each second encapsulated packet and avoids the repeated transmission of redundant fields, thereby improving the real-time data transmission efficiency.

[0089] Optionally, the redundant field includes a source port and a destination port.

[0090] Optionally, the optimization module 820 is specifically configured to:

[0091] obtain the source port and the destination port confirmed by the peer end and the local end in the communication process;

[0092] for each of the first segmented packets, delete the source port and the destination port in the TCP frame header of the first segmented packet to determine a second segmented packet; determine the first encapsulation packet based on the segment type corresponding to the second segmented packet; the segment type is used to represent the position of the second segmented packet in the TCP packet.

[0093] Optionally, the redundant field further includes an acknowledgement number.

[0094] Optionally, the optimization module 820 is further configured to:

[0095] in a case where the segment type corresponding to the second segmented packet is a first segment packet, determine the second segmented packet as the first encapsulation packet;

[0096] in a case where the segment type corresponding to the second segmented packet is a non-first segment packet, delete the acknowledgement number in the TCP frame header of the second segmented packet to obtain the first encapsulation packet.

[0097] Optionally, the determination module 830 is specifically configured to:

[0098] in a case where the check state data indicates that the local end enables check sum offloading, determine the check sum corresponding to the first encapsulation packet, and update the TCP frame header of the first encapsulation packet based on the check sum to obtain a second encapsulation packet;

[0099] in a case where the check state data indicates that the local end does not enable check sum offloading, determine the first encapsulation packet as the second encapsulation packet.

[0100] Optionally, the determination module 830 is specifically configured to:

[0101] determine the check sum corresponding to the first encapsulation packet based on the pseudo header corresponding to the first encapsulation packet.

[0102] Optionally, the TCP packet encapsulation apparatus 800 further includes a sending module, which is specifically configured to:

[0103] send each of the second encapsulation packets to the peer end in the order of the segment order of the second encapsulation packets.

[0104] Figure 9This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present invention, such as... Figure 9 As shown, the electronic device may include: a processor 910, a communications interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communications interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute a TCP packet encapsulation method, which includes:

[0105] Receive TCP packets sent by the CPU at this end, and if a communication connection is established between the peer end and the local end, segment the TCP packets into at least two first segment packets;

[0106] Optimize redundant fields in each of the first segmented messages to determine each of the first encapsulated messages;

[0107] For each of the first encapsulated packets, a second encapsulated packet corresponding to the first encapsulated packet is determined based on the verification status data corresponding to the local end; the verification status data is used to indicate whether the first encapsulated packet enables verification and offloading.

[0108] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0109] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the TCP packet encapsulation method provided by the above methods, the method comprising:

[0110] receive a TCP packet sent by a CPU at a local end, and in a case that a communication connection is established between a peer end and the local end, segment the TCP packet into at least two first segment packets;

[0111] optimize a redundant field in each of the first segment packets, and determine each first encapsulation packet;

[0112] for each of the first encapsulation packets, determine a second encapsulation packet corresponding to the first encapsulation packet based on a corresponding check state data of the local end, the check state data being used to indicate whether the first encapsulation packet enables check and offloading.

[0113] In another aspect, the application further provides a non-transitory computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement a TCP packet encapsulation method provided by each of the above methods, the method comprising:

[0114] receive a TCP packet sent by a CPU at a local end, and in a case that a communication connection is established between a peer end and the local end, segment the TCP packet into at least two first segment packets;

[0115] optimize a redundant field in each of the first segment packets, and determine each first encapsulation packet;

[0116] for each of the first encapsulation packets, determine a second encapsulation packet corresponding to the first encapsulation packet based on a corresponding check state data of the local end, the check state data being used to indicate whether the first encapsulation packet enables check and offloading.

[0117] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0118] From the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software and necessary general hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0119] Finally, it should be noted that the above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the same; although the present application has been described in detail with reference to the foregoing examples, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A TCP packet encapsulation method, characterized in that, The method comprises the following steps: receiving a TCP packet sent by a CPU at a local end, and segmenting the TCP packet into at least two first segment packets in a case where a communication connection is established between a peer end and the local end; optimizing a redundant field in each of the first segment packets to determine each first encapsulation packet; determining, for each of the first encapsulation packets, a second encapsulation packet corresponding to the first encapsulation packet based on check state data corresponding to the local end; the check state data is used to indicate whether the first encapsulation packet enables check sum offloading; the redundant field comprises a source port and a destination port; the optimization of the redundant field in each of the first segment packets to determine each first encapsulation packet comprises the following steps: obtaining a source port and a destination port confirmed by the peer end and the local end in a communication process; for each of the first segment packets, deleting the source port and the destination port in a TCP frame header of the first segment packet to determine a second segment packet, and determining the first encapsulation packet based on a segment type corresponding to the second segment packet; the segment type is used to represent a position of the second segment packet in the TCP packet; the determination of the second encapsulation packet corresponding to the first encapsulation packet based on the check state data corresponding to the local end comprises the following steps: in a case where the check state data indicates that the local end enables check sum offloading, determining a check sum corresponding to the first encapsulation packet, and updating a TCP frame header of the first encapsulation packet based on the check sum to obtain a second encapsulation packet; in a case where the check state data indicates that the local end does not enable check sum offloading, determining the first encapsulation packet as the second encapsulation packet.

2. The TCP packet encapsulation method of claim 1, wherein, the redundant field further comprises an acknowledgement number; the determination of the first encapsulation packet based on the segment type corresponding to the second segment packet comprises the following steps: in a case where the segment type corresponding to the second segment packet is a first segment packet, determining the second segment packet as the first encapsulation packet; in a case where the segment type corresponding to the second segment packet is a non-first segment packet, deleting the acknowledgement number in a TCP frame header of the second segment packet to obtain the first encapsulation packet.

3. The TCP packet encapsulation method of claim 1, wherein, the determination of the check sum corresponding to the first encapsulation packet comprises the following step: determining the check sum corresponding to the first encapsulation packet based on a pseudo header corresponding to the first encapsulation packet.

4. The TCP packet encapsulation method according to any one of claims 1-3, characterized in that, The method further comprises the following step: sending each of the second encapsulation packets to the peer end in a segment order of the second encapsulation packets.

5. A TCP packet encapsulation apparatus characterized by comprising: The device comprises: a receiving module configured to receive a TCP packet sent by a CPU at a local end, and segment the TCP packet into at least two first segment packets in a case where a communication connection is established between a peer end and the local end; an optimization module configured to optimize a redundant field in each of the first segment packets to determine each first encapsulation packet in a case where the communication connection is established between the peer end and the local end; the redundant field comprises a source port and a destination port; a determination module configured to determine, for each of the first encapsulation packets, a second encapsulation packet corresponding to the first encapsulation packet based on check state data corresponding to the local end. The check status data is used to indicate whether the first encapsulation packet enables check sum offloading; The optimization module is specifically configured to: acquire source ports and destination ports confirmed by the opposite end and the local end in a communication process; for each first segment packet, delete the source ports and the destination ports in a TCP frame header of the first segment packet to determine a second segment packet; determine the first encapsulation packet based on a segment type corresponding to the second segment packet, wherein the segment type is used to represent a position of the second segment packet in the TCP packet; and determine a check sum corresponding to the first encapsulation packet and update a TCP frame header of the first encapsulation packet based on the check sum to obtain a second encapsulation packet when the check status data indicates that the local end enables check sum offloading. The first encapsulation packet is determined as the second encapsulation packet when the check status data indicates that the local end does not enable check sum offloading. The processor executes the computer program to implement the TCP packet encapsulation method in any one of claims 1 to 4. The computer program is executed by the processor to implement the TCP packet encapsulation method in any one of claims 1 to 4.

6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the TCP packet encapsulation method in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, ​ 8. A computer program product comprising a computer program, characterized in that, ​

Citation Information

Patent Citations

  • TCP (transmission control protocol) message transmission method and TCP message receiving method and device

    CN102377651A

  • Message encapsulation / decapsulation device and method

    CN102447627A