Routing table compression method, device, computer equipment and storage medium

By generating nodes containing routing entry information and successor pointers, and splitting and connecting based on the next hop address information, the problem of large memory space occupied by routing tables is solved, and efficient compression and maintenance of routing tables are achieved.

CN119254695BActive Publication Date: 2025-04-22CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411786254.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-22
Estimated Expiration
2044-12-06

AI Technical Summary

Technical Problem

In the existing routing search algorithm, the routing table occupies a large amount of memory space, resulting in inefficiency.

Method used

By generating nodes corresponding to the routing table, the nodes include at least routing entry information and successor pointers. If the next hop address information corresponding to each routing entry is the same, the next hop address information is set to be the object pointed to by the successor pointer; if different, the routing table is split as a subroutine table and connected to the data structure of the node corresponding to the subroutine table through the successor pointer.

Benefits of technology

The compression of the routing table is realized, reducing memory usage, and not affecting the ability to find the next hop address information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254695B_ABST
    Figure CN119254695B_ABST
Patent Text Reader

Abstract

The present application relates to a routing table compression method, device, computer equipment and storage medium. The method comprises: generating a node corresponding to a target routing table, wherein the node comprises at least routing entry information and a successor pointer; in the case where the next-hop address information corresponding to each routing entry is the same, setting the next-hop address information to the object pointed to by the successor pointer; or in the case where there are routing entries with different corresponding next-hop address information, dividing the target routing table to obtain at least one sub-routing table, generating nodes corresponding to each sub-routing table respectively, constructing a node data structure based on the nodes corresponding to each sub-routing table, setting the node data structure to the object pointed to by the successor pointer, taking the sub-routing table as the target routing table, and jumping to the step of obtaining the next-hop address information corresponding to each routing entry in the target routing table. The use of this method can reduce the memory space occupied by the routing table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and in particular to a routing table compression method, device, computer equipment and storage medium. Background Art

[0002] The routing lookup algorithm is one of the main factors that determine the performance of Layer 3 forwarding network elements. The LPM (Longest Prefix Matching) lookup table in the DPDK (Data Plane Development Kit) is one of such algorithms. This algorithm uses the DIR-24-8 data structure. When performing routing queries, it first uses the first 24 bits of the destination address to search in the first table (called tbl24). After finding a matching entry, it continues to use the last 8 bits of the destination address to search in the second table (called tbl8) to obtain the routing information of the destination address.

[0003] However, current routing lookup algorithms generally have the problem that the routing table occupies a large amount of memory space. Taking the LMP lookup table as an example, since there are at most 2^24 entries in tbl24, the maximum number of tbl8 sheets is 2^24 in theory, and the maximum space occupied can reach 16GB. Therefore, it is necessary to provide a method for compressing the routing table. Summary of the invention

[0004] Based on this, it is necessary to provide a routing table compression method, device, computer equipment and storage medium to address the above technical problems.

[0005] In a first aspect, the present application provides a routing table compression method. The method comprises:

[0006] Obtain a target routing table, and generate a node corresponding to the target routing table, wherein the node includes at least routing entry information and a successor pointer, and the routing entry information is generated according to each routing entry in the target routing table;

[0007] Obtain the next hop address information corresponding to each routing entry in the target routing table;

[0008] When the next hop address information corresponding to each of the routing entries is the same, the next hop address information is set to the object pointed to by the successor pointer; or

[0009] In the case where there are routing entries with different corresponding next-hop address information, each routing entry in the target routing table is grouped to obtain at least one sub-routing table, and nodes corresponding to each sub-routing table are generated respectively. A node data structure is constructed based on the nodes corresponding to each sub-routing table, and the node data structure is set to the object pointed to by the successor pointer, the sub-routing table is used as the target routing table, and the step of obtaining the next-hop address information corresponding to each routing entry in the target routing table is jumped to.

[0010] In a second aspect, the present application also provides a routing table compression device. The device comprises:

[0011] A generating module, used to obtain a target routing table and generate a node corresponding to the target routing table, wherein the node at least includes routing entry information and a successor pointer, and the routing entry information is generated according to each routing entry in the target routing table;

[0012] A setting module is used to obtain the next hop address information corresponding to each routing entry in the target routing table, and when the next hop address information corresponding to each routing entry is the same, set the next hop address information to the object pointed to by the successor pointer; or when there are routing entries with different corresponding next hop address information, group the routing entries in the target routing table to obtain at least one sub-routing table, generate nodes corresponding to each sub-routing table respectively, construct a node data structure based on the nodes corresponding to each sub-routing table, set the node data structure to the object pointed to by the successor pointer, use the sub-routing table as the target routing table, and jump to the step of obtaining the next hop address information corresponding to each routing entry in the target routing table.

[0013] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, any one of the above methods is implemented.

[0014] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, any of the above methods is implemented.

[0015] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, any of the above methods is implemented.

[0016] The above-mentioned routing table compression method, device, computer equipment and storage medium represent the target routing table as a node composed of routing entry information and a successor pointer. If the next-hop address information corresponding to each routing entry is the same, the next-hop address information is set to the object pointed to by the successor pointer. If the next-hop address information corresponding to each routing entry is different, the target routing table is split into sub-routing tables, and the successor pointer is connected to the node data structure that can access the corresponding nodes of each sub-routing table. Repeat the above process until the next-hop address information corresponding to each routing entry in each sub-routing table split out is the same. The embodiment of the present application compresses the routing entry into routing entry information, and provides a path for accessing the next-hop address information corresponding to different routing entries through the successor pointer. Therefore, the ability of the target routing table to search for the next-hop address information can be unaffected while the size of the target routing table is compressed. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A schematic diagram of a process flow of a routing table compression method in one embodiment;

[0018] Figure 2 A schematic diagram of a process of splitting a sub-routing table in one embodiment;

[0019] Figure 3 A schematic diagram of a process for constructing a node data structure in one embodiment;

[0020] Figure 4 A schematic diagram of a process of searching for next-hop address information using a compressed routing table in one embodiment;

[0021] Figure 5 is a schematic diagram of a compressed routing table in one embodiment;

