Routing address storage method, device, network equipment and storage medium

By adopting a multi-level memory structure in network devices, the common prefix, intermediate prefix and suffix information of routing addresses are segmented, and the chip resource waste caused by routing address storage in the prior art is solved, and a more efficient storage utilization rate is achieved .

CN115987888BActive Publication Date: 2024-11-12SUZHOU CENTEC COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211636265.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2024-11-12
Estimated Expiration
2042-12-20

AI Technical Summary

Technical Problem

Existing routing address storage methods lead to the waste of chip resources, especially the waste of static random memory (SRAM) resources, which cannot efficiently utilize the huge number of routing addresses.

Method used

Using a multi-level memory structure, including three-state content addressing memory (TCAM) and multi-level static random memory (SRAM), the routing is realized by storing the common prefix in TCAM and the intermediate prefix and suffix information in different levels of SRAM respectively. The address is stored in segments, and the format of the storage unit is dynamically adjusted according to the length of the stored information to reduce redundant storage.

Benefits of technology

The utilization rate of each level of static random memory is improved, the waste of SRAM resources is greatly reduced, the utilization rate of chip resources is improved, and more efficient routing address storage is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115987888B_ABST
    Figure CN115987888B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention proposes a routing address storage method, device, network equipment and storage medium, which belongs to the field of communication technology. The common prefix of multiple routing addresses is stored in a ternary content addressable memory, and the multi-level intermediate prefix of each routing address is stored in sequence in a static random access memory other than the last-level static random access memory in the multi-level static random access memory. The suffix information of each routing address is stored in the last-level static random access memory of the multi-level static random access memory, so as to realize segmented storage of routing addresses, so that the last-level static random access memory does not need to store all the information of the routing addresses, and the utilization rate of each level of static random access memory can be improved, thereby greatly reducing the waste of SRAM resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a routing address storage method, device, network equipment and storage medium. Background Art

[0002] In the current network environment, the number of Internet Protocol (IP) addresses is very large. The number of IPv4 routing IP addresses can reach 2^32, and the number of IPv6 addresses currently in use has reached 2^128, which places huge demands on the storage of devices that store routing entries.

[0003] In the related art, the longest mask match (Algorithm Longest Prefix Match, ALPM) is used to store the routing address. The complete routing address is stored in the static random access memory (SRAM) of the APLM, and the common prefix of the routes in the same SRAM is stored in the ternary content addressable memory (Ternary Content Addressable Memory, TCAM). Each route has a next hop, and the TCAM prefix route has a next hop. If the route in the SRAM is matched, the route with the largest mask in the SRAM is used first.

[0004] However, current routing storage methods result in a waste of chip resources. Summary of the invention

[0005] In view of this, an object of the present invention is to provide a routing address storage method, apparatus, network device and storage medium, which can improve the problem of chip resource waste in the current routing address storage method.

[0006] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0007] In a first aspect, an embodiment of the present invention provides a method for storing a routing address, which is applied to a network device, wherein the network device includes a multi-level memory, wherein the multi-level memory includes a ternary content addressable memory and a multi-level static random access memory, and the method includes:

[0008] Storing common prefixes of multiple routing addresses in the ternary content addressable memory; wherein the routing addresses include IPv4 addresses and IPv6 addresses;

[0009] Storing the multi-level intermediate prefix of each routing address by using the static random access memory other than the last-level static random access memory in the multi-level static random access memory;

[0010] The suffix information of each routing address is stored in the final static random access memory.

[0011] Furthermore, each of the static random access memories includes a plurality of SRAM entries, each of the RAM entries includes a plurality of storage units of the same length, and the method further includes:

[0012] For a storage unit that has stored an intermediate prefix or a suffix information, the format of the storage unit is determined according to the length of the stored information; wherein the format includes the storage quantity and the storage length.

[0013] Furthermore, the method further comprises:

[0014] Using the longest mask matching algorithm, determine the target common prefix with the highest matching degree with the target routing address from all the stored common prefixes;

[0015] Removing information identical to the target common prefix from the target routing address to obtain a first address;

[0016] Using a longest mask matching algorithm, determine, from all intermediate prefixes of the target common prefix index, a target intermediate prefix having the highest matching degree with the first address;

[0017] Removing information in the first address that is identical to the target intermediate prefix to obtain a first suffix;

[0018] When there is a free storage unit in the SRAM entry of the target intermediate prefix index whose format matches the length of the first suffix, the first suffix is ​​stored in the storage unit.

[0019] Furthermore, the multi-level static random access memory includes a final-level static random access memory and a non-final-level static random access memory, and the method further includes:

[0020] When there is no storage unit whose format matches the length of the first suffix and / or is free in the SRAM entry of the target intermediate prefix index, triggering tree splitting, inserting the first suffix into the suffix tree of the SRAM entry, and splitting the inserted suffix tree into an old suffix tree and a new suffix tree;

[0021] When the first suffix is ​​located in the old suffix tree, storing the first suffix in the SRAM entry of the target intermediate prefix index;

[0022] Using the root node of the new suffix tree as a new intermediate prefix;

[0023] Storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix in the non-final static random access memory, and storing the new suffix tree in an empty SRAM entry in the final static random access memory;

