Message processing method and device, electronic device and storage medium

By receiving TCP packets, calculating encapsulation lengths and adjusting packet lengths in distributed multi-layer VPN scenarios, the problem of low processing efficiency of VPN devices is solved, and efficient packet processing is achieved in multi-VPN scenarios.

CN115695308BActive Publication Date: 2025-02-11HILLSTONE NETWORKS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211405560.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-10
Publication Date
2025-02-11
Estimated Expiration
2042-11-10

AI Technical Summary

Technical Problem

In the distributed multi-layer VPN packaging scenario, the existing technology cannot effectively adjust the packet length, resulting in low processing efficiency of VPN devices.

Method used

By receiving TCP messages, calculating the packet encapsulation length, and adjusting the packet length to achieve the target packet length when the packet length is greater than the packet length, the processed TCP messages can be adapted to adjustment in multiple VPN scenarios.

Benefits of technology

It effectively avoids the problem of TCP packets that need to be processed in shards after multiple VPN devices are encapsulated, and improves the forwarding performance and processing efficiency of VPN devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115695308B_ABST
    Figure CN115695308B_ABST
Patent Text Reader

Abstract

The present invention discloses a message processing method and device, electronic device and storage medium, wherein the processing method comprises: receiving a TCP message, calculating the message encapsulation length when the TCP message is a message of a preset format, adjusting the message length when the message length is greater than the message encapsulation length, obtaining a target message length, and processing a TCP message whose message length is the target message length. The present invention solves the technical problem in the related art that the message length cannot be adjusted under distributed multi-layer VPN encapsulation, resulting in low processing efficiency of VPN equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a message processing method and device, electronic equipment and storage medium. Background Art

[0002] VPN (Virtual Private Network) is a technology that establishes a private network on a public network for encrypted communication. Tunneling technology is a technology used to implement a virtual private network (VPN).

[0003] In distributed devices, in order to balance the performance between multiple business devices, different VPN processes are placed on different devices for processing. VPN devices need to encapsulate the original message and add additional encapsulation headers. The encapsulated message will become longer. When the message needs to be encapsulated multiple times by VPN, the encapsulated message is likely to exceed the MTU (Maximum Transmission Unit). The message needs to be fragmented, which seriously reduces the forwarding performance of the device.

[0004] In the related technology, a message forwarding method based on IPsec (Internet Protocol Securit) tunnel is proposed, which can obtain the TCP handshake negotiation message transmitted between the client and the server, and then determine whether the transmission interface of the TCP handshake negotiation message is the IPsec interface. When the transmission interface of the TCP handshake negotiation message is the IPsec interface, the MSS value (Maximum Segment Size) of the TCP handshake negotiation message is modified, and the modified TCP handshake negotiation message is transmitted, which can achieve the effect of real-time dynamic modification of MSS based on the interface MTU.

[0005] However, the above-mentioned message forwarding method can only process IPSec VPN single-layer VPN encapsulation and is not suitable for distributed multi-layer VPN encapsulation scenarios.

[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0007] The embodiment of the present invention provides a message processing method and device, electronic device and storage medium, so as to at least solve the technical problem in the related art that the message length cannot be adjusted adaptively under distributed multi-layer VPN encapsulation, resulting in low VPN device processing efficiency.

[0008] According to one aspect of an embodiment of the present invention, a method for processing a message is provided, comprising: receiving a TCP message, wherein the TCP message carries a message length; when the TCP message is a message in a preset format, calculating a message encapsulation length; when the message length is greater than the message encapsulation length, adjusting the message length to obtain a target message length; and processing the TCP message whose message length is the target message length.

[0009] Optionally, before calculating the message encapsulation length, it also includes: obtaining an encapsulation information table, wherein the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit; determining an information lookup table, wherein the information lookup table is used to find the device information of the network device, and the device information includes at least: routing output interface, routing next hop.

[0010] Optionally, the step of calculating the message encapsulation length includes: searching the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result includes at least: a routing output interface and a routing next hop; querying the information lookup table based on the first routing result to obtain a first layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first layer network device is encapsulated with a next destination address; determining the encapsulation length and the transmission unit of the first layer network device based on the encapsulation information table; searching the routing table based on the next destination address to obtain a second routing result, and querying the information lookup table based on the second routing result until the last layer of network devices is queried, wherein the second routing result includes at least: a routing output interface and a routing next hop corresponding to the next layer of network devices; calculating the message encapsulation length based on the encapsulation length and the transmission unit of each layer of network devices.

[0011] Optionally, the step of calculating the message encapsulation length based on the encapsulation length and the transmission unit of each network device includes: determining the minimum transmission unit based on the transmission unit of each layer of network equipment; determining a preset address header length and a preset TCP header length; determining the sum of the encapsulation lengths of multiple layers of network devices; calculating the message encapsulation length based on the minimum transmission unit, the preset address header length, the preset TCP header length and the sum of the encapsulation lengths of multiple layers of network devices.

