WO2013078644A1 - Route prefix storage method and device and route address searching method and device - Google Patents

Route prefix storage method and device and route address searching method and device Download PDF

Info

Publication number
WO2013078644A1
WO2013078644A1 PCT/CN2011/083242 CN2011083242W WO2013078644A1 WO 2013078644 A1 WO2013078644 A1 WO 2013078644A1 CN 2011083242 W CN2011083242 W CN 2011083242W WO 2013078644 A1 WO2013078644 A1 WO 2013078644A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
small tree
tree
address
storage space
Prior art date
Application number
PCT/CN2011/083242
Other languages
French (fr)
Chinese (zh)
Inventor
胡睿
郑远明
翟素平
王小忠
龚钧
陈洪飞
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2011/083242 priority Critical patent/WO2013078644A1/en
Priority to CN201180002985.6A priority patent/CN103404092B/en
Publication of WO2013078644A1 publication Critical patent/WO2013078644A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/48Routing tree calculation
    • H04L45/484Routing tree calculation using multiple routing trees

Definitions

  • the present invention relates to a network communication technology, and in particular, to a route prefix storage method, a device, and a route address searching method and apparatus. Background technique
  • CIDR Classless Inter-Domain Routing
  • the CIDR avoids the excessive exhaustion of the network address and the rapid expansion of the routing entries of the backbone routers, but at the same time, the length of the network address prefix can be any value, and the longest prefix match search must be performed when performing route lookup.
  • routing table lookup algorithms are weighed in the following three aspects: 1, the routing table query speed, which is mainly determined by the number of accesses to the memory; 2, the memory capacity required by the routing table; 3, insert or delete The difficulty of routing entries.
  • the most promising method in the prior art is to classify the data structure storing the route prefix, the vertices of the small tree (referred to as lifting nodes) are placed in the big tree, and the small tree adopts the path compression tree structure.
  • the path compression tree all route prefixes are stored at its leaf nodes.
  • N route prefixes with N leaf nodes and N-1 internal nodes.
  • the path compression tree allows each internal node to contain a "bit position" field, which is used to indicate the bit position corresponding to the branch node below the node, that is, the number of consecutively skipped bits and the value of the skipped bit.
  • the path compression tree compresses the redundant branch chain to a node.
  • the maximum height of the small tree is limited to a fixed value h, and the value of h is related to the specific hardware environment.
  • the small tree is split, and the split small tree vertex is placed in the large tree.
  • Delete In addition to the entry process, the small trees can be merged according to the merged height not greater than h.
  • the specific implementation method of the big tree is not limited, for example: Range Match, B-tree, TCAM, etc., which method can be used depending on the specific hardware implementation. This method has certain advantages in query speed, storage capacity, and update of routing entries. Therefore, it is a promising route storage and lookup scheme.
  • the present invention provides a route prefix storage method, apparatus, and routing address search method and apparatus for improving the routing capacity of a sparse tree.
  • An aspect of the present invention provides a method for storing a route prefix, including:
  • Locating location domain information for each node of each small tree the location domain information including a path length and a path of a parent node of the node to the node, a route identifier identifying whether the node has a next hop address, and Identifying whether the node has a child node identifier of the child node;
  • the location domain information of each node of each small tree and each small tree are sequentially pointed to the first address of the address storage space of all the next hop addresses corresponding to the routing prefix continuously.
  • the pointer is stored in the small tree storage space corresponding to each small tree.
  • An aspect of the present invention provides a route prefix storage device, including:
  • a small tree partitioning module configured to establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, where each small tree includes multiple nodes ;
  • An information setting module configured to set location domain information for each node of each small tree, where the location domain information includes a path length and a path of a parent node of the node to the node, and whether the node has a next a route identifier of the hop address and a child node identifier that identifies whether the node has a child node;
  • a storage module configured to sequentially follow the order of the number of layers of the small trees, and sequentially all the sections of each small tree
  • the location domain information of the point and the pointer of each small tree to the first address of the address storage space of all the next hop addresses corresponding to the route prefix are stored in the small tree storage space corresponding to each small tree.
  • Another aspect of the present invention provides a routing address searching method, including:
  • the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node;
  • the pointer to the first address of the address storage space contiguously storing the next hop address and the longest matching node matched to the node storing the next hop address in the small tree storage space of the matching longest matching node are stored.
  • the location of the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
  • Another aspect of the present invention provides a routing address searching apparatus, including:
  • a search module configured to start, according to the layer sequence of the small tree, the first node of the first layer of the small tree, and the route to be searched according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree
  • the prefix field performs a matching search
  • the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a flag indicating whether the node has a child node.
  • Child node identifier Child node identifier
  • An obtaining module configured to match, to the longest prefix node, the pointer and the matching of the first address of the address storage space that continuously stores the next hop address in the small tree storage space of the longest prefix node that is matched to the storage The location of the longest prefix node to which the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
  • a method and a device for storing a route prefix provided by an aspect of the present invention, by storing a route identifier that identifies whether a node has a next hop address, and not storing the next hop address of the node directly, the occupied storage space is significantly reduced, which is beneficial to Increase the number of nodes stored in the small tree storage space, increase the number of routing prefixes corresponding to the small trees, and thus improve the routing capacity of the entire large tree, especially for some sparse large trees, The routing capacity of the tree is more effective.
  • the routing address searching method and device provided by another aspect of the present invention cooperate with the routing prefix storage method and apparatus provided by the embodiment of the present invention, according to the layer sequence of the small tree, according to the small tree of each layer
  • the location domain information of each node in the corresponding small tree storage space is searched for the route prefix to be searched, because the next hop address corresponding to the node is not stored in each small tree storage space, but the storage node has the next hop address.
  • the route identifier increases the number of nodes stored in each small tree storage space, so that one search can find more bits, which improves the search speed and efficiency.
  • 1A is a flowchart of a method for storing a route prefix according to an embodiment of the present invention
  • FIG. 1B is a schematic structural diagram of a path compression tree established by a route prefix and a divided small tree according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for storing a route prefix according to another embodiment of the present invention.
  • FIG. 3 is a flowchart of a routing address searching method according to an embodiment of the present invention.
  • FIG. 4A is a schematic structural diagram of a route prefix storage device according to an embodiment of the present invention
  • FIG. 4B is a schematic structural diagram of a route prefix storage device according to another embodiment of the present invention
  • FIG. 5 is a schematic diagram of routing address search according to an embodiment of the present invention
  • Schematic diagram of the structure of the device Schematic diagram of the structure of the device. detailed description
  • FIG. 1 is a flowchart of a method for storing a route prefix according to an embodiment of the present invention. As shown in FIG. 1A, the storage method of this embodiment includes:
  • Step 101 Establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, and each small tree includes multiple nodes.
  • the path is first established according to the route prefix.
  • Path Compressed Trie that is, according to whether each bit in the route prefix is 0 or 1, the path branches to form a path compression tree.
  • the established path compression tree is a big tree.
  • the size of the fixed storage space on the hardware device for example, 128 bits is a fixed storage space
  • the established path compression tree is divided into one or more small trees.
  • the information about each small tree is stored in a fixed size storage space.
  • a storage space of a fixed size is referred to as a small tree storage space, which means that each small tree storage space corresponds to a small tree.
  • a path compression tree is established according to the route prefixes, and the established path compression tree is divided into three small trees, and the division result is shown in FIG. 1B.
  • the three small trees are small tree 1, small tree 2 and small tree 3.
  • Each small tree consists of multiple nodes.
  • the top nodes of the small tree 2 and the small tree 3 are child nodes of a certain node in the small tree 1.
  • the divided small trees can be layered, and the parent nodes of the top nodes are from the small trees of the small trees in the same layer as one layer. Taking FIG.
  • the small tree 1 is the first layer, and the parent nodes of the top nodes of the small tree 2 and the small tree 3 are all from the small tree 1, so the small tree 2 and the small tree 3 are the second layer.
  • the route prefix included in Figure 1B is shown in Table 1.
  • Step 102 Set location domain information for each node of each small tree, where the location domain information includes a path length and a path of the parent node of the node to the node, and a route identifier that identifies whether the node has a next hop address. Identifies whether the node has a child node ID of the child node.
  • the location domain information of each node includes: the path length and path, the identifier of the parent node of the node to the node Whether the node has a route identifier of the next hop address and a child node identifier that identifies whether the node has a child node.
  • Each node corresponds to a route prefix.
  • the route prefix may have a next hop address or a next hop address. Therefore, in this embodiment, the route identifier is used to indicate whether the node has a next hop address.
  • the route identifier can be encoded by using 1 bit. If the route prefix corresponding to the node has a next hop address, the route identifier is represented by 1 (or the route identifier is 1); if the route prefix corresponding to the node If there is no next hop address, the route ID is represented by 0 (or the route ID is 0). For another example, the route identifier may be encoded by using 1 bit.
  • the route identifier is represented by 0 (or the route identifier takes a value of 0); if the route corresponding to the node If the prefix does not have a next hop address, the route ID is represented by 1 (or the route ID is 1).
  • the route identifier is encoded by using 2 bits.
  • the route identifier is represented by 01 (or the route identifier is 01); if the route prefix corresponding to the node is not One-hop address, the route identifier is represented by 00 (or the route identifier takes the value 00).
  • the use of "01" and "00" for route IDs is just an example and can be other values.
  • the black node represents the node with the next hop address, and the hollow node represents the node without the next hop address.
  • this embodiment does not directly store the next hop address corresponding to each node, but stores a route identifier.
  • the routing identifier of this embodiment is generally smaller than the next hop address, so the storage space occupied by the small hop is relatively small, which increases the number of small trees that can be stored in the small tree storage space, thereby improving the storage capacity of the entire large tree.
  • each node has a maximum of 2 child nodes, which are respectively recorded as the left child node and the right child node.
  • a node may have only a left child node, or only a right child node, or any child node, or both a left child node and a right child node.
  • the child node identifier is used to identify the case where the node has child nodes.
  • the child node identification can be encoded using 2 bits.
  • One way to encode the child node identifier using 2 bits is: If the node has no child nodes, the child node identifier is represented by 00; if the node has only one left child node, the child node identifier is represented by 10; if the node has only one right Child node, child node ID is 01; if node is There are left child nodes and right child nodes, and the child node identifier is represented by 11.
  • Another way to encode the child node identifier using 2 bits is: If the node has no child nodes, the child node identifier is represented by 11; if the node has only one left child node, the child node identifier is represented by 10; if the node has only one node The right child node, the child node identifier uses 01; if the node has both the left child node and the right child node, the child node identifier is represented by 00.
  • This embodiment uses the child node identifier to identify the child node of a node, and does not use the pointer pointer to identify it as in the prior art.
  • the storage child node identifier has the advantage of being simple and easy to implement compared with the pointer.
  • the path length and path of the node's parent node to that node can be directly represented by its actual value.
  • Step 103 sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of each node of each small tree and each small tree point to the address storage space of all next hop addresses corresponding to the route prefix continuously.
  • the pointer of the address is stored in the small tree storage space corresponding to each small tree.
  • the information about each tree is sequentially stored in each tree.
  • the small tree corresponds to the small tree storage space.
  • the information about each small tree mainly includes: location domain information of all the nodes in the small tree and the address storage space of the next hop address corresponding to the route prefix to be stored in the tree. Pointer to the address. That is, for a small tree, the location information of all the nodes in the small tree and the small tree point to the first address of the address storage space of all the next hop addresses corresponding to the route prefix to be stored continuously.
  • the pointers are stored in the small tree storage space corresponding to the small tree.
  • the location domain information of each node is used to perform lookup matching with the route prefix when performing route prefix lookup.
  • the pointer to the first address of the address storage space is used to find the node with the longest prefix matching in the route prefix searching process, and obtain the next node of the node with the longest prefix matching. Jump address.
  • the occupied storage space is significantly reduced, which is beneficial to improving storage of the small tree storage space.
  • the number of nodes increases the number of route prefixes corresponding to the small tree, thereby increasing the routing capacity of the entire tree.
  • this embodiment improves the routing capacity of the entire tree by increasing the number of routing prefixes corresponding to each small tree.
  • FIG. 2 is a flowchart of a method for storing a route prefix according to another embodiment of the present invention. As shown in FIG. 2, the storage method of this embodiment includes:
  • Step 201 Establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, and each small tree includes multiple nodes.
  • the execution body of this embodiment may be a route prefix storage device such as a router or a switch. To simplify the description, the route prefix storage will be omitted later.
  • This step 201 can be referred to the description of step 101.
  • Step 202 Determine whether the number of layers of the divided small tree is less than or equal to a preset layer threshold; if the determination result is yes, go to step 203; if the judgment result is no, go to step 206.
  • the path compression tree when the number of layers of the small tree divided by the path compression tree is greater than a certain value, it indicates that the path compression tree is dense; if the number of layers of the small tree divided by the path compression tree is less than or equal to the value, the path compression tree is indicated. More sparse.
  • This embodiment defines this value as the layer number threshold.
  • the size of the layer threshold depends on the storage capacity of the route prefix storage device. For example, for a route prefix storage device with a small tree storage space of 128 bits, the corresponding layer threshold is generally 3 layers.
  • This embodiment mainly solves the problem that the path compression tree is sparse, and solves the problem that the path compression tree cannot increase the overall capacity due to the limitation of the number of small trees in the sparse case.
  • the path compression tree After the small tree is divided, it is determined whether the path compressed tree established according to the route prefix to be stored is sparse by judging the number of layers of the divided small trees. As shown in FIG. 1B, the path compression tree divides three small trees into two layers. If the number of layers is 3, the path compression tree shown in Figure 1B is sparse.
  • Step 203 Set location domain information for each node of each small tree, where the location domain information includes a path length and a path of the parent node of the node to the node, and a route identifier that identifies whether the node has a next hop address. Identifies whether the node has a child node ID of the child node. When it is judged that the path compression tree is sparse, the location domain information is set for each node of each small tree.
  • the location domain information of each node includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node.
  • Each of the nodes corresponds to a route prefix.
  • the route prefix may have a next hop address or a next hop address. Therefore, in this embodiment, the route identifier is used to indicate whether the node has a next if mega address.
  • each node has a maximum of 2 child nodes, which are respectively recorded as the left child node and the right child node.
  • a node may have only a left child node, or only a right child node, or any child node, or both a left child node and a right child node.
  • the child node identification is used to identify the case where the node has child nodes.
  • Step 204 sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of all nodes of each small tree and each small tree point to the address storage space of all next hop addresses corresponding to the route prefix continuously.
  • the pointer of the address is stored in the small tree storage space corresponding to each small tree.
  • the information about each tree is sequentially stored in each tree.
  • the small tree corresponds to the small tree storage space.
  • the related information of each small tree mainly includes: location domain information of all nodes in the small tree, and the small tree points to consecutively store addresses of all next hop addresses corresponding to the route prefix to be stored.
  • the pointer is stored in the small tree storage space corresponding to the small tree, and the current layer small tree needs to point to the pointer of the first address of the small tree storage space corresponding to the next small tree, and is stored in the small layer corresponding to the current layer small tree. Tree storage space.
  • the related information of the small trees included in each layer is continuously stored.
  • This storage mode can save storage space and facilitate routing address lookup. Since the size of the small tree storage space corresponding to each small tree is fixed, when the routing address is searched, the current layer small tree points to the pointer of the first address of the small tree storage space corresponding to the next small tree, and according to Small tree storage space The size of the address offset can find the d, tree storage space corresponding to each small tree in the next layer. In addition, the current layer small tree points to the pointer of the first address of the small tree storage space corresponding to the next small tree and the size of the small tree storage space, and the child node and the child node corresponding to the parent node in the next layer may also be found. Small tree storage space.
  • the location domain information of each node is used to perform lookup matching with the route prefix when performing route prefix lookup.
  • the pointer to the first address of the address storage space is used to obtain the next hop address of the node matching the longest prefix when the node with the longest prefix matching is found in the route prefix lookup process.
  • Step 205 Store all next hop addresses corresponding to the route prefix into the address storage space, and end the storage operation.
  • next hop addresses corresponding to the route prefix are continuously stored to the address. In storage space. This way of storing the next hop address continuously saves storage space.
  • Step 206 Store according to the storage manner of the existing path compression tree.
  • the storage method of the existing path compression tree may be stored.
  • the storage mode of the existing path compression tree is not described in detail in this embodiment.
  • the next hop address of the node is not directly stored by storing whether the node has the route identifier of the next hop address.
  • the occupied storage space is significantly reduced, which is beneficial to increase the number of nodes stored in the small tree storage space, improve the compression ratio of the small tree, and increase the number of routing prefixes corresponding to the small tree, thereby improving the entire tree.
  • the routing capacity especially for some sparse trees, is more effective in improving the routing capacity of the entire tree.
  • all the next hop addresses corresponding to the address prefix are separately stored and continuously stored, which is beneficial to save storage space and improve storage space utilization.
  • FIG. 3 is a flowchart of a method for searching for a route address according to an embodiment of the present invention. As shown in FIG. 3, the searching method in this embodiment includes:
  • Step 301 According to the layer sequence of the small tree, starting from the first node of the first layer of the small tree, according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree, the method is to be searched.
  • the route prefix performs a matching search;
  • the location domain information includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child that identifies whether the node has a child node Node ID.
  • the execution subject of this embodiment is a routing address searching device, such as a router or a switch. To simplify the description, the routing address lookup device will be omitted.
  • the routing address searching method in this embodiment is adapted to the routing prefix storage method provided in the foregoing embodiment.
  • the routing address searching method in this embodiment is implemented on the basis of the routing prefix storage method provided in the foregoing embodiment.
  • the small tree storage space is a storage space with a fixed size in the routing space.
  • the first node of the first layer of the small tree (only one small tree) stored in the routing space starts, according to each layer 'J
  • the tree corresponding to the 'j, the location domain information of each node stored in the tree storage space is matched and searched for the route prefix to be searched.
  • the location domain information of each node includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node.
  • the process of performing matching matching on the route prefix to be searched according to the location domain information of each node in the small tree storage space corresponding to each small tree includes:
  • the search for the route prefix is ended. If the judgment result is consistent, indicating that the matching is correct, it continues to determine whether the current node has a next hop address according to the routing identifier of the current node stored in the small tree storage space where the current node is located. For example, if the route ID of the current node is not 1, it indicates that the current node has a next hop address.
  • the route ID of the current node is 0, it indicates that the current node does not have a next hop address. If the current node has a next hop address, the location of the current node is recorded and the next hop address is identified. The location of the current node is the part of the route prefix that is currently matched.
  • the child node identifier of the current node stored in the space determines whether the current node has child nodes. For example, if the child node ID of the current node is 00, the current node has no child nodes; if the child node ID of the current node is 10, the current node has only the left child node; if the child node of the current node is queried The identifier is 01, indicating that the current node has only the right child node; if the child node identifier of the current node is 1 1 , it indicates that the current node has both the left child node and the right child node.
  • the search for the route prefix is ended. If the current child has child nodes, continue to query the child nodes. Specifically, if the current node has only the left child node, the left child node is directly queried; if the current node has only the right child node, the right child node is directly queried; if the current child node has both the left child node and the right child node Then, the left child node may be queried first, and when the left child node fails to query, the right child node is queried; or the right child node may be queried first, and when the right child node fails to query, the left child node is queried.
  • This embodiment performs matching according to the longest prefix matching principle.
  • Step 302 Determine whether the route prefix matches the longest prefix node. If the judgment result is yes, go to step 303. If the judgment result is no, go to step 304.
  • the longest prefix node is a node with a next hop address, and the matching length of the longest prefix node is relative.
  • step 303 is performed; if the node with the next hop address is not matched, indicating that the matching fails, step 304 is performed, that is, the operation ends.
  • Step 303 According to the location of the first address of the address storage space that points to the consecutive storage of the next hop address and the location of the matched longest prefix node in the small tree storage space of the longest prefix node that is matched, from the continuous storage to the next The next hop address of the route prefix is obtained in the address storage space of the hop address, and step 304 is performed.
  • the continuous address is found according to the pointer to the first address of the address storage space of the longest prefix node that stores the matching last storage address of the next hop address.
  • the relative position of the next hop address corresponding to the longest prefix matching node in the address storage space is determined according to the location of the longest prefix matching node, thereby obtaining the next hop address.
  • Step 304 ending the operation.
  • the route prefix to be searched according to the location domain information of each node in the small tree storage space corresponding to each layer of the small tree is performed according to the layer sequence of the small tree. Find. Since the next hop address corresponding to the node is not stored in each small tree storage space, but the storage node has the route identifier of the next hop address, the node information stored in each small tree storage space is increased, so that once Finding can find more bits, improving the speed and efficiency of the search.
  • FIG. 4 is a schematic structural diagram of a route prefix storage apparatus according to an embodiment of the present invention. As shown in FIG. 4A, the apparatus of this embodiment includes: a small tree dividing module 41, an information setting module 42, and a storage module 43.
  • the small tree division module 41 is configured to establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the d and the tree storage space, where each tree is j Includes multiple nodes.
  • the information setting module 42 is connected to the small tree dividing module 41, and is configured to set location domain information for each node of each small tree divided by the small tree dividing module 41, where the location domain information includes the parent node of the node to the node.
  • the storage module 43 is connected to the information setting module 42 for sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of all the nodes of each small tree and each small tree point to all the corresponding storage prefixes.
  • a pointer to the first address of the address storage space of the one-hop address is stored in the small tree storage space corresponding to each small tree.
  • the function modules of the route prefix storage device in this embodiment can be used to execute the flowchart of the route prefix storage method shown in FIG. 1A.
  • the specific working principle is not described here. For details, refer to the description of the method embodiment.
  • the route prefix storage device of the present embodiment stores the route identifier of the node with the next hop address, and does not directly store the next hop address of the node, and the occupied storage space is significantly reduced, which is beneficial to improving the small tree storage.
  • the number of nodes stored in the space increases the number of route prefixes corresponding to the small tree, thereby increasing the routing capacity of the entire tree.
  • this embodiment improves the routing capacity of the entire tree by increasing the number of routing prefixes corresponding to each small tree.
  • FIG. 4B is a schematic structural diagram of a route prefix storage apparatus according to another embodiment of the present invention. Real The embodiment is implemented based on the embodiment shown in FIG. 4A.
  • the information setting module 42 of the present embodiment includes: a first setting unit 421, a second setting unit 422, and a third setting unit 423.
  • the first setting unit 421 is connected to the small tree dividing module 41 and the storage module 43 for encoding, for each node, the child node identifier by using 2 bits, if the node has no child nodes, the child The node identifier is represented by 00. If the node has only one left child node, the child node identifier is represented by 10. If the node has only one right child node, the child node identifier is represented by 01, if the node There are both a left child node and a right child node, and the child node identifier is represented by 11.
  • the second setting unit 422 is connected to the small tree dividing module 41 and the storage module 43 for encoding, for each node, the routing identifier by using 1 bit. If the node has a next hop address, the routing identifier Indicated by 1, if the node does not have a next hop address, the routing node is represented by 0.
  • the third setting unit 423 is connected to the small tree dividing module 41 and the storage module 43 for setting a path length and a path of the parent node of the node to the node.
  • the storage module 43 is further configured to continuously store all the next hop addresses corresponding to the routing prefix into the address storage space.
  • the storage module 43 is further configured to point the current layer small tree to the pointer of the first address of the small tree storage space corresponding to the next layer of the small tree, and store the pointer to the small tree storage space corresponding to the current layer small tree.
  • the route prefix storage device of this embodiment further includes: a determining module 44.
  • the determining module 44 is connected to the small tree dividing module 41 and the information setting module 42 for determining whether the number of layers of the divided small tree is determined before the information setting module 42 sets the location domain information for each node of each small tree. If the result of the determination is yes, the trigger information setting module 42 sets the location domain information for each node of each small tree.
  • the routing prefix storage device in this embodiment performs the densification judgment on the path compression tree.
  • the storage node identifies whether there is a route identifier of the next hop address, and does not directly store the next node of the node.
  • the hop address, the occupied storage space is significantly reduced, which is beneficial to increase the number of nodes stored in the small tree storage space, improve the compression rate of the small tree, and increase the number of routing prefixes corresponding to the small tree, thereby improving the number of routing prefixes.
  • the routing capacity of the entire tree especially for some sparse For the big tree, the improvement of the routing capacity of the whole tree is more obvious.
  • the route prefix storage device of the embodiment saves the storage space and improves the utilization of the storage space by separately storing and continuously storing all the next hop addresses corresponding to the address prefix.
  • FIG. 5 is a schematic structural diagram of a routing address searching apparatus according to an embodiment of the present invention. As shown in FIG. 5, the routing address searching apparatus of this embodiment includes: a searching module 51 and an obtaining module 52.
  • the searching module 51 is configured to, according to the layer sequence of the small tree, start from the first node of the first layer of the small tree, and treat the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree.
  • the searched route prefix performs a matching search; the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a flag indicating whether the node has a child node. Child node ID.
  • the obtaining module 52 is connected to the searching module 51, and is configured to match the longest prefix node in the searching module 51, and according to the address storage space of the small tree storage space storing the matched longest prefix node to the consecutive storage of the next hop address
  • the pointer of the first address and the location of the longest prefix node that is matched are obtained, and the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
  • the searching module 51 performs a matching search process on the routing prefix to be searched according to the location domain information of each node stored in the small tree storage space.
  • the searching module 51 determines that the parent node of the current node stored in the small tree storage space is current. Whether the path of the node is consistent with the current matching part of the routing prefix; if they are consistent, the searching module 51 determines whether the current node has a next hop address according to the routing identifier of the current node in the small tree storage space, if the current node has a next The hop address records the location of the current node and identifies the next hop address, and determines whether the current node has a child node according to the child node identifier in the small tree storage space.
  • the search for the route prefix ends. If not, the lookup module 51 ends the lookup of the route prefix.
  • the function modules of the routing address lookup module in this embodiment can be used to perform the process of the routing address searching method shown in FIG. 3.
  • the specific working principle is not described here. For details, refer to the description of the method embodiment.
  • the route address locating device of the embodiment is matched with the route prefix storage device provided in the foregoing embodiment, and according to the layer sequence of the small tree, according to the location domain information of each node in the small tree storage space corresponding to each layer of the small tree
  • the discovered route prefix is searched, because each small tree storage space no longer stores the next hop address corresponding to the node but the storage node has the route identifier of the next hop address, and the node stored in each small tree storage space Increased information, so that a search can find more Multi-bit, improved search speed and efficiency.