[0024] The new intermediate prefix is ​​the intermediate prefix index of the new suffix tree.

[0025] Furthermore, the step of storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix in the non-final static random access memory comprises:

[0026] From the SRAM entries of the non-final static random access memory storing the target intermediate prefix, a free storage unit having a format matching the length of the new intermediate prefix is ​​determined, and the new intermediate prefix is ​​stored in the storage unit.

[0027] Furthermore, the method further comprises:

[0028] When there is no storage unit whose format matches the length of the new intermediate prefix and / or is idle in the SRAM entry storing the target intermediate prefix, trigger tree splitting, insert the new intermediate prefix into the intermediate prefix tree of the SRAM entry, and split the intermediate prefix tree after the insertion into the old intermediate prefix and the new intermediate prefix tree;

[0029] When the new intermediate prefix is ​​located in the old intermediate prefix tree, storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix;

[0030] Based on the new intermediate prefix tree, a new common prefix is ​​obtained;

[0031] The new common prefix is ​​stored in a free TCAM entry of the ternary content addressable memory, the new intermediate prefix tree is stored in an empty SRAM entry of the non-final static random access memory, and the new suffix tree is stored in an empty SRAM entry of the final static random access memory.

[0032] Furthermore, the method further comprises:

[0033] When no routing address is stored in the multi-level memory, a common prefix and a multi-level intermediate prefix of all routes are set, the common prefix is ​​stored in a common prefix stored in a TCAM entry of the ternary content addressable memory, and the multi-level intermediate prefix is ​​stored in sequence in an SRAM entry of each static random access memory in the multi-level static random access memory except the last level static random access memory.

[0034] In a second aspect, an embodiment of the present invention provides a routing address storage device, which is applied to a network device, wherein the network device includes a multi-level memory, the multi-level memory includes a ternary content addressable memory and a multi-level static random access memory, and the routing address storage device includes a storage module;

[0035] The storage module is used to store the common prefixes of multiple routing addresses in the ternary content addressable memory; wherein the routing addresses include IPv4 addresses and IPv6 addresses;

[0036] The storage module is further used to store the multi-level intermediate prefix of each routing address through the static random access memory except the last-level static random access memory in the multi-level static random access memory;

[0037] The storage module is also used to store the suffix information of each routing address through the final static random access memory.

[0038] In a third aspect, an embodiment of the present invention provides a network device, including a processor and a memory, wherein the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the routing address storage method as described in the first aspect.

[0039] In a fourth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the routing address storage method as described in the first aspect.

[0040] The routing address storage method, device, network device and storage medium provided by the embodiments of the present invention store the common prefix of multiple routing addresses in a ternary content addressable memory, store the multi-level intermediate prefix of each routing address in sequence in a static random access memory other than the last-level static random access memory in the multi-level static random access memory, store the suffix information of each routing address in the last-level static random access memory of the multi-level static random access memory, realize segmented storage of routing addresses, so that each level of memory in the multi-level memory only needs to store a segment of routing address information, and does not need to store all routing address information, which can improve the utilization rate of each level of static random access memory, thereby greatly reducing the waste of SRAM resources.

[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 A block diagram of a routing address storage system provided by an embodiment of the present invention is shown.

[0044] Figure 2 One of the flow charts of the routing address storage method provided by the embodiment of the present invention is shown.

[0045] Figure 3 A schematic diagram of the structure of a static random access memory provided by an embodiment of the present invention is shown.

[0046] Figure 4 One of the structural schematic diagrams of the storage state of the routing address storage method provided by the embodiment of the present invention is shown.

[0047] Figure 5 A structural schematic diagram of the storage state using a traditional routing address storage method is shown.

[0048] Figure 6 The second flowchart of the routing address storage method provided by the embodiment of the present invention is shown.

[0049] Figure 7 The third flowchart of the routing address storage method provided by the embodiment of the present invention is shown.

[0050] Figure 8 One of the schematic diagrams of the tree dismantling process of the routing address storage method provided by the embodiment of the present invention is shown.

[0051] Fig. 9 A schematic diagram of the structure of a new suffix tree provided by an embodiment of the present invention is shown.

[0052] Fig.10 The second schematic diagram of the tree dismantling process of the routing address storage method provided by the embodiment of the present invention is shown.

[0053] Fig.11 A fourth flow chart of the routing address storage method provided in an embodiment of the present invention is shown.

[0054] Fig.12 The second structural schematic diagram shows the storage state of the routing address storage method provided by the embodiment of the present invention.

[0055] Fig.13A block diagram of a routing address storage device provided by an embodiment of the present invention is shown.

[0056] Fig.14 A block diagram of a network device provided by an embodiment of the present invention is shown.

[0057] Reference numerals: 100 - routing address storage system; 110 - first electronic device; 120 - network device; 130 - second electronic device; 140 - routing address storage device; 150 - storage module; 160 - format determination module. DETAILED DESCRIPTION

[0058] The following will be combined with the accompanying 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. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0059] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.

[0060] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0061] In the traditional routing address storage method, the longest mask match (Algorithm LongestPrefix Match, ALPM) is usually used to store the routing address. The complete routing address is stored in the static random-access memory (SRAM) entry of the APLM, and the common prefix of all routing addresses in the same SRAM entry is stored in the ternary content addressable memory (TCAM) entry.

