A method and storage medium for storing overlapping IP segment types based on LPM

By constructing an IP scale array and converting the IP segment format, the problem of inaccurate querying in LPM tools when IP segments overlap is solved, achieving efficient IP segment storage and querying.

CN119621827BActive Publication Date: 2026-06-30HAOHAN DATA

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HAOHAN DATA
Filing Date
2024-12-10
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing LPM tools cannot effectively find multiple values ​​when dealing with overlapping IP segments, resulting in inaccurate query results.

Method used

By constructing an IP scale array, traversing the IPVALUE array, measuring IP segment fragments, and storing fragments that conform to the CIDR format into the LPM unit, fragments that do not conform to the format are converted into the minimum number of CIDR segments, and a VALUE set is created and stored in the LPM unit.

Benefits of technology

It achieves efficient storage and querying of multiple overlapping IP segments while maintaining low memory usage and high query efficiency, thus improving query accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621827B_ABST
    Figure CN119621827B_ABST
Patent Text Reader

Abstract

This invention relates to the field of Internet Protocol (IP) technology and discloses a method and storage medium for storing overlapping IP segment types based on LPM (Limited Memory Management). The method involves loading IP segment and VALUE information into an IPVALUE array; constructing an IP scale based on the IPVALUE array; traversing the IPValue array and measuring according to the IP scale array to obtain the IP segment fragment; querying the LPM unit based on the IP segment fragment; if a corresponding fragment IP is found, using the return value of the LPM unit as the VALUE set for that IP segment fragment; if no corresponding fragment IP is found, creating a Value set to store the fragment's Value information, and then storing the address of the fragment IP and the address of the Value set in the LPM unit; querying a specified IP based on the LPM unit, returning null if not found, and returning the address of the set array if found. This method effectively supports the storage and querying of multiple overlapping IP segment information while maintaining low memory usage and high query efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Internet protocol technology, and specifically to a method and storage medium for storing overlapping IP segment types based on LPM. Background Technology

[0002] The open-source DPDK's LPM tool provides a general route matching method: first, add the IP segment and its value (corresponding next hop and other routing information) to the LPM; then, search for specific IP information in the LPM as needed. If the IP exists in the LPM, it returns the value information; otherwise, it returns "not found". However, LPM lacks a method to handle overlapping IP segments. This means that when IP segments overlap, searching for a specific IP will only return the value information of the IP most recently added to the LPM; it cannot find multiple values ​​for overlapping IP segments. Summary of the Invention

[0003] To address the shortcomings of existing technologies, the present invention aims to provide a method and storage medium for storing overlapping IP segment types based on LPM.

[0004] To achieve the above objectives, the present invention provides the following technical solution:

[0005] A method for storing overlapping IP segment types based on LPM includes the following steps:

[0006] Load the IP segment and VALUE information into the IPVALUE array;

[0007] Construct an IP scale based on the IPVALUE array;

[0008] Iterate through the IPValue array, measure it according to the IP scale array, and obtain the fragmentation of the IP segment;

[0009] Based on the IP segment fragment, query the LPM unit. When the corresponding fragment IP is found, use the return value of the LPM unit as the VALUE set of the IP segment fragment.

[0010] If no corresponding fragment IP is found, a Value set is created to store the fragment's Value information, and then the address of the fragment IP and the address of the Value set are stored in the LPM unit.

[0011] If a specified IP is not found, an empty string is returned; if a IP is found, the address of a set array is returned.

[0012] In this invention, preferably, before storing the LPM unit, it includes verifying whether the LPM unit has been created. If the LPM unit has not been created, it must be created first.

[0013] In this invention, preferably, the construction of the IP scale specifically includes:

[0014] Iterate through the IPVALUE array, retrieve all IP ranges, and store them in the IP scale array as elements of the IP scale array;

[0015] Sort the elements of the IP scale array, remove duplicate IP segments, and construct the IP scale.

[0016] In this invention, preferably, the sorting is performed in ascending order according to the IP values ​​of the IP scale array.

[0017] In this invention, preferably, the specific steps for obtaining the IP segment fragment are as follows:

[0018] Iterate through the IPValue array.

[0019] Input the start IP value and end IP value into the IP scale, measure them, and obtain the fragmentation of this IP segment.

[0020] In this invention, preferably, before storing the IP segment fragments that do not conform to the CIDR format into the CIDR format, they need to be converted into the CIDR format and then stored into the LPM unit.

