Method for storing overlapped IP segment types based on LPM and storage medium

By building IP rulers and shards in LPM tools, the problem of the fact that IP segment overlap in the prior art is not able to effectively handle IP segment overlap, and the effective storage and query processing of multiple overlapping IP segment information is realized, which improves query efficiency and memory utilization.

CN119621827AActive Publication Date: 2025-03-14HAOHAN DATA
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411806234.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-03-14
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

When existing LPM tools handle IP segment overlap, they cannot effectively find multiple VALUE information, resulting in the last VALUE information being returned only when IP segment overlap.

Method used

By loading IP segments and VALUE information into the IPVALUE array, building an IP ruler, traversing the IPValue array for measurement, obtaining IP segment shards, and querying and storing these shards in the LPM unit, ensuring that multiple VALUE information can be correctly stored and queried in the case of overlapping IP segments.

Benefits of technology

It supports the storage and query processing of multiple overlapping IP segment information while maintaining low memory and high query efficiency, and solves the problem that IP segment overlap situation cannot be effectively handled in the prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621827A_ABST
    Figure CN119621827A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of Internet protocols, and discloses a method for storing overlapped IP segment types based on LPM and a storage medium, and the method comprises the steps: loading IP segments and VALUE information to an IPVALUE array; constructing an IP scale according to the IPVALUE array; the IPValue array is traversed, measurement is carried out according to the IP scale array, and the IP segment fragments are obtained; querying in an LPM unit according to the IP segment fragment, and when a corresponding fragment IP is found, taking a return value of the LPM unit as a VALUE set of the IP segment fragment; when the IP of the corresponding fragment is not found, creating a Value set, storing the Value information of the fragment, and storing the address of the IP of the fragment and the address of the Value set into an LPM unit; according to the method, the specified IP is queried based on the LPM unit, no return null is queried, the return set array address is queried, and storage and query processing of multiple pieces of overlapped IP segment information are effectively supported under the conditions that the memory is kept less and the query efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet protocol technology, and in particular to a method and storage medium for storing overlapping IP segment types based on LPM. Background Art

[0002] The LPM tool of the open source DPDK provides a general route matching method: first add the IP segment and VALUE (corresponding next hop and other routing information) to LPM; then search for specific IP information in LPM as needed, and return VALUE information when the IP exists in LPM, otherwise it returns non-existent. LPM does not have a method to handle overlapping IP segments; as a result, when IP segments overlap, searching for a specified IP will only return the VALUE information of the IP that was most recently added to LPM; there is no way to find multiple VALUE information of overlapping IP segments. Summary of the invention

[0003] In view of the deficiencies in the prior art, the object of the present invention is to provide a method and storage medium for storing overlapping IP segment types based on LPM.

[0004] In order to achieve the above object, the present invention provides the following technical solutions:

[0005] A method for storing overlapping IP segment types based on LPM, comprising the steps of:

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

[0007] Construct IP ruler based on IPVALUE array;

[0008] Traverse the IPValue array, measure it according to the IP ruler array, and obtain the IP segment fragment;

[0009] Query the LPM unit based on the IP segment fragment. When the corresponding fragment IP is found, the return value of the LPM unit is used as the VALUE set of the IP segment fragment.

[0010] When the corresponding shard IP is not found, a Value set is created to store the Value information of the shard, and then the address of the shard IP and the address of the Value set are stored in the LPM unit;

[0011] Query the specified IP based on the LPM unit. If no IP is found, the return value is null. If the IP is found, the return value is a collection array address.

[0012] In the present invention, preferably, before the LPM unit is stored, it is included to check whether the LPM unit is created. When it is checked that the LPM unit is not created, the LPM unit needs to be created first.

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

[0014] Traverse the IPVALUE array, obtain all IP segments, and store them in the IP scale array as elements of the IP scale array;

[0015] Sort the elements of the IP ruler array, delete duplicate IP segments, and construct the IP ruler.

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

[0017] In the present invention, preferably, the specific steps of obtaining the IP segment fragment are:

[0018] Traverse the IPValue array,

[0019] Bring the start IP value and the end IP value into the IP ruler for measurement to obtain the IP segment fragment.

[0020] In the present invention, preferably, before being stored in the LPM unit, the IP segment fragment format that does not conform to the CIDR format needs to be converted into the CIDR format and then stored in the LPM unit.

[0021] In the present invention, preferably, the step of converting the IP segment fragment format that does not conform to the CIDR format into the CIDR format specifically selects a conversion method with the least number of CIDR segments.

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

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

[0024] The IP segment minus the maximum CIDR segment is used as the next IP segment to be searched;

[0025] The above steps are repeated until the maximum CIDR segment is equal to the fragment being searched. The set of all saved CIDR segments is the minimum CIDR segment for the P segment fragment conversion.