[0062] For example, in the two-level LPM scheme, the storage of an entire route consists of three parts, including TCAM, SRAM1 and SRAM2. The SRAM entries of SRAM2 store the complete route information, the SRAM entries of SRAM1 store the partial prefix information of the route information, and the TCAM entries of TCAM store the prefix information of the route information. The storage units of SRAM1 and SRAM2 are also designed with the complete route length, such as v4-32bits, v6-128bits.

[0063] Furthermore, the format (storage quantity and length) of the storage cells in each SRAM entry is consistent, but in reality there are many routing addresses with inconsistent lengths, resulting in a situation where the storage cells in each SRAM entry have remaining space but cannot store other routing addresses.

[0064] Therefore, the current routing address storage method greatly wastes SRAM resources, that is, causes a waste of chip resources.

[0065] Based on the above considerations, an embodiment of the present invention provides a method for storing a routing address, which can improve the problem of SRAM resource waste in the current method for storing a routing address. The method for storing a routing address is introduced below.

[0066] The routing address storage method provided by the embodiment of the present invention can be applied to Figure 1 In the routing address storage system 100 shown, the routing address storage system 100 includes a first electronic device 110, a network device 120, and a second electronic device 130. The network device 120 can be communicatively connected with the first electronic device 110 and the second electronic device 130 via a network.

[0067] The first electronic device 110 is used to send a message to the network device 120 .

[0068] The network device 120 is used to send the message sent by the first electronic device 110 to the second electronic device 130 .

[0069] The first electronic device 110 and the second electronic device 130 may be, but are not limited to, servers, mobile terminals, personal computers, tablets, laptops, wearable mobile devices, and mobile phones, etc. The network device 120 includes, but is not limited to, switches, routers, mobile terminals, personal computers, tablets, laptops, wearable mobile devices, and mobile phones.

[0070] The network device 120 may include a multi-level memory, and the multi-level memory may include a ternary content addressable memory and a multi-level static random access memory. It should be noted that the multi-level static random access memory includes at least one static random access memory.

[0071] The network device 120 is also used to implement the routing address storage method provided in the embodiment of the present invention.

[0072] In one implementation, the present invention provides a method for storing a routing address. Figure 2 , may include the following steps. In this embodiment, the routing address storage method is applied to Figure 1 Take the network device 120 in FIG. 1 as an example.

[0073] S1, storing the common prefixes of multiple routing addresses in a ternary content addressable memory.

[0074] It should be noted that the routing address here includes but is not limited to: IPv4 address, IPv6 address, IPv7 address and other protocol version addresses.

[0075] S2, storing the multi-level intermediate prefix of each routing address through the static random access memory except the last-level static random access memory in the multi-level static random access memory.

[0076] S3, stores the suffix information of each routing address through the final static random access memory.

[0077] It should be understood that a complete routing address is composed of a common prefix, multi-level intermediate prefixes and suffix information. In the multi-level static random access memory, each static random access memory except the last level static random access memory stores the first level intermediate prefix of the routing address.

[0078] It should be noted that each static random access memory (SRAM) in a multi-level static random access memory may include multiple SRAM entries, each SRAM entry of other static random access memories except the last-level static random access memory stores an intermediate prefix tree composed of multiple intermediate prefixes, each SRAM entry of the last-level static random access memory stores a suffix tree composed of multiple suffix information, and the ternary content addressable memory may include multiple TCAM entries, each TCAM entry stores a node in a common prefix tree (i.e., a common prefix), and the entire ternary content addressable memory stores a common prefix tree (including multiple common prefixes).

[0079] Compared with the traditional routing address storage method, in the above routing address storage method, the common prefix of multiple routing addresses is stored in a ternary content addressable memory, the intermediate prefix of each routing address is stored in a static random access memory other than the last-level static random access memory in the multi-level static random access memory, and the suffix information of each routing address is stored in the last-level static random access memory of the multi-level static random access memory, thereby realizing segmented storage of routing addresses, making it unnecessary for the last-level static random access memory to store all the information of the routing addresses, and being able to improve the utilization rate of each level of static random access memory, thereby being able to greatly reduce the waste of SRAM chip resources.

[0080] In order to further reduce the waste of SRAM resources and improve the utilization of chip resources, in a possible implementation, a variable-length storage area is introduced in each level of the multi-level static random access memory to enable intermediate prefix and suffix information of different lengths to be stored by SRAM entries as much as possible. Figure 3 The SRAM entries of each level of the multi-level static random access memory may include multiple storage units of the same length, each storage unit may include a different number of storage areas, and the length of the storage area of ​​the storage unit is related to the length of the stored information (intermediate prefix or suffix information), that is, the format of the storage unit changes with the length of the stored information.

[0081] Furthermore, the routing address storage method provided by the embodiment of the present invention may also include: for a storage unit that has stored an intermediate prefix or a suffix information, determining the format of the storage unit according to the length of the stored information, wherein the format includes the storage quantity and the storage length.

[0082] For example, the storage space of each storage unit of the last-level static random access memory of a multi-level static random access memory is 128 bits, the length of the first suffix information stored in storage unit one is 8, and the length of the first suffix information stored in storage unit two is 32. Then the format of storage unit one is 16 storage areas with a storage length of 8 bits, and the format of storage unit two is 4 storage areas with a storage length of 32 bits.