Abstract

Provided are a route prefix storage method and device and route address searching method and device, the storage method comprising: establishing a path compression tree according to a route prefix to be stored, and dividing the path compression tree into one or more sub-trees; setting position domain information for each node of each sub-tree, the position domain information carrying the path length and the path from the parent node of a node to the node, a routing identifier identifying whether the node has a next hop address, and a sub-node identifier identifying whether the node has a sub-node; according to the sequence of the divided sub-tree layers, sequentially storing in the sub-tree storage space of each sub-tree the position domain information of all nodes of each sub-tree as well as the first address pointer of the address storage space pointed to by each sub-tree and used to successively store the next hop address. The technical solution of the present invention increases the routing capacity of a sparse big tree.

Description

路由前缀存储方法、 装置及路由地址查找方法、 装置  Route prefix storage method, device and routing address searching method and device
技术领域 本发明实施例涉及网络通信技术, 尤其涉及一种路由前缀存储方法、 装 置及路由地址查找方法、 装置。 背景技术 The present invention relates to a network communication technology, and in particular, to a route prefix storage method, a device, and a route address searching method and apparatus. Background technique
互联网工程任务组( Internet Engineering Task Force; 简称为: IETF ) 于 1993年提出了称为无类型域间路由( Classless Inter-Domain Routing; 简称为: CIDR ) 的地址结构。 虽然 CIDR只是为了阻止地址空间耗尽而采用的临时解 决办法, 但正是这项技术成了目前实际路由查表的基础。 在 CIDR中, 一个 IP网络由一个前缀代表,这个前缀是由 IP地址和标识其有效位的掩码复合表 示。 CIDR允许路由器进行路由聚合, 即大小相同、 在地址空间中相互邻近、 路由相同的 2的整数次幂个子网的路由表条目可以合并成一条路径, 并在路 由表中只占用一个表项。 CIDR避免了网络地址的过快枯竭和骨干路由器路由 表项的快速膨胀, 但同时使网络地址前缀的长度可以为任意值, 进行路由查 找时必须进行最长前缀匹配( the longest prefix match )搜索。  The Internet Engineering Task Force (IETF) introduced an address structure called Classless Inter-Domain Routing (CIDR) in 1993. Although CIDR is only a temporary solution to prevent the exhaustion of address space, it is this technology that forms the basis of the current actual route lookup table. In CIDR, an IP network is represented by a prefix, which is represented by a combination of an IP address and a mask identifying its valid bits. The CIDR allows the router to perform route aggregation. That is, the routing table entries of the same size, two adjacent subnets in the address space, and the same route are merged into one path, and only one entry is occupied in the routing table. The CIDR avoids the excessive exhaustion of the network address and the rapid expansion of the routing entries of the backbone routers, but at the same time, the length of the network address prefix can be any value, and the longest prefix match search must be performed when performing route lookup.
目前, 所有的路由查表算法都是在以下三个方面进行权衡: 1、 路由表查 询速度,这主要是由访问存储器的次数决定; 2、路由表所需要的存储器容量; 3、 插入或删除路由表项的难易程度。  At present, all routing table lookup algorithms are weighed in the following three aspects: 1, the routing table query speed, which is mainly determined by the number of accesses to the memory; 2, the memory capacity required by the routing table; 3, insert or delete The difficulty of routing entries.
针对上述问题, 现有技术中最有应用前景的方法是将存储路由前缀的数 据结构分级, 小树的顶点 (称为提升节点)放在大树中, 并且小树采用路径 压缩树结构。 在路径压缩树中, 所有路由前缀都存放在它的叶结点上, 假设 有 N个路由前缀则有 N个叶结点, 另外有 N-1个内部结点。 路径压缩树允许 每个内部结点包含一个 "比特位置" 域, 用来指示该结点以下的分支节点对 应的比特位置, 即表明连续跳过的比特个数和所跳过的比特数值, 这样路径 压缩树就将冗余的支路链压缩到了一个结点上, 在查找路由时不需要做连续 的比特匹配而是可以一次匹配多个比特来快速到达叶结点。 小树的最大高度 限制为固定值 h, h的取值和具体的硬件环境相关。 在添加表项过程中, 如果 小树的高度超过 h, 则将小树分裂, 将分裂后的小树顶点放在大树中。 在删 除表项过程中, 可以按照合并后的高度不大于 h的条件将小树合并。 而对大 树的具体实现方法不作限定, 例如: 可以用 Range Match, B-tree, TCAM等 方法, 具体采用哪种方法可视具体硬件实现而定。 该方法在查询速度、 存储 容量以及在路由表项的更新方面均具有一定优势, 因此, 是具有前途的路由 存储和查找方案。 In view of the above problems, the most promising method in the prior art is to classify the data structure storing the route prefix, the vertices of the small tree (referred to as lifting nodes) are placed in the big tree, and the small tree adopts the path compression tree structure. In the path compression tree, all route prefixes are stored at its leaf nodes. Suppose there are N route prefixes with N leaf nodes and N-1 internal nodes. The path compression tree allows each internal node to contain a "bit position" field, which is used to indicate the bit position corresponding to the branch node below the node, that is, the number of consecutively skipped bits and the value of the skipped bit. The path compression tree compresses the redundant branch chain to a node. It does not need to do continuous bit matching when searching for routes, but can match multiple bits at a time to reach the leaf nodes quickly. The maximum height of the small tree is limited to a fixed value h, and the value of h is related to the specific hardware environment. In the process of adding an entry, if the height of the small tree exceeds h, the small tree is split, and the split small tree vertex is placed in the large tree. Delete In addition to the entry process, the small trees can be merged according to the merged height not greater than h. The specific implementation method of the big tree is not limited, for example: Range Match, B-tree, TCAM, etc., which method can be used depending on the specific hardware implementation. This method has certain advantages in query speed, storage capacity, and update of routing entries. Therefore, it is a promising route storage and lookup scheme.
但是, 对于某些稀疏的大树来说, 该方案中每棵小树对应的路由前缀数 量一般比较少, 而小树的数量是有限的, 故整棵大树的路由容量将会受到影 响。 发明内容 本发明提供一种路由前缀存储方法、 装置及路由地址查找方法、 装置, 用以提升稀疏大树的路由容量。  However, for some sparse trees, the number of route prefixes per small tree in this scheme is generally small, and the number of small trees is limited. Therefore, the routing capacity of the entire tree will be affected. SUMMARY OF THE INVENTION The present invention provides a route prefix storage method, apparatus, and routing address search method and apparatus for improving the routing capacity of a sparse tree.
本发明一方面提供一种路由前缀存储方法, 包括:  An aspect of the present invention provides a method for storing a route prefix, including:
根据待存储的路由前缀建立路径压缩树, 并将所述路径压缩树根据小树 存储空间的大小划分为一棵或多棵小树, 每棵小树包括多个节点;  Establishing a path compression tree according to the route prefix to be stored, and dividing the path compression tree into one or more small trees according to the size of the small tree storage space, where each small tree includes multiple nodes;
为每棵小树的每个节点设置位置域信息, 所述位置域信息包括所述节点 的父节点到所述节点的路径长度和路径、 标识所述节点是否有下一跳地址的 路由标识和标识所述节点是否存在子节点的子节点标识;  Locating location domain information for each node of each small tree, the location domain information including a path length and a path of a parent node of the node to the node, a route identifier identifying whether the node has a next hop address, and Identifying whether the node has a child node identifier of the child node;
按照划分出的小树的层数顺序, 依次将每棵小树所有节点的位置域信息 和每棵小树指向连续存储所述路由前缀对应的所有下一跳地址的地址存储空 间的首地址的指针, 存储到每棵小树所对应的小树存储空间中。  According to the sequence order of the divided small trees, the location domain information of each node of each small tree and each small tree are sequentially pointed to the first address of the address storage space of all the next hop addresses corresponding to the routing prefix continuously. The pointer is stored in the small tree storage space corresponding to each small tree.
本发明一方面提供一种路由前缀存储装置, 包括:  An aspect of the present invention provides a route prefix storage device, including:
小树划分模块, 用于根据待存储的路由前缀建立路径压缩树, 并将所述 路径压缩树根据小树存储空间的大小划分为一棵或多棵小树, 每棵小树包括 多个节点;  a small tree partitioning module, configured to establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, where each small tree includes multiple nodes ;
信息设置模块, 用于为每棵小树的每个节点设置位置域信息, 所述位置 域信息包括所述节点的父节点到所述节点的路径长度和路径、 标识所述节点 是否有下一跳地址的路由标识和标识所述节点是否存在子节点的子节点标 识;  An information setting module, configured to set location domain information for each node of each small tree, where the location domain information includes a path length and a path of a parent node of the node to the node, and whether the node has a next a route identifier of the hop address and a child node identifier that identifies whether the node has a child node;
存储模块, 用于按照划分出的小树的层数顺序, 依次将每棵小树所有节 点的位置域信息和每棵小树指向连续存储所述路由前缀对应的所有下一跳地 址的地址存储空间的首地址的指针, 存储到每棵小树所对应的小树存储空间 中。 a storage module, configured to sequentially follow the order of the number of layers of the small trees, and sequentially all the sections of each small tree The location domain information of the point and the pointer of each small tree to the first address of the address storage space of all the next hop addresses corresponding to the route prefix are stored in the small tree storage space corresponding to each small tree.
本发明另一方面提供一种路由地址查找方法, 包括:  Another aspect of the present invention provides a routing address searching method, including:
按照小树的层数顺序, 从第一层小树的第一个节点开始, 根据各层小树 对应的小树存储空间中存储的各个节点的位置域信息对待查找的路由前缀进 行匹配查找; 所述位置域信息包括所述节点的父节点到所述节点的路径长度 和路径、 标识所述节点是否有下一跳地址的路由标识和标识所述节点是否存 在子节点的子节点标识;  According to the order of the number of layers of the small tree, starting from the first node of the first layer of the small tree, matching the searched route prefixes according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree; The location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node;
如果匹配到最长匹配的节点, 根据存储匹配到的最长匹配的节点的小树 存储空间中指向连续存储下一跳地址的地址存储空间的首地址的指针和匹配 到的最长匹配的节点的位置, 从连续存储下一跳地址的地址存储空间中获取 所述路由前缀的下一跳地址。  If the node matching the longest match is matched, the pointer to the first address of the address storage space contiguously storing the next hop address and the longest matching node matched to the node storing the next hop address in the small tree storage space of the matching longest matching node are stored. The location of the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
本发明另一方面提供一种路由地址查找装置, 包括:  Another aspect of the present invention provides a routing address searching apparatus, including:
查找模块, 用于按照小树的层数顺序, 从第一层小树的第一个节点开始, 根据各层小树对应的小树存储空间中存储的各个节点的位置域信息对待查找 的路由前缀进行匹配查找; 所述位置域信息包括所述节点的父节点到所述节 点的路径长度和路径、 标识所述节点是否有下一跳地址的路由标识和标识所 述节点是否存在子节点的子节点标识;  a search module, configured to start, according to the layer sequence of the small tree, the first node of the first layer of the small tree, and the route to be searched according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree The prefix field performs a matching search; the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a flag indicating whether the node has a child node. Child node identifier;
获取模块, 用于在所述查找模块匹配到最长前缀节点, 根据存储匹配到 的最长前缀节点的小树存储空间中指向连续存储下一跳地址的地址存储空间 的首地址的指针和匹配到的最长前缀节点的位置, 从连续存储下一跳地址的 地址存储空间中获取所述路由前缀的下一跳地址。  An obtaining module, configured to match, to the longest prefix node, the pointer and the matching of the first address of the address storage space that continuously stores the next hop address in the small tree storage space of the longest prefix node that is matched to the storage The location of the longest prefix node to which the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
本发明一方面提供的路由前缀存储方法及装置, 通过存储标识节点是否 有下一跳地址的路由标识, 而不再直接存储节点的下一跳地址, 所占用的存 储空间明显减小, 有利于提高小树存储空间所存储的节点的个数, 提高了小 树所对应的路由前缀的数量, 进而提高了整个大树的路由容量, 尤其对某些 稀疏的大树来说, 对整棵大树的路由容量的提升效果更为明显。  A method and a device for storing a route prefix provided by an aspect of the present invention, by storing a route identifier that identifies whether a node has a next hop address, and not storing the next hop address of the node directly, the occupied storage space is significantly reduced, which is beneficial to Increase the number of nodes stored in the small tree storage space, increase the number of routing prefixes corresponding to the small trees, and thus improve the routing capacity of the entire large tree, especially for some sparse large trees, The routing capacity of the tree is more effective.
本发明另一方面提供的路由地址查找方法及装置, 与本发明实施例提供 的路由前缀存储方法及装置相配合, 按照小树的层数顺序, 根据对各层小树 对应的小树存储空间中各个节点的位置域信息对待查找的路由前缀进行查 找, 由于每个小树存储空间中不再存储节点对应的下一跳地址而是存储节点 是否具有下一跳地址的路由标识, 每个小树存储空间中所存储的节点信息增 多, 使得一次查找可以查找更多比特, 提高了查找速度和效率。 附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作一简单地介绍, 显而易见地, 下 面描述中的附图是本发明的一些实施例, 对于本领域普通技术人员来讲, 在 不付出创造性劳动的前提下, 还可以根据这些附图获得其他的附图。 The routing address searching method and device provided by another aspect of the present invention cooperate with the routing prefix storage method and apparatus provided by the embodiment of the present invention, according to the layer sequence of the small tree, according to the small tree of each layer The location domain information of each node in the corresponding small tree storage space is searched for the route prefix to be searched, because the next hop address corresponding to the node is not stored in each small tree storage space, but the storage node has the next hop address. The route identifier increases the number of nodes stored in each small tree storage space, so that one search can find more bits, which improves the search speed and efficiency. BRIEF DESCRIPTION OF THE DRAWINGS In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. The drawings are some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative work.
图 1A为本发明一实施例提供的路由前缀存储方法的流程图;  1A is a flowchart of a method for storing a route prefix according to an embodiment of the present invention;
图 1B 为本发明一实施例提供的由路由前缀所建立的路径压缩树以及所 划分出的小树的一种结构示意图;  FIG. 1B is a schematic structural diagram of a path compression tree established by a route prefix and a divided small tree according to an embodiment of the present invention;
图 2为本发明另一实施例提供的路由前缀存储方法的流程图;  2 is a flowchart of a method for storing a route prefix according to another embodiment of the present invention;
图 3为本发明一实施例提供的路由地址查找方法的流程图;  FIG. 3 is a flowchart of a routing address searching method according to an embodiment of the present invention;
图 4A为本发明一实施例提供的路由前缀存储装置的结构示意图; 图 4B为本发明另一实施例提供的路由前缀存储装置的结构示意图; 图 5为本发明一实施例提供的路由地址查找装置的结构示意图。 具体实施方式  4A is a schematic structural diagram of a route prefix storage device according to an embodiment of the present invention; FIG. 4B is a schematic structural diagram of a route prefix storage device according to another embodiment of the present invention; FIG. 5 is a schematic diagram of routing address search according to an embodiment of the present invention; Schematic diagram of the structure of the device. detailed description
为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本发 明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于 本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提下所获 得的所有其他实施例, 都属于本发明保护的范围。  The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图 1A为本发明一实施例提供的路由前缀存储方法的流程图。如图 1A所 示, 本实施例的存储方法包括:  FIG. 1 is a flowchart of a method for storing a route prefix according to an embodiment of the present invention. As shown in FIG. 1A, the storage method of this embodiment includes:
步骤 101、 根据待存储的路由前缀建立路径压缩树, 并将路径压缩树根 据小树存储空间的大小划分为一棵或多棵小树, 每棵小树包括多个节点。  Step 101: Establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, and each small tree includes multiple nodes.
在本实施例中, 当需要存储某一路由前缀时, 首先根据路由前缀建立路 径压缩树( Path Compressed Trie ) , 也就是按照路由前缀中每比特是 0还是 1 进行路径分支从而形成一棵路径压缩树。 其中, 所建立的路径压缩树即为大 树。 然后, 按照硬件设备上大小固定的存储空间的大小 (例如 128bit为一固 定存储空间) , 将所建立的路径压缩树划分为一棵或多棵小树。 其中, 每棵 小树的有关信息被存储到一个大小固定的存储空间中。 在本实施例中, 将大 小固定的存储空间称为小树存储空间, 意味着每个小树存储空间对应一棵小 树。 In this embodiment, when a certain route prefix needs to be stored, the path is first established according to the route prefix. Path Compressed Trie, that is, according to whether each bit in the route prefix is 0 or 1, the path branches to form a path compression tree. The established path compression tree is a big tree. Then, according to the size of the fixed storage space on the hardware device (for example, 128 bits is a fixed storage space), the established path compression tree is divided into one or more small trees. Among them, the information about each small tree is stored in a fixed size storage space. In this embodiment, a storage space of a fixed size is referred to as a small tree storage space, which means that each small tree storage space corresponds to a small tree.
本实施例以一些路由前缀为例, 根据该些路由前缀建立了路径压缩树, 并将所建立的路径压缩树划分成了 3棵小树, 划分结果如图 1B所示。 如 1B 所示, 3棵小树分别为小树 1、 小树 2和小树 3。 每棵小树包括多个节点。 另 夕卜, 如图 1B所示, 小树 2和小树 3的顶节点是小树 1中某个节点的子节点。 根据各个小树之间节点的 "父子关系" 可以将划分出的小树进行分层, 对 于顶节点的父节点来自同一层中的小树的各个小树作为一层。 以图 1B为例, 小树 1是第一层, 小树 2的和小树 3的顶节点的父节点都来自小树 1 , 故小 树 2和小树 3是第二层。 在图 1B中包括的路由前缀如表 1所示。  In this embodiment, some route prefixes are taken as an example, a path compression tree is established according to the route prefixes, and the established path compression tree is divided into three small trees, and the division result is shown in FIG. 1B. As shown in 1B, the three small trees are small tree 1, small tree 2 and small tree 3. Each small tree consists of multiple nodes. In addition, as shown in Fig. 1B, the top nodes of the small tree 2 and the small tree 3 are child nodes of a certain node in the small tree 1. According to the "parent-child relationship" of the nodes between the small trees, the divided small trees can be layered, and the parent nodes of the top nodes are from the small trees of the small trees in the same layer as one layer. Taking FIG. 1B as an example, the small tree 1 is the first layer, and the parent nodes of the top nodes of the small tree 2 and the small tree 3 are all from the small tree 1, so the small tree 2 and the small tree 3 are the second layer. The route prefix included in Figure 1B is shown in Table 1.
表 1  Table 1
Figure imgf000007_0001
Figure imgf000007_0001
步骤 102、 为每棵小树的每个节点设置位置域信息, 所述位置域信息包 括该节点的父节点到该节点的路径长度和路径、 标识该节点是否有下一跳地 址的路由标识和标识该节点是否存在子节点的子节点标识。  Step 102: Set location domain information for each node of each small tree, where the location domain information includes a path length and a path of the parent node of the node to the node, and a route identifier that identifies whether the node has a next hop address. Identifies whether the node has a child node ID of the child node.
当划分出各棵小树后, 为每棵小树中的每个节点设置位置域信息。 每个 节点的位置域信息包括: 该节点的父节点到该节点的路径长度和路径、 标识 该节点是否有下一跳地址的路由标识和标识该节点是否有子节点的子节点标 识。 After dividing each small tree, set location domain information for each node in each small tree. The location domain information of each node includes: the path length and path, the identifier of the parent node of the node to the node Whether the node has a route identifier of the next hop address and a child node identifier that identifies whether the node has a child node.
其中, 每个节点对应一个路由前缀, 该路由前缀可能有下一跳地址, 也 可能没有下一跳地址, 故在本实施例中, 通过路由标识来表示该节点是否有 下一跳地址。 例如, 可以使用 1 比特对该路由标识进行编码, 如果该节点对 应的路由前缀有下一跳地址, 则路由标识用 1表示 (或者说路由标识取值为 1 ); 如果该节点对应的路由前缀没有下一跳地址, 则路由标识用 0表示(或 者说路由标识取值为 0 ) 。 又例如, 可以使用 1比特对该路由标识进行编码, 如果该节点对应的路由前缀有下一跳地址, 则路由标识用 0表示(或者说路 由标识取值为 0 ) ; 如果该节点对应的路由前缀没有下一跳地址, 则路由标 识用 1表示(或者说路由标识取值为 1 ) 。 另外, 除了使用 1 比特对路由标 识进行编码外, 还可以使用 2比特、 3比特等。 举例说明, 使用 2比特对路 由标识进行编码, 如果该节点对应的路由前缀有下一跳地址, 路由标识用 01 表示(或者说路由标识取值为 01 ) ; 如果该节点对应的路由前缀没有下一跳 地址,路由标识用 00表示(或者说路由标识取值为 00 )。路由标识使用 "01" 和 "00"表示仅是一种举例, 还可以是其他值。 如图 1B所示, 黑色节点表示 的是有下一跳地址的节点, 空心的节点表示没有下一跳地址的节点。  Each node corresponds to a route prefix. The route prefix may have a next hop address or a next hop address. Therefore, in this embodiment, the route identifier is used to indicate whether the node has a next hop address. For example, the route identifier can be encoded by using 1 bit. If the route prefix corresponding to the node has a next hop address, the route identifier is represented by 1 (or the route identifier is 1); if the route prefix corresponding to the node If there is no next hop address, the route ID is represented by 0 (or the route ID is 0). For another example, the route identifier may be encoded by using 1 bit. If the route prefix corresponding to the node has a next hop address, the route identifier is represented by 0 (or the route identifier takes a value of 0); if the route corresponding to the node If the prefix does not have a next hop address, the route ID is represented by 1 (or the route ID is 1). In addition, in addition to encoding the route identifier using 1 bit, 2 bits, 3 bits, or the like can be used. For example, the route identifier is encoded by using 2 bits. If the route prefix corresponding to the node has a next hop address, the route identifier is represented by 01 (or the route identifier is 01); if the route prefix corresponding to the node is not One-hop address, the route identifier is represented by 00 (or the route identifier takes the value 00). The use of "01" and "00" for route IDs is just an example and can be other values. As shown in Fig. 1B, the black node represents the node with the next hop address, and the hollow node represents the node without the next hop address.
在此说明, 使用 1 比特对路由标识进行编码是优选实施方式, 所占用的 存储空间少, 具有节约存储空间的优势。  It is explained here that encoding the route identifier by using 1 bit is a preferred implementation manner, which occupies less storage space and has the advantage of saving storage space.
与现有技术相比,本实施例的并不直接存储每个节点对应的下一跳地址, 而是存储一个路由标识。 本实施例的路由标识一般要小于下一跳地址, 故所 占用的存储空间相对较少, 提高了小树存储空间所能存储的小树数量, 进而 提升了整个大树的存储容量。  Compared with the prior art, this embodiment does not directly store the next hop address corresponding to each node, but stores a route identifier. The routing identifier of this embodiment is generally smaller than the next hop address, so the storage space occupied by the small hop is relatively small, which increases the number of small trees that can be stored in the small tree storage space, thereby improving the storage capacity of the entire large tree.
其中, 每个节点最多有 2个子节点, 分别记为左子节点和右子节点。 在 实际应用中, 一个节点可以只有左子节点, 还可以只有右子节点, 还可以没 有任何子节点, 或者同时具有左子节点和右子节点。 在本实施例中, 使用子 节点标识来标识节点具有子节点的情况。 例如, 可以使用 2比特对子节点标 识进行编码。 使用 2比特对子节点标识进行编码的一种方式为: 如果节点没 有子节点, 子节点标识用 00表示; 如果节点仅有一个左子节点, 子节点标识 用 10表示; 如果节点仅有一个右子节点, 子节点标识用 01 ; 如果节点同时 有左子节点和右子节点, 则子节点标识用 11表示。 使用 2比特对子节点标识 进行编码的另一种方式为: 如果节点没有子节点, 子节点标识用 11表示; 如 果节点仅有一个左子节点, 子节点标识用 10表示; 如果节点仅有一个右子节 点, 子节点标识用 01 ; 如果节点同时有左子节点和右子节点, 则子节点标识 用 00表示。 Among them, each node has a maximum of 2 child nodes, which are respectively recorded as the left child node and the right child node. In practical applications, a node may have only a left child node, or only a right child node, or any child node, or both a left child node and a right child node. In this embodiment, the child node identifier is used to identify the case where the node has child nodes. For example, the child node identification can be encoded using 2 bits. One way to encode the child node identifier using 2 bits is: If the node has no child nodes, the child node identifier is represented by 00; if the node has only one left child node, the child node identifier is represented by 10; if the node has only one right Child node, child node ID is 01; if node is There are left child nodes and right child nodes, and the child node identifier is represented by 11. Another way to encode the child node identifier using 2 bits is: If the node has no child nodes, the child node identifier is represented by 11; if the node has only one left child node, the child node identifier is represented by 10; if the node has only one node The right child node, the child node identifier uses 01; if the node has both the left child node and the right child node, the child node identifier is represented by 00.
另外, 除了使用 2比特对子节点标识进行编码外, 还可以使用 3比特、 4 比特等。 举例说明, 使用 3比特对子节点标识进行编码的一种方式为: 如果 节点没有子节点, 子节点标识用 000表示; 如果节点仅有一个左子节点, 子 节点标识用 100表示; 如果节点仅有一个右子节点, 子节点标识用 001 ; 如 果节点同时有左子节点和右子节点, 则子节点标识用 111表示。 但不限于这 一种编码方式。  In addition, in addition to encoding the child node identifier using 2-bit, it is also possible to use 3 bits, 4 bits, or the like. For example, one way to encode a child node identifier using 3-bit is: If the node has no child nodes, the child node identifier is represented by 000; if the node has only one left child node, the child node identifier is represented by 100; There is a right child node, the child node identifier is 001; if the node has both a left child node and a right child node, the child node identifier is represented by 111. But not limited to this type of coding.
本实施例使用子节点标识来标识一个节点的子节点情况, 而不再像现有 技术那样使用指针指向来标识, 存储子节点标识与指针相比具有简单、 易于 实现的优势。  This embodiment uses the child node identifier to identify the child node of a node, and does not use the pointer pointer to identify it as in the prior art. The storage child node identifier has the advantage of being simple and easy to implement compared with the pointer.
对于一个节点, 该节点的父节点到该节点的路径长度和路径可以直接使 用其实际值表示。  For a node, the path length and path of the node's parent node to that node can be directly represented by its actual value.
步骤 103、 按照划分出的小树的层数顺序, 依次将每棵小树所有节点的 位置域信息和每棵小树指向连续存储该路由前缀对应的所有下一跳地址的地 址存储空间的首地址的指针, 存储到每棵小树所对应的小树存储空间中。  Step 103: sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of each node of each small tree and each small tree point to the address storage space of all next hop addresses corresponding to the route prefix continuously. The pointer of the address is stored in the small tree storage space corresponding to each small tree.
当为每棵小树的每个节点设置好位置域信息后, 按照划分出的小树的层 数顺序, 例如按照先低层再高层的顺序, 依次将每棵小树的相关信息存储到 每棵小树所对应的小树存储空间中。 其中, 每棵小树的相关信息主要包括: 该棵小树中所有节点的位置域信息和该棵小树指向连续存储该待存储的路由 前缀对应的所有下一跳地址的地址存储空间的首地址的指针。 即对于一棵小 树来说, 需要将该棵小树中所有节点的位置信息和该棵小树指向连续存储该 待存储的路由前缀对应的所有下一跳地址的地址存储空间的首地址的指针, 都存储到该棵小树对应的小树存储空间中。  After setting the location domain information for each node of each small tree, according to the order of the number of layers of the divided small trees, for example, according to the order of the lower layer and then the upper layer, the information about each tree is sequentially stored in each tree. The small tree corresponds to the small tree storage space. The information about each small tree mainly includes: location domain information of all the nodes in the small tree and the address storage space of the next hop address corresponding to the route prefix to be stored in the tree. Pointer to the address. That is, for a small tree, the location information of all the nodes in the small tree and the small tree point to the first address of the address storage space of all the next hop addresses corresponding to the route prefix to be stored continuously. The pointers are stored in the small tree storage space corresponding to the small tree.
其中, 每个节点的位置域信息用于在进行路由前缀查找时, 与路由前缀 进行查找匹配。 而指向所述地址存储空间的首地址的指针用于在路由前缀查 找过程中找到最长前缀匹配的节点时, 去获取该最长前缀匹配的节点的下一 跳地址。 The location domain information of each node is used to perform lookup matching with the route prefix when performing route prefix lookup. And the pointer to the first address of the address storage space is used to find the node with the longest prefix matching in the route prefix searching process, and obtain the next node of the node with the longest prefix matching. Jump address.
在本实施例中, 通过存储标识节点是否有下一跳地址的路由标识, 而不 再直接存储节点的下一跳地址, 所占用的存储空间明显减小, 有利于提高小 树存储空间所存储的节点的个数, 提高了小树所对应的路由前缀的数量, 进 而提高了整个大树的路由容量。 尤其对某些稀疏的大树来说, 由于小树的数 量是有限, 本实施例通过提升每棵小树对应的路由前缀的数量, 对整棵大树 的路由容量的提升效果更为明显。  In this embodiment, by storing the route identifier that identifies whether the node has the next hop address, and not directly storing the next hop address of the node, the occupied storage space is significantly reduced, which is beneficial to improving storage of the small tree storage space. The number of nodes increases the number of route prefixes corresponding to the small tree, thereby increasing the routing capacity of the entire tree. In particular, for some sparse large trees, since the number of small trees is limited, this embodiment improves the routing capacity of the entire tree by increasing the number of routing prefixes corresponding to each small tree.
图 2为本发明另一实施例提供的路由前缀存储方法的流程图。 如图 2所 示, 本实施例的存储方法包括:  FIG. 2 is a flowchart of a method for storing a route prefix according to another embodiment of the present invention. As shown in FIG. 2, the storage method of this embodiment includes:
步骤 201、 根据待存储的路由前缀建立路径压缩树, 并将路径压缩树根 据小树存储空间的大小划分为一棵或多棵小树, 每棵小树包括多个节点。  Step 201: Establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, and each small tree includes multiple nodes.
本实施例的执行主体可以是路由前缀存储装置,例如路由器或交换机等。 为简化描述, 后续将省略路由前缀存储装置。  The execution body of this embodiment may be a route prefix storage device such as a router or a switch. To simplify the description, the route prefix storage will be omitted later.
本步骤 201可参见步骤 101的描述。  This step 201 can be referred to the description of step 101.
步骤 202、 判断划分出的小树的层数是否小于或等于预设层数阈值; 如 果判断结果为是, 执行步骤 203; 如果判断结果为否, 执行步骤 206。  Step 202: Determine whether the number of layers of the divided small tree is less than or equal to a preset layer threshold; if the determination result is yes, go to step 203; if the judgment result is no, go to step 206.
通常, 路径压缩树划分出的小树的层数大于某个数值时, 说明该路径压 缩树比较密集; 如果路径压缩树划分出的小树的层数小于或等于该数值, 说 明该路径压缩树比较稀疏。 本实施例将该数值定义为层数阈值。 其中, 层数 阈值的大小视路由前缀存储装置的存储能力而定。 例如, 对于小树存储空间 大小为 128bit的路由前缀存储装置, 其所对应的层数阈值一般为 3层。  Generally, when the number of layers of the small tree divided by the path compression tree is greater than a certain value, it indicates that the path compression tree is dense; if the number of layers of the small tree divided by the path compression tree is less than or equal to the value, the path compression tree is indicated. More sparse. This embodiment defines this value as the layer number threshold. The size of the layer threshold depends on the storage capacity of the route prefix storage device. For example, for a route prefix storage device with a small tree storage space of 128 bits, the corresponding layer threshold is generally 3 layers.
本实施例主要针对路径压缩树比较稀疏的情况, 用以解决路径压缩树在 稀疏情况下, 因受小树数量限制而无法提升整体容量的问题。  This embodiment mainly solves the problem that the path compression tree is sparse, and solves the problem that the path compression tree cannot increase the overall capacity due to the limitation of the number of small trees in the sparse case.
故在本实施例中, 当划分出小树后, 通过判断划分出的小树的层数来判 断根据待存储的路由前缀所建立的路径压缩树是否比较稀疏。 如图 1B所示, 该路径压缩树划分出 3棵小树, 分为 2层。 如果层数阈值为 3 , 则图 1B所示 的路径压缩树比较稀疏。  Therefore, in this embodiment, after the small tree is divided, it is determined whether the path compressed tree established according to the route prefix to be stored is sparse by judging the number of layers of the divided small trees. As shown in FIG. 1B, the path compression tree divides three small trees into two layers. If the number of layers is 3, the path compression tree shown in Figure 1B is sparse.
步骤 203、 为每棵小树的每个节点设置位置域信息, 所述位置域信息包 括该节点的父节点到该节点的路径长度和路径、 标识该节点是否有下一跳地 址的路由标识和标识该节点是否存在子节点的子节点标识。 当判断出路径压缩树比较稀疏时, 为每棵小树的每个节点设置位置域信 息。 每个节点的位置域信息包括: 该节点的父节点到该节点的路径长度和路 径、 标识该节点是否有下一跳地址的路由标识和标识该节点是否有子节点的 子节点标识。 Step 203: Set location domain information for each node of each small tree, where the location domain information includes a path length and a path of the parent node of the node to the node, and a route identifier that identifies whether the node has a next hop address. Identifies whether the node has a child node ID of the child node. When it is judged that the path compression tree is sparse, the location domain information is set for each node of each small tree. The location domain information of each node includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node.
其中, 每个节点对应一个路由前缀, 该路由前缀可能有下一跳地址, 也 可能没有下一跳地址, 故在本实施例中, 通过路由标识来表示该节点是否有 下一 if兆地址。  Each of the nodes corresponds to a route prefix. The route prefix may have a next hop address or a next hop address. Therefore, in this embodiment, the route identifier is used to indicate whether the node has a next if mega address.
其中, 每个节点最多有 2个子节点, 分别记为左子节点和右子节点。 在 实际应用中, 一个节点可以只有左子节点, 还可以只有右子节点, 还可以没 有任何子节点, 或者同时具有左子节点和右子节点。 在本实施例中, 使用子 节点标识来标识节点具有子节点的情况。  Among them, each node has a maximum of 2 child nodes, which are respectively recorded as the left child node and the right child node. In practical applications, a node may have only a left child node, or only a right child node, or any child node, or both a left child node and a right child node. In this embodiment, the child node identification is used to identify the case where the node has child nodes.
有关本步骤 203的其他描述可参见步骤 102的描述, 在此不再赘述。 步骤 204、 按照划分出的小树的层数顺序, 依次将每棵小树所有节点的 位置域信息和每棵小树指向连续存储该路由前缀对应的所有下一跳地址的地 址存储空间的首地址的指针, 存储到每棵小树所对应的小树存储空间中。  For other descriptions of this step 203, refer to the description of step 102, and details are not described herein again. Step 204: sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of all nodes of each small tree and each small tree point to the address storage space of all next hop addresses corresponding to the route prefix continuously. The pointer of the address is stored in the small tree storage space corresponding to each small tree.
当为每棵小树的每个节点设置好位置域信息后, 按照划分出的小树的层 数顺序, 例如按照先低层再高层的顺序, 依次将每棵小树的相关信息存储到 每棵小树所对应的小树存储空间中。  After setting the location domain information for each node of each small tree, according to the order of the number of layers of the divided small trees, for example, according to the order of the lower layer and then the upper layer, the information about each tree is sequentially stored in each tree. The small tree corresponds to the small tree storage space.
在本实施例中, 每棵小树的相关信息主要包括: 该棵小树中所有节点的 位置域信息、 该棵小树指向连续存储该待存储的路由前缀对应的所有下一跳 地址的地址存储空间的首地址的指针、 以及指向下一层小树对应的 d、树存储 空间的首地址的指针。 即对于一棵小树来说, 不仅要将该棵小树中所有节点 的位置信息和该棵小树指向连续存储该待存储的路由前缀对应的所有下一跳 地址的地址存储空间的首地址的指针存储到该棵小树对应的小树存储空间 中, 还需要将当前层小树指向下一层小树对应的小树存储空间的首地址的指 针, 存储到当前层小树对应的小树存储空间中。  In this embodiment, the related information of each small tree mainly includes: location domain information of all nodes in the small tree, and the small tree points to consecutively store addresses of all next hop addresses corresponding to the route prefix to be stored. A pointer to the first address of the storage space, and a pointer to the d, the first address of the tree storage space corresponding to the next layer of the small tree. That is, for a small tree, not only the location information of all the nodes in the small tree and the first address of the address storage space of all the next hop addresses corresponding to the route prefix to be stored are consecutively stored in the small tree. The pointer is stored in the small tree storage space corresponding to the small tree, and the current layer small tree needs to point to the pointer of the first address of the small tree storage space corresponding to the next small tree, and is stored in the small layer corresponding to the current layer small tree. Tree storage space.
在本实施例中, 各层所包含的小树的相关信息是连续存储的, 这种存储 方式既可以节约存储空间, 又便于进行路由地址查找。 由于每个小树对应的 小树存储空间的大小是固定的, 故在进行路由地址查找时, 通过当前层小树 指向下一层小树对应的小树存储空间的首地址的指针, 并按照小树存储空间 的大小进行地址偏移可以找到下一层中各个小树对应的 d、树存储空间。另夕卜, 通过当前层小树指向下一层小树对应的小树存储空间的首地址的指针和小树 存储空间的大小, 还可以找到父节点在下一层中的子节点和子节点对应的小 树存储空间。 In this embodiment, the related information of the small trees included in each layer is continuously stored. This storage mode can save storage space and facilitate routing address lookup. Since the size of the small tree storage space corresponding to each small tree is fixed, when the routing address is searched, the current layer small tree points to the pointer of the first address of the small tree storage space corresponding to the next small tree, and according to Small tree storage space The size of the address offset can find the d, tree storage space corresponding to each small tree in the next layer. In addition, the current layer small tree points to the pointer of the first address of the small tree storage space corresponding to the next small tree and the size of the small tree storage space, and the child node and the child node corresponding to the parent node in the next layer may also be found. Small tree storage space.
其中, 每个节点的位置域信息用于在进行路由前缀查找时, 与路由前缀 进行查找匹配。 而指向所述地址存储空间的首地址的指针用于在路由前缀查 找过程中找到最长前缀匹配的节点时, 去获取该最长前缀匹配的节点的下一 跳地址。  The location domain information of each node is used to perform lookup matching with the route prefix when performing route prefix lookup. The pointer to the first address of the address storage space is used to obtain the next hop address of the node matching the longest prefix when the node with the longest prefix matching is found in the route prefix lookup process.
步骤 205、 将路由前缀对应的所有下一跳地址连续存储到所述的地址存 储空间中, 并结束存储操作。  Step 205: Store all next hop addresses corresponding to the route prefix into the address storage space, and end the storage operation.
在本实施例中, 除了将路由前缀建立的路径压缩树中各个节点的位置域 信息存储到对应的小树存储空间中, 还将路由前缀对应的所有下一跳地址连 续存储到所述的地址存储空间中。 这种连续存储下一跳地址的存储方式有利 于节约存储空间。  In this embodiment, in addition to storing the location domain information of each node in the path compression tree established by the route prefix into the corresponding small tree storage space, all next hop addresses corresponding to the route prefix are continuously stored to the address. In storage space. This way of storing the next hop address continuously saves storage space.
步骤 206、 按照现有路径压缩树的存储方式进行存储。  Step 206: Store according to the storage manner of the existing path compression tree.
其中, 如果根据待存储的路由前缀所建立的路径压缩树比较密集, 则可 以按照现有路径压缩树的存储方式进行存储。  If the path compression tree established according to the route prefix to be stored is relatively dense, the storage method of the existing path compression tree may be stored.
其中, 现有路径压缩树的存储方式本实施例不再详述。  The storage mode of the existing path compression tree is not described in detail in this embodiment.
在本实施例中, 通过对路径压缩树进行疏密判断, 在路径压缩树比较稀 疏时, 通过存储标识节点是否有下一跳地址的路由标识, 而不再直接存储节 点的下一跳地址, 所占用的存储空间明显减小, 有利于提高小树存储空间所 存储的节点的个数, 提高了小树的压缩率, 提高了小树所对应的路由前缀的 数量, 进而提高了整个大树的路由容量, 尤其对某些稀疏的大树来说, 对整 棵大树的路由容量的提升效果更为明显。 另外, 本实施例通过将地址前缀对 应的所有下一跳地址进行单独存储且连续存储, 有利于节约存储空间和提高 存储空间的利用率。  In this embodiment, when the path compression tree is sparsely judged, when the path compression tree is sparse, the next hop address of the node is not directly stored by storing whether the node has the route identifier of the next hop address. The occupied storage space is significantly reduced, which is beneficial to increase the number of nodes stored in the small tree storage space, improve the compression ratio of the small tree, and increase the number of routing prefixes corresponding to the small tree, thereby improving the entire tree. The routing capacity, especially for some sparse trees, is more effective in improving the routing capacity of the entire tree. In addition, in this embodiment, all the next hop addresses corresponding to the address prefix are separately stored and continuously stored, which is beneficial to save storage space and improve storage space utilization.
图 3为本发明一实施例提供的路由地址查找方法的流程图。如图 3所示, 本实施例的查找方法包括:  FIG. 3 is a flowchart of a method for searching for a route address according to an embodiment of the present invention. As shown in FIG. 3, the searching method in this embodiment includes:
步骤 301、 按照小树的层数顺序, 从第一层小树的第一个节点开始, 根 据各层小树对应的小树存储空间中存储的各个节点的位置域信息对待查找的 路由前缀进行匹配查找; 所述位置域信息包括: 该节点的父节点到该节点的 路径长度和路径、 标识该节点是否有下一跳地址的路由标识和标识所述节点 是否存在子节点的子节点标识。 Step 301: According to the layer sequence of the small tree, starting from the first node of the first layer of the small tree, according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree, the method is to be searched. The route prefix performs a matching search; the location domain information includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child that identifies whether the node has a child node Node ID.
本实施例的执行主体为路由地址查找装置, 例如路由器或交换机等。 为 简化描述, 将省略路由地址查找装置。  The execution subject of this embodiment is a routing address searching device, such as a router or a switch. To simplify the description, the routing address lookup device will be omitted.
本实施例的路由地址查找方法与上述实施例提供的路由前缀存储方法相 适应。 本实施例的路由地址查找方法在上述实施例提供的路由前缀存储方法 的基础上实现。  The routing address searching method in this embodiment is adapted to the routing prefix storage method provided in the foregoing embodiment. The routing address searching method in this embodiment is implemented on the basis of the routing prefix storage method provided in the foregoing embodiment.
具体的, 在路由空间中, 已经预先按照待存储的路由前缀划分出的小树 的层数, 将各个小树的位置域信息存储到了相应的小树存储空间中。 其中, 小树存储空间是路由空间中具有固定大小的存储空间。  Specifically, in the routing space, the number of layers of the small tree that has been divided according to the route prefix to be stored is pre-stored, and the location domain information of each small tree is stored in the corresponding small tree storage space. The small tree storage space is a storage space with a fixed size in the routing space.
当接收到某个路由前缀, 需要查询该路由前缀对应的下一跳地址时, 路 由空间中存储的第一层小树(只有一棵小树) 的第一个节点开始, 根据各层 'J、树对应的 ' j、树存储空间中存储的各个节点的位置域信息对待查找的路由前 缀进行匹配查找。  When a route prefix is received and the next hop address corresponding to the route prefix needs to be queried, the first node of the first layer of the small tree (only one small tree) stored in the routing space starts, according to each layer 'J The tree corresponding to the 'j, the location domain information of each node stored in the tree storage space is matched and searched for the route prefix to be searched.
其中, 每个节点的位置域信息包括: 节点的父节点到该节点的路径长度 和路径、 标识该节点是否有下一跳地址的路由标识和标识该节点是否存在子 节点的子节点标识。  The location domain information of each node includes: a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node.
其中, 根据每棵小树对应的小树存储空间中的各节点的位置域信息对待 查找的路由前缀进行匹配查找的过程包括:  The process of performing matching matching on the route prefix to be searched according to the location domain information of each node in the small tree storage space corresponding to each small tree includes:
当查询到当前节点时, 判断当前节点所在的 d、树存储空间中所存储的当 前节点的父节点到当前节点的路径是否与路由前缀当前匹配到的部分相一 致。 如果判断结果为不一致, 说明发生错误, 则结束对该路由前缀的查找。 如果判断结果为一致, 说明匹配正确, 则继续根据当前节点所在的小树存储 空间中所存储的当前节点的路由标识, 判断当前节点是否有下一跳地址。 例 如, 如果查询到当前节点的路由标识未 1 , 表明当前节点有下一跳地址; 如 果查询到当前节点的路由标识为 0 , 表明当前节点没有下一跳地址。 如果当 前节点有下一跳地址, 则记录当前节点的位置并标识具有下一跳地址。 其中, 当前节点的位置亦即路由前缀当前匹配到的部分。  When the current node is queried, it is determined whether the path of the current node's parent node to the current node stored in the d, tree storage space of the current node is consistent with the current matching part of the route prefix. If the judgment result is inconsistent, indicating that an error occurs, the search for the route prefix is ended. If the judgment result is consistent, indicating that the matching is correct, it continues to determine whether the current node has a next hop address according to the routing identifier of the current node stored in the small tree storage space where the current node is located. For example, if the route ID of the current node is not 1, it indicates that the current node has a next hop address. If the route ID of the current node is 0, it indicates that the current node does not have a next hop address. If the current node has a next hop address, the location of the current node is recorded and the next hop address is identified. The location of the current node is the part of the route prefix that is currently matched.
另外, 在判断结果为一致的情况下, 还要根据当前节点所在的小树存储 空间中所存储的当前节点的子节点标识判断当前节点是否有子节点。 例如, 如果查询到当前节点的子节点标识为 00, 表示当前节点没有子节点; 如果查 询到当前节点的子节点标识为 10, 表示当前节点仅有左子节点; 如果查询到 当前节点的子节点标识为 01 , 表示当前节点仅有右子节点; 如果查询到当前 节点的子节点标识为 1 1 , 表示当前节点同时有左子节点和右子节点。 如果当 前节点没有子节点, 则结束对路由前缀的查找。 如果当前子节点有子节点, 继续查询子节点。 具体的, 如果当前节点仅有左子节点, 则直接去查询左子 节点; 如果当前节点仅有右子节点, 则直接去查询右子节点; 如果当前子节 点同时具有左子节点和右子节点, 则可以先查询左子节点, 当对左子节点查 询失败时, 去查询右子节点; 或者可以先查询右子节点, 当右子节点查询失 败时, 去查询左子节点。 In addition, in the case where the judgment result is consistent, it is also stored according to the small tree where the current node is located. The child node identifier of the current node stored in the space determines whether the current node has child nodes. For example, if the child node ID of the current node is 00, the current node has no child nodes; if the child node ID of the current node is 10, the current node has only the left child node; if the child node of the current node is queried The identifier is 01, indicating that the current node has only the right child node; if the child node identifier of the current node is 1 1 , it indicates that the current node has both the left child node and the right child node. If the current node has no children, the search for the route prefix is ended. If the current child has child nodes, continue to query the child nodes. Specifically, if the current node has only the left child node, the left child node is directly queried; if the current node has only the right child node, the right child node is directly queried; if the current child node has both the left child node and the right child node Then, the left child node may be queried first, and when the left child node fails to query, the right child node is queried; or the right child node may be queried first, and when the right child node fails to query, the left child node is queried.
本实施例按照最长前缀匹配原则进行匹配。  This embodiment performs matching according to the longest prefix matching principle.
步骤 302、 判断路由前缀是否匹配到最长前缀节点; 如果判断结果为是, 执行步骤 303 ; 如果判断结果为否, 执行步骤 304。  Step 302: Determine whether the route prefix matches the longest prefix node. If the judgment result is yes, go to step 303. If the judgment result is no, go to step 304.
当匹配结束后, 判断路由前缀是否匹配到了最长前缀节点。 其中, 最长 前缀节点是有下一跳地址的节点, 且对该最长前缀节点的匹配长度是相对而 言的。  When the match is over, determine whether the route prefix matches the longest prefix node. The longest prefix node is a node with a next hop address, and the matching length of the longest prefix node is relative.
如果匹配到了前缀最长且具有下一跳地址的节点, 则执行步骤 303 ; 如 果没有匹配到任何具有下一跳地址的节点, 说明匹配失败, 则执行步骤 304, 即结束操作。  If the node with the longest prefix and the next hop address is matched, step 303 is performed; if the node with the next hop address is not matched, indicating that the matching fails, step 304 is performed, that is, the operation ends.
步骤 303、 根据存储匹配到的最长前缀节点的小树存储空间中指向连续 存储下一跳地址的地址存储空间的首地址的指针和匹配到的最长前缀节点的 位置, 从连续存储下一跳地址的地址存储空间中获取所述路由前缀的下一跳 地址, 并执行步骤 304。  Step 303: According to the location of the first address of the address storage space that points to the consecutive storage of the next hop address and the location of the matched longest prefix node in the small tree storage space of the longest prefix node that is matched, from the continuous storage to the next The next hop address of the route prefix is obtained in the address storage space of the hop address, and step 304 is performed.
当匹配到了前缀最长且具有下一跳地址的节点时, 根据存储匹配到的最 长前缀节点的小树存储空间中指向连续存储下一跳地址的地址存储空间的首 地址的指针, 找到连续存储下一跳地址的地址存储空间的首地址。 然后, 根 据最长前缀匹配节点的位置, 确定该最长前缀匹配节点对应的下一跳地址在 所述的地址存储空间中的相对位置, 从而获取下一跳地址。  When the node with the longest prefix and the next hop address is matched, the continuous address is found according to the pointer to the first address of the address storage space of the longest prefix node that stores the matching last storage address of the next hop address. The first address of the address storage space where the next hop address is stored. Then, the relative position of the next hop address corresponding to the longest prefix matching node in the address storage space is determined according to the location of the longest prefix matching node, thereby obtaining the next hop address.
在本实施例中, 所有下一跳地址连续存储在所述的地址存储空间中。 所 述的地址存储空间与各个小树存储空间是独立的。 In this embodiment, all next hop addresses are continuously stored in the address storage space. Place The address storage space described is independent of each small tree storage space.
步骤 304、 结束操作。  Step 304, ending the operation.
本实施例在上述实施例提供的路由前缀存储方法的基础上, 按照小树的 层数顺序, 根据对各层小树对应的小树存储空间中各个节点的位置域信息对 待查找的路由前缀进行查找。 由于每个小树存储空间中不再存储节点对应的 下一跳地址而是存储节点是否具有下一跳地址的路由标识, 因此, 每个小树 存储空间中所存储的节点信息增多, 使得一次查找可以查找更多比特, 提高 了查找速度和效率。  In this embodiment, based on the route prefix storage method provided in the foregoing embodiment, the route prefix to be searched according to the location domain information of each node in the small tree storage space corresponding to each layer of the small tree is performed according to the layer sequence of the small tree. Find. Since the next hop address corresponding to the node is not stored in each small tree storage space, but the storage node has the route identifier of the next hop address, the node information stored in each small tree storage space is increased, so that once Finding can find more bits, improving the speed and efficiency of the search.
图 4A为本发明一实施例提供的路由前缀存储装置的结构示意图。 如图 4A所示, 本实施例的装置包括: 小树划分模块 41、 信息设置模块 42和存储 模块 43。  FIG. 4 is a schematic structural diagram of a route prefix storage apparatus according to an embodiment of the present invention. As shown in FIG. 4A, the apparatus of this embodiment includes: a small tree dividing module 41, an information setting module 42, and a storage module 43.
其中, 小树划分模块 41 , 用于根据待存储的路由前缀建立路径压缩树, 并将路径压缩树根据 d、树存储空间的大小划分为一棵或多棵小树, 每棵 ' j、树 包括多个节点。 信息设置模块 42, 与小树划分模块 41连接, 用于为小树划 分模块 41划分出的每棵小树的每个节点设置位置域信息,所述位置域信息包 括该节点的父节点到该节点的路径长度和路径、 标识该节点是否有下一跳地 址的路由标识和标识该节点是否存在子节点的子节点标识。 存储模块 43 , 与 信息设置模块 42连接, 用于按照划分出的小树的层数顺序, 依次将每棵小树 所有节点的位置域信息和每棵小树指向连续存储路由前缀对应的所有下一跳 地址的地址存储空间的首地址的指针, 存储到每棵小树所对应的小树存储空 间中。  The small tree division module 41 is configured to establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the d and the tree storage space, where each tree is j Includes multiple nodes. The information setting module 42 is connected to the small tree dividing module 41, and is configured to set location domain information for each node of each small tree divided by the small tree dividing module 41, where the location domain information includes the parent node of the node to the node The path length and path of the node, the route identifier that identifies whether the node has a next hop address, and the child node identifier that identifies whether the node has a child node. The storage module 43 is connected to the information setting module 42 for sequentially, in order of the number of layers of the divided small trees, sequentially, the location domain information of all the nodes of each small tree and each small tree point to all the corresponding storage prefixes. A pointer to the first address of the address storage space of the one-hop address is stored in the small tree storage space corresponding to each small tree.
本实施例路由前缀存储装置的各功能模块可用于执行图 1A所示路由前 缀存储方法的流程图, 其具体工作原理不再赘述, 详见方法实施例的描述。  The function modules of the route prefix storage device in this embodiment can be used to execute the flowchart of the route prefix storage method shown in FIG. 1A. The specific working principle is not described here. For details, refer to the description of the method embodiment.
本实施例的路由前缀存储装置, 通过存储标识节点是否有下一跳地址的 路由标识, 而不再直接存储节点的下一跳地址, 所占用的存储空间明显减小, 有利于提高小树存储空间所存储的节点的个数, 提高了小树所对应的路由前 缀的数量, 进而提高了整个大树的路由容量。 尤其对某些稀疏的大树来说, 由于小树的数量是有限,本实施例通过提升每棵小树对应的路由前缀的数量, 对整棵大树的路由容量的提升效果更为明显。  The route prefix storage device of the present embodiment stores the route identifier of the node with the next hop address, and does not directly store the next hop address of the node, and the occupied storage space is significantly reduced, which is beneficial to improving the small tree storage. The number of nodes stored in the space increases the number of route prefixes corresponding to the small tree, thereby increasing the routing capacity of the entire tree. Especially for some sparse trees, because the number of small trees is limited, this embodiment improves the routing capacity of the entire tree by increasing the number of routing prefixes corresponding to each small tree.
图 4B为本发明另一实施例提供的路由前缀存储装置的结构示意图。本实 施例基于图 4A所示实施例实现,如图 4B所示,本实施例的信息设置模块 42 包括: 第一设置单元 421、 第二设置单元 422和第三设置单元 423。 FIG. 4B is a schematic structural diagram of a route prefix storage apparatus according to another embodiment of the present invention. Real The embodiment is implemented based on the embodiment shown in FIG. 4A. As shown in FIG. 4B, the information setting module 42 of the present embodiment includes: a first setting unit 421, a second setting unit 422, and a third setting unit 423.
其中, 第一设置单元 421 , 与小树划分模块 41和存储模块 43连接, 用 于对每个节点, 用 2比特对所述子节点标识进行编码, 如果所述节点没有子 节点, 所述子节点标识用 00表示, 如果所述节点仅有一个左子节点, 所述子 节点标识用 10表示, 如果所述节点仅有一个右子节点, 所述子节点标识用 01 表示, 如果所述节点同时有左子节点和右子节点, 所述子节点标识用 11 表示。  The first setting unit 421 is connected to the small tree dividing module 41 and the storage module 43 for encoding, for each node, the child node identifier by using 2 bits, if the node has no child nodes, the child The node identifier is represented by 00. If the node has only one left child node, the child node identifier is represented by 10. If the node has only one right child node, the child node identifier is represented by 01, if the node There are both a left child node and a right child node, and the child node identifier is represented by 11.
第二设置单元 422, 与小树划分模块 41和存储模块 43连接, 用于对每 个节点, 用 1 比特对所述路由标识进行编码, 如果所述节点有下一跳地址, 所述路由标识用 1表示, 如果所述节点没有下一跳地址, 所述路由节点用 0 表示。  The second setting unit 422 is connected to the small tree dividing module 41 and the storage module 43 for encoding, for each node, the routing identifier by using 1 bit. If the node has a next hop address, the routing identifier Indicated by 1, if the node does not have a next hop address, the routing node is represented by 0.
第三设置单元 423 , 与小树划分模块 41和存储模块 43连接, 用于设置 所述节点的父节点到该节点的路径长度和路径。  The third setting unit 423 is connected to the small tree dividing module 41 and the storage module 43 for setting a path length and a path of the parent node of the node to the node.
进一步,存储模块 43还用于将所述路由前缀对应的所有下一跳地址连续 存储到所述地址存储空间中。  Further, the storage module 43 is further configured to continuously store all the next hop addresses corresponding to the routing prefix into the address storage space.
更进一步,存储模块 43还用于将当前层小树指向下一层小树对应的小树 存储空间的首地址的指针, 存储到当前层小树对应的小树存储空间中。  Further, the storage module 43 is further configured to point the current layer small tree to the pointer of the first address of the small tree storage space corresponding to the next layer of the small tree, and store the pointer to the small tree storage space corresponding to the current layer small tree.
本实施例的路由前缀存储装置还包括: 判断模块 44。  The route prefix storage device of this embodiment further includes: a determining module 44.
其中, 判断模块 44与小树划分模块 41和信息设置模块 42连接, 用于在 信息设置模块 42为每棵小树的每个节点设置位置域信息之前,判断划分出的 小树的层数是否小于或等于预设层数阈值, 如果判断结果为是, 触发信息设 置模块 42为每棵小树的每个节点设置位置域信息。  The determining module 44 is connected to the small tree dividing module 41 and the information setting module 42 for determining whether the number of layers of the divided small tree is determined before the information setting module 42 sets the location domain information for each node of each small tree. If the result of the determination is yes, the trigger information setting module 42 sets the location domain information for each node of each small tree.
上述各功能单元或模块可用于执行图 1A或图 2所示路由前缀存储方法 中的相应流程, 其具体工作原理不再赘述, 详见方法实施例的描述。  The foregoing functional units or modules may be used to perform the corresponding processes in the method for storing the route prefix shown in FIG. 1A or FIG. 2, and the specific working principles are not described herein again. For details, refer to the description of the method embodiments.
本实施例的路由前缀存储装置, 通过对路径压缩树进行疏密判断, 在路 径压缩树比较稀疏时, 通过存储标识节点是否有下一跳地址的路由标识, 而 不再直接存储节点的下一跳地址, 所占用的存储空间明显减小, 有利于提高 小树存储空间所存储的节点的个数, 提高了小树的压缩率, 提高了小树所对 应的路由前缀的数量, 进而提高了整个大树的路由容量, 尤其对某些稀疏的 大树来说, 对整棵大树的路由容量的提升效果更为明显。 另外, 本实施例的 路由前缀存储装置通过将地址前缀对应的所有下一跳地址进行单独存储且连 续存储, 有利于节约存储空间和提高存储空间的利用率。 The routing prefix storage device in this embodiment performs the densification judgment on the path compression tree. When the path compression tree is sparse, the storage node identifies whether there is a route identifier of the next hop address, and does not directly store the next node of the node. The hop address, the occupied storage space is significantly reduced, which is beneficial to increase the number of nodes stored in the small tree storage space, improve the compression rate of the small tree, and increase the number of routing prefixes corresponding to the small tree, thereby improving the number of routing prefixes. The routing capacity of the entire tree, especially for some sparse For the big tree, the improvement of the routing capacity of the whole tree is more obvious. In addition, the route prefix storage device of the embodiment saves the storage space and improves the utilization of the storage space by separately storing and continuously storing all the next hop addresses corresponding to the address prefix.
图 5为本发明一实施例提供的路由地址查找装置的结构示意图。 如图 5 所示, 本实施例的路由地址查找装置包括: 查找模块 51和获取模块 52。  FIG. 5 is a schematic structural diagram of a routing address searching apparatus according to an embodiment of the present invention. As shown in FIG. 5, the routing address searching apparatus of this embodiment includes: a searching module 51 and an obtaining module 52.
其中, 查找模块 51 , 用于按照小树的层数顺序, 从第一层小树的第一个 节点开始, 根据各层小树对应的小树存储空间中存储的各个节点的位置域信 息对待查找的路由前缀进行匹配查找; 所述位置域信息包括节点的父节点到 该节点的路径长度和路径、 标识所述节点是否有下一跳地址的路由标识和标 识所述节点是否存在子节点的子节点标识。  The searching module 51 is configured to, according to the layer sequence of the small tree, start from the first node of the first layer of the small tree, and treat the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree. The searched route prefix performs a matching search; the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a flag indicating whether the node has a child node. Child node ID.
获取模块 52, 与查找模块 51连接, 用于在查找模块 51匹配到最长前缀 节点, 根据存储匹配到的最长前缀节点的小树存储空间中指向连续存储下一 跳地址的地址存储空间的首地址的指针和匹配到的最长前缀节点的位置, 从 连续存储下一跳地址的地址存储空间中获取所述路由前缀的下一跳地址。  The obtaining module 52 is connected to the searching module 51, and is configured to match the longest prefix node in the searching module 51, and according to the address storage space of the small tree storage space storing the matched longest prefix node to the consecutive storage of the next hop address The pointer of the first address and the location of the longest prefix node that is matched are obtained, and the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
其中 ,查找模块 51根据小树存储空间中存储的各个节点的位置域信息对 待查找的路由前缀进行匹配查找的过程具体为:查找模块 51判断小树存储空 间中存储的当前节点的父节点到当前节点的路径是否与路由前缀当前匹配到 的部分相一致; 如果相一致, 查找模块 51根据小树存储空间中当前节点的路 由标识, 确定当前节点是否有下一跳地址, 如果当前节点有下一跳地址, 则 记录当前节点的位置并标识具有下一跳地址, 并根据小树存储空间中的子节 点标识, 判断当前节点是否存在子节点; 如果当前节点存在子节点, 继续查 询当前节点的子节点; 如果当前节点不存在子节点, 结束对路由前缀的查找。 如果不一致, 查找模块 51结束对路由前缀的查找。  The searching module 51 performs a matching search process on the routing prefix to be searched according to the location domain information of each node stored in the small tree storage space. The searching module 51 determines that the parent node of the current node stored in the small tree storage space is current. Whether the path of the node is consistent with the current matching part of the routing prefix; if they are consistent, the searching module 51 determines whether the current node has a next hop address according to the routing identifier of the current node in the small tree storage space, if the current node has a next The hop address records the location of the current node and identifies the next hop address, and determines whether the current node has a child node according to the child node identifier in the small tree storage space. If the current node has a child node, continue to query the current node's child. Node; If the current node does not have a child node, the search for the route prefix ends. If not, the lookup module 51 ends the lookup of the route prefix.
本实施例路由地址查找模块的各功能模块可用于执行图 3所示路由地址 查找方法的流程, 其具体工作原理不再赘述, 详见方法实施例的描述。  The function modules of the routing address lookup module in this embodiment can be used to perform the process of the routing address searching method shown in FIG. 3. The specific working principle is not described here. For details, refer to the description of the method embodiment.
本实施例的路由地址查找装置, 与上述实施例提供的路由前缀存储装置 相配合, 按照小树的层数顺序, 根据对各层小树对应的小树存储空间中各个 节点的位置域信息对待查找的路由前缀进行查找, 由于每个小树存储空间中 不再存储节点对应的下一跳地址而是存储节点是否具有下一跳地址的路由标 识, 每个小树存储空间中所存储的节点信息增多, 使得一次查找可以查找更 多比特, 提高了查找速度和效率。 The route address locating device of the embodiment is matched with the route prefix storage device provided in the foregoing embodiment, and according to the layer sequence of the small tree, according to the location domain information of each node in the small tree storage space corresponding to each layer of the small tree The discovered route prefix is searched, because each small tree storage space no longer stores the next hop address corresponding to the node but the storage node has the route identifier of the next hop address, and the node stored in each small tree storage space Increased information, so that a search can find more Multi-bit, improved search speed and efficiency.
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步骤 可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机可读 取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述 的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码的介 质。  A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或 者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技 术方案的本质脱离本发明各实施例技术方案的精神和范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