[0022] Figure 6 A schematic diagram of a segmented sub-routing table in one embodiment;

[0023] Figure 7 A schematic diagram of constructing a linked list in one embodiment;

[0024] Figure 8 A schematic diagram of a bisecting trap in one embodiment;

[0025] Fig. 9 is a schematic diagram of a compressed routing table in one embodiment;

[0026] Fig.10 is a schematic diagram of a pruned routing table in one embodiment;

[0027] Fig.11 A schematic diagram of a process of searching for next hop address information in an embodiment;

[0028] Fig.12is a schematic diagram of a compressed tbl24 in one embodiment;

[0029] Fig.13 A structural block diagram of a routing table compression device in one embodiment;

[0030] Fig.14 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0032] In one embodiment, Figure 1 As shown, a routing table compression method is provided. This embodiment takes the method applied to a forwarding network element as an example, and includes the following steps:

[0033] Step 102, obtaining the target routing table, and generating a node corresponding to the target routing table, the node at least including routing entry information and a successor pointer, the routing entry information is generated according to each routing entry in the target routing table.

[0034] In the embodiment of the present application, the target routing table is a routing table that needs to be compressed. The target routing table is composed of routing entries, and a routing entry includes a destination address and next hop address information corresponding to the destination address.

[0035] The node corresponding to the target routing table includes routing entry information and successor pointers. The routing entry information is generated according to each routing entry in the target routing table, and is used to represent the information summarized from each routing entry contained in the target routing table. The storage space occupied by the routing entry information should be smaller than the sum of the storage space occupied by the original routing entries, so as to achieve the effect of compressing the target routing table. Exemplarily, the routing entry information may include the destination address range covered by each routing entry, the total number of routing entries, etc.

[0036] The successor pointer is used to point to the next object that needs to be searched when retrieving the next hop address information of the destination address. The specific object needs to be determined according to the next hop address information corresponding to each routing entry in the target routing table. For details, please refer to the following description and will not be repeated here. When creating the node corresponding to the target routing table, you can temporarily not define the object pointed to by the successor pointer.

[0037] Step 104: Obtain the next hop address information corresponding to each routing entry in the target routing table.

[0038] Step 106: When the next hop address information corresponding to each routing entry is the same, the next hop address information is set as the object pointed to by the successor pointer.

[0039] In the embodiment of the present application, after obtaining the next hop address information corresponding to each routing entry, if the next hop address information corresponding to each routing entry is the same next hop address information, the next hop address information can be set to the object pointed to by the successor pointer. "Setting the next hop address information to the object pointed to by the successor pointer" specifically refers to setting the successor pointer to point to the storage address of the next hop address information, so that in actual applications, the next hop address information can be accessed through the successor pointer.

[0040] Step 108, in the case where there are routing entries with different corresponding next-hop address information, group the routing entries in the target routing table to obtain at least one sub-routing table, generate nodes corresponding to each sub-routing table, construct a node data structure based on the nodes corresponding to each sub-routing table, set the node data structure to the object pointed to by the successor pointer, use the sub-routing table as the target routing table, and jump to the step of obtaining the next-hop address information corresponding to each routing entry in the target routing table.

[0041] In the embodiment of the present application, after obtaining the next hop address information corresponding to each routing entry, if there are routing entries with different corresponding next hop address information, the target routing table needs to be split into sub-routing tables. The embodiment of the present application does not limit the method of splitting to obtain the sub-routing table. Generally speaking, the more the number of split sub-routing tables, the higher the probability that the next hop address information corresponding to each routing entry in the sub-routing table is the same, and the corresponding node depth accessed when retrieving the next hop address information in the application will become less, and the efficiency of the retrieval will be improved, but at the same time, the compressed routing table will occupy a larger space. Those skilled in the art can dynamically set the method of splitting the sub-routing table according to the different requirements for retrieval efficiency and the space occupied by the routing table in actual applications.

[0042] After generating the nodes corresponding to each sub-routing table in the manner described in the aforementioned step 102, it is necessary to organize these nodes into a data structure (i.e., a node data structure), and make the successor pointer in the node of the target routing table point to the node data structure, so that in actual applications, the node data structure can be accessed through the successor pointer, and then the nodes corresponding to each sub-routing table can be accessed.

[0043] It should be further explained that the purpose of forming the node into a node data structure is to obtain an object that can be pointed to by a successor pointer, and at the same time, the node corresponding to each sub-routing table can be accessed through the object. Otherwise, without forming a data structure, in order to access the nodes corresponding to each sub-routing table, it is necessary to add pointers pointing to the nodes corresponding to each sub-routing table in the node corresponding to the target routing table, resulting in an increase in the storage space occupied by the node corresponding to the target routing table.

[0044] The node data structure can be a linked list or an array, or any more complex data structure based on linked lists and arrays, such as a tree, a graph, a queue, etc. The specific data structure used as the node data structure can be determined according to actual needs. For example, when higher reading efficiency is required, an array can be used as the node data structure, because the efficiency of accessing elements in an array is usually higher than the efficiency of accessing nodes in a list; when the target routing table needs to be frequently modified, resulting in the number of sub-routing tables that may change, a linked list can be used as the node data structure, because the convenience of modifying a linked list is higher than the convenience of modifying an array.

[0045] After linking each node to form a linked list to obtain the node data structure (when linking a linked list, a pointer to the next node in the linked list needs to be added to each node, and this pointer is not a successor pointer), or defining an array for each node and filling each node into the array to obtain the node data structure, the node data structure can be set to the object pointed to by the successor pointer. In the case where the node data structure is a linked list, "setting the node data structure to the object pointed to by the successor pointer" specifically refers to setting the successor pointer to the storage address of the first node of the linked list. In the case where the node data structure is an array, "setting the node data structure to the object pointed to by the successor pointer" specifically refers to setting the successor pointer to the storage address of the first element of the array.

[0046] Furthermore, for each sub-routing table, it is necessary to use the sub-routing table as the target routing table, re-execute the steps of obtaining the next-hop address information corresponding to each routing entry in the target routing table, and determining whether the next-hop address information corresponding to each routing entry is the same. Until the next-hop address information corresponding to each routing entry in each target routing table is the same, the next-hop address information can be set as the object pointed to by the successor pointer.