[0021] In this invention, preferably, the conversion of IP segment fragments that do not conform to the CIDR format to the CIDR format specifically selects the minimum number of CIDR segment conversion methods.

[0022] In this invention, preferably, the specific steps of the minimum number of CIDR segment conversion method include:

[0023] Find the IP segment fragment containing the largest CIDR segment and save the largest CIDR segment;

[0024] The IP segment fragment minus the largest CIDR segment is used as the next IP segment fragment to look up;

[0025] Repeat the above steps until the maximum CIDR segment equals the searched fragment. The set of all saved CIDR segments is the minimum CIDR segment converted from the P segment fragment.

[0026] Compared with the prior art, the beneficial effects of the present invention are:

[0027] The method of the present invention converts the user's overlapping IP segments into non-overlapping IP segments that can be stored by LPM, which can effectively support the storage and query processing of multiple overlapping IP segment information while keeping memory small and query efficiency high. Attached Figure Description

[0028] Figure 1This is a schematic diagram of the method for storing overlapping IP segment types based on LPM as described in this invention.

[0029] Figure 2 This is a schematic diagram of a standard measurement labeling according to a specific embodiment of the present invention.

[0030] Figure 3 This is a schematic diagram of strategy fragmentation annotation according to another specific embodiment of the present invention.

[0031] Figure 4 This is a schematic diagram illustrating the start and end annotations of a fragmented IP in another specific embodiment of the present invention. Detailed Implementation

[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0033] 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 invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0034] Proper nouns:

[0035] IP range: A range of IP addresses that has a start IP address and an end IP address;

[0036] DPDK: DataPlaneDevelopmentKit;

[0037] LPM: LongestPrefixMatch;

[0038] VALUE: This is the information that needs to be retrieved using an IP address, and it is strictly associated with an IP range.

[0039] Strategy: A combination containing information such as IP range and value;

[0040] The IPVALUE array is used to cache multiple IP ranges and VALUE information that need to be loaded.

[0041] IP fragmentation: The structure is the same as that of IP segments, and the source method is to obtain IP segments by quantizing IP tags;

[0042] Fragmentation: The structure and strategy are consistent, and the source method is to obtain the IP segment of the strategy through IP tagging.

[0043] CIDR: Classless Addressing Format.

[0044] Please see Figure 1 A preferred embodiment of the present invention provides a method for storing overlapping IP segment types based on LPM, which converts user-overlapping IP segments into non-overlapping IP segments that can be stored by LPM, including the following steps:

[0045] Load the IP segment and VALUE information into the IPVALUE array. The IP segment includes the start IP and the end IP.

[0046] Construct an IP scale based on the IPVALUE array;

[0047] Iterate through the IPValue array, measure it according to the IP scale array, and obtain the fragmentation of the IP segment;

[0048] Based on the IP segment fragment, query the LPM unit. When the corresponding fragment IP is found, use the return value of the LPM unit as the VALUE set of the IP segment fragment.

[0049] If no corresponding fragment IP is found, a Value set is created to store the fragment's Value information, and then the address of the fragment IP and the address of the Value set are stored in the LPM unit.

[0050] If a specified IP is not found, an empty string is returned; if a IP is found, the address of a set array is returned.

[0051] In this embodiment, before storing the LPM unit, it is necessary to verify whether the LPM unit has been created. If the LPM unit has not been created, it must be created first.

[0052] In this embodiment, constructing the IP scale specifically includes:

[0053] Iterate through the IPVALUE array, retrieve all IP ranges, and store them in the IP scale array as elements of the IP scale array;

[0054] Sort the elements of the IP scale array, remove duplicate IP segments, and construct the IP scale.

[0055] In this embodiment, the sorting is performed in ascending order according to the IP values ​​in the IP scale array.

[0056] In this embodiment, the specific steps for obtaining the IP segment fragment are as follows:

[0057] Iterate through the IPValue array, input the start IP value and end IP value into the IP scale, measure them, and obtain the fragmentation of the IP segment.

[0058] In this embodiment, since the LPM unit can only store IP segments in CIDR format, the IP segment fragments that do not conform to the CIDR format need to be converted to CIDR format before being stored in the LPM unit.