权 利 要求 书 Claim
1、 一种路由前缀存储方法, 其特征在于, 包括:  A method for storing a route prefix, comprising:
根据待存储的路由前缀建立路径压缩树, 并将所述路径压缩树根据小树 存储空间的大小划分为一棵或多棵小树 , 每棵小树包括多个节点;  Establishing a path compression tree according to the route prefix to be stored, and dividing the path compression tree into one or more small trees according to the size of the small tree storage space, where each small tree includes multiple nodes;
为每棵小树的每个节点设置位置域信息, 所述位置域信息包括所述节点 的父节点到所述节点的路径长度和路径、 标识所述节点是否有下一跳地址的 路由标识和标识所述节点是否存在子节点的子节点标识;  Locating location domain information for each node of each small tree, the location domain information including a path length and a path of a parent node of the node to the node, a route identifier identifying whether the node has a next hop address, and Identifying whether the node has a child node identifier of the child node;
按照划分出的小树的层数顺序, 依次将每棵小树所有节点的位置域信息 和每棵小树指向连续存储所述路由前缀对应的所有下一跳地址的地址存储空 间的首地址的指针, 存储到每棵小树所对应的小树存储空间中。  According to the sequence order of the divided small trees, the location domain information of each node of each small tree and each small tree are sequentially pointed to the first address of the address storage space of all the next hop addresses corresponding to the routing prefix continuously. The pointer is stored in the small tree storage space corresponding to each small tree.
2、 根据权利要求 1所述的路由前缀存储方法, 其特征在于, 为每棵小树 的每个节点设置位置域信息包括:  2. The route prefix storage method according to claim 1, wherein the setting the location domain information for each node of each small tree comprises:
对每个节点, 用 2比特对所述子节点标识进行编码, 如果所述节点没有 子节点, 所述子节点标识用 00表示, 如果所述节点仅有一个左子节点, 所述 子节点标识用 10表示, 如果所述节点仅有一个右子节点, 所述子节点标识用 01 表示, 如果所述节点同时有左子节点和右子节点, 所述子节点标识用 11 表示;  For each node, the child node identifier is encoded with 2 bits. If the node has no child nodes, the child node identifier is represented by 00, and if the node has only one left child node, the child node identifier Indicated by 10, if the node has only one right child node, the child node identifier is represented by 01, and if the node has both a left child node and a right child node, the child node identifier is represented by 11;
对每个节点, 用 1 比特对所述路由标识进行编码, 如果所述节点有下一 跳地址, 所述路由标识用 1表示, 如果所述节点没有下一跳地址, 所述路由 节点用 0表示;  For each node, the route identifier is encoded by 1 bit. If the node has a next hop address, the route identifier is represented by 1. If the node does not have a next hop address, the routing node uses 0. Express
设置所述节点的父节点到所述节点的路径长度和路径。  Set the path length and path of the parent node of the node to the node.
3、根据权利要求 1或 2所述的路由前缀存储方法,其特征在于,还包括: 将所述路由前缀对应的所有下一跳地址连续存储到所述地址存储空间 中。  The method for storing a route prefix according to claim 1 or 2, further comprising: continuously storing all next hop addresses corresponding to the route prefix into the address storage space.
4、根据权利要求 1或 2所述的路由前缀存储方法,其特征在于,还包括: 将当前层小树指向下一层小树对应的小树存储空间的首地址的指针, 存 储到当前层小树对应的小树存储空间中。  The method for storing a route prefix according to claim 1 or 2, further comprising: pointing the current layer small tree to a pointer of a first address of the small tree storage space corresponding to the next layer of the small tree, and storing the pointer to the current layer The small tree corresponds to the small tree storage space.
5、 根据权利要求 1或 2所述的路由前缀存储方法, 其特征在于, 为每棵 小树的每个节点设置位置域信息之前包括:  The method for storing a route prefix according to claim 1 or 2, wherein before the location domain information is set for each node of each small tree, the method includes:
判断划分出的小树的层数是否小于或等于预设层数阈值; 如果判断结果 为是, 执行为每棵小树的每个节点设置位置域信息的操作。 Determining whether the number of layers of the divided small tree is less than or equal to a preset layer threshold; As a result, an operation of setting location domain information for each node of each small tree is performed.
6、 一种路由地址查找方法, 其特征在于, 包括:  A routing address searching method, comprising:
按照小树的层数顺序, 从第一层小树的第一个节点开始, 根据各层小树 对应的小树存储空间中存储的各个节点的位置域信息对待查找的路由前缀进 行匹配查找; 所述位置域信息包括所述节点的父节点到所述节点的路径长度 和路径、 标识所述节点是否有下一跳地址的路由标识和标识所述节点是否存 在子节点的子节点标识;  According to the order of the number of layers of the small tree, starting from the first node of the first layer of the small tree, matching the searched route prefixes according to the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree; The location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a child node identifier that identifies whether the node has a child node;
如果匹配到最长前缀节点, 根据存储匹配到的最长前缀节点的小树存储 空间中指向连续存储下一跳地址的地址存储空间的首地址的指针和匹配到的 最长前缀节点的位置, 从连续存储下一跳地址的地址存储空间中获取所述路 由前缀的下一跳地址。  If the longest prefix node is matched, the pointer to the first address of the address storage space that continuously stores the next hop address and the location of the longest prefix node that is matched are stored according to the storage space of the longest prefix node that matches the longest prefix node. The next hop address of the route prefix is obtained from an address storage space in which the next hop address is continuously stored.
7、 根据权利要求 6所述的路由地址查找方法, 其特征在于, 根据所述小 树存储空间中存储的各个节点的位置域信息对待查找的路由前缀进行匹配查 找包括:  The routing address searching method according to claim 6, wherein the matching of the route prefix to be searched according to the location domain information of each node stored in the small tree storage space includes:
判断所述小树存储空间中当前节点的父节点到当前节点的路径是否与所 述路由前缀当前匹配到的部分相一致;  Determining whether the path of the parent node of the current node in the small tree storage space to the current node is consistent with the current matching part of the route prefix;
如果相一致, 根据所述小树存储空间中当前节点的路由标识, 确定当前 节点是否有下一跳地址, 如果当前节点有下一跳地址, 则记录当前节点的位 置并标识具有下一跳地址, 并根据所述小树存储空间中的子节点标识, 判断 当前节点是否存在子节点; 如果当前节点存在子节点, 继续查询所述子节点; 如果当前节点不存在子节点, 结束对所述路由前缀的查找;  If they are consistent, determine whether the current node has a next hop address according to the route identifier of the current node in the small tree storage space. If the current node has a next hop address, record the current node location and identify the next hop address. And determining, according to the child node identifier in the small tree storage space, whether the current node has a child node; if the current node has a child node, continuing to query the child node; if the current node does not have a child node, ending the routing Lookup of the prefix;
如果不一致, 结束对所述路由前缀的查找。  If not, the search for the route prefix is ended.
8、 一种路由前缀存储装置, 其特征在于, 包括:  8. A route prefix storage device, comprising:
小树划分模块, 用于根据待存储的路由前缀建立路径压缩树, 并将所述 路径压缩树根据小树存储空间的大小划分为一棵或多棵小树, 每棵小树包括 多个节点;  a small tree partitioning module, configured to establish a path compression tree according to the route prefix to be stored, and divide the path compression tree into one or more small trees according to the size of the small tree storage space, where each small tree includes multiple nodes ;
信息设置模块, 用于为每棵小树的每个节点设置位置域信息, 所述位置 域信息包括所述节点的父节点到所述节点的路径长度和路径、 标识所述节点 是否有下一跳地址的路由标识和标识所述节点是否存在子节点的子节点标 识; 存储模块, 用于按照划分出的小树的层数顺序, 依次将每棵小树所有节 点的位置域信息和每棵小树指向连续存储所述路由前缀对应的所有下一跳地 址的地址存储空间的首地址的指针, 存储到每棵小树所对应的小树存储空间 中。 An information setting module, configured to set location domain information for each node of each small tree, where the location domain information includes a path length and a path of a parent node of the node to the node, and whether the node has a next a route identifier of the hop address and a child node identifier that identifies whether the node has a child node; a storage module, configured to sequentially store location domain information of all nodes of each small tree and each small tree to address consecutively storing addresses of all next hop addresses corresponding to the routing prefix according to the hierarchical order of the divided small trees. A pointer to the first address of the space is stored in the small tree storage space corresponding to each small tree.
9、 根据权利要求 8所述的路由前缀存储装置, 其特征在于, 所述信息设 置模块包括:  The routing prefix storage device according to claim 8, wherein the information setting module comprises:
第一设置单元, 用于对每个节点, 用 2比特对所述子节点标识进行编码, 如果所述节点没有子节点, 所述子节点标识用 00表示, 如果所述节点仅有一 个左子节点, 所述子节点标识用 10表示, 如果所述节点仅有一个右子节点, 所述子节点标识用 01表示, 如果所述节点同时有左子节点和右子节点, 所述 子节点标识用 1 1表示;  a first setting unit, configured to encode the child node identifier by 2 bits for each node, if the node has no child nodes, the child node identifier is represented by 00, if the node has only one left child a node, the child node identifier is represented by 10, if the node has only one right child node, the child node identifier is represented by 01, and if the node has both a left child node and a right child node, the child node identifier Expressed by 1 1;
第二设置单元, 用于对每个节点, 用 1 比特对所述路由标识进行编码, 如果所述节点有下一跳地址, 所述路由标识用 1表示, 如果所述节点没有下 一跳地址, 所述路由节点用 0表示;  a second setting unit, configured to encode the route identifier by using 1 bit for each node, if the node has a next hop address, the route identifier is represented by 1, if the node does not have a next hop address The routing node is represented by 0;
第三设置单元, 用于设置所述节点的父节点到所述节点的路径长度和路 径。  And a third setting unit, configured to set a path length and a path of the parent node of the node to the node.
10、 根据权利要求 8或 9所述的路由前缀存储装置, 其特征在于, 所述 存储模块还用于将所述路由前缀对应的所有下一跳地址连续存储到所述地址 存储空间中。  The routing prefix storage device according to claim 8 or 9, wherein the storage module is further configured to continuously store all next hop addresses corresponding to the routing prefix into the address storage space.
1 1、 根据权利要求 8或 9所述的路由前缀存储装置, 其特征在于, 所述 存储模块还用于将当前层小树指向下一层小树对应的小树存储空间的首地址 的指针, 存储到当前层小树对应的小树存储空间中。  The routing prefix storage device according to claim 8 or 9, wherein the storage module is further configured to point the current layer small tree to a pointer of a first address of a small tree storage space corresponding to the next layer of the small tree. , stored in the small tree storage space corresponding to the current layer small tree.
12、 根据权利要求 8或 9所述的路由前缀存储装置, 其特征在于, 还包 括:  The routing prefix storage device according to claim 8 or 9, further comprising:
判断模块, 用于在所述信息设置模块为每棵小树的每个节点设置位置域 信息之前, 判断划分出的小树的层数是否小于或等于预设层数阈值, 如果判 断结果为是,触发所述信息设置模块为每棵小树的每个节点设置位置域信息。  a judging module, configured to determine, before the information setting module sets location domain information for each node of each small tree, whether the number of layers of the divided small tree is less than or equal to a preset layer threshold, and if the judgment result is yes The information setting module is triggered to set location domain information for each node of each small tree.
13、 一种路由地址查找装置, 其特征在于, 包括:  13. A routing address searching device, comprising:
查找模块, 用于按照小树的层数顺序, 从第一层小树的第一个节点开始, 根据各层小树对应的小树存储空间中存储的各个节点的位置域信息对待查找 的路由前缀进行匹配查找; 所述位置域信息包括所述节点的父节点到所述节 点的路径长度和路径、 标识所述节点是否有下一跳地址的路由标识和标识所 述节点是否存在子节点的子节点标识; a search module, configured to start from the first node of the first layer of the small tree according to the layer sequence of the small tree, and to find the location domain information of each node stored in the small tree storage space corresponding to each layer of the small tree The route prefix performs a matching search; the location domain information includes a path length and a path of the parent node of the node to the node, a route identifier that identifies whether the node has a next hop address, and a flag indicating whether the node exists. The child node identifier of the node;
获取模块, 用于在所述查找模块匹配到最长前缀节点, 根据存储匹配到 的最长前缀节点的小树存储空间中指向连续存储下一跳地址的地址存储空间 的首地址的指针和匹配到的最长前缀节点的位置, 从连续存储下一跳地址的 地址存储空间中获取所述路由前缀的下一跳地址。  An obtaining module, configured to match, to the longest prefix node, the pointer and the matching of the first address of the address storage space that continuously stores the next hop address in the small tree storage space of the longest prefix node that is matched to the storage The location of the longest prefix node to which the next hop address of the route prefix is obtained from the address storage space in which the next hop address is continuously stored.
14、 根据权利要求 13所述的路由地址查找装置, 其特征在于, 所述查找 模块具体用于判断所述小树存储空间中当前节点的父节点到当前节点的路径 是否与所述路由前缀当前匹配到的部分相一致; 如果相一致, 根据所述小树 存储空间中当前节点的路由标识, 确定当前节点是否有下一跳地址, 如果当 前节点有下一跳地址, 则记录当前节点的位置并标识具有下一跳地址, 并根 据所述小树存储空间中的子节点标识, 判断当前节点是否存在子节点; 如果 当前节点存在子节点, 继续查询所述子节点; 如果当前节点不存在子节点, 结束对所述路由前缀的查找; 如果不一致, 结束对所述路由前缀的查找。  The routing address locating device according to claim 13, wherein the searching module is specifically configured to determine whether a path of a parent node of the current node in the small tree storage space to a current node is current with the route prefix. The matched parts are consistent; if they are consistent, determining whether the current node has a next hop address according to the routing identifier of the current node in the small tree storage space, and if the current node has a next hop address, recording the current node location And identifying the next hop address, and determining whether the current node has a child node according to the child node identifier in the small tree storage space; if the current node has a child node, continuing to query the child node; if the current node does not exist The node ends the lookup of the route prefix; if not, ends the lookup of the route prefix.
PCT/CN2011/083242 2011-11-30 2011-11-30 Route prefix storage method and device and route address searching method and device WO2013078644A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2011/083242 WO2013078644A1 (en) 2011-11-30 2011-11-30 Route prefix storage method and device and route address searching method and device
CN201180002985.6A CN103404092B (en) 2011-11-30 2011-11-30 Route prefix storage means, device and routing address lookup method, device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/083242 WO2013078644A1 (en) 2011-11-30 2011-11-30 Route prefix storage method and device and route address searching method and device