[0026] Compared with the prior art, the present invention has the following beneficial effects:

[0027] The method of the present invention can effectively support the storage and query processing of multiple overlapping IP segment information while keeping the memory small and the query efficiency high by converting the overlapping IP segments of users into non-overlapping IP segments that can be stored in LPM. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1The present invention is a flowchart of a method for storing overlapping IP segment types based on LPM.

[0029] Figure 2 The figure is a schematic diagram of measuring and labeling a specific embodiment of the present invention.

[0030] Figure 3 A schematic diagram of policy slicing annotation according to another specific embodiment of the present invention.

[0031] Figure 4 This is a schematic diagram of the start and end marking of fragmented IPs in another specific embodiment of the present invention. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 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 those commonly understood by those skilled in the art of the present invention. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.

[0034] Proper Noun:

[0035] IP segment: an IP range with a start IP and an end IP;

[0036] DPDK: Data Plane Development Kit, data plane development kit;

[0037] LPM: Longest Prefix Match, longest prefix match;

[0038] VALUE: the information to be queried through the IP, which is strictly associated with the IP segment;

[0039] Strategy: A combination of IP segment, VALUE and other information;

[0040] IPVALUE array: used to cache multiple IP segments and VALUE information that need to be loaded;

[0041] IP fragmentation: The structure is consistent with the IP segment, and the source is obtained by measuring the IP segment through the IP scaler;

[0042] Sharding: The structure is consistent with the policy, and the source is obtained by measuring the IP segment of the policy through IP scaling;

[0043] CIDR: Classless Addressing format.

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

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

[0046] Construct IP ruler based on IPVALUE array;

[0047] Traverse the IPValue array, measure it according to the IP ruler array, and obtain the IP segment fragment;

[0048] Query the LPM unit based on the IP segment fragment. When the corresponding fragment IP is found, the return value of the LPM unit is used as the VALUE set of the IP segment fragment.

[0049] When the corresponding shard IP is not found, a Value set is created to store the Value information of the shard, and then the address of the shard IP and the address of the Value set are stored in the LPM unit;

[0050] Query the specified IP based on the LPM unit. If no IP is found, the return value is null. If the IP is found, the return value is a collection array address.

[0051] In this embodiment, before the LPM unit is stored, it is included to check whether the LPM unit is created. When it is checked that the LPM unit is not created, the LPM unit needs to be created first.

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

[0053] Traverse the IPVALUE array, obtain all IP segments, and store them in the IP scale array as elements of the IP scale array;

[0054] Sort the elements of the IP ruler array, delete duplicate IP segments, and construct the IP ruler.

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

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

[0057] Traverse the IPValue array, bring the start IP value and the end IP value into the IP ruler, measure them, and obtain the IP segment fragment.

[0058] In this embodiment, since the LPM unit can only store IP segments in CIDR format, before storing them in the LPM unit, the IP segment fragment format that does not conform to the CIDR format needs to be converted into the CIDR format and then stored in the LPM unit.

[0059] In this embodiment, in order to reduce memory usage as much as possible and improve query efficiency, the conversion of the IP segment fragment format that does not conform to the CIDR format into the CIDR format specifically selects the least number of CIDR segment conversion methods.

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

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

[0062] The IP segment minus the maximum CIDR segment is used as the next IP segment to be searched;

[0063] The above steps are repeated until the maximum CIDR segment is equal to the fragment being searched. The set of all saved CIDR segments is the minimum CIDR segment for the P segment fragment conversion.

[0064] See also Figure 2 In this embodiment, it is assumed that there are 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 starting address of the IP segment is A, the ending address is D, and the corresponding VALUE information is ID1;

[0067] Strategy 2: The starting address of the IP segment is B, the ending address is E, and the corresponding VALUE information is ID2;

[0068] The IP to be queried is C, and the expected query results are ID1 and ID2.

[0069] Step 1: Extract the IP start address A and end address D of strategy 1, and the IP start address B and end address E of strategy 2 and put them into the IP ruler 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: Use IP scaler to measure strategy 1, and get the starting address of fragment 1 as A, the ending address as B, and the value information as ID1; get the starting address of fragment 2 as B, the ending address as D, and the value information as ID1;

[0072] Step 4: Use the scale measurement strategy 2 to obtain that the starting address of shard 3 is B, the ending address is D, and the VALUE information is ID2; the starting address of shard 4 is D, the ending address is E, and the VALUE information is ID2;

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

[0074] Step 6: Since the IP start and end 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 the set 2 of fragment 2.

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

[0076] In this way, the overlapping user strategies 1 and 2 are converted into non-overlapping shards 1, 2, and 4 through the ruler and stored in LPM; shard 3 is not stored in LPM, and only the set 2 storing the VALUE information ID2 of shard 3 to the VALUE information ID1 of shard 2 is saved. Figure 2 .