[0047] The above process is explained below through a practical example. Assume that the target routing table is tbl24 in the LMP lookup table. Tbl24 contains 6 routing entries. The next hop address information corresponding to the first 2 routing entries is 100; the next hop address information corresponding to the last 4 routing entries is 200. See Table 1:

[0048] Table 1

[0049]

[0050] First, generate the node corresponding to the target routing table. Assume that the routing entry information includes the starting destination address (start_dip) and the ending destination address (end_dip) of the destination address range covered by each routing entry (the destination addresses corresponding to consecutive routing entries in tbl24 are generally continuous, so each routing entry can be compressed by recording the starting destination address and the ending destination address). The node composed of the routing entry information and the successor pointer (*next) can be expressed as {start_dip, end_dip, *next}.

[0051] When generating the node corresponding to the target routing table, you can assign values ​​to start_dip and end_dip. The node corresponding to the target routing table (node0) can be expressed as:

[0052] node0 = [10.10.2.0, 10.10.7.0, *next];

[0053] Next, the next hop address information corresponding to each routing entry in the target routing table is obtained, that is, 100 and 200. Since there are routing entries with different corresponding next hop address information, the target routing table needs to be divided into sub-routing tables.

[0054] Assume that the first two routing entries are divided into one sub-routing table, the middle two routing entries are divided into one sub-routing table, and the last two routing entries are divided into one sub-routing table. Then generate nodes node1, node2, and node3 corresponding to the sub-routing tables respectively. After the assignment, node1, node2, and node3 are:

[0055] node1=[10.10.2.0, 10.10.3.0, *next];

[0056] node2=[10.10.4.0, 10.10.5.0, *next];

[0057] node3=[10.10.6.0, 10.10.7.0, *next];

[0058] Then node1, node2 and node3 are combined into a node data structure. Here, an array is used as the node data structure. First, define an array whose number of elements is the number of sub-routing tables, and then fill node1, node2 and node3 into the array respectively to obtain the node data structure: arr0=[node1, node2, node3]. Assign *next in node0 to arr0.

[0059] Then use the sub-routing table corresponding to node1, the sub-routing table corresponding to node2, and the sub-routing table corresponding to node3 as the target routing table. In the sub-routing table corresponding to node2, there are still routing entries with different next-hop address information. Therefore, it is necessary to re-execute the steps of splitting the sub-routing table and forming the data structure to obtain the node data structure: arr1=[node4, node5], node4=[10.10.4.0, 10.10.4.0, *next], node5=[10.10.5.0, 10.10.5.0, *next].

[0060] In the sub-routing tables corresponding to node1 and node3, the next-hop address information corresponding to the routing entries is the same. Therefore, the object pointed to by the successor pointer can be set to the next-hop address information, which is 100 and 200 respectively.

[0061] Then the sub-routing table corresponding to node4 and the sub-routing table corresponding to node5 are used as the target routing table respectively. The next-hop address information corresponding to the routing entries in these two sub-routing tables is the same, so the object pointed to by the successor pointer can be set to the next-hop address information, which is 100 and 200 respectively.

[0062] The final nodes are:

[0063] node0=[10.10.2.0, 10.10.7.0, arr0];

[0064] node1=[10.10.2.0, 10.10.3.0, 100];

[0065] node2=[10.10.4.0, 10.10.5.0, arr1];

[0066] node3=[10.10.6.0, 10.10.7.0, 200];

[0067] node4=[10.10.4.0, 10.10.4.0, 100];

[0068] node5=[10.10.5.0, 10.10.5.0, 200];

[0069] These nodes together form the compressed routing table. Set node0 as the entry node of the compressed routing table. Each time the next hop address information is searched, the match starts from node0.

[0070] The practical application is explained below. Suppose you want to find the next hop address information for the target address 10.10.5.0. First, match the target address 10.10.5.0 with node0. 10.10.5.0 is in the target address range represented by node0, so continue to search based on node0. Read the object pointed to by the successor pointer in node0, that is, arr0. Then traverse each element in arr0 sequentially (it should be noted that the strategy for dividing the sub-routing table can be designed to quickly locate the element corresponding to the target address in the node data structure in the application. The embodiment of the present application temporarily uses the traversal method) to determine whether the target address is in the target address range represented by the traversed elements. Here, 10.10.5.0 matches node2. Continue to search based on node2.

[0071] Read the object pointed to by the successor pointer in node2, which is arr1. Then traverse each element in arr1 sequentially and match it to node5. Continue searching based on node5.

[0072] Read the object pointed to by the successor pointer in node5, which is 200. At this time, the next hop address information corresponding to 10.10.5.0 is successfully retrieved.

[0073] The routing table compression method provided by the embodiment of the present application represents the target routing table as a node composed of routing entry information and a successor pointer. If the next hop address information corresponding to each routing entry is the same, the next hop address information is set to the object pointed to by the successor pointer. If the next hop address information corresponding to each routing entry is different, the target routing table is split into sub-routing tables, and the successor pointer is connected to the node data structure that can access the corresponding nodes of each sub-routing table. Repeat the above process until the next hop address information corresponding to each routing entry in each sub-routing table split out is the same. The embodiment of the present application compresses the routing entry into routing entry information, and provides the path of accessing the next hop address information corresponding to different routing entries through the successor pointer, so that the ability of the target routing table to find the next hop address information can be not affected while the size of the target routing table is compressed.

[0074] In one embodiment, Figure 2 As shown, each routing entry in the target routing table is grouped to obtain at least one sub-routing table, including:

[0075] Step 202, determining the number of target sub-routing tables corresponding to the target routing table;

[0076] Step 204, divide each routing entry in the target routing table into sub-routing tables equal to the number of the target sub-routing tables; wherein each routing entry contained in each sub-routing table is continuous in the target routing table.