[0083] In this embodiment, each storage unit of a format can store routing information within a specific length range. For example, a storage area with a storage length of 8 bits can store routing information of 1-8 bits, a storage area with a storage length of 16 bits can store routing information of 9-16 bits, a storage area with a storage length of 24 bits can store routing information of 17-24 bits, and a storage area with a storage length of 32 bits can store routing information of 25-32 bits.

[0084] Through the above implementation, there is no need to predefine the format of the storage unit of each SRAM entry of the multi-level static random access memory, so that the format of the storage unit changes with the length of the first information stored, and different storage units of the same SRAM entry can store information of different lengths, thereby realizing variable storage length of the SRAM entry, thereby being able to store as much routing information of different lengths as possible and reducing the waste of SRAM resources.

[0085] In a possible implementation, based on the format of the SRAM entry of the static random access memory, the complete routing address is divided into a plurality of continuous but non-overlapping routing address segments (including common prefix, intermediate prefix and suffix information) according to the longest mask matching algorithm, and the plurality of routing address segments are respectively stored in the ternary content addressable memory and the multi-level static random access memory of the multi-level memory, so as to finally achieve the effect of the above steps S1-S3. The plurality of routing address segments together constitute the complete routing address, and each level of memory (i.e., the ternary content addressable memory and the multi-level static random access memory) only stores the routing information of the corresponding segment length.

[0086] Assume that there are 6 routes as shown in Table 1.

[0087] Table 1

[0088] ID IP Mask 1 1.1.1.0 24 2 1.3.3.0 24 3 1.5.5.0 24 4 1.6.6.0 24 5 1.7.0.0 16 6 1.8.0.0 16

[0089] The storage states of the six routes in Table 1 in the multi-level memory (including a ternary content addressable memory TCAM and a static random access memory SRAM) composed of a first-level static random access memory are as follows: Figure 4 shown.

[0090] The common prefix of the 6 routes is 000000010000b / 12, among which the length of the first 4 routes after removing the common prefix (the length of the suffix) is the same, which is 12. The sum of the lengths of the prefix and suffix is ​​24, which is exactly the length of the routing mask, that is, the complete routing information. The suffix lengths of the last 2 routes are the same, which is 4. The sum of the lengths of the prefix and suffix is ​​16, which is exactly the length of the routing mask, that is, the complete routing information. The two suffix lengths occupy two different formats of storage units of the SRAM entry, namely, a storage unit with a storage length of 8 bits (storage range of 1-8 bits) and a storage unit with a storage length of 16 bits (storage range of 9-16 bits). The left shift length Shift obtained from the TCAM entry of the ternary content addressable memory is 12, indicating that the length of the common prefix is ​​12.

[0091] Reference Figure 5 , which is a schematic diagram of the storage state stored using the traditional routing address storage method.

[0092] Compared with the existing routing address storage scheme in which each level stores complete routing information, the routing address storage method provided by the embodiment of the present invention can greatly save chip resources.

[0093] In one possible implementation, refer to Figure 6 The routing address storage method provided by the embodiment of the present invention can be further implemented as the following steps.

[0094] S101, using the longest mask matching algorithm, to determine the target common prefix with the highest matching degree with the target routing address from all stored common prefixes.

[0095] S102, removing information identical to the target common prefix in the target routing address to obtain a first address.

[0096] S103: Using the longest mask matching algorithm, determine the target intermediate prefix with the highest matching degree with the first address from all intermediate prefixes of the target common prefix index.

[0097] S104, removing information in the first address that is identical to the target middle prefix, to obtain a first suffix.

[0098] S105 , when there is a free storage unit in the SRAM entry of the target intermediate prefix index whose format matches the length of the first suffix, store the first suffix in the storage unit.

[0099] Taking the multi-level static random access memory as an example, the TCAM entry in the ternary content addressable memory in the multi-level memory stores the common prefix of the routing address, and the SRAM entry in the static random access memory stores the routing information (suffix information) excluding the common prefix. At this time, there is no intermediate prefix, and the common prefix directly indexes the suffix information.

[0100] Therefore, after the network device 120 obtains the target routing address, the longest mask matching algorithm is used to match the target routing address information with all the common prefixes stored in all TCAM entries in the ternary content addressable memory. After matching the common prefix with the highest matching degree (assuming that the common prefix is ​​a shift bit), the target routing address is shifted left by the shift bit, that is, the information identical to the target common prefix is ​​removed to obtain the suffix information. When there is a storage unit whose format matches the length of the suffix information and is idle in the SRAM entry indexed by the target common prefix (SRAM entry of the static random access memory), the suffix information is stored in the storage unit.

[0101] Taking a multi-level static random access memory with two levels as an example, including a non-final static random access memory and a final static random access memory, the TCAM entry in the ternary content addressable memory in the multi-level memory stores the common prefix of the routing address, the SRAM entry in the non-final static random access memory stores the intermediate prefix, and the SRAM entry in the final static random access memory stores the routing information (suffix information) excluding the common prefix and the intermediate prefix. At this time, there is only one intermediate prefix, the common prefix indexes the intermediate prefix, and the intermediate prefix indexes the suffix information.