[0012] Optionally, the step of determining the sum of the encapsulation lengths of the multi-layer network devices includes: obtaining the encapsulation length of each layer of network devices; and accumulating the encapsulation length of each layer of network devices to obtain the sum of the encapsulation lengths of the multi-layer network devices.

[0013] Optionally, the step of adjusting the message length to obtain a target message length includes: reducing the current message length by a preset length value in sequence until a preset check is passed to obtain the target message length.

[0014] Optionally, the preset verification step includes: calculating the verification value of the TCP message based on the adjusted message length; when the verification value does not fall within the preset threshold range, continuing to adjust the message length until the verification value falls within the preset threshold range, thereby completing the adjustment of the message length.

[0015] According to another aspect of an embodiment of the present invention, a message processing device is also provided, including: a receiving unit, used to receive a TCP message, wherein the TCP message carries a message length; a calculating unit, used to calculate the message encapsulation length when the TCP message is a message of a preset format; an adjusting unit, used to adjust the message length to obtain a target message length when the message length is greater than the message encapsulation length; and a processing unit, used to process the TCP message whose message length is the target message length.

[0016] Optionally, the processing device also includes: a first acquisition module, used to obtain an encapsulation information table before calculating the message encapsulation length, wherein the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit; a first determination module, used to determine an information lookup table, wherein the information lookup table is used to look up device information of the network device, and the device information includes at least: routing output interface, routing next hop.

[0017] Optionally, the calculation unit includes: a first search module, used to search the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result includes at least: a routing output interface and a routing next hop; a first query module, used to query the information lookup table based on the first routing result, and obtain a first layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first layer network device is encapsulated with a next destination address; a second determination module, used to determine the encapsulation length and the transmission unit of the first layer network device based on the encapsulation information table; a second search module, used to search the routing table based on the next destination address to obtain a second routing result, and query the information lookup table based on the second routing result until the last layer of network devices is queried, wherein the second routing result includes at least: a routing output interface and a routing next hop corresponding to the next layer of network devices; a first calculation module, used to calculate the message encapsulation length based on the encapsulation length and the transmission unit of each layer of network devices.

[0018] Optionally, the first calculation module includes: a first determination submodule, used to determine the minimum transmission unit based on the transmission unit of each layer of network equipment; a second determination submodule, used to determine the preset address header length and the preset TCP header length; a third determination submodule, used to determine the sum of the encapsulation lengths of multi-layer network devices; the first calculation submodule, used to calculate the message encapsulation length based on the minimum transmission unit, the preset address header length, the preset TCP header length and the sum of the encapsulation lengths of the multi-layer network devices.

[0019] Optionally, the third determination submodule includes: a first acquisition submodule, used to acquire the encapsulation length of each layer of network equipment; a first accumulation submodule, used to accumulate the encapsulation length of each layer of network equipment to obtain the sum of the encapsulation lengths of multiple layers of network equipment.

[0020] Optionally, the adjustment unit includes: a first decreasing module, configured to sequentially decrease the current message length by a preset length value until a preset check is passed to obtain the target message length.

[0021] Optionally, the first verification module includes: a second calculation module, used to calculate the verification value of the TCP message based on the adjusted message length; a first adjustment module, used to continue adjusting the message length when the verification value does not fall within a preset threshold range, until the verification value falls within the preset threshold range, thereby completing the adjustment of the message length.

[0022] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned message processing method.

[0023] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned message processing method.

[0024] In the present disclosure, a TCP message is received, and when the TCP message is a message of a preset format, the message encapsulation length is calculated, and when the message length is greater than the message encapsulation length, the message length is adjusted to obtain a target message length, and a TCP message whose message length is the target message length is processed. In the present disclosure, if the TCP message is a message of a preset format, the message encapsulation length can be calculated first, and then the message length of the TCP message and the message encapsulation length can be compared. If the message length is greater than the message encapsulation length, the TCP message is processed after the message length is adjusted, and the message length can be adjusted in multiple VPN scenarios, effectively avoiding the problem that the TCP message needs to be fragmented after passing through multiple VPN devices, improving the forwarding performance and processing efficiency of the VPN device, and thus solving the technical problem that the message length cannot be adjusted in the distributed multi-layer VPN encapsulation in the related technology, resulting in low processing efficiency of the VPN device. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0026] Figure 1 is a flowchart of an optional message processing method according to an embodiment of the present invention;

[0027] Figure 2 is a schematic diagram of an optional process for processing TCP packets according to an embodiment of the present invention;

[0028] Figure 3 is a schematic diagram of an optional TCP_MSS value adjustment process according to an embodiment of the present invention;

[0029] Figure 4 is a schematic diagram of an optional message processing device according to an embodiment of the present invention;

[0030] Figure 5 The present invention is a hardware structure block diagram of an electronic device (or mobile device) for a message processing method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0033] To facilitate those skilled in the art to understand the present invention, some terms or nouns involved in the embodiments of the present invention are explained below:

[0034] Transmission Control Protocol (TCP) is a connection-oriented, reliable, byte stream-based transport layer communication protocol.

[0035] SYN message: used to request and establish a connection, and can also be used to synchronize serial numbers between devices.

[0036] ACK message is used to confirm whether the remote end has received the SYN message.

[0037] SYN_ACK message: from the local device and the previous ACK message.

[0038] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0039] In order to achieve the best transmission performance, the TCP protocol usually negotiates the MSS value of both parties when establishing a connection. When the TCP layer of the sender finds that the data exceeds the MSS, it will first fragment it, so that no additional fragmentation is required during the transmission process.

[0040] In order to avoid the problem that TCP messages need to be fragmented after multiple VPN encapsulations between distributed devices, resulting in performance degradation, the present invention proposes a method for adjusting a suitable TCP_MSS value (i.e., the message length of the TCP message) in a multi-VPN scenario to reduce the need for re-fragmentation of the TCP message during the encapsulation process of the intermediate device. The method can calculate the message encapsulation length (i.e., the total length of multiple VPN encapsulations) under multi-layer VPN encapsulation in a distributed environment, and then can adaptively adjust the TCP_MSS value according to the total length of multiple VPN encapsulations, thereby improving the device forwarding performance.

[0041] The present invention is described in detail below in conjunction with various embodiments.

[0042] Embodiment 1

[0043] According to an embodiment of the present invention, an embodiment of a method for processing a message is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0044] Figure 1 is a flowchart of an optional message processing method according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:

[0045] Step S101: receiving a TCP message, wherein the TCP message carries a message length.

[0046] Step S102: When the TCP message is a message in a preset format, the message encapsulation length is calculated.

[0047] Step S103: When the message length is greater than the message encapsulation length, the message length is adjusted to obtain a target message length.

[0048] Step S104, processing a TCP message whose message length is the target message length.

[0049] Through the above steps, a TCP message can be received, and when the TCP message is a message of a preset format, the message encapsulation length is calculated, and when the message length is greater than the message encapsulation length, the message length is adjusted to obtain the target message length, and the TCP message whose message length is the target message length is processed. In an embodiment of the present invention, if the TCP message is a message of a preset format, the message encapsulation length can be calculated first, and then the message length of the TCP message and the message encapsulation length are compared. If the message length is greater than the message encapsulation length, the TCP message is processed after adjusting the message length, and the message length can be adjusted in a multi-VPN scenario, effectively avoiding the problem that the TCP message needs to be processed by fragmentation after passing through multiple VPN devices, improving the forwarding performance and processing efficiency of the VPN device, and thus solving the technical problem that the message length cannot be adjusted in a distributed multi-layer VPN encapsulation in the related technology, resulting in low processing efficiency of the VPN device.

[0050] The embodiment of the present invention is described in detail below in combination with the above steps.

[0051] Step S101: receiving a TCP message, wherein the TCP message carries a message length.

[0052] In the embodiment of the present invention, after a distributed VPN device receives a TCP message, it can adaptively adjust the message length according to the message length carried by the TCP message, so as to effectively avoid the problem that the TCP message needs to be fragmented again during the encapsulation process of the intermediate device.

[0053] Optionally, before calculating the message encapsulation length, it also includes: obtaining an encapsulation information table, wherein the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit; determining an information lookup table, wherein the information lookup table is used to find the device information of the network device, and the device information includes at least: routing output interface, routing next hop.

[0054] In an embodiment of the present invention, an encapsulation information table (i.e., a VPN encapsulation information table) may be obtained first. The VPN encapsulation information table is used to store the encapsulation length that needs to be additionally increased for each VPN device (i.e., a network device). When each VPN is created, it is stored in the information table according to the encapsulation length, and is removed from the information table when the VPN is deleted (i.e., the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit).

[0055] Table 1 is an optional VPN encapsulation information table, as shown in Table 1:

[0056] Table 1

[0057] VPN ID Package length MTU VPN-1 LEN-1 MTU-1 VPN-2 LEN-2 MTU-2 VPN-3 LEN-3 MTU-3 VPN-N LEN-N MTU-N

[0058] Among them, VPN ID (such as VPN-1, VPN-2, VPN-3, VPN-N) is the unique identifier of the VPN device, encapsulation length (such as LEN-1, LEN-2, LEN-3, LEN-N) is the encapsulation length that needs to be increased additionally, and MTU (such as MTU-1, MTU-2, MTU-3, MTU-N) is the maximum transmission unit of each network device.

[0059] Then, an information lookup table (ie, VPN lookup table) is determined. The information lookup table is used to look up device information of network devices. The device information at least includes: a routing output interface and a routing next hop.

[0060] In this embodiment, each VPN device stores an information search table of all VPN information (ie, device information) for searching for multi-layer VPN information through routing results (including routing outbound interfaces, routing next hops, etc.).

