A method and system for improving UDP fragmentation forwarding performance based on PMTU
By constructing ICMP error messages in network communication devices to adjust the MTU value, the problem of low forwarding efficiency of UDP fragmented packets is solved, achieving fast forwarding and resource optimization, thereby improving device performance and user experience.
Patent Information
- Application Number
- CN202310297908.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2026-03-10
- Estimated Expiration
- 2043-03-24
AI Technical Summary
In existing technologies, network communication devices waste CPU and memory resources when forwarding UDP fragmented packets, failing to meet standard levels, especially for devices with weak CPU performance, and software/hardware acceleration modules cannot effectively forward UDP fragmented packets.
By constructing ICMP error messages to notify the client to modify the MTU value, and utilizing the PMTU mechanism, the UDP fragmentation packets are avoided from being cached and reassembled on the network communication device. Fragmentation is performed directly at the source end, and fast forwarding is achieved by combining software/hardware acceleration modules and the Linux protocol stack.
It improves the forwarding efficiency of UDP fragmented packets, reduces CPU and memory consumption, and enhances the competitiveness of the device and the user experience.
Smart Images

Figure CN116260895B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and specifically to a method and system for improving UDP fragmented packet forwarding performance based on PMTU. Background Technology
[0002] When forwarding UDP packets, the client fragments the packets according to its own MTU (default 1500). However, depending on the WAN access method (PPPoE, VPN, etc.), network communication devices need to encapsulate a header on top of the original packet before forwarding. The length of the packet after header encapsulation may exceed the maximum packet length specified by the protocol. If the original packet is not re-fragmented, it will be considered invalid by the upstream and discarded directly.
[0003] The existing approach involves network communication devices using the Linux protocol stack to forward UDP fragmented packets. Upon receiving a UDP fragmented packet, the device first caches it in the kernel protocol stack. After receiving all the UDP fragmented packets, it reassembles the cached UDP packets and then re-fragments them according to the destination interface's MTU before sending them out. This approach wastes a significant amount of memory and CPU processing power. For network communication devices with weak CPUs, the UDP fragmentation forwarding performance is limited and cannot reach standard levels.
[0004] Network communication devices that use software / hardware acceleration modules to forward UDP fragmented packets only support forwarding unfragmented UDP packets because these modules lack the function of caching and refragmenting packets. Since different network communication devices require caching received packets before refragmenting and sending them due to their different access methods, the lack of such caching and refragmentation capabilities in the software / hardware acceleration modules limits their ability to forward unfragmented UDP packets. This results in an inability to fully utilize existing resources for fast forwarding of fragmented UDP packets. Summary of the Invention
[0005] To address the problems in the prior art, this invention provides a method and system for improving UDP fragmented packet forwarding performance based on PMTU, thereby reducing CPU and memory consumption.
[0006] This invention relates to a method for improving UDP fragmented packet forwarding performance based on PMTU, comprising the following steps:
[0007] After a UDP connection packet enters the FORWAED chain of the Linux protocol stack for forwarding, it is determined whether it is the first packet of the UDP connection. If so, the Linux protocol stack fragmentation check step is executed, followed by forwarding; otherwise, PMTU is executed to speed up the process.
[0008] The processing procedure of the PMTU acceleration module is as follows:
[0009] S1: Obtain the exit routing information based on the destination IP address;
[0010] S2: Obtain the exit MTU value based on the exit routing information;
[0011] S3: Determine whether the length of the UDP connection packet exceeds the egress MTU value. If not, return to the Linux protocol stack to perform the fragmentation judgment step and then perform forwarding processing. If yes, execute step S4.
[0012] S4: Set a new egress MTU value according to the length of the UDP connection data packet, construct an ICMP error message, the ICMP error message includes the new egress MTU value used by the next hop, and then execute steps S5 and S6 simultaneously.
[0013] S5: Sends an ICMP error message to the source terminal to modify the egress MTU value to a new egress MTU value;
[0014] S6: Discard the UDP connection packet to be forwarded and wait for the source terminal to send a UDP connection packet message according to the new egress MTU value.
[0015] In a further improvement to this invention, after the newly constructed UDP connection data packet enters the PMTU acceleration processing module of the Linux protocol stack, step S3 also includes a judgment step: determining whether the source terminal successfully modified the outgoing MTU value.
[0016] If the modification fails, reconstruct and send an ICMP error message to the source terminal, and record the number of times the ICMP error message was sent.
[0017] The present invention is further improved by stopping the construction and transmission of ICMP error messages when the number of transmissions exceeds a set threshold, executing the Linux protocol stack fragmentation judgment step, and the data packets of the UDP connection are forwarded and processed through the normal Linux protocol stack.
[0018] The present invention is further improved. If the modification is successful, the Linux protocol stack forwarding process in step S3 is executed.
[0019] The present invention is further improved by adding an accelerated matching forwarding step to the method for improving UDP fragmented packet forwarding performance based on PMTU. The processing procedure of the accelerated matching forwarding step is as follows:
[0020] When a UDP connection packet is received, it first enters the acceleration module to match the acceleration entry. If the match is successful, the packet is accelerated and forwarded. If the match is unsuccessful, the packet is forwarded normally through the Linux protocol stack.
[0021] The present invention is further improved in step S3. If the length of the UDP connection data packet does not exceed the egress MTU value, the invention also includes a step of recording the forwarding information into the acceleration table entry, and then returning to the Linux protocol stack to perform the fragmentation judgment step after recording.
[0022] After the forwarding information is recorded in the acceleration table, all packets of the UDP connection that need to be received will first be matched with the acceleration table entry, and then enter the acceleration module for accelerated forwarding processing.
[0023] This invention also provides a system for implementing the method for improving UDP fragmented packet forwarding performance based on PMTU, comprising a protocol stack forwarding processing module and a PMTU acceleration processing module, wherein,
[0024] The protocol stack forwarding processing module includes:
[0025] The FORWAED chain: used to initiate UDP connection packet forwarding processing;
[0026] First determination module: used to determine whether the UDP connection packet is the first packet of the UDP connection;
[0027] Fragmentation Decision Module: Used to determine whether fragmentation is needed and to process the fragmentation accordingly;
[0028] Forwarding processing module: used for forwarding and processing the UDP connection data packets.
[0029] The PMTU acceleration processing module includes:
[0030] The module for obtaining outbound routing information is used to obtain outbound routing information based on the destination IP address.
[0031] The module for obtaining the outbound MTU value is used to obtain the outbound MTU value based on the outbound routing information.
[0032] The second judgment module is used to determine whether the length of the UDP connection data packet exceeds the egress MTU value.
[0033] ICMP Error Message Construction Module: Used to set a new egress MTU value based on the length of the UDP connection data packet and construct an ICMP error message, wherein the ICMP error message includes the new egress MTU value adopted by the next hop;
[0034] Sending module: Used to send ICMP error messages to the source terminal and to modify the egress MTU value to a new egress MTU value;
[0035] Packet dropping module: Used to drop UDP connection packets that are to be forwarded.
[0036] The present invention is further improved in that the second judgment module further includes a judgment unit: used to judge whether the source terminal successfully modified the exit MTU value, and the system further includes a counting module: used to record the number of ICMP error messages sent.
[0037] The present invention is further improved by including an accelerated matching forwarding module: used for accelerated forwarding of UDP connection packets that have successfully matched accelerated entries.
[0038] In a further improvement to the present invention, the second judgment module further includes a recording unit for recording forwarding information into an acceleration table entry.
[0039] Compared with existing technologies, the beneficial effects of this invention are as follows: By constructing ICMP error messages to notify the client to fragment UDP packets according to the modified MTU, this invention fully utilizes the software / hardware acceleration modules of network communication devices and the protocol stack of the Linux kernel. This eliminates the need to first cache received packets and then reassemble, segment, and fragment them based on different access methods. It fully utilizes existing software and hardware resources to quickly forward fragmented UDP packets, which is extremely useful for network communication devices with limited CPU processing power, greatly improving packet forwarding efficiency. Furthermore, since there is no need to cache received packets for reassembly, CPU and memory consumption can be effectively reduced, significantly enhancing product competitiveness and user experience. Attached Figure Description
[0040] To more clearly illustrate the solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0041] Figure 1 This is a flowchart of the method of the present invention;
[0042] Figure 2 This is a flowchart of a method according to an embodiment of the present invention. Detailed Implementation
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0044] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0045] This invention addresses the limitation that client UDP packets, when fragmented according to their own MTU (Maximum Transmission Unit, default 1500), cannot be quickly forwarded by network communication device software / hardware acceleration modules or Linux protocol stacks by using the Path Maximum Transmission Unit (PMTU) mechanism, thereby improving the forwarding performance of UDP fragmented data packets in network communication devices.
[0046] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0047] like Figure 1 As shown, the present invention provides a method for improving UDP fragmented packet forwarding performance based on PMTU, comprising the following steps:
[0048] After a UDP connection packet enters the FORWAED chain of the Linux protocol stack for forwarding, it is determined whether it is the first packet of the UDP connection. If so, the Linux protocol stack fragmentation judgment step is executed, and then forwarding is performed; otherwise, PMTU is executed to speed up the processing.
[0049] The processing procedure of the PMTU acceleration module is as follows:
[0050] S1: Obtain the exit routing information based on the destination IP address;
[0051] S2: Obtain the exit MTU value based on the exit routing information;
[0052] S3: Determine whether the length of the UDP connection packet exceeds the egress MTU value. If not, return to the Linux protocol stack to perform the fragmentation judgment step and then perform forwarding processing. If yes, execute step S4.
[0053] S4: Set a new egress MTU value according to the length of the UDP connection data packet, construct an ICMP error message, the ICMP error message includes the new egress MTU value used by the next hop, and then execute steps S5 and S6 simultaneously.
[0054] S5: Sends an ICMP error message to the source terminal to modify the egress MTU value to a new egress MTU value;
[0055] S6: Discard the UDP connection packet to be forwarded and wait for the source terminal to send a UDP connection packet message according to the new egress MTU value.
[0056] PMTU refers to the maximum MTU (Medium-to-Large Unit) that allows packets to be transmitted without fragmentation across all IP hops from the source address to the destination address on an Internet transmission path. The source terminal sends a data packet by setting the "Do Not Fragment (DF)" bit in the IP header. When a device along the path receives a packet with the DF bit set and its length exceeds the current MTU, it discards the packet and returns an ICMP unreachable error. Upon receiving the ICMP unreachable error, the source terminal sets the MTU carried in the ICMP error message to the current MTU and retransmits the data packet until no more ICMP error messages are returned along the path; the MTU at this point is the PMTU.
[0057] Because the constructed ICMP error message carries a new egress MTU value, when the source terminal receives the new egress MTU value, it modifies it, thus enabling smooth forwarding. This invention fully utilizes the software / hardware acceleration modules and Linux kernel protocol stack of network communication equipment, eliminating the need to first cache the received packets according to different egress access methods, then reassemble, segment, and send them in fragments. This is very useful for network communication equipment with weak CPU processing power, greatly improving packet forwarding efficiency, reducing CPU and memory consumption, and significantly enhancing product competitiveness and user experience.
[0058] like Figure 2 As shown, this invention supports both IPv4 and IPv6 protocols. This example uses the IPv4 protocol. By adjusting the PMTU using the method of this invention, the software / hardware acceleration module and the Linux protocol stack can accelerate UDP fragmentation.
[0059] The specific implementation process of this example includes the following steps:
[0060] 1. After receiving a message, the network communication device first enters the acceleration module. If no acceleration entry is matched, or if the length of the message after adding the header required for the exit exceeds the maximum length specified by the protocol, the message cannot be forwarded through the software / hardware acceleration module and needs to be returned to the Linux kernel protocol stack for processing.
[0061] 2. The first UDP fragment packet passes through the Linux protocol stack without any processing. Specifically, the first packet of a UDP connection first enters the software / hardware acceleration module. Since no acceleration entry is found, the packet returns to the Linux protocol stack. From the ip_rcv function at the IP layer of the Linux protocol stack, it enters the PRE_ROUTING chain, and then the connection is initialized by the init_conntrack function. After the PRE_ROUTING chain finishes processing, it queries routing information. Packets that need to be forwarded enter the FORWARD chain for processing. Upon reaching the FORWARD chain, since it is the first packet of the connection and the connection has not yet been confirmed, it is not processed yet. Finally, it enters the POST_ROUTING chain, where the nf_conntrack_confirm function confirms the connection is established and forwards the packet.
[0062] 3. Upon receiving the second packet of the UDP connection, it also enters the software / hardware acceleration module. If no acceleration entry is found, the packet is returned to the Linux protocol stack. Then, after passing through the PRE_ROUTING chain, it enters the FORWARD chain for processing. First, the outgoing IP address is confirmed based on the connection trace information ctinfo. Then, the outgoing routing information dst_entry is obtained through the nf_ip_route function. After obtaining the routing information, the outgoing MTU value is finally obtained using the dst_mtu function.
[0063] 4. After obtaining the egress MTU value, if the length of the client's UDP packet exceeds the egress MTU value and the number of ICMP error packets sent by the current connection (using the PMTU mechanism) has not exceeded the limit, then start constructing ICMP error packets.
[0064] This example constructs two types of ICMP error messages. For instance, setting the message type code to 3 represents a destination unreachable message, and setting it to 4 represents a message that needs to be re-fragmented. The message then carries the message type and the new egress MTU value for the next hop. This message is used to notify the source terminal that it needs to re-fragment the message according to the MTU carried in the message before sending it.
[0065] 5. After an ICMP error message is sent, the current UDP connection data packet is discarded, and the system waits for the source terminal to send a packet fragmented according to the egress MTU.
[0066] 6. According to the PMTU mechanism of the present invention, when the source terminal receives an ICMP error message or reads information that needs to be re-fragmented, the source terminal will re-fragment the message with the MTU carried in the ICMP error message and then send it out.
[0067] 7. When a network communication device receives a re-fragmented UDP packet and enters the FORWAR chain for processing, it compares the egress MTU value with the current UDP connection packet length skb->len (when not fragmented) or the data length frag_max_size in the UDP connection packet skb (when fragmented) to determine whether the source terminal has modified the egress MTU value, based on the ICMP error message recorded in the connection trace ctinfo.
[0068] 8. If the source terminal does not modify the MTU carried in the ICMP error message, the ICMP error message may be lost. In this case, reconstruct the ICMP error message and send it to the source terminal, incrementing the ICMP error message count. If the source terminal still does not fragment according to the egress MTU after sending multiple ICMP error messages, it will stop constructing and sending ICMP error messages. Subsequent packets for this UDP connection will be forwarded through the protocol stack according to the existing normal process.
[0069] 9. If the source terminal has been modified to the MTU expected by the network communication device as required, the source IP, source port, destination IP, destination port, protocol, and other relevant information of the UDP connection are obtained and updated in the software / hardware acceleration table. Then, the current packet will continue to enter the POST_ROUTING chain for forwarding according to the normal Linux forwarding process.
[0070] 10. After a UDP connection is successfully updated in the acceleration table, all subsequent packets received from that connection will first be matched against the acceleration table entry and then enter the acceleration module for accelerated forwarding processing.
[0071] Even on network communication devices that do not support software / hardware acceleration modules, when all subsequent packets of the UDP connection are received, the Linux protocol stack will not need to re-cut and reassemble the cached UDP packets according to the different destination interface MTUs after processing by the ip_fragment function, as the packets have already been fragmented according to the new exit MTU value, thus reducing the waste of memory and CPU.
[0072] In existing technologies, if the outbound access method is PPPoE, VPN, or other access methods that require an additional header layer on top of the original packet, the client will fragment the packet according to an MTU of 1500, send it to the router, and after adding the header required for the outbound process, the packet will exceed the limit. For example, if the original fragmented packet consists of 14 (MAC) + 20 (IP) + 1480 (DATA) + 4 (FCS) = 1518, and then any other header such as a PPP header is added, the packet length will be 1518 + 8 (PPP) = 1526, which exceeds the maximum length of 1518 specified in the protocol. The upstream device will directly discard packets of illegal length, so the packet cannot be directly forwarded by the acceleration module. The packet needs to be returned to the protocol stack for buffering, fragmentation, reassembly, and then sent, which seriously consumes CPU resources.
[0073] This invention applies PMTU to network communication devices. After receiving a message, if the network communication device finds that the message needs to be re-fragmented, it will directly discard the message and return an ICMP message so that the terminal can re-fragment and send it according to the DUT's output.
[0074] This example allows lower-level communication terminals to fragment packets according to the requirements of the network communication equipment. This eliminates the need for the network communication equipment to re-fragment the received packets. Since re-fragmentation of packets is unnecessary, hardware / software acceleration modules without packet buffering capabilities can perform NAT translation and then forward the packets directly, improving forwarding efficiency.
[0075] This invention is not limited to a specific export protocol and can support various tunneling protocols. In addition, this invention supports direct forwarding through the acceleration module without the need for route lookup and packet reassembly and fragmentation.
[0076] This invention constructs ICMP error messages to notify clients to fragment UDP packets according to the required egress MTU value. The software / hardware acceleration modules and Linux kernel protocol stack of network communication equipment no longer need to cache received packets before reassembling, segmenting, and fragmenting them based on different egress access methods. This allows the software / hardware acceleration modules and Linux kernel protocol stack to quickly forward UDP fragmented packets, fully utilizing existing software and hardware resources to rapidly forward UDP fragmented packets, greatly improving packet forwarding efficiency, reducing CPU and memory consumption, and significantly enhancing the user experience.
[0077] The specific embodiments described above are preferred embodiments of the present invention and are not intended to limit the specific scope of the present invention. The scope of the present invention includes, but is not limited to, these specific embodiments. All equivalent changes made in accordance with the present invention are within the protection scope of the present invention.
Claims
1. A method for improving the forwarding performance of UDP fragmented packets based on PMTU, characterized in that, Comprising the following steps: After the UDP connection data packet enters the FORWAED chain of the Linux protocol stack for forwarding processing, it is judged whether it is the first data packet of the UDP connection. If yes, the Linux protocol stack fragmentation judgment step is executed, and then forwarding processing is performed; if no, PMTU acceleration processing is executed, The process of the PMTU acceleration processing is: S1: obtaining the egress route information according to the destination IP address; S2: obtaining the egress MTU value based on the egress route information; S3: judging whether the length of the UDP connection data packet exceeds the egress MTU value. If no, returning to the Linux protocol stack to execute the fragmentation judgment step and then performing forwarding processing; if yes, executing step S4; S4: setting a new egress MTU value according to the length of the UDP connection data packet, constructing an ICMP error message, the ICMP error message including the new egress MTU value adopted by the next hop, and then simultaneously executing steps S5 and S6; S5: sending the ICMP error message to the source terminal for modifying the egress MTU value to the new egress MTU value; S6: discarding the UDP connection data packet to be forwarded, and waiting for the source terminal to send the UDP connection data packet message sent according to the new egress MTU value, After the newly constructed UDP connection data packet message enters the PMTU acceleration processing module of the Linux protocol stack, step S3 further includes a judgment step: judging whether the source terminal successfully modifies the egress MTU value, If the modification is not successful, the ICMP error message is reconstructed and sent to the source terminal, and the number of times of sending the ICMP error message is recorded.
2. The method for improving the performance of forwarding the UDP fragmented packets based on PMTU according to claim 1, wherein: When the number of times of sending the ICMP error message exceeds a set threshold, the sending of the ICMP error message is stopped, the Linux protocol stack fragmentation judgment step is executed, and the data packet of the UDP connection is forwarded through the normal Linux protocol stack forwarding processing.
3. The method for improving the performance of forwarding the UDP fragmented packets based on PMTU according to claim 1, wherein: If the modification is successful, the Linux protocol stack forwarding processing flow in step S3 is executed.
4. The method for improving the forwarding performance of the UDP fragmented packet based on PMTU according to any one of claims 1-3, characterized in that: The method for accelerating the forwarding performance of the UDP fragmentation packet based on the PMTU further includes an accelerated matching forwarding step, and the processing process of the accelerated matching forwarding step is: When the UDP connection data packet is received, it first enters the acceleration module, matches the acceleration table item, and if the matching is successful, the accelerated forwarding processing is performed, and if the matching is not successful, the normal forwarding processing of the Linux protocol stack is entered.
5. The method for forwarding performance of PMTU-based UDP fragmented packets according to claim 4, characterized in that: In step S3, if the length of the UDP connection data packet does not exceed the egress MTU value, the forwarding information is recorded to the acceleration table item, and after the recording, the Linux protocol stack executes the fragmentation judgment step; After the forwarding information is recorded to the acceleration table item, all the messages of the UDP connection received thereafter will first match the acceleration table item, and then enter the acceleration module for accelerated forwarding processing.
6. A system for implementing the method of any of claims 1-5 for improving the forwarding performance of UDP fragmented packets based on PMTU, characterized in that, Comprising a protocol stack forwarding processing module and a PMTU acceleration processing module, wherein, The protocol stack forwarding processing module comprises: a FORWAED chain for starting the forwarding processing of the UDP connection data packet; a first judgment module for judging whether the UDP connection data packet is the first data packet of the UDP connection; Fragmentation judgment module: used for judging whether fragmentation is needed and processing fragmentation; Forwarding processing module: used for forwarding processing of the UDP connection data packet, The PMTU acceleration processing module comprises: Acquisition of egress route information module: used for acquiring egress route information according to a destination IP address; Acquisition of egress MTU value module: used for acquiring an egress MTU value based on the egress route information; Second judgment module: used for judging whether the length of the UDP connection data packet exceeds the egress MTU value; Construction of ICMP error message module: used for setting a new egress MTU value according to the length of the UDP connection data packet, and constructing an ICMP error message, wherein the ICMP error message comprises the new egress MTU value adopted by a next hop; Sending module: used for sending the ICMP error message to a source terminal, and used for modifying the egress MTU value to the new egress MTU value; Data packet discarding module: used for discarding the UDP connection data packet to be forwarded, After the newly constructed UDP connection data packet enters the PMTU acceleration processing module of the Linux protocol stack, the second judgment module performs a judgment step: judging whether the source terminal successfully modifies the egress MTU value, If the modification is not successful, the ICMP error message is reconstructed and sent to the source terminal, and the number of times of sending the ICMP error message is recorded.
7. The system of claim 6, wherein: The second judgment module further comprises a judgment unit: used for judging whether the source terminal successfully modifies the egress MTU value, The system further comprises a counting module: used for recording the number of times of sending the ICMP error message.
8. The system of claim 6 or 7, wherein: The system further comprises an acceleration matching forwarding module: used for acceleration forwarding processing of the UDP connection data packet received and successfully matched with the acceleration table entry.
9. The system of claim 8, wherein: The second judgment module further comprises a recording unit: used for recording the forwarding information to the acceleration table entry.
Citation Information
Patent Citations
Data packet forwarding method and device
CN104869062A
MTU determination method and system, electronic equipment and storage medium
CN112787905A