Publications (1)

Publication Number Publication Date
WO2013078644A1 true WO2013078644A1 (en) 2013-06-06

Family

ID=48534625

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/083242 WO2013078644A1 (en) 2011-11-30 2011-11-30 Route prefix storage method and device and route address searching method and device

Country Status (2)

Country Link
CN (1) CN103404092B (en)
WO (1) WO2013078644A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110800008A (en) * 2019-03-04 2020-02-14 阿里巴巴集团控股有限公司 Building block chain world state mercker patricia dictionary tree subtree
CN112527753A (en) * 2020-12-11 2021-03-19 平安科技(深圳)有限公司 DNS analysis record lossless compression method and device, electronic equipment and storage medium
CN115567444A (en) * 2022-09-23 2023-01-03 北京香哈网络股份有限公司 Controller routing address searching and calling method and system

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090942A (en) * 2014-06-30 2014-10-08 中国电子科技集团公司第三十二研究所 Trie search method and device applied to network processor
CN106330721B (en) * 2015-06-30 2019-09-17 新华三技术有限公司 IP method for searching route and device
CN106330716B (en) * 2015-06-30 2019-12-13 新华三技术有限公司 IP route searching method and device
CN111641729B (en) * 2019-05-23 2021-03-30 北京航空航天大学 Inter-domain path identification prefix conflict detection and decomposition method based on prefix tree
CN113133052B (en) * 2020-01-13 2023-01-13 中国移动通信有限公司研究院 Path selection method and device and IAB base station
CN112134805B (en) * 2020-09-23 2022-07-08 中国人民解放军陆军工程大学 Fast route updating circuit structure and updating method based on hardware implementation
CN117150086B (en) * 2023-09-12 2024-03-22 北京云枢创新软件技术有限公司 Hierarchical tree-based child node generation method, electronic equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030236793A1 (en) * 2002-06-19 2003-12-25 Ericsson Inc. Compressed prefix tree structure and method for traversing a compressed prefix tree
CN101459569A (en) * 2008-12-12 2009-06-17 华为技术有限公司 Method, apparatus for establishing route index tree and method, apparatus for searching route index tree
CN101645844A (en) * 2009-08-14 2010-02-10 华为技术有限公司 Methods and devices for storing and searching route
CN102045412A (en) * 2010-12-28 2011-05-04 赛尔网络有限公司 Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030236793A1 (en) * 2002-06-19 2003-12-25 Ericsson Inc. Compressed prefix tree structure and method for traversing a compressed prefix tree
CN101459569A (en) * 2008-12-12 2009-06-17 华为技术有限公司 Method, apparatus for establishing route index tree and method, apparatus for searching route index tree
CN101645844A (en) * 2009-08-14 2010-02-10 华为技术有限公司 Methods and devices for storing and searching route
CN102045412A (en) * 2010-12-28 2011-05-04 赛尔网络有限公司 Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110800008A (en) * 2019-03-04 2020-02-14 阿里巴巴集团控股有限公司 Building block chain world state mercker patricia dictionary tree subtree
CN110800008B (en) * 2019-03-04 2023-06-30 创新先进技术有限公司 Building a blockchain world state merker patril Xia Zidian tree subtree
CN112527753A (en) * 2020-12-11 2021-03-19 平安科技(深圳)有限公司 DNS analysis record lossless compression method and device, electronic equipment and storage medium
CN112527753B (en) * 2020-12-11 2023-05-26 平安科技(深圳)有限公司 DNS analysis record lossless compression method and device, electronic equipment and storage medium
CN115567444A (en) * 2022-09-23 2023-01-03 北京香哈网络股份有限公司 Controller routing address searching and calling method and system
CN115567444B (en) * 2022-09-23 2024-02-27 北京香哈网络股份有限公司 Controller routing address searching and calling method and system

