Reconstructing network IP packets to achieve IP non-fragmentation method
By reconstructing network IP packets into non-fragmented packets and encapsulating them with encryption, the high latency and memory requirements of IPsec VPN devices on resource-constrained devices are solved, achieving low-cost, low-power, and high-performance IPsec VPN functionality.
Patent Information
- Application Number
- CN202211492826.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-11-25
AI Technical Summary
Existing IPsec VPN devices struggle to reassemble and encapsulate network IP packets on small, high-speed devices with limited resources, resulting in high latency, excessive memory requirements, and the inability to correctly transmit IP packets of maximum length.
By reconstructing network IP packets into non-fragmented packets, adding new IP and UDP headers, performing encrypted encapsulation, and restoring the original packet structure at the other end, reassembly and fragmentation are avoided.
It achieves low-cost, low-power, and high-performance IPsec VPN functionality, saving 40 times the memory space, with network latency below 5ms, and supporting normal transmission of IP packets of extreme length.
Smart Images

Figure CN115988103B
Abstract
Description
Technical Field
[0001] The invention discloses an IP non-fragmentation method, belongs to the technical field of encryption encapsulation of IP messages, and specifically relates to a method for reconstructing network IP messages to realize IP non-fragmentation. Background Art
[0002] Traditional IPsec VPN equipment implements encryption and encapsulation of network IP messages. It needs to reorganize the network messages entering the protocol stack according to the fragmentation identifier and offset value of the three-layer IP packet header to form a complete network IP message containing a three-layer and four-layer header structure. On this basis, the complete network IP message is encrypted and encapsulated, and then fragmented according to the MTU value before being sent.
[0003] In this way, the IPsec VPN device has the following problems during the processing:
[0004] 1. A large amount of cache space is required. For small and high-speed IPsec VPN devices with limited resources, network IP message reassembly and encryption encapsulation processing cannot be achieved.
[0005] 2. Network IP packets need to be cached, reassembled, encrypted and encapsulated according to the length of the network IP packets, and then fragmented according to the requirements of the MTU value. The network delay often exceeds 100ms, which does not provide sufficient support for application scenarios with high real-time requirements.
[0006] 3. After the traditional IPsec VPN equipment completes the network IP message reassembly, if it encounters an IP packet of the maximum length (the maximum length has been reached, i.e. 65536 bytes), because the encryption encapsulation also needs to increase the message length, after the encapsulation is completed, it exceeds the maximum length of the network IP message, resulting in the network IP message cannot be transmitted correctly.
[0007] The shortcomings of the above-mentioned technology are exactly the technical problems to be solved by the present invention. Summary of the invention
[0008] Purpose of the invention: To provide a method for reconstructing network IP messages to achieve IP non-fragmentation, thereby solving the above-mentioned problems.
[0009] Technical solution: Reconstructing the network IP message to implement the IP non-fragmentation method, the IP non-fragmentation method reconstructs the structure of the network IP message entering the protocol stack, that is, for the fragmented packet or the non-fragmented packet, so that the new network IP message becomes a complete non-fragmented packet, and encrypts and encapsulates the non-fragmented packet and sends it to the other end IPsec VPN device for decryption and decapsulation, and reconstructs it again according to the original fragmentation information retained in the network message to restore the data structure of the original network message.
[0010] In a further embodiment, the IP non-fragmentation method specifically comprises the following steps:
[0011] Step 1: Build a new IP header;
[0012] Step 2: Add a new UDP header;
[0013] Step 3: Add a new additional IPA header;
[0014] Step 4: Add the original IP payload to the end of the IPA header to form a complete network IP message;
[0015] Step 5: Recalculate the total length of the IP packet and modify the new IP header to complete the reconstruction of the network IP message structure;
[0016] Step 6: The reconstructed IP packet is an independent non-fragmented packet, so that the current network IP message is not related to the previous and next network IP messages;
[0017] Step 7: After the reconstruction, the network IP message is encrypted and encapsulated by IPsec VPN;
[0018] Step 8: The packet encrypted and encapsulated by IPsec VPN arrives at the peer decryption device. After decryption and decapsulation, the fragment identifier and offset value stored in the IPA header are restored.
[0019] In a further embodiment, the construction of the new IP header is to concentrate the IP protocol and IP fragmentation information of the IP header of the original network IP message into a newly attached IPA header for retention, so as to facilitate use during restoration; modify the IP protocol of the IP header of the original network IP message to UDP, and set the fragmentation flag MF to 0, indicating a non-fragmented packet; set the fragment offset value to 0, recalculate the checksum of the IP header, and use most of the contents of the original three-layer IP header to complete the construction of the new IP header.
[0020] In a further embodiment, the adding of the new additional IPA header is that the header of the additional IPA needs to retain the IP protocol and IP fragmentation information of the original network IP message.
[0021] In a further embodiment, the IP fragmentation information includes: a fragmentation identifier and an offset value.
[0022] In a further embodiment, the adding of a new UDP header is to add a fixed UDP header after the new IP header, and the source port and destination port of the UDP header are set to 4500.
[0023] Beneficial effects: Compared with the method of implementing encryption encapsulation of network IP messages by IPsec VPN equipment in the prior art, the present invention has the following advantages:
[0024] 1. The network IP message preprocessing method provided by the present invention can fully achieve the requirements of low cost, low power consumption and high performance. The technology provided by the present invention can save 40 times of memory space.
[0025] 2. The present invention performs individual preprocessing on each network IP message, so that the network IP message does not need to be cached or reassembled. Even if the encrypted and encapsulated network IP message is larger than the MTU value, it only needs to be fragmented once. The network delay is less than 5ms after testing and verification with a core i5 processor.
[0026] 3. The present invention does not require IP packet reorganization, even for network IP messages of extreme length, because only fragmented packets are processed, there is no need to process 65536-byte packets, and normal communication transmission of the network will not be affected. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a schematic diagram of the method of the present invention.
[0028] Figure 2 It is a diagram of the method steps of the present invention. DETAILED DESCRIPTION
[0029] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. 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 are within the scope of protection of the present invention.
[0030] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0031] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances. In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0032] The method for reconstructing network IP messages to realize IP non-fragmentation is to reconstruct the structure of network IP messages for fragmented or non-fragmented packets entering the protocol stack, so that the new network IP messages become complete non-fragmented packets, and the encryption encapsulation processing and sending of non-fragmented packets can be realized, and it is no longer necessary to reassemble, encrypt and encapsulate the entire network IP message, and then send it in fragments. When the encrypted and encapsulated network IP message reaches the opposite end IPsec vpn device, after decryption and decapsulation, it is reconstructed according to the original fragmentation information retained in the network message to restore the data structure of the original network message.
[0033] According to the above description, combined with the attached Figure 1 , the specific operation process is given below:
[0034] The encapsulated object can be a fragmented or non-fragmented network IP message, and the network IP message needs to be reconstructed by building a new IP header, adding a new UDP header, and adding a new additional IPA header.
[0035] (1) Construct a new IP header
[0036] The IP protocol and IP fragmentation information (including fragmentation identifier and offset value) of the IP header of the original network IP message are concentrated in the newly attached IPA header for easy use during restoration. Change the IP protocol of the IP header of the original network IP message to UDP, and set the fragmentation identifier MF to 0, indicating a non-fragmented packet. Set the fragment offset value to 0. Recalculate the checksum of the IP header. Most of the other contents of the original three-layer IP header are used. Complete the construction of the new IP header.
[0037] (2) Add a new UDP header
[0038] A fixed UDP header is added after the new IP header, and the source and destination ports of the UDP header are set to 4500.
[0039] (3) Add a new additional IPA header
[0040] The header of the additional IPA needs to retain the IP protocol and IP fragmentation information (including fragment identification and offset value) of the original network IP message.
[0041] (4) The original IP payload is added to the end of the IPA header to form a complete network IP message.
[0042] (5) Recalculate the total length of the IP packet and modify the new IP header to complete the reconstruction of the network IP message structure.
[0043] (6) The reconstructed IP packet is an independent non-fragmented packet, so that the current network IP message is not related to the previous and next network IP messages.
[0044] (7) The reconstructed network IP message is then encrypted and encapsulated by IPsec VPN.
[0045] The packet encrypted and encapsulated by IPsec VPN arrives at the peer decryption device. After decryption and decapsulation, the fragment identifier and offset value stored in the IPA header are restored.
[0046] Through the above description, the advantages of the present invention and the prior art are illustrated below by way of example:
[0047] Embodiment 1:
[0048] The IPsec VPN function implemented by the present invention saves a lot of memory space
[0049] In the traditional IPsec VPN function implementation method, if 10 connections need to be processed simultaneously, 10*64K bytes of space, i.e. 640K bytes of space, need to be prepared for packet reassembly. However, this processing method only requires 10*1.6K=16K bytes of space, which greatly reduces memory overhead. If the number of connections is greater, such as 100 or 1000 connections need to be implemented, the reduced memory space is even greater. For small and high-speed IPsec VPN devices, especially the use of hardware logic to implement IPsec VPN processing, great convenience is provided. At the same time, if the IPsec VPN function is implemented by chipization, using the traditional packet assembly mode, the memory space basically cannot meet the requirements of low cost, low power consumption and high performance at the same time. The network IP message preprocessing method provided by the present invention can fully meet the requirements of low cost, low power consumption and high performance. The technology provided by the present invention can save 40 times the memory space.
[0050] Embodiment 2:
[0051] The present invention realizes IPsec VPN function and greatly reduces network delay
[0052] The traditional IPsec VPN function implementation method, because the network IP message needs to be cached, reassembled, encrypted and encapsulated according to the length of the IP message, and then fragmented according to the requirements of the MTU value, there are many processing processes. After testing and verification with a core i5 processor, the network delay exceeds 100ms, and the support for application scenarios with high real-time requirements is insufficient. The present invention performs separate preprocessing for each network IP message, so that the network IP message does not need to be cached or reassembled. Even if the encrypted and encapsulated network IP message is larger than the MTU value, it only needs to be fragmented once at most. After testing and verification with a core i5 processor, the network delay is less than 5ms.
[0053] Embodiment 3:
[0054] The present invention provides a feasible method for processing network IP messages of extreme length.
[0055] In the traditional IPsec VPN function implementation, if an IP message of the maximum length (which has reached the maximum length of 65536 bytes) is encountered, after the network IP message is reassembled, the encryption encapsulation needs to increase the length, so the encapsulation exceeds the maximum length of the network IP message, resulting in the inability to transmit the network IP packet. The present invention does not require IP packet reassembly, and even if it is a network IP message of the maximum length, because only the fragmented packets are processed, there is no packet that needs to process 65536 bytes, and the normal communication transmission of the network will not be affected.
[0056] The network IP message preprocessing technology and method proposed in the present invention greatly reduce the memory overhead and network delay in the realization of IPsec VPN function, and at the same time realize the feasibility of IPsec VPN function for network IP messages of extreme length.
[0057] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the invention.
Claims
1. A method for reconstructing network IP packets to realize IP non-fragmentation, characterized in that: The IP non-fragmentation method reconstructs the structure of the network IP message entering the protocol stack, so that the new network IP message becomes a complete non-fragmented packet, and encrypts and encapsulates the non-fragmented packet and sends it to the opposite IPsec VPN device; the IPsec VPN device decrypts and decapsulates, and reconstructs it according to the original fragmentation information retained in the network message, and restores the data structure of the original network message; The IP non-fragmentation method specifically comprises the following steps: Step 1: Build a new IP header; Step 2: Add a new UDP header; Step 3: Add a new additional IPA header; Step 4: Add the original IP payload to the end of the IPA header to form a complete network IP message; Step 5: Recalculate the total length of the IP packet and modify the new IP header to complete the reconstruction of the network IP message structure; Step 6: The reconstructed IP packet is an independent non-fragmented packet, so that the current network IP message is not related to the previous and next network IP messages; Step 7: After the reconstruction, the network IP message is encrypted and encapsulated by IPsec VPN; Step 8: The packet encrypted and encapsulated by IPsec VPN arrives at the peer decryption device. After decryption and decapsulation, the fragment identifier and offset value stored in the IPA header are restored. The construction of the new IP header is to concentrate the IP protocol and IP fragmentation information of the IP header of the original network IP message into the newly attached IPA header for preservation, so as to facilitate use during restoration; modify the IP protocol of the IP header of the original network IP message to UDP, set the fragmentation identifier MF to 0, indicating a non-fragmented packet; set the fragment offset value to 0, recalculate the checksum of the IP header, and use most of the original three-layer IP header content to complete the construction of the new IP header.
2. The method for reconstructing network IP packets to realize IP non-fragmentation according to claim 1, characterized in that: The adding of the new additional IPA header means that the header of the additional IPA needs to retain the IP protocol and IP fragmentation information of the original network IP message.
3. The method for reconstructing network IP packets to realize IP non-fragmentation according to claim 1, characterized in that: IP fragment information includes: fragment identifier and offset value.
4. The method for reconstructing network IP packets to realize IP non-fragmentation according to claim 1, characterized in that: The adding of the new UDP header is to add a fixed UDP header after the new IP header, and the source port and the destination port of the UDP header are set to 4500.