[0077] In the embodiment of the present application, when the target routing table is divided into multiple sub-routing tables, the number of target sub-routing tables corresponding to the target routing table can be determined first. The number of target sub-routing tables can refer to the relationship between the number of sub-routing tables, retrieval efficiency and routing table space mentioned in the above embodiment, and can be set by those skilled in the art according to actual needs.

[0078] After obtaining the number of target sub-routing tables, the routing entries in the target routing table can be divided into the number of target sub-routing tables, each of which is a sub-routing table, and the routing entries in each sub-routing table are continuous routing entries in the target routing table. In this way, the scope covered by these routing entries can be characterized by a small amount of information (for example: the starting destination address and the ending destination address, or the starting destination address and the number of routing entries), so that the storage space occupied by the routing entry information in the sub-routing table can be greatly reduced compared to the original routing entries.

[0079] Furthermore, the number of target sub-routing tables can be added to the routing entry information of the node corresponding to the target routing table. Since the number of routing entries corresponding to each sub-routing table is the same, the range covered by the routing entries in each sub-routing table can be determined based on the number of target sub-routing tables and the range covered by the routing entries represented by the routing entry information of the target routing table. When applied, it can quickly determine which node corresponding to the sub-routing table matches the target address.

[0080] It should be noted that if the number of route entries in the target routing table cannot be divided by the number of target sub-routing tables, any of the following strategies can be used to divide each route entry equally: add empty route entries to fill the number of route entries to the smallest value among the values ​​that are greater than the number of route entries and can be divided by the number of target sub-routing tables; or, the number of route entries can be rounded down to a value that can be divided by the number of target sub-routing tables, and then the remaining route entries are allocated to the last sub-routing table. Those skilled in the art can also use other methods to handle this situation, and the embodiments of the present application are not specifically limited.

[0081] In one embodiment, in step 202, determining the number of target sub-routing tables corresponding to the target routing table includes:

[0082] Determine the total number of target segments corresponding to the target routing table, and use the total number as the number of target sub-routing tables. The target segment consists of routing entries in the target routing table that have the same and continuous corresponding next-hop address information.

[0083] In the embodiment of the present application, a "target segment" refers to all routing entries in the target routing table whose corresponding next-hop address information is the same and continuous. The next-hop address information corresponding to the first routing entry in the target routing table can be read, and a target segment corresponding to the next-hop address information can be created. Then, the target segment is used as the current target segment, and the next-hop address information is used as the current next-hop address information, and the target routing table is traversed from the first routing entry in the target routing table. For the currently traversed routing entry, if the next-hop address information of the routing entry is the same as the current next-hop address information, the routing entry is added to the current target segment. If the next-hop address information of the routing entry is different from the current next-hop address information, a new target segment is created, the target segment is used as the current target segment, and the next-hop address information of the routing entry is used as the current next-hop address information, and the traversal continues until the target routing table is traversed.

[0084] Taking Table 1 in the aforementioned embodiment as an example, there are two target segments in Table 1: the target segment corresponding to the next hop address information 100 composed of the first routing entry to the second routing entry, and the target segment corresponding to the next hop address information 200 composed of the third routing entry to the sixth routing entry.

[0085] The reason for taking the total number of target segments as the number of target sub-routing tables is that the number of routing entries contained in most target segments is similar. Therefore, when the strategy of equally dividing each routing entry according to the number of target sub-routing tables in the aforementioned embodiment is adopted to obtain the sub-routing table, most of the sub-routing tables can include only a small number of routing entries with different corresponding next-hop address information, thereby reducing the number of times the sub-routing table needs to be split and reducing the node depth of the compressed routing table.

[0086] In one embodiment, Figure 3 As shown, a node data structure is constructed based on the nodes corresponding to each sub-routing table, including:

[0087] Step 302, respectively determine the total number of target segments corresponding to each sub-routing table, where the target segments are composed of routing entries in the sub-routing tables that have the same and continuous next-hop address information;

[0088] Step 304: if there are sub-routing tables whose total number meets the preset number condition, regroup the routing entries in the target routing table according to the target segments corresponding to the sub-routing tables to obtain at least one sub-routing table, and link the nodes corresponding to the sub-routing tables into a node linked list;

[0089] Step 306: If there is no sub-routing table whose total number meets the preset number condition, construct a node array including elements of the number of target sub-routing tables, and fill the nodes corresponding to each sub-routing table into the node array.

[0090] In the embodiment of the present application, the total number of target segments also needs to be determined for the sub-routing table. The preset number condition is that the total number is the same as the preset target number, and the target number is the number under which it is foreseeable that the sub-routing table needs to be split for multiple rounds, resulting in a larger depth of nodes in the compressed routing table.

[0091] In one embodiment, the preset quantity condition is that the total number of target segments is 2, or the total number of target segments is the same as the total number of target segments corresponding to the target routing table. When the total number of target segments is 2, if the number of routing entries corresponding to each target segment is different, when the sub-routing table is continued to be split, it may fall into the bisection oscillation trap, resulting in a larger node depth. When the total number of target segments is the same as the total number of target segments corresponding to the target routing table, when the sub-routing table is continued to be split, it may fall into the bisection stability trap, which may also result in a larger node depth. Those skilled in the art may also determine other target quantities by means of experiments, etc.

[0092] If there are sub-routing tables whose total number meets the preset number condition, in order to avoid the situation where the node depth of a sub-routing table is too large, the sub-routing table can be rebuilt according to each target segment of the sub-routing table, and then the nodes of each sub-routing table are connected in a linked list. In this way, the node depth is controllable (the maximum depth is the total number of target segments), avoiding the situation where the node depth obtained after the sub-routing table is split for multiple rounds in accordance with the method in the aforementioned embodiment is greater than the total number of target segments.

[0093] Furthermore, the sub-routing tables can be sorted from high to low according to the number of routing entries contained, and the sorted order is used as the order of each node in the linked list, so as to improve the probability of matching the corresponding node by traversing a small number of nodes when matching the destination address with the nodes in the linked list in practical applications.

[0094] If there is no sub-routing table that meets the preset number conditions, it means that the number of rounds of further splitting each sub-routing table is controllable. In this case, an array can be used to construct a node data structure to improve the efficiency of jumping to the corresponding node after matching the node corresponding to the destination address in actual applications.