[0077] In this implementation, it is assumed that the user has issued three policies:

[0078] The IP segment of strategy 1 is 223.104.38.0 / 24, that is, starting IP: 223.104.38.0, ending IP: 223.104.38.255;

[0079] The IP segment of strategy 2: 223.104.38.192 / 28, that is: starting IP: 223.104.38.192, ending IP: 223.104.38.207;

[0080] The IP segment of strategy 3 is: 223.104.38.228 / 30, that is: starting IP: 223.104.38.228, ending 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. Figure 3 .

[0082] Step 2: Shards 2 and 4 conform to the CIDR format and can be directly expressed as 223.104.38.192 / 28 and 223.104.38.228 / 30; but the starting IP of Shard 1 is 223.104.38.0, and the ending IP is 223.104.38.192 minus 1, that is, 223.104.38.191; the starting IP of Shard 3 is 223.104.38.207 Add 1, that is: 223.104.38.208, the end IP is 223.104.38.228 minus 1, that is: 223.104.38.227; the start IP of shard 5 is 223.104.38.231 plus 1, that is: 223.104.38.232, the end IP is 223.104.38.255; neither meets the CIDR format and needs CIDR format conversion, please refer to 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 be converted to at least 2 CIDR segments, namely: 223.104.38.128 / 26, 223.104.38.0 / 25; in order to reduce memory and improve efficiency, you should choose to convert the least CIDR segment, namely: 223.104.38.0 / 25, 223.104.38.128 / 26, 2 CIDR segments, and store them in the LPM unit.

[0084] Step 4: Shards 2 and 4 conform to the CIDR format and can be directly stored in LPM units, that is, a CIDR segment.

[0085] The selection method for shards 3 and 5 needs to be the same as that for shard 1. The shards 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. When the computer program is executed by a processor, the processor executes the steps of the method described in the above embodiment.

[0087] If the functions are implemented in the form of 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 the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several 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 methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0088] The above description is a detailed description of the preferred feasible embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. All equivalent changes or modified changes completed under the technical spirit suggested by 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: Includes steps: Load IP segment and VALUE information into IPVALUE array; Construct IP ruler based on IPVALUE array; Traverse the IPValue array, measure it according to the IP ruler array, and obtain the IP segment fragment; Query the LPM unit based on the IP segment fragment. When the corresponding fragment IP is found, the return value of the LPM unit is used as the VALUE set of the IP segment fragment. When the corresponding shard IP is not found, a Value set is created to store the Value information of the shard, and then the address of the shard IP and the address of the Value set are stored in the LPM unit; Query the specified IP based on the LPM unit. If no IP is found, the return value is null. If the IP is found, the return value is a collection array address.

2. A method for storing overlapping IP segment types based on LPM according to claim 1, characterized in that: Before the LPM unit is stored, it is necessary to verify whether the LPM unit is created. If the LPM unit is not created, the LPM unit needs to be created first.

3. A method for storing overlapping IP segment types based on LPM according to claim 2, characterized in that: The construction of the IP scale specifically includes: Traverse the IPVALUE array, obtain all IP segments, and store them in the IP scale array as elements of the IP scale array; Sort the elements of the IP ruler array, delete duplicate IP segments, and construct the IP ruler.

4. A method for storing overlapping IP segment types based on LPM according to claim 3, characterized in that: The sorting is performed in ascending order according to the IP values ​​of 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 of obtaining the IP segment fragment are: Traverse the IPValue array, Bring the start IP value and the end IP value into the IP ruler for measurement to obtain the IP segment fragment.

6. A method for storing overlapping IP segment types based on LPM according to claim 1, characterized in that: Before storing in the LPM unit, the IP segment fragment format that does not conform to the CIDR format needs to be converted into the CIDR format and then stored in the LPM unit.

7. A method for storing overlapping IP segment types based on LPM according to claim 6, characterized in that: The conversion of the IP segment fragment format that does not conform to the CIDR format into the CIDR format specifically selects a conversion method with the least 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 largest CIDR segment in the IP segment fragment and save the largest CIDR segment; The IP segment minus the maximum CIDR segment is used as the next IP segment to be searched; The above steps are repeated until the maximum CIDR segment is equal to the fragment being searched. The set of all saved CIDR segments is the minimum CIDR segment for the P segment fragment conversion.

9. A storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the processor executes the steps of a method for storing overlapping IP segment types based on LPM as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • TCAM-based high-speed and low-power IP routing table lookup method

    CN104301227A

  • IP binary searching method and apparatus with compatibility with IPV4 / IPV6

    CN105827530A

  • Segmented IP aggregation method and device, equipment and storage medium

    CN116260785A

  • File downloading method based on fragment multiplexing

    CN117459522A

  • Method for quickly recombining ip fragmented message

    CN117955940A