Also Published As

Publication number Publication date
CN103404092A (en) 2013-11-20
CN103404092B (en) 2015-11-25

Similar Documents

Publication Publication Date Title
WO2013078644A1 (en) Route prefix storage method and device and route address searching method and device
CN102484610B (en) Routing table construction method and device and routing table lookup method and device
US8325721B2 (en) Method for selecting hash function, method for storing and searching routing table and devices thereof
CN103595637B (en) Based on tree and the content center network node processing data method of Hash table
CN101594319B (en) Entry lookup method and entry lookup device
CN102333036B (en) Method and system for realizing high-speed routing lookup
US8923298B2 (en) Optimized trie-based address lookup
CN102405622A (en) Methods and devices for binary tree construction, compression and lookup
WO2008014188A1 (en) Dynamic tree bitmap for ip lookup and update
WO2015127721A1 (en) Data matching method and apparatus and computer storage medium
WO2011085577A1 (en) Classification method and device for packets
WO2017000893A1 (en) Ip routing lookup
CN103051543A (en) Route prefix processing, lookup, adding and deleting method
CN107948060A (en) A kind of new routing table is established and IP method for searching route and device
CN101110778A (en) Method for compressing path transmitting table by router
CN102045412B (en) Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix
WO2009132556A1 (en) A data searching method and apparatus
WO2011124030A1 (en) Method and device for storing routing table entry
WO2008119242A1 (en) Method for traversal of multi-bit trie tree
WO2008028412A1 (en) A routing method, a routing apparatus and a method for storing routing information
WO2010054599A1 (en) Method, device and system for storing data
CN113315705A (en) Flexible IP addressing method and device based on single Hash bloom filter
EP3018871B1 (en) Content name compression method and apparatus
CN117435912A (en) Data packet index and retrieval method based on network data packet attribute value length characteristics
CN108566335B (en) Network topology generation method based on NetFlow

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11876754

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11876754

Country of ref document: EP

Kind code of ref document: A1