[0095] In one embodiment, the above method also includes: for any node, obtaining the tail node of all reachable nodes corresponding to the node, and determining the next hop address information pointed to by the successor pointer of each tail node, and deleting the node when the next hop address information pointed to by each tail node is empty.

[0096] In the embodiment of the present application, after the compression of the target routing table is completed, the compressed routing table may be further pruned.

[0097] For any node, the reachable nodes corresponding to the node include the node itself, the nodes that can be jumped to through the successor pointer of the node, and the nodes that can be further jumped to through the successor pointers of the nodes jumped to. For example, if the successor pointer of node 1 points to an array that includes nodes 2 and 3, and the successor pointer of node 2 points to a linked list that includes nodes 4, 5, and 6, the reachable nodes of node 1 are nodes 1, 2, 3, 4, 5, and 6.

[0098] The tail node in the reachable node refers to the node whose successor pointer points to the next hop address information. If the next hop address information is empty, it means that the routing entries corresponding to the tail node are invalid routing entries. If the next hop address information pointed to by all the tail nodes of a node is empty, then the routing entries corresponding to the node are invalid routing entries. Therefore, the node can be deleted to further reduce the storage space occupied by the compressed routing table.

[0099] After deleting a node, the node data structure where the node is located also needs to be adaptively modified. If the node data structure is a linked list, obtain the node in the linked list whose pointer points to the node, and modify the assignment of the node pointer to null or the default value. If the node data structure is an array, you can redefine a node array in which the number of elements is the number of nodes remaining in the array after deleting the node, and refill the remaining nodes into the new node array, and then modify the object pointed to by the pointer to the node data structure to the new node array.

[0100] In one embodiment, the above method also includes: determining the target node from each node, the number of nodes in the node data structure to which the target node belongs is 1; for any target node, obtaining the object pointed to by the successor pointer of the target node, and when the object is a node data structure and the number of nodes in the node data structure is 1, deleting the target node, and modifying the object pointed to by the successor pointer of the predecessor node of the target node to the object pointed to by the successor pointer of the target node.

[0101] In the embodiment of the present application, after completing the pruning process in the aforementioned embodiment, it is necessary to further clean up the redundant parts in the compressed routing table. If there is only one node in the node data structure to which a certain node belongs, that is, if there is only this node in this node data structure, if there is only one node in the node data structure pointed to by the successor pointer of this node, then it is equivalent to that the target routing table corresponding to the target node has only one sub-routing table with valid information. At this time, the target node is redundant, and the node corresponding to the sub-routing table can be connected to the predecessor node of the target node pointed to by the successor pointer.

[0102] Through the above pruning operation, the node depth of the compressed target routing table can be reduced, reducing the efficiency loss of routing search.

[0103] In one embodiment, Figure 4 As shown, the above method also includes:

[0104] Step 402, matching the destination address with the routing entry information in the target node;

[0105] Step 404, when the destination address matches the routing entry information in the target node, obtain the object pointed to by the successor pointer of the target node;

[0106] Step 406, when the object is the next hop address information, generating a routing policy for the destination address according to the next hop address information; or,

[0107] Step 408: When the object is a node data structure, the node in the node data structure is used as the target node, and the process jumps to the step of matching the destination address with the routing entry information in the target node.

[0108] In the embodiment of the present application, after the target routing table is compressed, if the next-hop routing information of the destination address needs to be queried, the destination address can be matched with each node in the compressed routing table.

[0109] First, the node representing the entire target routing table can be used as the target node, and then the destination address and the routing entry information in the target node are matched. If the destination address matches the routing entry information, that is, the destination address is in the routing entry covered by the node represented by the routing entry information, then the object pointed to by the successor pointer in the target node is obtained.

[0110] If the object pointed to by the successor pointer is the next hop address information, it indicates that the search for the next hop address information is completed, and a routing strategy for the destination address can be generated based on the next hop address information.

[0111] If the object pointed to by the successor pointer is a node data structure, further determine which node in the destination address and the node data structure matches (if it cannot be determined, then sequentially use each node in the node data structure as the target node), and use the node as the target node, and repeat steps 402 to 406 until a node with a successor pointer pointing to the next-hop address information is retrieved, thereby completing the search for the next-hop address information.

[0112] In one embodiment, a routing table compression method is provided, comprising:

[0113] S1, create a target routing table, add routing items to the target routing table, obtain a target routing table containing multiple routing items, and generate nodes corresponding to the target routing table.

[0114] Before compressing the target routing table, the target routing table is first created. Those skilled in the art can create the target routing table in any existing manner, and the embodiments of the present application will not be described in detail.

[0115] The specific structure of the node is defined as follows:

[0116] {start_dip: 4 bytes, the starting destination address of the routing entry corresponding to this node;

[0117] end_dip: 4 bytes, the destination address of the routing entry corresponding to this node;

[0118] *next: 8 bytes, successor pointer;

[0119] flag: 1 byte, the subsequent pointer points to the object's attributes, including array, linked list or next hop address information;

[0120] meta_len: 4 bytes, valid when the flag value represents an array, representing the number of routing entries covered by the node corresponding to each element in the array;

[0121] meta_num: 4 bytes, valid when the flag value represents an array, representing the number of elements in the array;

[0122] next_start_dip: 4 bytes, valid when the flag value represents an array, indicating that the node corresponding to the first element in the array covers the starting destination address in the routing entry;

[0123] *list: 8 bytes, valid when the flag value represents a linked list, and is a pointer to the next node in the linked list}

[0124] That is, the size of a node is 37 bytes, which is 40 bytes after being aligned to 4 or 8 bytes in the operating system. Figure 5 , which is a schematic diagram of a compressed routing table composed of various nodes, and a schematic diagram of an object specifically pointed to by each pointer in a node after the parameters in some nodes in the compressed routing table are represented in detail.

[0125] Each time a node corresponding to a routing table is subsequently generated, the predefined node structure may be called, and each parameter in the node structure may be assigned a value according to the actual situation of the routing table.