[0061] Table 2 is an optional VPN lookup table, as shown in Table 2:

[0062] Table 2

[0063] Routing outbound interface Route next hop VPN Interface-1 Nexthop-1 VPN-1 Interface-2 Nexthop-2 VPN-2 Interface-3 Nexthop-3 VPN-3 Interface-N Nexthop-N VPN-N

[0064] Each VPN device (such as VPN-1, VPN-2, VPN-3, VPN-N) corresponds to a routing outbound interface (such as Interface-1, Interface-2, Interface-3, Interface-N) and a routing next hop (such as Nexthop-1, Nexthop-2, Nexthop-3, Nexthop-N).

[0065] Step S102: When the TCP message is a message in a preset format, the message encapsulation length is calculated.

[0066] Optionally, the step of calculating the message encapsulation length includes: searching the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result includes at least: a routing output interface and a routing next hop; querying the information lookup table based on the first routing result to obtain a first-layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first-layer network device is encapsulated with the next destination address; determining the encapsulation length and transmission unit of the first-layer network device based on the encapsulation information table; searching the routing table based on the next destination address to obtain a second routing result, and querying the information lookup table based on the second routing result until the last layer of network devices is queried, wherein the second routing result includes at least: a routing output interface and a routing next hop corresponding to the next layer of network devices; calculating the message encapsulation length based on the encapsulation length and transmission unit of each layer of network devices.

[0067] In the embodiment of the present invention, it is possible to first check whether the received TCP message is a preset format message (such as STN or SYN_ACK message). If not, the message can be directly processed without adjusting the TCP_MSS value (i.e., message length) of the message. If the TCP message is a preset format message, it is necessary to perform TCP_MSS adjustment check processing, and the message encapsulation length must be calculated first, specifically: the routing table can be searched by the destination address of the TCP message to obtain the outgoing interface and the next hop (i.e., the routing table is searched based on the destination address carried by the TCP message to obtain the first routing result, and the first routing result at least includes: the routing outgoing interface and the routing next hop). Then, according to the outgoing interface and the next hop, the first layer encapsulation VPN-1 is searched from the VPN lookup table. If it is found, the encapsulation length LEN-1 and MTU-1 of VPN-1 are obtained (i.e., based on the first routing result, the information lookup table is queried to obtain the first layer network device corresponding to the routing outgoing interface and the routing next hop in the first routing result, and the first layer network device is encapsulated with the next destination address, and then based on the encapsulation information table, the encapsulation length and transmission unit of the first layer network device are determined); if not found, the message is directly processed. Then, according to the VPN-1 encapsulation destination IP address, the route is searched to obtain the outgoing interface and the next hop. According to the outgoing interface and the next hop, the Nth layer encapsulation VPN-N is obtained from the VPN lookup table. If found, the encapsulation length LEN-N and MTU-N of VPN-N are obtained (that is, the routing table is searched based on the next destination address to obtain the second routing result, and the information lookup table is searched based on the second routing result until the last layer of network equipment is queried. The second routing result at least includes: the routing outgoing interface and the routing next hop corresponding to the next layer of network equipment); if not found, the search is terminated and the VPN_MSS value (that is, the packet encapsulation length) is calculated (that is, the packet encapsulation length is calculated based on the encapsulation length and transmission unit of each layer of network equipment).

[0068] Optionally, the step of calculating the message encapsulation length based on the encapsulation length and transmission unit of each network device includes: determining the minimum transmission unit based on the transmission unit of each layer of network equipment; determining the preset address header length and the preset TCP header length; determining the sum of the encapsulation lengths of multiple layers of network devices; calculating the message encapsulation length based on the minimum transmission unit, the preset address header length, the preset TCP header length and the sum of the encapsulation lengths of multiple layers of network devices.

[0069] In the embodiment of the present invention, the minimum transmission unit MTU_min can be determined based on the transmission unit of each layer of network equipment, and then the preset address header length IP_len and the preset TCP header length TCP_len can be determined, and then the sum of the encapsulation lengths of the multi-layer network equipment ENCAP_LEN_SUM can be determined. Then, the message encapsulation length VPN_MSS value can be calculated based on the minimum transmission unit, the preset address header length, the preset TCP header length, and the sum of the encapsulation lengths of the multi-layer network equipment. The calculation formula of VPN_MSS is as follows:

[0070] VPN_MSS=MTU_min-IP_len-TCP_len-ENCAP_LEN_SUM;

[0071] Among them, MTU_min indicates the minimum MTU of N-layer VPN encapsulation; IP_len indicates the length of the IP header, which can be set to 20 bytes for the IPv4 header and 40 bytes for the IPv6 header; TCP_len indicates the length of the TCP header, which can be set to 20 bytes; ENCAP_LEN_SUM indicates the total length of the N-layer VPN encapsulation.