[0102] Therefore, after the network device 120 obtains the target routing address, the longest mask matching algorithm is used to match the target routing address information with all the common prefixes stored in all TCAM entries in the ternary content addressable memory. After matching the common prefix with the highest matching degree (assuming that the common prefix is ​​shift1 bit), the target routing address is shifted left by shift1 bit, that is, the information identical to the target common prefix is ​​removed to obtain the first address. Thus, the first address is matched with all the intermediate prefixes stored in all SRAM entries in the non-final static random access memory. After matching the target intermediate front and back with the highest matching degree (assuming that the common prefix is ​​shift2 bit), the first address is shifted left by shift2 bits, that is, the information identical to the target intermediate prefix is ​​removed to obtain the first suffix.

[0103] When there is a free storage unit whose format matches the length of the first suffix in the SRAM entry of the target intermediate prefix index (the SRAM entry of the final static random access memory), the first suffix is ​​stored in the storage unit. In this embodiment, the length matches and is free means: (i) the storage unit is not empty, but at least one suffix information whose length matches the format of the storage unit can be stored; (ii) the storage unit is empty. When the first suffix is ​​stored in the storage unit that is empty, the format of the storage unit is set to be suitable for the format of the first suffix.

[0104] Considering that when the network device 120 is just shipped, no routing address is stored in the multi-level memory of the network device 120. In order to store the routing address using the routing address storage method provided by the embodiment of the present invention, an initial setting step is introduced. In a possible implementation, the routing address storage method provided by the embodiment of the present invention may also include step S100, which may be performed before step S101 and only needs to be performed initially.

[0105] S100, when no routing address is stored in the multi-level memory, set the common prefix and the multi-level intermediate prefix of all routes, store the common prefix in a TCAM entry of the ternary content addressable memory, and store the multi-level intermediate prefix in sequence in an SRAM entry of each static random access memory in the multi-level static random access memory except the last level static random access memory.

[0106] It should be understood that each level of intermediate prefix is ​​stored in a static random access memory of a corresponding level, for example, the second level intermediate prefix is ​​stored in a second level static random access memory.

[0107] In order to store as many routing addresses as possible and improve the utilization of storage chip resources, in a possible implementation mode, during initial setting, the common prefix and all intermediate prefixes may be set to 0, that is, / 0.

[0108] According to the order of the static random access memory, the static random access memory in the multi-level static random access memory can be divided into the final static random access memory and the non-final static random access memory. Considering that each SRAM entry of the static random access memory has a storage upper limit, in order to quickly store the routing address and avoid repeated storage, tree splitting is introduced in the storage process. In a possible implementation, refer to Figure 7 The routing address storage method provided by the embodiment of the present invention may further include the following steps: Step S106 may be performed after step S104.

[0109] S106, when there is no storage unit whose format matches the length of the first suffix and / or is free in the SRAM entry of the target intermediate prefix index, the tree is triggered to remove the tree, insert the first suffix into the suffix tree of the SRAM entry, and replace the inserted suffix tree with the old suffix tree and the new suffix tree.

[0110] It should be noted that all the intermediate prefixes stored in each SRAM entry of the multi-level static random constitute an intermediate prefix tree. After the tree is removed, the SRAM entry of the target intermediate prefix index must be able to store all nodes (suffixes) in the old suffix tree. The first suffix may be in the old suffix tree or in the new suffix tree. If the first suffix is ​​in the old suffix tree, the first suffix is ​​stored in the SRAM entry of the target intermediate prefix index. The tree removal is based on the tree removal algorithm. In a possible implementation, when the tree is removed, the suffix tree can be split into the old suffix tree and the new suffix tree in half as much as possible.

[0111] S107, taking the root node of the new suffix tree as a new intermediate prefix.

[0112] S108, storing the new intermediate prefix in an SRAM entry storing the target intermediate prefix in the non-final-level static random access memory, and storing the new suffix tree in an empty SRAM entry in the final-level static random access memory.

[0113] It should be understood that the new intermediate prefix is ​​the intermediate prefix index of the new suffix tree, and the root node of the new suffix tree is the new intermediate prefix. The root node of the new suffix tree is the new intermediate prefix. And after the tree is dismantled, the suffix information that does not exist in the old suffix tree in the SRAM entry of the target intermediate prefix index will be deleted.

[0114] In a possible implementation, the step of storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix in the non-final static random access memory in S108 can be further implemented as follows: from the SRAM entry storing the target intermediate prefix in the non-final static random access memory, a storage unit whose format matches the length of the new intermediate prefix and is free is determined, and the new intermediate prefix is ​​stored in the storage unit. In this implementation, length matching and free means: (i) the storage unit is not empty, but at least one intermediate prefix whose length matches the format of the storage unit can be stored; (ii) the storage unit is empty. When the new intermediate prefix is ​​stored in the storage unit that is empty, the format of the storage unit is set to be suitable for the format of the new intermediate prefix.