[0126] S2, determine the total number of target segments in the target routing table. If the total number is 1, the next hop address information corresponding to the target segment is used as the object pointed to by the successor pointer of the corresponding node in the target routing table. If the total number is not 1, the routing entries in the target routing table are divided into multiple sub-routing tables according to the total number.

[0127] If the number of routing entries cannot be divided by the total number, the number of routing entries is rounded up to the minimum number that can be divided by the total number. Then the ratio of the minimum number to the total number is used as the number of routing entries in each sub-routing table. For the last sub-routing table, the number of routing entries in this sub-routing table is the difference between the actual number of routing entries in the target routing table and the sum of the numbers of routing entries in other sub-routing tables.

[0128] For example, when the total number of routing entries is 16777216, if the total number of target segments is 7, 16777216 can be rounded up to 16777222. The ratio of 16777222 to 7 is 2396746. Therefore, except for the last sub-routing table, the number of routing entries contained in the other 6 sub-routing tables is 2396746. The number of routing entries contained in the last sub-routing table is the difference between 16777216 and 2396746×6, that is, 2396740.

[0129] Each sub-routing table may contain different target segments, or may contain part of a target segment, such as Figure 6 shown.

[0130] S3, using the starting destination address and the ending destination address in the destination address range covered by each sub-routing table as the routing address information corresponding to the sub-routing table.

[0131] Generally speaking, the destination addresses represented by adjacent routing entries in the routing table are continuous. If they are not continuous, routing entries can be filled between the two routing entries to make the destination addresses continuous. The next hop address information of the filled routing entries can be set to empty.

[0132] S4, for any sub-routing table, if the total number of target segments corresponding to the sub-routing table is 2 or the same as the total number of target segments of the target routing table, then re-divide each sub-routing table according to the target segments and regenerate the nodes corresponding to the sub-routing table. The node with the most corresponding routing entries in each node is used as the first node of the linked list, and the nodes corresponding to each sub-routing table are linked to form a linked list. The object pointed to by the successor pointer of the corresponding node of the target routing table is set to the linked list. Figure 7 shown.

[0133] The reason why a linked list is constructed when the total number is 2 or the same as the total number of target segments in the target routing table is that if an array is constructed and each node in the array is returned to S2 for bisection, it will fall into the bisection trap and cause the node depth to be too large. Figure 8 shown. Figure 8 If a linked list is constructed in , the maximum node depth is 2 or 3 respectively. However, if the array is continuously constructed and the sub-routing table is further divided according to S2, the node depth will reach 5 and 4 respectively, resulting in the search efficiency of using an array as a node data structure being lower than that of using a linked list as a node data structure.

[0134] S5, if there is no corresponding sub-routing table with a total number of target segments of 2 or the same as the total number of target segments of the target routing table, generate nodes corresponding to each sub-routing table, define an array containing elements of the number of sub-routing tables, and fill the nodes corresponding to the sub-routing table into the array. Set the object pointed to by the successor pointer of the corresponding node of the target routing table to the array.

[0135] Take each sub-routing table as the target routing table in sequence and repeat S2 to S5. The final nodes and the objects pointed to by the successor pointers of each node are shown in Fig. 9 . Fig. 9 That is, the compressed target routing table.

[0136] S6, traverse each node starting from the node corresponding to the original target routing table. For the currently traversed node, determine all the tail nodes of all reachable nodes of the node, and if the next hop address information pointed to by the successor pointers of all the tail nodes is empty, delete the node.

[0137] S7, traverse each node starting from the node corresponding to the original target routing table. For the currently traversed node, if the currently traversed node is in an array with only one element, and the object pointed to by the successor pointer of the current node is also an array with only one element, then delete the current node, and set the successor pointer of the predecessor node of the current node to point to the object pointed to by the successor pointer of the current node.

[0138] Reference Fig.10 As shown in the figure, the pruning method of S6 and S7 is used to prune Fig. 9 Schematic diagram of the routing table obtained after pruning the compressed routing table in . Fig.10 The nodes filled with shades in the figure are the nodes whose tail nodes all point to null and are deleted in the first pruning step. The nodes marked with dotted lines are located in an array with only one element, and the object pointed to by the successor pointer is also an array with only one element, and are deleted in the second pruning step.

[0139] In one embodiment, referring to Fig.11 As shown, a routing search method is provided. The embodiment of the present application takes the method applied to the tbl24 routing table compressed according to the above embodiment as an example, including:

[0140] S1, obtain the destination address, perform an AND operation or an OR operation on the destination address and the mask, and obtain an integer value.

[0141] The integer value is the index value in tbl24, which represents the row number of the destination address in the target routing table.

[0142] S2, taking the node corresponding to the target routing table as the target node, and obtaining the address and type of the object pointed to by the successor pointer according to *next and flag in the target node.

[0143] S3, if the object type is an array, use (integer value - integer value of next_start_dip) / meta_len to get the subscript of the array, that is, the node corresponding to the destination address in the array is the nth element in the array. If the subscript is greater than or equal to meta_num, it means that the node corresponding to the destination address in the array does not exist, and an error value is returned and the search ends. Otherwise, determine whether the destination address is between the starting destination address and the ending destination address of the node corresponding to the destination address. If not, an error value is returned and the search ends. If so, the node corresponding to the destination address in the array is used as the target node, and S2-S5 are repeated.

[0144] S4, if the type of the object is a linked list, traverse the linked list starting from the first node of the linked list to determine whether the destination address is between the starting destination address and the ending destination address. If not, get the next node according to the node's *list and continue to determine until a node is found whose destination address is between the starting destination address and the ending destination address of the node, or *list is empty (empty means that the last node of the linked list has been traversed, an error value is returned and the search ends). If the node is found, repeat S2-S5 according to the node's *next and flag.

[0145] S5. If the type of the object is next-hop address information, the next-hop address information is returned (the next-hop address information includes blank or specific routing items), and the search is completed.