[0072] Optionally, the step of determining the total encapsulation length of the multi-layer network devices includes: obtaining the encapsulation length of each layer of network devices; accumulating the encapsulation length of each layer of network devices to obtain the total encapsulation length of the multi-layer network devices.

[0073] In the embodiment of the present invention, the encapsulation length of each layer of network equipment can be obtained first, and then the encapsulation length of each layer of network equipment can be accumulated to obtain the sum of the encapsulation lengths of multiple layers of network equipment ENCAP_LEN_SUM. The calculation formula of ENCAP_LEN_SUM is as follows:

[0074]

[0075] Wherein, LEN_i represents the encapsulation length of each layer of network equipment, N represents a total of N layers of network equipment, and N is a positive integer greater than or equal to 1.

[0076] Step S103: When the message length is greater than the message encapsulation length, the message length is adjusted to obtain a target message length.

[0077] In the embodiment of the present invention, after the VPN_MSS value is calculated, the TCP_MSS value and the VPN_MSS value of the TCP message record can be compared. If the TCP_MSS value is less than or equal to the VPN_MSS value, the VPN_MSS value does not need to be adjusted; if the TCP_MSS value is greater than the VPN_MSS value, the TCP_MSS value needs to be adjusted to obtain a TCP message with a target message length suitable for transmission.

[0078] Optionally, the step of adjusting the message length to obtain a target message length includes: decreasing the current message length by a preset length value in sequence until a preset check is passed to obtain the target message length.

[0079] In an embodiment of the present invention, the current message length may be reduced by a preset length value (the length value may be specifically set) in sequence until a preset check (i.e., checking that various parameters in the TCP message meet the standard) is passed to obtain a target message length.

[0080] Optionally, the preset verification step includes: calculating the verification value of the TCP message based on the adjusted message length; when the verification value does not fall within the preset threshold range, continuing to adjust the message length until the verification value falls within the preset threshold range, thereby completing the adjustment of the message length.

[0081] In an embodiment of the present invention, after each adjustment of the message length, the check value of the TCP message (i.e., the check value of various parameters in the TCP message) can be calculated. If the check value does not fall within a preset threshold range (the threshold range can be specifically set), the message length continues to be adjusted until the check value falls within the preset threshold range to complete the adjustment of the message length.

[0082] Step S104, processing a TCP message whose message length is the target message length.

[0083] In the embodiment of the present invention, after the message length adjustment is completed, a TCP message whose message length is the target message length can be processed.

[0084] In this embodiment, by setting a suitable TCP_MSS value, it is possible to effectively avoid the problem that the TCP message exceeds the MTU after multiple VPN encapsulations, resulting in the need for fragmentation, thereby improving forwarding performance.

[0085] For a specific TCP message processing process, the comparison before and after optimization is shown in Table 3 below. After optimization, fragmentation and reassembly are no longer required, which improves performance.

[0086] Table 3

[0087]

[0088] Another optional specific implementation is described in detail below.

[0089] Figure 2 is a schematic diagram of an optional process for processing TCP packets according to an embodiment of the present invention, such as Figure 2 As shown, the process is as follows:

[0090] (1) Check whether the TCP_MSS value of the TCP message needs to be adjusted;

[0091] (2) If not necessary, the adjustment process ends directly; otherwise, the length of a single VPN encapsulation is estimated, and the maximum encapsulation lengths of multiple VPNs are calculated to obtain the VPN_MSS value;

[0092] (3) Compare the VPN_MSS value and the TCP_MSS value, and adjust the TCP_MSS value based on the comparison result.

[0093] Figure 3 is a schematic diagram of an optional TCP_MSS value adjustment process according to an embodiment of the present invention, such as Figure 3 As shown, the process is as follows:

[0094] (1) Receive TCP messages;

[0095] (2) Check whether the TCP message is a SYN or SYN_ACK message. If not, process the message directly; otherwise, perform TCP_MSS adjustment check and processing;

[0096] (3) Search the routing table based on the destination IP address of the message to obtain the outgoing interface and next hop;

[0097] (4) Search the VPN lookup table based on the outgoing interface and the next hop to find the VPN, that is, search for the first layer encapsulation VPN-1 from the VPN lookup table. If found, obtain the encapsulation length LEN-1 and MTU-1 of VPN-1; if not found, directly process the message;

[0098] (5) Search the routing table based on the destination IP address of VPN-1 to obtain the outgoing interface and next hop.

[0099] (6) Search the VPN lookup table based on the outgoing interface and the next hop to find VPN-N, that is, obtain the Nth layer encapsulation VPN-N from the VPN lookup table. If found, obtain the encapsulation length LEN-N and MTU-N of VPN-N; if not found, end the search;

[0100] (7) Calculate VPN_MSS value;

[0101] (8) Adjust the TCP_MSS value based on the calculation results;

[0102] (9) Process the message.