[0115] Take the multi-level static random access memory as two levels, namely SRAM L0 and SRAM L1, as an example, see Figure 8, the figure shows the storage conditions in the current ternary content addressable memory, non-final static random access memory (SRAM L0) and final static random access memory (SRAML1). The TCAM entry of the ternary content addressable memory stores the " / 0" common prefix, the SRAM entry of SRAM L0 stores the intermediate prefix " / 0", and the SRAM entry of SRAM L1 stores the suffix tree (composed of the suffixes " / 0, / 8, / 12 and / 24").

[0116] When the target routing address is "1.1.1.1 / 32", the first suffix obtained by matching is "1.1.1.1 / 32". The suffix tree formed by the first suffix and the original suffix tree in SRAM L1 is Fig. 9 , assuming that there is no free 32-bit storage unit in the SRAM entry of SRAM L1, triggering tree removal. The storage status after tree removal is as follows Fig.10 As shown, when the tree is torn down, it is torn down into the old suffix tree (the suffix tree without the "1.1.1.1 / 32" node) and the new suffix tree (the suffix tree with the "1.1.1.1 / 32" node), the new suffix tree is stored in an empty SRAM entry of SRAM L1, and the root node " / 12" of the new suffix tree is stored as a child node of the intermediate prefix tree stored in the SRAM entry of SRAM L0, generating a new intermediate prefix. At the same time, the suffix information that does not exist in the old suffix tree is deleted in the SRAM entry storing the original suffix tree.

[0117] In the above example, since the first suffix exists in the new suffix tree, it is only necessary to store the new suffix tree and delete the suffix information that does not exist in the old suffix tree in the SRAM entry storing the original suffix tree.

[0118] Similarly, when the SRAM of the next-level static random access memory cannot store data and the previous-level static random access memory is not the first-level static random access memory, the tree removal principle is exactly the same as the tree removal principle of S106-S108 above, and will not be repeated in this embodiment.

[0119] Taking into account the storage limit of the SRAM entries of the first-level static random access memory during the tree removal process, and the situation that the new intermediate prefix cannot be stored, and then when the tree needs to be removed, in order to avoid affecting and damaging the stored routing addresses, in this embodiment, a TCAM entry of the ternary content addressable memory is set to store only one common prefix. At this time, only when the TCAM entry is empty, it is an idle TCAM entry. Based on this setting, the routing address storage method provided in the embodiment of the present invention can also include the following steps. Refer to Fig.11 , step S109 is executed after step S107.

[0120] S109, when there is no storage unit whose format matches the length of the new intermediate prefix and / or is free in the SRAM entry storing the target intermediate prefix, the tree splitting is triggered, the new intermediate prefix is ​​inserted into the intermediate prefix tree of the SRAM entry, and the intermediate prefix tree after the insertion is split into the old intermediate prefix tree and the new intermediate prefix tree.

[0121] It should be understood that, in the present embodiment, the target intermediate prefix refers to the intermediate prefix stored in the SRAM entries of the first-level static random access memory. The SRAM entries storing the target intermediate prefix index must be able to store all nodes (intermediate prefixes) in the old intermediate prefix tree. The new intermediate prefix may be in the old intermediate prefix tree, or it may be in the new intermediate prefix tree. If the new intermediate prefix is ​​in the old intermediate prefix tree, the new intermediate prefix is ​​stored in the SRAM entries storing the target intermediate prefix. Tree removal is based on a tree removal algorithm. In a possible implementation, when removing the tree, the intermediate prefix tree can be split into the old intermediate prefix tree and the new intermediate prefix tree in half as far as possible.

[0122] S110, obtaining a new common prefix based on the new intermediate prefix tree.

[0123] S111, store the new common prefix in an idle TCAM entry of the ternary content addressable memory, store the new intermediate prefix tree in an empty SRAM entry of the non-final static random access memory, and store the new suffix tree in an empty SRAM entry of the final static random access memory.

[0124] The root node of the new intermediate prefix tree is the new common prefix. After the tree is dismantled, the intermediate prefixes that do not exist in the old intermediate prefix tree will be deleted from all the intermediate prefixes stored in the SRAM entry storing the target intermediate prefix.

[0125] Since tree removal starts from the suffix tree stored in the last level of static random access memory, tree removal in the previous level must be caused by tree removal in the next level. Therefore, when tree removal is to be performed in the first level static random access memory, all static random access memories except the first level static random access memory in the multi-level static random access memory also remove the tree.

[0126] The tree removal principle in the process of S109 and S110 is consistent with the tree removal principle between static random access memories, and will not be repeated in this embodiment. Different from the tree removal between static random access memories, after obtaining the new common prefix and the new intermediate prefix tree, the new common prefix (essentially also a single-branch common prefix tree) is stored in the idle TCAM entry of the ternary content addressable memory, the new intermediate prefix tree is stored in an empty SRAM entry of the non-final static random access memory, and the new suffix tree is stored in an empty SRAM entry of the final static random access memory, so as to obtain a multi-level SRAM entry indexed by the new TCAM entry (the TCAM entry storing the new common prefix).

[0127] Reference Fig.12 , which is a possible storage state after storage using the routing address storage method provided by an embodiment of the present invention.

[0128] Through the above steps S100-S111, the storage of routing addresses is realized based on a multi-level static random access memory with storage units of different formats, and under the premise of ensuring the integrity of the routing addresses, TCAM and multi-level SRAM respectively save partial, continuous and non-overlapping routing information, thereby maximizing the utilization of SRAM and further improving the routing specifications.