[0059] In this embodiment, in order to minimize memory usage and improve query efficiency, the method of converting IP segment fragments that do not conform to the CIDR format to the CIDR format specifically selects the minimum number of CIDR segment conversion methods.

[0060] In this embodiment, the specific steps of the minimum number of CIDR segment conversion method include:

[0061] Find the IP segment fragment containing the largest CIDR segment and save the largest CIDR segment;

[0062] The IP segment fragment minus the largest CIDR segment is used as the next IP segment fragment to look up;

[0063] Repeat the above steps until the maximum CIDR segment equals the searched fragment. The set of all saved CIDR segments is the minimum CIDR segment converted from the P segment fragment.

[0064] Please see Figure 2 In this embodiment, it is assumed that there exist five integers A, B, C, D, and E that can represent IP, and A <B<C<D<E;

[0065] Two strategies were issued:

[0066] Strategy 1: The IP segment starts at address A and ends at address D, with the corresponding VALUE information being ID1;

[0067] Strategy 2: The IP segment starts at address B and ends at address E, with the corresponding VALUE information being ID2;

[0068] We need to query IP C, and expect the query results to be ID1 and ID2.

[0069] Step 1: Extract the start address A and end address D of the IP address for strategy 1, and the start address B and end address E of the IP address for strategy 2, and put them into the IP scale array;

[0070] Step 2: Sort the elements A, D, B, and E of the IP scale array in ascending order to obtain IP scales A, B, D, and E;

[0071] Step 3: Using IP metric strategy 1, we obtain the start address of fragment 1 as A, the end address as B, and the VALUE information as ID1. We also obtain the start address of fragment 2 as B, the end address as D, and the VALUE information as ID1.

[0072] Step 4: Using scaling strategy 2, we obtain the start address of fragment 3 as B, the end address as D, and the VALUE information as ID2. We also obtain the start address of fragment 4 as D, the end address as E, and the VALUE information as ID2.

[0073] Step 5: Store the VALUE information (ID1) of fragment 1 into set 1, and store the IP address of fragment 1 and the address of set 1 into the LPM unit; store fragments 2 and 4 in the same way as fragment 1.

[0074] Step 6: Since the start and end IP addresses of fragment 3 are the same as those of fragment 2, fragment 3 does not need to be stored in the LPM unit. Only the VALUE information ID2 of fragment 3 needs to be placed in set 2 of fragment 2.

[0075] Step 7: Query the information with IP C in the LPM unit. The query result is the address of set 2. At this time, set 2 contains two VALUE information (ID1, ID2); that is, the query result information is overlapping.

[0076] This converts user overlap policies 1 and 2 into non-overlapping shards 1, 2, and 4 using a scale and stores them in the LPM. Shard 3 is not stored in the LPM; only the value information ID2 of shard 3 to the value information ID1 of shard 2 is stored in set 2. See [link to LPM documentation]. Figure 2 .

[0077] In this implementation, assume that the user has now issued three policies:

[0078] The IP range for Strategy 1 is 223.104.38.0 / 24, that is: start IP: 223.104.38.0, end IP: 223.104.38.255;

[0079] The IP range for Strategy 2 is 223.104.38.192 / 28, that is: start IP: 223.104.38.192, end IP: 223.104.38.207;

[0080] The IP range for Strategy 3 is 223.104.38.228 / 30, which means: start IP: 223.104.38.228, end IP: 223.104.38.231.

[0081] Step 1: Referring to the above implementation method, the IP segment of Strategy 1 will be divided into 5 fragments, corresponding to fragment 1, fragment 2, fragment 3, fragment 4, and fragment 5 respectively. Please refer to [link to relevant documentation]. Figure 3 .

[0082] Step 2: Fragments 2 and 4 conform to CIDR format and can be directly represented as 223.104.38.192 / 28 and 223.104.38.228 / 30, respectively. However, the starting IP of fragment 1 is 223.104.38.0, and the ending IP is 223.104.38.192 minus 1, i.e., 223.104.38.191; the starting IP of fragment 3 is 223.104.38.207. Adding 1, we get 223.104.38.208, and the ending IP is 223.104.38.228 minus 1, which is 223.104.38.227. Fragment 5's starting IP is 223.104.38.231 plus 1, which is 223.104.38.232, and the ending IP is 223.104.38.255. None of these meet the CIDR format requirement and require CIDR format conversion. Please refer to [link to relevant documentation]. Figure 4 .