[0103] For example, a manufacturer has a research and development headquarters and multiple branches, each of which is connected to the headquarters using GRE (Generic Routing Encapsulat ion) over IPSec VPN (GRE over IPSec can transmit data as long as there is a GRE tunnel, and IPSec is only for security). When transmitting TCP messages through the tunnel, it is easy to exceed the MTU fragmentation after TCP encapsulation, resulting in a decrease in forwarding performance. After using this embodiment to process TCP messages, the fragmentation of TCP messages during transmission is significantly reduced, thereby improving device performance.

[0104] In an embodiment of the present invention, in order to avoid the problem of performance degradation caused by the need to fragment TCP messages after multiple VPN encapsulation between distributed devices, a method is proposed to adjust the appropriate TCP_MSS value (i.e., the message length of the TCP message) in a multi-VPN scenario to reduce the need for re-fragmentation of the TCP message during the encapsulation process of the intermediate device, thereby improving the device forwarding performance.

[0105] The following is a detailed description in conjunction with another embodiment.

[0106] Embodiment 2

[0107] A message processing device provided in this embodiment includes multiple implementation units, each implementation unit corresponds to each implementation step in the above-mentioned embodiment 1.

[0108] Figure 4 is a schematic diagram of an optional message processing device according to an embodiment of the present invention, such as Figure 4 As shown, the processing device may include: a receiving unit 40, a calculating unit 41, an adjusting unit 42, and a processing unit 43, wherein:

[0109] The receiving unit 40 is used to receive a TCP message, wherein the TCP message carries a message length;

[0110] A calculation unit 41, configured to calculate a message encapsulation length when the TCP message is a message in a preset format;

[0111] An adjusting unit 42, configured to adjust the message length to obtain a target message length when the message length is greater than the message encapsulation length;

[0112] The processing unit 43 is used to process a TCP message whose message length is the target message length.

[0113] The above-mentioned processing device can receive a TCP message through the receiving unit 40, calculate the message encapsulation length through the calculation unit 41 when the TCP message is a message of a preset format, adjust the message length through the adjustment unit 42 when the message length is greater than the message encapsulation length, obtain the target message length, and process the TCP message whose message length is the target message length through the processing unit 43. In the embodiment of the present invention, if the TCP message is a message of a preset format, the message encapsulation length can be calculated first, and then the message length of the TCP message and the message encapsulation length can be compared. If the message length is greater than the message encapsulation length, the TCP message is processed after adjusting the message length, and the message length can be adjusted in a multi-VPN scenario, effectively avoiding the problem that the TCP message needs to be fragmented after passing through multiple VPN devices, improving the forwarding performance and processing efficiency of the VPN device, and thus solving the technical problem that the message length cannot be adjusted in a distributed multi-layer VPN encapsulation in the related art, resulting in low processing efficiency of the VPN device.

[0114] Optionally, the processing device also includes: a first acquisition module, used to obtain an encapsulation information table before calculating the message encapsulation length, wherein the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit; a first determination module, used to determine the information lookup table, wherein the information lookup table is used to look up device information of the network device, and the device information includes at least: routing output interface, routing next hop.

[0115] In an embodiment of the present invention, an encapsulation information table (i.e., a VPN encapsulation information table) may be obtained first. The VPN encapsulation information table is used to store the encapsulation length that needs to be additionally increased for each VPN device (i.e., a network device). When each VPN is created, it is stored in the information table according to the encapsulation length, and is removed from the information table when the VPN is deleted (i.e., the encapsulation information table is used to record the encapsulation information of each network device, and the encapsulation information includes at least: encapsulation length, transmission unit).

[0116] Then, an information lookup table (ie, VPN lookup table) is determined. The information lookup table is used to look up device information of network devices. The device information at least includes: a routing output interface and a routing next hop.

[0117] In this embodiment, each VPN device stores an information search table of all VPN information (ie, device information) for searching for multi-layer VPN information through routing results (including routing outbound interfaces, routing next hops, etc.).

[0118] Optionally, the calculation unit includes: a first search module, used to search the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result includes at least: a routing output interface and a routing next hop; a first query module, used to query the information lookup table based on the first routing result, and obtain a first-layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first-layer network device is encapsulated with the next destination address; a second determination module, used to determine the encapsulation length and transmission unit of the first-layer network device based on the encapsulation information table; a second search module, used to search the routing table based on the next destination address to obtain a second routing result, and query the information lookup table based on the second routing result until the last layer of network devices is queried, wherein the second routing result includes at least: a routing output interface and a routing next hop corresponding to the next layer of network devices; a first calculation module, used to calculate the message encapsulation length based on the encapsulation length and transmission unit of each layer of network devices.