[0129] In the routing address storage method provided by the embodiment of the present invention, by designing each SRAM entry of each level of static random access memory in the multi-level static random access memory as an SRAM storage unit of variable length and different formats, that is, different storage units can store routing information of different lengths, and dividing the routing information into multiple segments, continuous and non-repetitive content is stored separately, the utilization rate of SRAM is greatly improved, thereby improving the routing specifications.

[0130] Based on the concept of the routing address storage method provided in the above embodiment of the present invention, the embodiment of the present invention provides a routing address storage device 140, which can be applied to Figure 1 The network device 120 in FIG. Fig.13 , the routing address storage device 140 may include a storage module 150.

[0131] The storage module 150 is used to store the common prefixes of multiple routing addresses in the ternary content addressable memory, wherein the routing addresses include but are not limited to: IPv4 addresses and IPv6 addresses.

[0132] The storage module 150 is also used to store the multi-level intermediate prefix of each routing address through the static random access memory except the last-level static random access memory in the multi-level static random access memory.

[0133] The storage module 150 is also used to store the suffix information of each routing address through the final static random access memory.

[0134] Furthermore, the routing address storage device 140 may also include a format determination module 160 .

[0135] The format determination module 160 is used to determine the format of a storage unit storing an intermediate prefix or a suffix information according to the length of the stored information, wherein the format includes the storage quantity and the storage length.

[0136] The storage module 150 is also used to: use the longest mask matching algorithm to determine the target common prefix with the highest matching degree with the target routing address from all stored common prefixes; remove the information in the target routing address that is identical to the target common prefix to obtain the first address; use the longest mask matching algorithm to determine the target intermediate prefix with the highest matching degree with the first address from all intermediate prefixes indexed by the target common prefix; remove the information in the first address that is identical to the target intermediate prefix to obtain the first suffix; and when there is a free storage unit in the SRAM entry of the target intermediate prefix index whose format matches the length of the first suffix, store the first suffix in the storage unit.

[0137] In the above-mentioned routing address storage device 140, the segmented storage of the routing address is realized through the function of the storage module 150, so that the final level static random access memory does not need to store all the information of the routing address, which can improve the utilization rate of each level of static random access memory, thereby greatly reducing the waste of SRAM resources.

[0138] Furthermore, the storage length of the SRAM strip of each static random access memory of the multi-level static random access memory can be varied, and there is no need to predefine the format of the storage unit of each SRAM entry of the multi-level static random access memory. The format of the storage unit is determined by the length of the first information stored, and different storage units of the same SRAM entry can store information of different lengths, thereby achieving variable storage length of the SRAM entry, thereby being able to store as much information of different lengths as possible, further improving the utilization rate of chip resources, and reducing the waste of SRAM resources.

[0139] For the specific definition of the routing address storage device 140, please refer to the definition of the routing address storage method above, which will not be repeated here. Each module in the above-mentioned routing address storage device 140 can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0140] In one embodiment, a network device 120 is provided. The network device 120 may be a terminal, and its internal structure diagram may be as follows: Fig.14 As shown. The network device 120 includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. Among them, the processor of the network device 120 is used to provide computing and control capabilities. The memory of the network device 120 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 computer programs in the non-volatile storage medium. The communication interface of the network device 120 is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, an operator network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, the routing address storage method provided in the above embodiment is implemented.

[0141] 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 invention, and does not constitute a limitation on the network device 120 to which the solution of the present invention is applied. The specific network device 120 may include Fig.14 More or fewer components may be shown, or certain components may be combined, or may have a different arrangement of components.

[0142] In one embodiment, the routing address storage device 140 provided by the present invention can be implemented in the form of a computer program. The computer program can be used in Fig.14 The network device 120 shown in FIG. 1 is executed on the network device 120. The memory of the network device 120 may store various program modules constituting the routing address storage device 140, for example, Fig.13 The first storage module 150, the second storage module 150, the third storage module 150, the format determination module 160 and the processing module are shown. The computer program composed of each program module enables the processor to execute the steps in the routing address storage method described in this specification.

[0143] For example, Fig.14 The network device 120 shown can be Fig.13 The storage module 150 in the routing address storage device 140 shown in the figure performs step S1, step S2 and step S3. The network device 120 can perform step S100 through the format determination module 160. The network device 120 can also perform steps S101-S111 through the processing module.

[0144] In one embodiment, a network device 120 is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented: storing a common prefix of multiple routing addresses in a ternary content addressable memory; storing a multi-level intermediate prefix of each routing address through a static random access memory other than a last-level static random access memory in a multi-level static random access memory; and storing suffix information of each routing address through the last-level static random access memory.

[0145] In one embodiment, a storage medium is provided on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: storing multi-level intermediate prefixes of each routing address through a static random access memory other than a last-level static random access memory in a multi-level static random access memory; and storing suffix information of each routing address through the last-level static random access memory.

[0146] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0147] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0148] If the functions are implemented in the form of software function modules 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.