[0083] Step 3: Shard 1 can convert up to 192 CIDR segments, namely: 223.104.38.0 / 32, 223.104.38.1 / 32, ..., 223.104.38.191 / 32; or it can convert to a minimum of 2 CIDR segments, namely: 223.104.38.128 / 26, 223.104.38.0 / 25. In order to reduce memory and improve efficiency, the minimum number of CIDR segments should be selected, namely: 223.104.38.0 / 25, 223.104.38.128 / 26, and stored in the LPM unit.

[0084] Step 4: Fragments 2 and 4 conform to the CIDR format and can be directly stored in the LPM unit, i.e., a CIDR segment.

[0085] The selection method for fragments 3 and 5 needs to be the same as that for fragment 1. The fragments need to be converted and stored using the least CIDR segment conversion method.

[0086] In some other preferred embodiments of the present invention, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, causes the processor to perform the steps of the method as described in the above embodiments.

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

[0088] The above description is a detailed description of the preferred embodiments of the present invention. However, the embodiments are not intended to limit the scope of the patent application of the present invention. All equivalent changes or modifications made under the technical spirit of the present invention should fall within the patent scope covered by the present invention.

Claims

1. A method for storing overlapping IP segment types based on LPM, characterized in that, Including the following steps: Load the IP segment and VALUE information into the IPVALUE array; Construct an IP scale based on the IPVALUE array; Iterate through the IPValue array, measure it according to the IP scale array, and obtain the fragmentation of the IP segment; Based on the IP segment fragment, query the LPM unit. When the corresponding fragment IP is found, use the return value of the LPM unit as the VALUE set of the IP segment fragment. If no corresponding fragment IP is found, a Value set is created to store the fragment's Value information, and then the address of the fragment IP and the address of the Value set are stored in the LPM unit. If a specified IP is not found, an empty string is returned; if a IP is found, the address of a set array is returned. The construction of the IP scale specifically includes: traversing the IPVALUE array, obtaining all IP segments, and storing them in the IP scale array as elements of the IP scale array; Sort the elements of the IP scale array, remove duplicate IP segments, and construct the IP scale; the specific steps to obtain the IP segment fragment are as follows: traverse the IPValue array, input the start IP value and end IP value into the IP scale, measure, and obtain the IP segment fragment.

2. The method for storing overlapping IP segment types based on LPM according to claim 1, wherein, Before storing the LPM unit, it is necessary to verify whether the LPM unit has been created. If the LPM unit has not been created, it must be created first.

3. The method for storing overlapping IP segment types based on LPM according to claim 2, characterized in that, The construction of the IP benchmark specifically includes: Iterate through the IPVALUE array, retrieve all IP ranges, and store them in the IP scale array as elements of the IP scale array; Sort the elements of the IP scale array, remove duplicate IP segments, and construct the IP scale.

4. The method for storing overlapping IP segment types based on LPM according to claim 3, characterized in that, The sorting is performed in ascending order based on the IP values ​​in the IP scale array.

5. The method for storing overlapping IP segment types based on LPM according to claim 1, characterized in that, The specific steps for obtaining the fragments of this IP segment are as follows: Iterate through the IPValue array. Input the start IP value and end IP value into the IP scale, measure them, and obtain the fragmentation of this IP segment.

6. The method for storing overlapping IP segment types based on LPM according to claim 1, characterized in that, Before storing the IP segment fragments that do not conform to the CIDR format into the LPM unit, they need to be converted to the CIDR format and then stored into the LPM unit.

7. A method for storing overlapping IP segment types based on LPM according to claim 6, characterized in that, The specific method for converting IP segment fragments that do not conform to the CIDR format to the CIDR format is to select the conversion method with the minimum number of CIDR segments.

8. A method for storing overlapping IP segment types based on LPM according to claim 7, characterized in that, The specific steps of the minimum number of CIDR segment conversion method include: Find the IP segment fragment containing the largest CIDR segment and save the largest CIDR segment; The IP segment fragment minus the largest CIDR segment is used as the next IP segment fragment to look up; Repeat the above steps until the maximum CIDR segment equals the searched fragment. The set of all saved CIDR segments is the minimum CIDR segment converted from the P segment fragment.

9. A storage medium, characterized in that, The system contains a computer program that, when executed by a processor, causes the processor to perform the steps of a method for storing overlapping IP segment types based on LPM as described in any one of claims 1-8.