[0119] In the embodiment of the present invention, it is possible to first check whether the received TCP message is a preset format message (such as STN or SYN_ACK message). If not, the message can be directly processed without adjusting the TCP_MSS value (i.e., message length) of the message. If the TCP message is a preset format message, it is necessary to perform TCP_MSS adjustment check processing, and the message encapsulation length must be calculated first, specifically: the routing table can be searched by the destination address of the TCP message to obtain the outgoing interface and the next hop (i.e., the routing table is searched based on the destination address carried by the TCP message to obtain the first routing result, and the first routing result at least includes: the routing outgoing interface and the routing next hop). Then, according to the outgoing interface and the next hop, the first layer encapsulation VPN-1 is searched from the VPN lookup table. If it is found, the encapsulation length LEN-1 and MTU-1 of VPN-1 are obtained (i.e., based on the first routing result, the information lookup table is queried to obtain the first layer network device corresponding to the routing outgoing interface and the routing next hop in the first routing result, and the first layer network device is encapsulated with the next destination address, and then based on the encapsulation information table, the encapsulation length and transmission unit of the first layer network device are determined); if not found, the message is directly processed. Then, according to the VPN-1 encapsulation destination IP address, the route is searched to obtain the outgoing interface and the next hop. According to the outgoing interface and the next hop, the Nth layer encapsulation VPN-N is obtained from the VPN lookup table. If found, the encapsulation length LEN-N and MTU-N of VPN-N are obtained (that is, the routing table is searched based on the next destination address to obtain the second routing result, and the information lookup table is searched based on the second routing result until the last layer of network equipment is queried. The second routing result at least includes: the routing outgoing interface and the routing next hop corresponding to the next layer of network equipment); if not found, the search is terminated and the VPN_MSS value (that is, the packet encapsulation length) is calculated (that is, the packet encapsulation length is calculated based on the encapsulation length and transmission unit of each layer of network equipment).

[0120] Optionally, the first calculation module includes: a first determination submodule, used to determine the minimum transmission unit based on the transmission unit of each layer of network equipment; a second determination submodule, used to determine the preset address header length and the preset TCP header length; a third determination submodule, used to determine the sum of the encapsulation lengths of multiple layers of network equipment; the first calculation submodule, used to calculate the message encapsulation length based on the minimum transmission unit, the preset address header length, the preset TCP header length and the sum of the encapsulation lengths of multiple layers of network equipment.

[0121] In the embodiment of the present invention, the minimum transmission unit MTU_min can be determined based on the transmission unit of each layer of network equipment, and then the preset address header length IP_len and the preset TCP header length TCP_len can be determined, and then the sum of the encapsulation lengths of the multi-layer network equipment ENCAP_LEN_SUM can be determined. Then, the message encapsulation length VPN_MSS value can be calculated based on the minimum transmission unit, the preset address header length, the preset TCP header length, and the sum of the encapsulation lengths of the multi-layer network equipment. The calculation formula of VPN_MSS is as follows:

[0122] VPN_MSS=MTU_min-IP_len-TCP_len-ENCAP_LEN_SUM;

[0123] Among them, MTU_min indicates the minimum MTU of N-layer VPN encapsulation; IP_len indicates the length of the IP header, which can be set to 20 bytes for the IPv4 header and 40 bytes for the IPv6 header; TCP_len indicates the length of the TCP header, which can be set to 20 bytes; ENCAP_LEN_SUM indicates the total length of the N-layer VPN encapsulation.

[0124] Optionally, the third determination submodule includes: a first acquisition submodule, used to acquire the encapsulation length of each layer of network equipment; a first accumulation submodule, used to accumulate the encapsulation length of each layer of network equipment to obtain the sum of the encapsulation lengths of multiple layers of network equipment.

[0125] In the embodiment of the present invention, the encapsulation length of each layer of network equipment can be obtained first, and then the encapsulation length of each layer of network equipment can be accumulated to obtain the sum of the encapsulation lengths of multiple layers of network equipment ENCAP_LEN_SUM. The calculation formula of ENCAP_LEN_SUM is as follows:

[0126]

[0127] Wherein, LEN_i represents the encapsulation length of each layer of network equipment, N represents a total of N layers of network equipment, and N is a positive integer greater than or equal to 1.

[0128] Optionally, the adjustment unit includes: a first decreasing module, used to sequentially decrease the current message length by a preset length value until a preset check is passed to obtain a target message length.

[0129] In an embodiment of the present invention, the current message length may be reduced by a preset length value (the length value may be specifically set) in sequence until a preset check (i.e., checking that various parameters in the TCP message meet the standard) is passed to obtain a target message length.

[0130] Optionally, the first verification module includes: a second calculation module, used to calculate the verification value of the TCP message based on the adjusted message length; a first adjustment module, used to continue adjusting the message length when the verification value does not fall within the preset threshold range, until the verification value falls within the preset threshold range, thereby completing the adjustment of the message length.

[0131] In an embodiment of the present invention, after each adjustment of the message length, the check value of the TCP message (i.e., the check value of various parameters in the TCP message) can be calculated. If the check value does not fall within a preset threshold range (the threshold range can be specifically set), the message length continues to be adjusted until the check value falls within the preset threshold range to complete the adjustment of the message length.