[0146] The following is a specific example to illustrate the above route search process. Figure 6 The result of compressing the tbl24 routing table is as follows Fig.12 As shown, there are 15 nodes in the table, with a total size of 600 bytes, while the original tbl24 routing table size is 2^24×4=64MB. It can be seen that after compressing the routing table using the method provided in the embodiment of the present application, the compression rate can be close to 0%. At the same time, the deepest node in the table has a depth of 9, and there is not much loss in search efficiency.

[0147] Example 1: The destination address is 10.10.2.1.

[0148] Starting from the node corresponding to the target routing table, search for the object pointed to by the successor pointer. The object is an array. The result of the AND operation between 10.10.2.1 and the 24-bit mask is 10.10.2.0. 10.10.2.0 is converted to an integer value of: 0xA0A02=657922. The subscript is calculated: (657922-0) / 2396746=0. The subscript of the array is matched to 0, which is less than meta_num=7, and 657922 is between the integer value 0 of the starting destination address and the integer value 2396745 of the end destination address. Therefore, we can continue to search for the object pointed to by the successor pointer of the element corresponding to subscript 0. This object is still an array, so we continue to calculate the subscript (657922-657922) / 2=0, which is less than meta_num=1, and 657922 is between 657922-657923. Next, search for the object pointed to by the successor pointer of the element corresponding to index 0. If the object is the next-hop address information, then return the routing entry 10.10.2.0 / 23 represented by the next-hop address information to complete the search.

[0149] Example 2: The destination address is 192.168.2.1.

[0150] Starting from the node corresponding to the target routing table, find the object pointed to by the successor pointer. The object is an array, and the integer value corresponding to the target address is 12625922. Calculate the subscript (12625922-0) / 2396746=5. The object pointed to by the successor pointer of the element with subscript 5 is still an array, and continue to calculate the subscript (12625922-12625920) / 3=0. The object pointed to by the successor pointer of the element with subscript 0 is a linked list, so start traversing the linked list from the first node until the second node of the linked list is traversed. Determine the integer value corresponding to the target address, which is between the integer value of the starting destination address corresponding to the node and the integer value of the end destination address. The object pointed to by the successor pointer of the second node is the next-hop routing information, and return the routing item 192.168.2.0 / 23 represented by the next-hop routing information.

[0151] Example 3: The destination address is 192.168.8.1.

[0152] Starting from the node corresponding to the target routing table, search for the object pointed to by the successor pointer. The object is an array, and the integer value corresponding to the target address is 12625928. The calculated subscript is (12625928-0) / 2396746=5. The object pointed to by the successor pointer of the element with subscript 5 is still an array. The subscript is (12625928-12625920) / 3=2. However, 192.168.8.0 (the network segment IP obtained by calculating 192.168.8.1 and the mask) is not between the starting destination address 192.168.6.0 and the end destination address 192.168.7.0 corresponding to the element with subscript 2, so the search fails. See Fig.12 As shown in the figure, the reason for the search failure is that in the original compressed target routing table, the next hop address information corresponding to 192.168.8.0 is empty, so the node to which this destination address belongs is deleted during pruning, resulting in 192.168.8.0 matching the nodes corresponding to 192.168.6.0-192.168.7.0. Therefore, after calculating the subscript to obtain the node corresponding to the target address in the array, it is also necessary to verify whether the target address is between the starting destination address and the ending destination address of the node to prevent mismatching of routes.

[0153] The routing table compression method provided in the embodiment of the present application provides a compression algorithm with high compression efficiency, and the compressed routing table greatly reduces the depth of the routing table due to the pruning operation, which can reduce the loss of routing lookup performance.

[0154] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0155] Based on the same inventive concept, the embodiment of the present application also provides a routing table compression device for implementing the routing table compression method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more routing table compression device embodiments provided below can refer to the limitations of the routing table compression method above, and will not be repeated here.

[0156] In one embodiment, Fig.13 As shown, a routing table compression device 1300 is provided, including: a generating module 1302, a setting module 1304, wherein:

[0157] A generating module 1302 is used to obtain a target routing table and generate a node corresponding to the target routing table, wherein the node includes at least routing entry information and a successor pointer, and the routing entry information is generated according to each routing entry in the target routing table;

[0158] The setting module 1304 is used to obtain the next hop address information corresponding to each routing entry in the target routing table, and when the next hop address information corresponding to each routing entry is the same, set the next hop address information to the object pointed to by the successor pointer; or when there are routing entries with different corresponding next hop address information, group the routing entries in the target routing table to obtain at least one sub-routing table, generate nodes corresponding to each sub-routing table respectively, construct a node data structure based on the nodes corresponding to each sub-routing table, set the node data structure to the object pointed to by the successor pointer, use the sub-routing table as the target routing table, and jump to the step of obtaining the next hop address information corresponding to each routing entry in the target routing table.

[0159] The routing table compression device provided by the embodiment of the present application represents the target routing table as a node composed of routing entry information and a successor pointer. If the next hop address information corresponding to each routing entry is the same, the next hop address information is set to the object pointed to by the successor pointer. If the next hop address information corresponding to each routing entry is different, the target routing table is split into sub-routing tables, and the successor pointer is connected to the node data structure that can access the corresponding nodes of each sub-routing table. Repeat the above process until the next hop address information corresponding to each routing entry in each sub-routing table split out is the same. The embodiment of the present application compresses the routing entry into routing entry information, and provides a path for accessing the next hop address information corresponding to different routing entries through the successor pointer, so that the ability of the target routing table to find the next hop address information can be not affected while the size of the target routing table is compressed.

[0160] In one embodiment, the setting module 1304 is further used to:

[0161] Determine the number of target sub-routing tables corresponding to the target routing table;

[0162] Each routing entry in the target routing table is equally divided into sub-routing tables which are the same as the target sub-routing tables; wherein each routing entry contained in each sub-routing table is continuous in the target routing table.

[0163] In one embodiment, the setting module 1304 is further used to:

[0164] Determine the total number of target segments corresponding to each of the sub-routing tables respectively, wherein the target segments are composed of routing entries in the sub-routing tables that have the same and continuous corresponding next-hop address information;

[0165] In the case where there are sub-routing tables whose total number satisfies the preset number condition, regrouping the routing entries in the target routing table according to the target segments corresponding to the sub-routing tables to obtain at least one sub-routing table, and linking the nodes corresponding to the sub-routing tables into a node linked list; or