[0149] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for storing a routing address, characterized in that: Applied to a network device, the network device includes a multi-level memory, the multi-level memory includes a ternary content addressable memory and a multi-level static random access memory, the method includes: Storing common prefixes of multiple routing addresses in the ternary content addressable memory; wherein the routing addresses include IPv4 addresses and IPv6 addresses; Storing the multi-level intermediate prefix of each routing address by using a static random access memory other than the last-level static random access memory in the multi-level static random access memory; Storing the suffix information of each routing address through the final static random access memory; Each of the static random access memories includes a plurality of SRAM entries, each of the SRAM entries includes a plurality of storage cells of the same length, and the method further includes: For a storage unit that has stored an intermediate prefix or a suffix information, determining the format of the storage unit according to the length of the stored information; wherein the format includes the storage quantity and the storage length; The method further comprises: Using the longest mask matching algorithm, determine the target common prefix with the highest matching degree with the target routing address from all the stored common prefixes; Removing information identical to the target common prefix from the target routing address to obtain a first address; Using a longest mask matching algorithm, determine, from all intermediate prefixes of the target common prefix index, a target intermediate prefix having the highest matching degree with the first address; Removing information in the first address that is identical to the target intermediate prefix to obtain a first suffix; When there is a free storage unit in the SRAM entry of the target intermediate prefix index whose format matches the length of the first suffix, the first suffix is ​​stored in the storage unit.

2. The method for storing routing addresses according to claim 1, characterized in that: The multi-level static random access memory includes a final-level static random access memory and a non-final-level static random access memory, and the method further includes: When there is no storage unit whose format matches the length of the first suffix and / or is free in the SRAM entry of the target intermediate prefix index, triggering tree splitting, inserting the first suffix into the suffix tree of the SRAM entry, and splitting the inserted suffix tree into an old suffix tree and a new suffix tree; When the first suffix is ​​located in the old suffix tree, storing the first suffix in the SRAM entry of the target intermediate prefix index; The root node of the new suffix tree is used as the new intermediate prefix; Storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix in the non-final static random access memory, and storing the new suffix tree in an empty SRAM entry in the final static random access memory; The new intermediate prefix is ​​the intermediate prefix index of the new suffix tree.

3. The method for storing routing addresses according to claim 2, characterized in that: The step of storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix in the non-final static random access memory comprises: From the SRAM entries of the non-final static random access memory storing the target intermediate prefix, a free storage unit having a format matching the length of the new intermediate prefix is ​​determined, and the new intermediate prefix is ​​stored in the storage unit.

4. The method for storing routing addresses according to claim 2, characterized in that: The method further comprises: When there is no storage unit whose format matches the length of the new intermediate prefix and / or is idle in the SRAM entry storing the target intermediate prefix, trigger tree splitting, insert the new intermediate prefix into the intermediate prefix tree of the SRAM entry, and split the intermediate prefix tree after the insertion into an old intermediate prefix tree and a new intermediate prefix tree; When the new intermediate prefix is ​​located in the old intermediate prefix tree, storing the new intermediate prefix in the SRAM entry storing the target intermediate prefix; Based on the new intermediate prefix tree, a new common prefix is ​​obtained; The new common prefix is ​​stored in a free TCAM entry of the ternary content addressable memory, the new intermediate prefix tree is stored in an empty SRAM entry of the non-final static random access memory, and the new suffix tree is stored in an empty SRAM entry of the final static random access memory.

5. The method for storing routing addresses according to claim 1, characterized in that: The method further comprises: When no routing address is stored in the multi-level memory, a common prefix and a multi-level intermediate prefix of all routes are set, the common prefix is ​​stored in a TCAM entry of the ternary content addressable memory, and the multi-level intermediate prefix is ​​stored in sequence in an SRAM entry of each static random access memory in the multi-level static random access memory except the last-level static random access memory.

6. A routing address storage device, characterized in that: Applied to a network device, the network device comprises a multi-level memory, the multi-level memory comprises a ternary content addressable memory and a multi-level static random access memory, and the routing address storage device comprises a storage module and a format determination module; The storage module is used to store the common prefixes of multiple routing addresses in the ternary content addressable memory; wherein the routing addresses include IPv4 addresses and IPv6 addresses; The storage module is further used to store the multi-level intermediate prefix of each routing address through the static random access memory except the last-level static random access memory in the multi-level static random access memory; The storage module is further used to store the suffix information of each routing address through the final static random access memory; Each of the static random access memories comprises a plurality of SRAM entries, and each of the RAM entries comprises a plurality of storage cells of the same length; The format determination module is used to determine the format of the storage unit according to the length of the stored information for the storage unit that has stored an intermediate prefix or a suffix information; wherein the format includes the storage quantity and the storage length; The storage module is also used to: use the longest mask matching algorithm to determine the target common prefix with the highest matching degree with the target routing address from all the stored common prefixes; remove the information in the target routing address that is identical to the target common prefix to obtain a first address; use the longest mask matching algorithm to determine the target intermediate prefix with the highest matching degree with the first address from all the intermediate prefixes indexed by the target common prefix; remove the information in the first address that is identical to the target intermediate prefix to obtain a first suffix; and when there is a free storage unit in the SRAM entry of the target intermediate prefix index whose format matches the length of the first suffix, store the first suffix in the storage unit.

7. A network device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the routing address storage method according to any one of claims 1 to 5.

8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the routing address storage method according to any one of claims 1 to 5 is implemented.