[0132] The above-mentioned processing device may also include a processor and a memory. The above-mentioned receiving unit 40, calculation unit 41, adjustment unit 42, processing unit 43, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0133] The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set to process TCP packets with a target packet length by adjusting kernel parameters.

[0134] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.

[0135] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: receiving a TCP message, and when the TCP message is a message in a preset format, calculating the message encapsulation length, and when the message length is greater than the message encapsulation length, adjusting the message length to obtain a target message length, and processing a TCP message with a message length that is the target message length.

[0136] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned message processing method.

[0137] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the above-mentioned message processing method.

[0138] Figure 5 1 is a hardware structure block diagram of an electronic device (or mobile device) for a message processing method according to an embodiment of the present invention. Figure 5 As shown, the electronic device may include one or more (502a, 502b, ..., 502n are used to illustrate) processors 502 (the processor 502 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 504 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 5 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 5 More or fewer components as shown, or with Figure 5 Different configurations are shown.

[0139] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0140] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0141] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0142] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0143] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0144] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0145] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for processing a message, characterized in that: include: Receiving a TCP message, wherein the TCP message carries a message length; In the case where the TCP message is a message of a preset format, the message encapsulation length is calculated, wherein the step of calculating the message encapsulation length includes: searching the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result includes at least: a routing output interface and a routing next hop; querying the information lookup table based on the first routing result to obtain a first layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first layer network device is encapsulated with a next destination address; determining the encapsulation length and transmission unit of the first layer network device based on the encapsulation information table; searching the routing table based on the next destination address to obtain a second routing result, and querying the information lookup table based on the second routing result until the last layer network device is queried, wherein the second routing result includes at least: a routing output interface and a routing next hop corresponding to the next layer network device; calculating the message encapsulation length based on the encapsulation length and the transmission unit of each layer network device; When the message length is greater than the message encapsulation length, adjusting the message length to obtain a target message length; Process the TCP message whose message length is the target message length.

2. The processing method according to claim 1, characterized in that: Before calculating the packet encapsulation length, the following are also included: Obtaining an encapsulation information table, wherein the encapsulation information table is used to record encapsulation information of each network device, and the encapsulation information at least includes: encapsulation length and transmission unit; An information lookup table is determined, wherein the information lookup table is used to look up device information of the network device, and the device information at least includes: a routing output interface and a routing next hop.

3. The processing method according to claim 1, characterized in that: The step of calculating the message encapsulation length based on the encapsulation length of each network device and the transmission unit includes: Determine a minimum transmission unit based on the transmission unit of each layer of network equipment; Determine the preset address header length and the preset TCP header length; Determine the sum of the encapsulation lengths of multi-layer network devices; The message encapsulation length is calculated based on the minimum transmission unit, the preset address header length, the preset TCP header length and the sum of the multi-layer network device encapsulation lengths.

4. The processing method according to claim 3, characterized in that: The steps of determining the sum of encapsulation lengths of a multi-layer network device include: Obtain the encapsulation length of each layer of network equipment; The encapsulation lengths of the network devices at each layer are accumulated to obtain the sum of the encapsulation lengths of the network devices at multiple layers.

5. The processing method according to claim 1, characterized in that: The step of adjusting the message length to obtain a target message length includes: The current message length is reduced by the preset length value in sequence until the preset check passes, thereby obtaining the target message length.

6. The processing method according to claim 5, characterized in that: The steps of preset verification include: Based on the adjusted message length, calculating the check value of the TCP message; When the check value does not belong to the preset threshold range, the message length continues to be adjusted until the check value belongs to the preset threshold range, thereby completing the adjustment of the message length.

7. A message processing device, characterized in that: include: A receiving unit, configured to receive a TCP message, wherein the TCP message carries a message length; A calculation unit, used for calculating the message encapsulation length when the TCP message is a message in a preset format; An adjusting unit, configured to adjust the message length to obtain a target message length when the message length is greater than the message encapsulation length; A processing unit, configured to process the TCP message whose message length is the target message length; The calculation unit includes: a first search module, which is used to search the routing table based on the destination address carried by the TCP message to obtain a first routing result, wherein the first routing result at least includes: a routing output interface and a routing next hop; a first query module, which is used to query the information lookup table based on the first routing result to obtain a first-layer network device corresponding to the routing output interface and the routing next hop in the first routing result, wherein the first-layer network device is encapsulated with a next destination address; a second determination module, which is used to determine the encapsulation length and transmission unit of the first-layer network device based on the encapsulation information table; a second search module, which is used to search the routing table based on the next destination address to obtain a second routing result, and query the information lookup table based on the second routing result until the last layer of network devices is queried, wherein the second routing result at least includes: a routing output interface and a routing next hop corresponding to the next layer of network devices; a first calculation module, which is used to calculate the message encapsulation length based on the encapsulation length and the transmission unit of each layer of network devices.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the message processing method according to any one of claims 1 to 6.

9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the message processing method described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Negotiation method and apparatus of maximum segment size (MSS)

    CN103647759A