[0166] In the case that there are no sub-routing tables whose total number meets the preset number condition, a node array including elements of the number of target sub-routing tables is constructed, and nodes corresponding to each sub-routing table are filled into the node array.

[0167] In one of the embodiments, the preset quantity condition is that the total number of the target segments is 2, or the total number of the target segments is the same as the total number of the target segments corresponding to the target routing table.

[0168] In one embodiment, the device further comprises:

[0169] The deletion module is used to obtain the tail node of all reachable nodes corresponding to any of the nodes, and determine the next hop address information pointed to by the successor pointer of each of the tail nodes. If the next hop address information pointed to by each of the tail nodes is empty, the node is deleted.

[0170] In one embodiment, the device further comprises:

[0171] A determination module, used to determine a target node from each of the nodes, wherein the number of nodes in the node data structure to which the target node belongs is 1;

[0172] A modification module is used to obtain the object pointed to by the successor pointer of any target node, and when the object is a node data structure and the number of nodes in the node data structure is 1, delete the target node and modify the object pointed to by the successor pointer of the predecessor node of the target node to the object pointed to by the successor pointer of the target node.

[0173] In one embodiment, the device further comprises:

[0174] A matching module is used to match a destination address with routing entry information in a target node; when the destination address matches the routing entry information in the target node, obtain the object pointed to by the successor pointer of the target node; when the object is next-hop address information, generate a routing strategy for the destination address based on the next-hop address information; or when the object is a node data structure, use a node in the node data structure as a target node and jump to the step of matching the destination address with the routing entry information in the target node.

[0175] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0176] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.14As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a routing table compression method is implemented.

[0177] Those skilled in the art will understand that Fig.14 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0178] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0179] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0180] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0181] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0182] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0183] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0184] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A routing table compression method, characterized in that: The method comprises: Obtain a target routing table, and generate a node corresponding to the target routing table, wherein the node includes at least routing entry information and a successor pointer, and the routing entry information is generated according to each routing entry in the target routing table; Obtain the next hop address information corresponding to each routing entry in the target routing table; When the next hop address information corresponding to each of the routing entries is the same, the next hop address information is set to the object pointed to by the successor pointer; or In the case where there are routing entries with different corresponding next-hop address information, each routing entry in the target routing table is grouped to obtain at least one sub-routing table, and nodes corresponding to each sub-routing table are generated respectively. A node data structure is constructed based on the nodes corresponding to each sub-routing table, and the node data structure is set to the object pointed to by the successor pointer, the sub-routing table is used as the target routing table, and the step of obtaining the next-hop address information corresponding to each routing entry in the target routing table is jumped to.

2. The method according to claim 1, characterized in that: The grouping of the routing entries in the target routing table to obtain at least one sub-routing table includes: Determine the number of target sub-routing tables corresponding to the target routing table; Each routing entry in the target routing table is equally divided into sub-routing tables as many as the target sub-routing tables; wherein each routing entry contained in each sub-routing table is continuous in the target routing table.

3. The method according to claim 2, characterized in that The node data structure is obtained based on the nodes corresponding to each of the sub-routing tables, including: Determine the total number of target segments corresponding to each of the sub-routing tables respectively, wherein the target segments are composed of routing entries in the sub-routing tables that have the same and continuous corresponding next-hop address information; In the case where there are sub-routing tables whose total number meets the preset number condition, regrouping the routing entries in the target routing table according to the target segments corresponding to the sub-routing tables to obtain at least one sub-routing table, and linking the nodes corresponding to the sub-routing tables into a node linked list; or In the case that there are no sub-routing tables whose total number meets the preset number condition, a node array including elements of the number of target sub-routing tables is constructed, and nodes corresponding to each sub-routing table are filled into the node array.

4. The method according to claim 3, characterized in that The preset quantity condition is that the total number of the target segments is 2, or the total number of the target segments is the same as the total number of the target segments corresponding to the target routing table.

5. The method according to claim 3, characterized in that: The method further comprises: For any of the nodes, obtain the tail nodes of all reachable nodes corresponding to the node, and determine the next hop address information pointed to by the successor pointers of each of the tail nodes. If the next hop address information pointed to by each of the tail nodes is empty, delete the node.

6. The method according to claim 5, characterized in that The method further comprises: Determine a target node from each of the nodes, the number of nodes in the node data structure to which the target node belongs is 1; For any of the target nodes, obtain the object pointed to by the successor pointer of the target node. If the object is a node data structure and the number of nodes in the node data structure is 1, delete the target node and modify the object pointed to by the successor pointer of the predecessor node of the target node to the object pointed to by the successor pointer of the target node.

7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: Match the destination address with the routing entry information in the target node; When the destination address matches the routing entry information in the target node, obtaining the object pointed to by the successor pointer of the target node; In the case where the object is next-hop address information, generating a routing policy for the destination address according to the next-hop address information; or, In the case where the object is a node data structure, the node in the node data structure is used as the target node, and the process jumps to the step of matching the destination address with the routing entry information in the target node.

8. A routing table compression device, characterized in that: The device comprises: A generating module, used to obtain a target routing table and generate a node corresponding to the target routing table, wherein the node at least includes routing entry information and a successor pointer, and the routing entry information is generated according to each routing entry in the target routing table; A setting module is used to obtain the next hop address information corresponding to each routing entry in the target routing table, and when the next hop address information corresponding to each routing entry is the same, set the next hop address information to the object pointed to by the successor pointer; or when there are routing entries with different corresponding next hop address information, group the routing entries in the target routing table to obtain at least one sub-routing table, generate nodes corresponding to each sub-routing table respectively, construct a node data structure based on the nodes corresponding to each sub-routing table, set the node data structure to the object pointed to by the successor pointer, use the sub-routing table as the target routing table, and jump to the step of obtaining the next hop address information corresponding to each routing entry in the target routing table.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Route prefix storage method and device and route address searching method and device

    CN103404092A

  • Method and device for searching routing table item

    CN118282943A