WO2016184069A1 - Route lookup method and device - Google Patents

Route lookup method and device Download PDF

Info

Publication number
WO2016184069A1
WO2016184069A1 PCT/CN2015/095448 CN2015095448W WO2016184069A1 WO 2016184069 A1 WO2016184069 A1 WO 2016184069A1 CN 2015095448 W CN2015095448 W CN 2015095448W WO 2016184069 A1 WO2016184069 A1 WO 2016184069A1
Authority
WO
WIPO (PCT)
Prior art keywords
routing
storage structure
level tree
entry
tree storage
Prior art date
Application number
PCT/CN2015/095448
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 中兴通讯股份有限公司
Publication of WO2016184069A1 publication Critical patent/WO2016184069A1/en

Links

Images

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/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/02Topology update or discovery

Definitions

  • the present invention relates to the field of route optimization, and in particular, to a route query method and apparatus.
  • the packet forwarding capability is at least 20Mpps and supports at least 250,000 forwarding routes.
  • Clustering technology emerged as a single router could not continue to scale to meet demand.
  • the cluster system can work well between the single routers of each router, which greatly expands the capacity of the router. Since the cluster router is only embodied as a router, the network topology and routing strategy become simple and clear. However, the router cluster system involves many individual devices. When the system is running at full load, while ensuring high reliability and high stability, the routing query speed between multiple routers plays a crucial role in the performance of the high-speed router.
  • the switching device After learning a routing entry, the switching device stores it in a software layer routing table for soft forwarding by a central processing unit (CPU), and then sends it to the forwarding chip for hardware implementation.
  • Layer-forward hardware layer routing table When a routing entry needs to be updated or deleted, the CPU needs to query the routing table entry from the software layer routing table, and then update or delete it. Finally, the hardware layer routing table in the forwarding chip is updated or deleted. Therefore, the query efficiency of the routing entry of the software layer directly affects the progress of the routing entry being sent to the hardware layer, which affects the progress of packet hardware layer forwarding.
  • the query efficiency of software layer routing entries usually depends on how the routing entries are stored. The cluster system routing table storage mode has a more obvious impact on routing query efficiency.
  • IP route storage methods are mostly based on a tree.
  • the public network and each virtual private network (VPN) occupy a tree and use the IP address prefix as a tree. node.
  • IP address prefix with a maximum length of 32 bits, the depth of the tree is 32 layers. Then, when the IP address is used to traverse each layer in order from the root node of the tree to find the routing entry, it takes up to 32 searches to find it. The target node corresponding to the routing table entry is to be searched, so the query efficiency is low.
  • the present invention provides a route query method and device, which solves the problem that the route query speed is slow and the query efficiency is low in the prior art.
  • a route query method including:
  • the root node associated with the routing entry to be queried is searched to obtain the first routing cluster;
  • the routing cluster is a root node of the first-level tree storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
  • a second-level tree-shaped storage structure formed by a plurality of routing entries in a single routing device, searching for a root node associated with the routing entry to be queried, to obtain a first routing device; wherein, the first-level tree
  • the leaf node of the storage structure is the root node of the second-level tree storage structure, and the routing entry is the leaf node of the second-level tree storage structure;
  • the root node associated with the routing entry to be queried is obtained according to the routing entry to be queried, and the first node is obtained.
  • the steps of routing a cluster include:
  • the first hash address is obtained by using the routing entry to be queried as a key and calculating according to the first preset hash function; wherein the first hash address stores The routing cluster associated with the routing entry to be queried;
  • the candidate routing cluster is read in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
  • the step of searching for the root node associated with the routing entry to be queried includes:
  • the second hash address is obtained by using the routing entry to be queried as a key and calculating according to the second preset hash function; wherein, the second hash address stores The routing device associated with the routing entry to be queried;
  • the candidate routing device is read in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
  • the step of searching for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and returning the query structure includes:
  • the third hash address is obtained by using the routing entry to be queried as a key and calculating according to the third preset hash function; All routing entries of the first routing device are stored in the third hash address;
  • Reading the corresponding candidate routing entry in the third hash address if the candidate routing entry is the routing table to be queried If the item is found, the search succeeds; otherwise, the linear list is traversed to find the routing entry to be queried.
  • the root node associated with the routing entry to be queried is searched for according to the routing entry to be queried.
  • the cluster Before the step of routing the cluster, it also includes:
  • the first routing cluster is looked up in the first level tree storage structure.
  • the root node associated with the routing entry to be queried is searched for according to the routing entry to be queried.
  • the cluster Before the step of routing the cluster, it also includes:
  • the second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created, and the routing device is stored in the leaf node or the first level in the first-level tree storage structure.
  • the root node of the secondary tree storage structure In the root node of the secondary tree storage structure;
  • the routing table entry is stored in the leaf node of the second level tree storage structure.
  • the first-level tree-shaped storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the root of the first-level tree-shaped storage structure.
  • the steps in the node include:
  • a plurality of first hash addresses storing different routing clusters are constructed as root nodes of the first level tree storage structure.
  • the second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the leaf of the first-level tree-shaped storage structure.
  • the steps in the root node of the node or the second level tree storage structure include:
  • a plurality of second hash addresses storing different routing devices are constructed as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  • the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function includes:
  • a plurality of third hash addresses storing different routing table entries are constructed as leaf nodes of the second level tree storage structure.
  • the first level tree storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the first level tree storage structure.
  • the steps in the root node it also includes:
  • the frequent item is used as a key, and the first preset hash function is used to calculate, the first hash address is obtained, and the corresponding new routing cluster is stored in the first hash address, and the first level tree storage structure is updated. Root node.
  • the first level tree storage structure of the plurality of routing devices under the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the first level tree storage structure.
  • the steps in the root node it also includes:
  • the routing cluster in the corresponding first hash address is deleted, and the root node of the first-level tree storage structure is updated.
  • the second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the leaf of the first-level tree-shaped storage structure.
  • the frequent item is used as a key, and the second preset hash address is calculated according to the second preset hash function, and the corresponding new routing device is stored in the second new hash address to update the first level tree storage.
  • the second level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the first level tree storage structure.
  • the routing device stored in the corresponding second hash address is deleted, and the root node of the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
  • the method further includes:
  • the frequent item is used as a key, and the third preset hash function is calculated according to the third preset hash function, and the corresponding new routing entry is stored in the third hash address, and the second level tree storage is updated.
  • the method further includes:
  • the routing entry stored in the corresponding third hash address is deleted, and the leaf node of the second-level tree storage structure is updated.
  • a route query apparatus including:
  • the first search module is configured to search for a root node associated with the to-be-queried routing entry in a first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster according to the routing entry to be queried. Obtaining a first routing cluster; wherein the routing cluster is a root node of the first-level tree-shaped storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
  • a second search module configured to search for a root node associated with the routing entry to be queried in a second-level tree storage structure formed by a plurality of routing entries in a single routing device, to obtain a first routing device;
  • the leaf node of the first-level tree-shaped storage structure is a root node of the second-level tree-shaped storage structure, and the routing entry is a leaf node of the second-level tree-shaped storage structure;
  • the third search module is configured to search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
  • the first search module includes:
  • the first search unit is configured to perform, in the first-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the first preset hash function to obtain a first hash address; wherein, the first A hash cluster is stored with a route cluster associated with the routing entry to be queried;
  • the first reading unit is configured to read the corresponding candidate routing cluster in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
  • the second search module includes:
  • a second search unit is configured to perform, in the second-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the second preset hash function to obtain a second hash address; wherein, the second A routing device associated with the routing entry to be queried is stored in the hash address;
  • the second reading unit is configured to read the corresponding candidate routing device in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
  • the third search module includes:
  • the third search unit is configured to use the routing entry to be queried as a key in the second-level tree storage structure of the first routing device as the root node, and perform calculation according to the third preset hash function to obtain the first a three-hash address; wherein the third hash address stores all routing entries of the first routing device;
  • the third reading unit is configured to read the corresponding candidate routing entry in the third hash address, and if the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, traversing the linear linked list to find the routing table to be queried item.
  • the route querying device further includes:
  • the determining module is configured to obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent item; wherein the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold;
  • the first routing cluster is looked up in the first level tree storage structure.
  • the route querying device further includes:
  • the first creating module is configured to obtain a frequent item in multiple routing devices in a single routing cluster, and create a first-level tree of multiple routing devices in the routing cluster corresponding to the frequent item according to the first preset hash function. Storing the structure and storing the routing cluster in a root node in the first level tree storage structure;
  • the second creating module is configured to create a second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the first-level tree storage structure In the root node of the leaf node or the second level tree storage structure;
  • the third creating module is configured to store the routing entry in the leaf node of the second level tree storage structure according to the third preset hash function.
  • the first creating module includes:
  • a first calculating unit configured to use a frequent item as a key, and perform calculation according to the first preset hash function, Obtaining a first hash address, and storing the corresponding routing cluster in the first hash address;
  • the first creating unit is configured to construct a plurality of first hash addresses storing different routing clusters as root nodes of the first level tree storage structure.
  • the second creating module includes:
  • a second calculating unit configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding routing device in the second hash address;
  • the second creating unit is configured to construct a plurality of second hash addresses storing different routing devices as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  • the third creating module includes:
  • the third calculating unit is configured to use the routing entry as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding routing entry in the third hash address;
  • the third creating unit is configured to construct a plurality of third hash addresses storing different routing table entries as leaf nodes of the second level tree storage structure.
  • the route querying device further includes:
  • the first obtaining module is configured to acquire frequent items of the new routing cluster when adding a new routing cluster
  • the first update module is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding new routing cluster in the first hash address, and update The root node of the first level tree storage structure.
  • the route querying device further includes:
  • the second update module is configured to: when the routing cluster is reduced, delete the routing cluster in the corresponding first hash address, and update the root node of the first level tree storage structure.
  • the route querying device further includes:
  • the second obtaining module is configured to acquire a frequent item of the new routing device when adding a new routing device
  • the third update module is configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding new routing device in the second new hash address. Update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure.
  • the route querying device further includes:
  • the fourth update module is configured to: when the routing device is reduced, delete the routing device stored in the corresponding second hash address, and update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure point.
  • the route querying device further includes:
  • the third obtaining module is configured to acquire a frequent item of the new routing entry when the new routing entry is added;
  • the fifth update module is configured to use a frequent item as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding new routing entry in the third hash address. Update the leaf nodes of the second level tree storage structure.
  • the route querying device further includes:
  • the sixth update module is configured to: when the routing entry is reduced, delete the routing entry stored in the corresponding third hash address, and update the leaf node of the second-level tree storage structure.
  • the beneficial effects of the embodiment of the present invention are: a route query method and device, and searching for a route entry to be queried in a first-level tree storage structure based on a pre-created two-level tree storage structure
  • the first routing cluster searches for the first routing device associated with the routing entry to be queried in the first routing cluster, and then searches for the routing entry to be queried on the first routing device, and returns a query structure, where A routing device is a leaf node in a first level tree storage structure and a root node in a second level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.
  • FIG. 1 is a schematic flow chart showing a route query method of the present invention
  • FIG. 2 is a schematic view showing the specific flow of the step 10 in Figure 1;
  • FIG. 3 is a schematic view showing the specific flow of the step 20 in Figure 1;
  • FIG. 4 is a schematic diagram showing the specific flow of step 30 in FIG. 1;
  • FIG. 5 is a schematic diagram showing a specific process before step 10 is performed in FIG. 1;
  • FIG. 6 is a schematic diagram showing a process of creating a tree-shaped storage structure in an embodiment of the present invention.
  • Fig. 7 is a block diagram showing the structure of a route inquiring device of the present invention.
  • an embodiment of the present invention provides a route query method, which specifically includes the following steps:
  • Step 10 According to the routing entry to be queried, in the first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster, the root node associated with the routing entry to be queried is searched to obtain the first route. Cluster.
  • the routing cluster forms a root node of the first-level tree-shaped storage structure, and the routing device forms a leaf node of the first-level tree-shaped storage structure.
  • Step 20 In the second-level tree-shaped storage structure formed by the multiple routing entries of the single routing device, the root node associated with the routing entry to be queried is searched to obtain the first routing device.
  • the leaf node of the first-level tree-shaped storage structure is the root node of the second-level tree-shaped storage structure, and the routing entry is the leaf node of the second-level tree-shaped storage structure; that is, the routing device is the first-level tree.
  • the leaf node of the shape storage structure is the root node of the second level tree storage structure. That is to say, each routing cluster forms a first-level tree-shaped storage structure, and each routing device forms a second-level tree-shaped storage structure, so that after the first routing cluster is found, it can be under the first routing cluster. Finding a first routing device associated with the routing entry to be queried.
  • Step 30 Search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
  • the first routing device searches for the same leaf node as the routing entry to be queried, that is, whether the routing entry to be queried exists in the first routing device, and if so, The search succeeds, and if it does not exist, the search fails.
  • the route query method in the embodiment of the present invention is based on the pre-created two-level tree storage structure, and searches for the first route cluster associated with the to-be-queried routing entry in the first-level tree-shaped storage structure, and then in the first
  • the routing device searches for the first routing device associated with the routing entry to be queried, and then searches for the routing entry to be queried on the first routing device, and returns a query structure, where the first routing device is a first-level tree.
  • the leaf node in the storage structure is the root node in the second-level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.
  • the hash tree can be used in the embodiment of the present invention because the structure is simple, and the search speed is fast, and the hash algorithm can be replaced conveniently, so that it is often used to store key data.
  • the tree structure stores the routes. Step 10 can be specifically implemented by referring to the steps shown in FIG. 2:
  • Step 11 In the first-level tree-shaped storage structure, the first hash address is obtained by using the routing entry to be queried as a key and performing calculation according to the first preset hash function.
  • the first hash address stores a routing cluster associated with the routing entry to be queried; when the routing entry to be queried is used as the key K, and K is substituted into the root node of the first-level tree storage structure
  • the first preset hash function H_1 is used to calculate the first hash address H_1(K).
  • Step 12 The candidate routing cluster is read in the first hash address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
  • the corresponding candidate routing cluster is read in the first hash address H_1(K), and it is determined whether there is a routing entry to be queried in the candidate routing cluster, and if present, the candidate routing cluster is used as the first routing cluster.
  • the specific implementation manner of searching for the first routing device in step 20 is similar to the specific implementation manner of searching for the first routing cluster in step 10, and may be implemented by referring to the steps shown in FIG. 3:
  • Step 21 In the second-level tree-shaped storage structure, the second hash address is obtained by using the routing entry to be queried as a key and performing calculation according to the second preset hash function.
  • the second hash address stores a routing device associated with the routing entry to be queried; the routing entry to be queried is used as the key K, and K is substituted into the leaf node that creates the first-level tree-shaped storage structure or
  • the second preset hash function H_2 used in the root node of the second level tree storage structure calculates the second hash address H_2(K).
  • Step 22 The corresponding routing device is read in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
  • the corresponding candidate routing device is read in the second hash address H_2(K), and it is determined whether there is a routing entry to be queried in the candidate routing device, and if present, the candidate routing device is used as the first routing device.
  • step 30 can be implemented by referring specifically to the steps shown in FIG. 4:
  • Step 31 In the second-level tree-shaped storage structure in which the first routing device is the root node, use the routing entry to be queried as a key, and perform calculation according to the third preset hash function to obtain a third hash address. .
  • All the routing entries of the first routing device are stored in the third hash address, and the routing entry to be queried is used as the key K, and the K is used to create the leaf node of the second-level tree storage structure.
  • Step 32 The corresponding candidate routing entry is read in the third hash address. If the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, the linear linked list is traversed to find the routing entry to be queried.
  • the corresponding routing entry is read in the third hash address H_3(K) and compared with the routing entry to be queried. If they are equal, the search succeeds and the query structure is fed back; if not, Then, the next address is searched according to the method of processing conflicts when the tree storage structure is created, until the routing entry stored in an address is the same as the routing entry to be queried or when an address is not occupied. The search is stopped.
  • the conflicting routing entry is stored in the linear linked list. When the found routing entry is not equal to the routing entry to be queried, the linear linked list is traversed.
  • a linear linked list storage manner may also be adopted.
  • the route search method of the embodiment of the present invention as shown in FIG. 5, before step 10, may further include:
  • Step 01 Obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent entry.
  • the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold. For example, we can set the preset threshold to 0.001, so that when the entire routing system includes 100,000 routing entries, the routing entry A If the number of occurrences is greater than or equal to 100, the routing entry A is a frequent entry.
  • Step 02 If not, traverse the linear linked list to find the routing entry to be queried; if yes, look up the first routing cluster in the first-level tree storage structure.
  • step 10 the step of creating a tree storage structure as shown in FIG. 6 is further included.
  • Step 0A Acquire frequent items in multiple routing devices in a single routing cluster, and create a first-level tree storage structure of multiple routing devices in the routing cluster corresponding to the frequent items according to the first preset hash function, and The routing cluster is stored in the root node in the first level tree storage structure.
  • step 0A can be specifically implemented by referring to the following steps:
  • the frequent item is used as a key, and the calculation is performed according to the first preset hash function to obtain a first hash address, and the corresponding routing cluster is stored in the first hash address.
  • the first preset hash function is H_1
  • each frequent item K_i is substituted into the first preset hash function H_1 to obtain a first hash address H_1(K_i), and the routing cluster including the frequent item K_i is obtained.
  • a plurality of first hash addresses storing different routing clusters are constructed as root nodes of the first level tree storage structure.
  • Step 0B Create a second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the leaf node in the first-level tree-shaped storage structure. Point or the root node of the second level tree storage structure.
  • step 0B can be specifically implemented by referring to the following steps:
  • the second hash address is obtained, and the corresponding routing device is stored in the second hash address.
  • the second preset hash function is H_2
  • each frequent item K_i is substituted into the second preset hash function H_2 to obtain a second hash address H_2(K_i), and the routing cluster including the frequent item K_i is obtained.
  • a plurality of second hash addresses storing different routing devices are constructed as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  • Step 0C Store the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function.
  • step 0C can be specifically implemented by referring to the following steps:
  • the routing table entry is used as a key, and is calculated according to the third preset hash function to obtain a third hash address, and the corresponding routing entry is stored in the third hash address.
  • the third preset hash function is H_3, and each frequent item K_i is substituted into the third preset hash function H_3 to obtain a third hash address H_3 (K_i), and the routing cluster including the frequent item K_i is obtained. Stored in the third hash address H_3 (K_i).
  • a plurality of third hash addresses storing different routing table entries are constructed as leaf nodes of the second level tree storage structure.
  • the routing entries of a single routing device are stored in a tree structure.
  • the routing entry is used as the leaf node of the tree structure. If a routing entry is found on a routing device, In the case of K, the third preset hash function H_3, which is used when the K is built into the tree, is used to calculate the third hash address H_3(K), and the routing entry stored in the address is read, and the routing entry to be queried is read. K is compared. If they are equal, the query is successful. Otherwise, the linear list is traversed until the search fails or the search is successful.
  • the above-mentioned routing devices are divided into multiple routing clusters, and the support degree of each routing entry in each routing cluster is counted and calculated in parallel, and frequent items with a support degree higher than a preset threshold are obtained, and frequent items are supported. Sorting the descending order of the degree, sorting the routing devices according to the sorted frequent items list, and then calculating the second hash address according to the routing table entry K and according to the second preset hash function H_2 in the divided group. The corresponding routing device is stored in the second hash address, that is, a complete tree storage structure is formed in each of the individual routing clusters.
  • the routing cluster is regarded as a whole, and a plurality of different routing clusters are stored in different first hash addresses by using a preset first hash function H_1.
  • the tree storage structure changes, which involves updating the tree storage structure.
  • This section describes how to update the tree storage structure when frequent items, routing devices, or routing clusters change.
  • Case 1 When the frequent items change, the data stored in the first hash address, the second hash address, and the third hash address in the old frequent item mapping relationship is deleted, and the first hash under the new frequent item mapping relationship is added. Data stored in the hash address, the second hash address, and the third hash address to implement updating of data in the tree storage structure. Specifically, refer to the following steps:
  • the first-level tree storage structure is updated to be the same as the original first-level tree storage structure.
  • Step 3 can be specifically referred to as follows:
  • nNode nItem ⁇ L ⁇ _ ⁇ 1, and the routing entry to be queried in the route set appearing in the frequent list intersects the difference set ⁇ L ⁇ _ ⁇ 1 to find a new nNode;
  • Case 2 When a new route cluster is added to cause frequent item changes, the frequent items of the new route cluster are obtained, and the frequent items are used as keywords, and the first preset hash function is used to calculate, and the first hash address is obtained. And storing the corresponding new routing cluster in the first hash address, and updating the root node of the first level tree storage structure.
  • [L]_ ⁇ 2 L_ ⁇ (DP1@)+L_dP1-L_1, where L_DP1 is the item set of routing entry 1 in the original routing cluster under the new frequent item, and L_DP1 is the new route under the new frequent item.
  • the item set of the routing entry 1 of the cluster, L_1 is the item set of the routing entry 1 of the original routing cluster under the original frequent item; and then the routing cluster stored in the first hashing address is updated by the difference [L]_ ⁇ 2.
  • the new route cluster may cause frequent items to change. Therefore, you need to obtain frequent items again.
  • the frequent items refer to the following:
  • the support number of each path is calculated by the updated tree storage structure; by determining whether the support number of the item in c_ ⁇ k is not less than the new threshold s', Get the item set of the new frequent item routing entry k.
  • the item set L_dP1 of the frequent item routing entry k of the newly added routing cluster is obtained.
  • the frequent item is used as a key, and the second preset hash address is calculated according to the second preset hash function, and the corresponding new routing device is stored in the second new hash address to update the first level tree storage.
  • Case 5 When the routing device is reduced, the routing device stored in the corresponding second hash address is deleted, and the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
  • the frequent item is used as a key, and the third preset hash function is calculated according to the third preset hash function, and the corresponding new routing entry is stored in the third hash address, and the second level tree storage is updated.
  • a route query device as shown in FIG. 7, includes:
  • the first search module 101 is configured to search for a root node associated with the routing entry to be queried in the first-level tree storage structure formed by multiple routing devices in a single routing cluster according to the routing entry to be queried. Obtaining a first routing cluster; wherein the routing cluster is a root node of the first-level tree-shaped storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
  • the second search module 102 is configured to search for a root node associated with the routing entry to be queried in the second-level tree storage structure formed by the multiple routing entries of the single routing device, to obtain the first routing device.
  • the leaf node of the first level tree storage structure is the root node of the second level tree storage structure
  • the routing table entry is the leaf node of the second level tree storage structure
  • the third search module 103 is configured to search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
  • the first searching module 101 includes:
  • the first search unit is configured to perform, in the first-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the first preset hash function to obtain a first hash address; wherein, the first A hash cluster is stored with a route cluster associated with the routing entry to be queried;
  • the first reading unit is configured to read the corresponding candidate routing cluster in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
  • the second search module 102 includes:
  • a second search unit is configured to perform, in the second-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the second preset hash function to obtain a second hash address; wherein, the second A routing device associated with the routing entry to be queried is stored in the hash address;
  • the second reading unit is configured to read the corresponding candidate routing device in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
  • the third lookup module 103 includes:
  • the third search unit is configured to use the routing entry to be queried as a key in the second-level tree storage structure of the first routing device as the root node, and perform calculation according to the third preset hash function to obtain the first a three-hash address; wherein the third hash address stores all routing entries of the first routing device;
  • the third reading unit is configured to read the corresponding candidate routing entry in the third hash address, and if the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, traversing the linear linked list to find the routing table to be queried item.
  • the route querying device further includes:
  • the determining module is configured to obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent item; wherein the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold;
  • the first routing cluster is looked up in the first level tree storage structure.
  • the route querying device further includes:
  • the first creating module is configured to obtain a frequent item in multiple routing devices in a single routing cluster, and create a first-level tree of multiple routing devices in the routing cluster corresponding to the frequent item according to the first preset hash function. Storing the structure and storing the routing cluster in a root node in the first level tree storage structure;
  • the second creating module is configured to create a second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the first-level tree storage structure In the root node of the leaf node or the second level tree storage structure;
  • the third creating module is configured to store the routing entry in the leaf node of the second level tree storage structure according to the third preset hash function.
  • the first creating module includes:
  • the first calculating unit is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding routing cluster in the first hash address;
  • the first creating unit is configured to construct a plurality of first hash addresses storing different routing clusters as root nodes of the first level tree storage structure.
  • the second creating module includes:
  • a second calculating unit configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding routing device in the second hash address;
  • the second creating unit is configured to construct a plurality of second hash addresses storing different routing devices as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  • the third creating module includes:
  • the third calculating unit is configured to use the routing entry as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding routing entry in the third hash address;
  • the third creating unit is configured to construct a plurality of third hash addresses storing different routing table entries as leaf nodes of the second level tree storage structure.
  • the route querying device further includes:
  • the first obtaining module is configured to acquire frequent items of the new routing cluster when adding a new routing cluster
  • the first update module is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding new routing cluster in the first hash address, and update The root node of the first level tree storage structure.
  • the route querying device further includes:
  • the second update module is configured to: when the routing cluster is reduced, delete the routing cluster in the corresponding first hash address, and update the root node of the first level tree storage structure.
  • the route querying device further includes:
  • the second obtaining module is configured to acquire a frequent item of the new routing device when adding a new routing device
  • the third update module is configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding new routing device in the second new hash address. Update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure.
  • the route querying device further includes:
  • the fourth update module is configured to: when the routing device is reduced, delete the routing device stored in the corresponding second hash address, and update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure point.
  • the route querying device further includes:
  • the third obtaining module is configured to acquire a frequent item of the new routing entry when the new routing entry is added;
  • the fifth update module is configured to use a frequent item as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding new routing entry in the third hash address. Update the leaf nodes of the second level tree storage structure.
  • the route querying device further includes:
  • the sixth update module is configured to: when the routing entry is reduced, delete the routing entry stored in the corresponding third hash address, and update the leaf node of the second-level tree storage structure.
  • the route querying device is a device corresponding to the above-mentioned route query method, and all the implementation manners in the foregoing method embodiments are suitable for the embodiment of the device, and the same technical effects can be achieved.
  • the technical solution provided by the embodiment of the present invention is applied to a route query process, and a pre-created two-level tree storage structure is used in the process, and the first-level tree-shaped storage structure is searched for related to the to-be-queried routing entry.
  • the first routing cluster is connected to the first routing device, and then the first routing device associated with the routing entry to be queried is searched for, and then the routing entry to be queried is searched for by the first routing device, and the query structure is returned.
  • the first routing device is a leaf node in the first level tree storage structure and a root node in the second level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Disclosed are a route lookup method and device. The method comprises: searching, based on a pre-built two-tier tree-shaped storage structure, a first tier of the tree-shaped storage structure for a first route cluster associated with a route table entry to be queried; searching the first route cluster for a first routing apparatus associated with the route table entry to be queried; and searching the first routing apparatus for the route table entry to be queried, and returning a lookup structure, wherein the first routing apparatus is a leaf node of the first tier of the tree-shaped storage structure, and is also a root node of a second tier of the tree-shaped storage structure. The lookup structure of the route table entry to be queried can be obtained by performing the lookup three times only, thereby significantly speeding up the route lookup process.

Description

一种路由查询方法及装置Route query method and device 技术领域Technical field
本发明涉及路由优化领域,尤其涉及一种路由查询方法及装置。The present invention relates to the field of route optimization, and in particular, to a route query method and apparatus.
背景技术Background technique
对于高速路由器的包转发能力至少达到20Mpps以上,支持转发路由至少25万条以上。在单台路由器无法继续扩展以适应需求的情况下,集群化技术应运而生。集群系统能够在各台路由器单机之间很好的协同工作,极大的扩展了路由器的容量,由于集群路由器对外仅体现为一台路由器,使得网络拓扑和路由策略变得简单和清晰。但路由器集群系统涉及设备个体较多,当系统满负荷运行时,在保证高可靠性和高稳定性同时,多台路由器之间交换路由查询速度,对高速路由器的性能有着至关重要的作用。For high-speed routers, the packet forwarding capability is at least 20Mpps and supports at least 250,000 forwarding routes. Clustering technology emerged as a single router could not continue to scale to meet demand. The cluster system can work well between the single routers of each router, which greatly expands the capacity of the router. Since the cluster router is only embodied as a router, the network topology and routing strategy become simple and clear. However, the router cluster system involves many individual devices. When the system is running at full load, while ensuring high reliability and high stability, the routing query speed between multiple routers plays a crucial role in the performance of the high-speed router.
交换设备在学习到某路由表项后,会先存放至供中央处理器(Central Processing Unit,简称为CPU)进行软转发的软件层路由表中,然后再下发至转发芯片中用于实现硬件层转发的硬件层路由表。当需要更新或删除某条路由表项时,需要CPU先从软件层路由表中查询到该路由表项,然后再予以更新或删除,最后才会更新或删除转发芯片中的硬件层路由表。因此,软件层路由表项的查询效率将直接影响到路由表项下发至硬件层的进度,从而影响报文硬件层转发的进度。而软件层路由表项的查询效率通常取决于路由表项的存储方式。集群系统路由表存储方式对于路由查询效率影响更明显。After learning a routing entry, the switching device stores it in a software layer routing table for soft forwarding by a central processing unit (CPU), and then sends it to the forwarding chip for hardware implementation. Layer-forward hardware layer routing table. When a routing entry needs to be updated or deleted, the CPU needs to query the routing table entry from the software layer routing table, and then update or delete it. Finally, the hardware layer routing table in the forwarding chip is updated or deleted. Therefore, the query efficiency of the routing entry of the software layer directly affects the progress of the routing entry being sent to the hardware layer, which affects the progress of packet hardware layer forwarding. The query efficiency of software layer routing entries usually depends on how the routing entries are stored. The cluster system routing table storage mode has a more obvious impact on routing query efficiency.
现有网协(Internet Protocol,简称为IP)路由存储方式大多基于树形,公网和每个虚拟专用网络(Virtual Private Network,简称为VPN)分别占用一棵树,并利用IP地址前缀作为树节点。对于最大长度为32位的IP地址前缀来说,树的深度即为32层,那么利用IP地址从树的根节点依次遍历每一层来查找路由表项时,最多需要32次查找才能够找到待查找路由表项所对应的目标节点,因而查询效率较低。The existing Internet Protocol (IP) route storage methods are mostly based on a tree. The public network and each virtual private network (VPN) occupy a tree and use the IP address prefix as a tree. node. For an IP address prefix with a maximum length of 32 bits, the depth of the tree is 32 layers. Then, when the IP address is used to traverse each layer in order from the root node of the tree to find the routing entry, it takes up to 32 searches to find it. The target node corresponding to the routing table entry is to be searched, so the query efficiency is low.
发明内容Summary of the invention
为了解决上述技术问题,本发明提供了一种路由查询方法及装置,解决了现有技术中路由查询速度慢,查询效率低的问题。In order to solve the above technical problem, the present invention provides a route query method and device, which solves the problem that the route query speed is slow and the query efficiency is low in the prior art.
依据本发明实施例的一个方面,提供了一种路由查询方法,包括: According to an aspect of the embodiments of the present invention, a route query method is provided, including:
根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群;其中,路由集群为第一级树形存储结构的根结点,路由设备为第一级树形存储结构的叶子结点;According to the routing entry to be queried, in the first-level tree-shaped storage structure formed by the multiple routing devices in the single routing cluster, the root node associated with the routing entry to be queried is searched to obtain the first routing cluster; The routing cluster is a root node of the first-level tree storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由设备;其中,第一级树形存储结构的叶子结点为第二级树形存储结构的根结点,路由表项为第二级树形存储结构的叶子结点;In a second-level tree-shaped storage structure formed by a plurality of routing entries in a single routing device, searching for a root node associated with the routing entry to be queried, to obtain a first routing device; wherein, the first-level tree The leaf node of the storage structure is the root node of the second-level tree storage structure, and the routing entry is the leaf node of the second-level tree storage structure;
在第二级树形存储结构的根结点下查找与待查询路由表项相同的叶子结点,并返回查询结果。Find the leaf node that is the same as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
可选地,根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群的步骤包括:Optionally, in the first-level tree-shaped storage structure formed by the multiple routing devices in the single routing cluster, the root node associated with the routing entry to be queried is obtained according to the routing entry to be queried, and the first node is obtained. The steps of routing a cluster include:
在第一级树形存储结构中,以待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址;其中,第一哈希地址中存储有与待查询路由表项相关联的路由集群;In the first-level tree-shaped storage structure, the first hash address is obtained by using the routing entry to be queried as a key and calculating according to the first preset hash function; wherein the first hash address stores The routing cluster associated with the routing entry to be queried;
在第一哈希地址中读取对应的候选路由集群,若候选路由集群中包括待查询路由表项,则将候选路由集群作为第一路由集群。The candidate routing cluster is read in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
可选地,在由单个路由设备下多个路由表项形成的第二级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由设备的步骤包括:Optionally, in the second-level tree-shaped storage structure formed by the multiple routing entries of the single routing device, the step of searching for the root node associated with the routing entry to be queried, the step of obtaining the first routing device includes:
在第二级树形存储结构中,以待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址;其中,第二哈希地址中存储有与待查询路由表项相关联的路由设备;In the second-level tree-shaped storage structure, the second hash address is obtained by using the routing entry to be queried as a key and calculating according to the second preset hash function; wherein, the second hash address stores The routing device associated with the routing entry to be queried;
在第二哈希地址中读取对应的候选路由设备,若候选路由设备中包括待查询路由表项,则将候选路由设备作为第一路由设备。The candidate routing device is read in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
可选地,在第二级树形存储结构的根结点下查找与待查询路由表项相同的叶子结点,并返回查询结构的步骤包括:Optionally, the step of searching for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and returning the query structure includes:
在第一路由设备为根结点的第二级树形存储结构中,以待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址;其中,第三哈希地址中存储有第一路由设备的全部路由表项;In the second-level tree-shaped storage structure in which the first routing device is the root node, the third hash address is obtained by using the routing entry to be queried as a key and calculating according to the third preset hash function; All routing entries of the first routing device are stored in the third hash address;
在第三哈希地址中读取对应的候选路由表项,若候选路由表项为待查询路由表 项,则查找成功;否则,遍历线性链表查找待查询路由表项。Reading the corresponding candidate routing entry in the third hash address, if the candidate routing entry is the routing table to be queried If the item is found, the search succeeds; otherwise, the linear list is traversed to find the routing entry to be queried.
可选地,在根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群的步骤之前,还包括:Optionally, in the first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster, the root node associated with the routing entry to be queried is searched for according to the routing entry to be queried. Before the step of routing the cluster, it also includes:
获取待查询路由表项,并判断待查询路由表项是否为预设频繁项;其中,预设频繁项为占有率高于预设阈值的路由表项;Obtaining a routing entry to be queried, and determining whether the routing entry to be queried is a preset frequent entry; wherein the preset frequent entry is a routing entry whose occupation rate is higher than a preset threshold;
若不是,则遍历线性链表查找待查询路由表项;If not, traverse the linear linked list to find the routing entry to be queried;
若是,则在第一级树形存储结构中查找第一路由集群。If so, the first routing cluster is looked up in the first level tree storage structure.
可选地,在根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群的步骤之前,还包括:Optionally, in the first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster, the root node associated with the routing entry to be queried is searched for according to the routing entry to be queried. Before the step of routing the cluster, it also includes:
获取单个路由集群下多个路由设备中的频繁项,并根据第一预设哈希函数,创建频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中;Obtaining a frequent entry in a plurality of routing devices in a single routing cluster, and creating a first-level tree storage structure of multiple routing devices in the routing cluster corresponding to the frequent items according to the first preset hash function, and storing the routing clusters In the root node in the first level tree storage structure;
根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中;According to the second preset hash function, the second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created, and the routing device is stored in the leaf node or the first level in the first-level tree storage structure. In the root node of the secondary tree storage structure;
根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中。According to the third preset hash function, the routing table entry is stored in the leaf node of the second level tree storage structure.
可选地,根据第一预设哈希函数,创建频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中的步骤包括:Optionally, the first-level tree-shaped storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the root of the first-level tree-shaped storage structure. The steps in the node include:
以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的路由集群存储于第一哈希地址中;Taking the frequent item as a key, and performing calculation according to the first preset hash function, obtaining the first hash address, and storing the corresponding routing cluster in the first hash address;
存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根结点。A plurality of first hash addresses storing different routing clusters are constructed as root nodes of the first level tree storage structure.
可选地,根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中的步骤包括:Optionally, the second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the leaf of the first-level tree-shaped storage structure. The steps in the root node of the node or the second level tree storage structure include:
以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并 将对应的路由设备存储于第二哈希地址中;Taking the frequent item as a key and performing calculation according to the second preset hash function, obtaining a second hash address, and Storing the corresponding routing device in the second hash address;
存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。A plurality of second hash addresses storing different routing devices are constructed as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
可选地,根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中的步骤包括:Optionally, the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function includes:
以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于第三哈希地址中;Taking a routing entry as a key, and performing calculation according to the third preset hash function, obtaining a third hash address, and storing the corresponding routing entry in the third hash address;
存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。A plurality of third hash addresses storing different routing table entries are constructed as leaf nodes of the second level tree storage structure.
可选地,在根据第一预设哈希函数,创建频繁项对应的路由集群下的多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中的步骤之后,还包括:Optionally, the first level tree storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the first level tree storage structure. After the steps in the root node, it also includes:
当增加新路由集群时,获取新路由集群的频繁项;When adding a new routing cluster, obtain frequent items of the new routing cluster;
以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于第一哈希地址中,更新第一级树形存储结构的根结点。The frequent item is used as a key, and the first preset hash function is used to calculate, the first hash address is obtained, and the corresponding new routing cluster is stored in the first hash address, and the first level tree storage structure is updated. Root node.
可选地,在根据第一预设哈希函数,创建频繁项对应的路由集群下的多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中的步骤之后,还包括:Optionally, the first level tree storage structure of the plurality of routing devices under the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the routing cluster is stored in the first level tree storage structure. After the steps in the root node, it also includes:
当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新第一级树形存储结构的根结点。When the routing cluster is reduced, the routing cluster in the corresponding first hash address is deleted, and the root node of the first-level tree storage structure is updated.
可选地,根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中的步骤之后,还包括:Optionally, the second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the leaf of the first-level tree-shaped storage structure. After the steps in the root node of the node or the second-level tree storage structure, the method further includes:
当增加新路由设备时,获取新路由设备的频繁项;When adding a new routing device, acquire frequent items of the new routing device;
以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于第二新哈希地址中,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。The frequent item is used as a key, and the second preset hash address is calculated according to the second preset hash function, and the corresponding new routing device is stored in the second new hash address to update the first level tree storage. The root node of the structure's leaf node or secondary tree storage structure.
可选地,在根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二 级树形存储结构的根结点中的步骤之后,还包括:Optionally, the second level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the routing device is stored in the first level tree storage structure. Leaf node or second After the steps in the root node of the level tree storage structure, it also includes:
当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。When the routing device is reduced, the routing device stored in the corresponding second hash address is deleted, and the root node of the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
可选地,根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中的步骤之后,还包括:Optionally, after the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function, the method further includes:
当增加新路由表项时,获取新路由表项的频繁项;When a new routing entry is added, the frequent entries of the new routing entry are obtained.
以频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于第三哈希地址中,更新第二级树形存储结构的叶子结点。The frequent item is used as a key, and the third preset hash function is calculated according to the third preset hash function, and the corresponding new routing entry is stored in the third hash address, and the second level tree storage is updated. The structure of the leaf nodes.
可选地,在根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中的步骤之后,还包括:Optionally, after the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function, the method further includes:
当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新第二级树形存储结构的叶子结点。When the routing entry is decreased, the routing entry stored in the corresponding third hash address is deleted, and the leaf node of the second-level tree storage structure is updated.
依据本发明实施例的另一个方面,还提供了一种路由查询装置,包括:According to another aspect of the embodiments of the present invention, a route query apparatus is further provided, including:
第一查找模块,设置为根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群;其中,路由集群为第一级树形存储结构的根结点,路由设备为第一级树形存储结构的叶子结点;The first search module is configured to search for a root node associated with the to-be-queried routing entry in a first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster according to the routing entry to be queried. Obtaining a first routing cluster; wherein the routing cluster is a root node of the first-level tree-shaped storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
第二查找模块,设置为在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由设备;其中,第一级树形存储结构的叶子结点为第二级树形存储结构的根结点,路由表项为第二级树形存储结构的叶子结点;a second search module, configured to search for a root node associated with the routing entry to be queried in a second-level tree storage structure formed by a plurality of routing entries in a single routing device, to obtain a first routing device; The leaf node of the first-level tree-shaped storage structure is a root node of the second-level tree-shaped storage structure, and the routing entry is a leaf node of the second-level tree-shaped storage structure;
第三查找模块,设置为在第二级树形存储结构的根结点下查找与待查询路由表项相同的叶子结点,并返回查询结果。The third search module is configured to search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
可选地,第一查找模块包括:Optionally, the first search module includes:
第一查找单元,设置为在第一级树形存储结构中,以待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址;其中,第一哈希地址中存储有与待查询路由表项相关联的路由集群;The first search unit is configured to perform, in the first-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the first preset hash function to obtain a first hash address; wherein, the first A hash cluster is stored with a route cluster associated with the routing entry to be queried;
第一读取单元,设置为在第一哈希地址中读取对应的候选路由集群,若候选路由集群中包括待查询路由表项,则将候选路由集群作为第一路由集群。 The first reading unit is configured to read the corresponding candidate routing cluster in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
可选地,第二查找模块包括:Optionally, the second search module includes:
第二查找单元,设置为在第二级树形存储结构中,以待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址;其中,第二哈希地址中存储有与待查询路由表项相关联的路由设备;a second search unit is configured to perform, in the second-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the second preset hash function to obtain a second hash address; wherein, the second A routing device associated with the routing entry to be queried is stored in the hash address;
第二读取单元,设置为在第二哈希地址中读取对应的候选路由设备,若候选路由设备中包括待查询路由表项,则将候选路由设备作为第一路由设备。The second reading unit is configured to read the corresponding candidate routing device in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
可选地,第三查找模块包括:Optionally, the third search module includes:
第三查找单元,设置为在第一路由设备为根结点的第二级树形存储结构中,以待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址;其中,第三哈希地址中存储有第一路由设备的全部路由表项;The third search unit is configured to use the routing entry to be queried as a key in the second-level tree storage structure of the first routing device as the root node, and perform calculation according to the third preset hash function to obtain the first a three-hash address; wherein the third hash address stores all routing entries of the first routing device;
第三读取单元,设置为在第三哈希地址中读取对应的候选路由表项,若候选路由表项为待查询路由表项,则查找成功;否则,遍历线性链表查找待查询路由表项。The third reading unit is configured to read the corresponding candidate routing entry in the third hash address, and if the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, traversing the linear linked list to find the routing table to be queried item.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
判断模块,设置为获取待查询路由表项,并判断待查询路由表项是否为预设频繁项;其中,预设频繁项为占有率高于预设阈值的路由表项;The determining module is configured to obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent item; wherein the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold;
若不是,则遍历线性链表查找待查询路由表项;If not, traverse the linear linked list to find the routing entry to be queried;
若是,则在第一级树形存储结构中查找第一路由集群。If so, the first routing cluster is looked up in the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第一创建模块,设置为获取单个路由集群下的多个路由设备中的频繁项,并根据第一预设哈希函数,创建频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中;The first creating module is configured to obtain a frequent item in multiple routing devices in a single routing cluster, and create a first-level tree of multiple routing devices in the routing cluster corresponding to the frequent item according to the first preset hash function. Storing the structure and storing the routing cluster in a root node in the first level tree storage structure;
第二创建模块,设置为根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中;The second creating module is configured to create a second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the first-level tree storage structure In the root node of the leaf node or the second level tree storage structure;
第三创建模块,设置为根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中。The third creating module is configured to store the routing entry in the leaf node of the second level tree storage structure according to the third preset hash function.
可选地,第一创建模块包括:Optionally, the first creating module includes:
第一计算单元,设置为以频繁项为关键字,并根据第一预设哈希函数进行计算, 得到第一哈希地址,并将对应的路由集群存储于第一哈希地址中;a first calculating unit, configured to use a frequent item as a key, and perform calculation according to the first preset hash function, Obtaining a first hash address, and storing the corresponding routing cluster in the first hash address;
第一创建单元,设置为将存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根结点。The first creating unit is configured to construct a plurality of first hash addresses storing different routing clusters as root nodes of the first level tree storage structure.
可选地,第二创建模块包括:Optionally, the second creating module includes:
第二计算单元,设置为以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的路由设备存储于第二哈希地址中;a second calculating unit, configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding routing device in the second hash address;
第二创建单元,设置为将存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。The second creating unit is configured to construct a plurality of second hash addresses storing different routing devices as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
可选地,第三创建模块包括:Optionally, the third creating module includes:
第三计算单元,设置为以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于第三哈希地址中;The third calculating unit is configured to use the routing entry as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding routing entry in the third hash address;
第三创建单元,设置为将存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。The third creating unit is configured to construct a plurality of third hash addresses storing different routing table entries as leaf nodes of the second level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第一获取模块,设置为当增加新路由集群时,获取新路由集群的频繁项;The first obtaining module is configured to acquire frequent items of the new routing cluster when adding a new routing cluster;
第一更新模块,设置为以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于第一哈希地址中,更新第一级树形存储结构的根结点。The first update module is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding new routing cluster in the first hash address, and update The root node of the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第二更新模块,设置为当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新第一级树形存储结构的根结点。The second update module is configured to: when the routing cluster is reduced, delete the routing cluster in the corresponding first hash address, and update the root node of the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第二获取模块,设置为当增加新路由设备时,获取新路由设备的频繁项;The second obtaining module is configured to acquire a frequent item of the new routing device when adding a new routing device;
第三更新模块,设置为以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于第二新哈希地址中,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。The third update module is configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding new routing device in the second new hash address. Update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure.
可选地,该路由查询装置还包括: Optionally, the route querying device further includes:
第四更新模块,设置为当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。The fourth update module is configured to: when the routing device is reduced, delete the routing device stored in the corresponding second hash address, and update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure point.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第三获取模块,设置为当增加新路由表项时,获取新路由表项的频繁项;The third obtaining module is configured to acquire a frequent item of the new routing entry when the new routing entry is added;
第五更新模块,设置为以频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于第三哈希地址中,更新第二级树形存储结构的叶子结点。The fifth update module is configured to use a frequent item as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding new routing entry in the third hash address. Update the leaf nodes of the second level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第六更新模块,设置为当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新第二级树形存储结构的叶子结点。The sixth update module is configured to: when the routing entry is reduced, delete the routing entry stored in the corresponding third hash address, and update the leaf node of the second-level tree storage structure.
本发明实施例的实施例的有益效果是:一种路由查询方法及装置,基于预先创建的两级树形存储结构,在第一级树形存储结构中查找与待查询路由表项相关联的第一路由集群,再在第一路由集群下查找与待查询路由表项相关联的第一路由设备,然后再在第一路由设备下查找待查询路由表项,并返回查询结构,其中,第一路由设备是第一级树形存储结构中的叶子结点,又是第二级树形存储结构中的根结点。这样仅需要三次查找过程,即可得到待查询路由表项的查询结构,大大提高了路由的查询速度。The beneficial effects of the embodiment of the present invention are: a route query method and device, and searching for a route entry to be queried in a first-level tree storage structure based on a pre-created two-level tree storage structure The first routing cluster searches for the first routing device associated with the routing entry to be queried in the first routing cluster, and then searches for the routing entry to be queried on the first routing device, and returns a query structure, where A routing device is a leaf node in a first level tree storage structure and a root node in a second level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.
附图说明DRAWINGS
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the invention, and are intended to be a part of the invention. In the drawing:
图1表示本发明的路由查询方法的流程示意图;1 is a schematic flow chart showing a route query method of the present invention;
图2表示图1中步骤10的具体流程示意图;Figure 2 is a schematic view showing the specific flow of the step 10 in Figure 1;
图3表示图1中步骤20的具体流程示意图;Figure 3 is a schematic view showing the specific flow of the step 20 in Figure 1;
图4表示图1中步骤30的具体流程示意图;4 is a schematic diagram showing the specific flow of step 30 in FIG. 1;
图5表示图1中执行步骤10之前的具体流程示意图;FIG. 5 is a schematic diagram showing a specific process before step 10 is performed in FIG. 1;
图6表示本发明实施例中树形存储结构的创建流程示意图; 6 is a schematic diagram showing a process of creating a tree-shaped storage structure in an embodiment of the present invention;
图7表示本发明的路由查询装置的模块结构示意图。Fig. 7 is a block diagram showing the structure of a route inquiring device of the present invention.
其中图中:101、第一查找模块,102、第二查找模块,103、第三查找模块。In the figure: 101, the first search module, 102, the second search module, 103, the third search module.
具体实施方式detailed description
下面将参照附图更详细地描述本发明的示例性实施例。虽然附图中显示了本发明的示例性实施例,然而应当理解,可以以各种形式实现本发明而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本发明,并且能够将本发明的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While the invention has been shown and described with reference to the embodiments Rather, these embodiments are provided so that this invention may be more fully understood and the scope of the invention can be fully conveyed by those skilled in the art.
实施例Example
在网络需求日益增大的情况下,集群概念普遍应用于各种网络拓扑结构中,为了扩大路由器的容量,引进了路由集群,但由于路由集群中涉及到的路由设备个体较多,路由查询的速度会影响着整体的性能,为了提高查询速度,如图1所示,本发明的实施例提供了一种路由查询方法,具体包括以下步骤:In the case of increasing network demand, the cluster concept is widely used in various network topologies. In order to expand the capacity of the router, a routing cluster is introduced. However, because there are many routing devices involved in the routing cluster, the routing query is The speed affects the overall performance. To improve the query speed, as shown in FIG. 1 , an embodiment of the present invention provides a route query method, which specifically includes the following steps:
步骤10:根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群。Step 10: According to the routing entry to be queried, in the first-level tree-shaped storage structure formed by multiple routing devices in a single routing cluster, the root node associated with the routing entry to be queried is searched to obtain the first route. Cluster.
其中,路由集群形成第一级树形存储结构的根结点,路由设备形成第一级树形存储结构的叶子结点。在需要查询某一路由表项时,需要先在第一级树形存储结构中查找到与其相关联的路由集群。The routing cluster forms a root node of the first-level tree-shaped storage structure, and the routing device forms a leaf node of the first-level tree-shaped storage structure. When you need to query a routing entry, you need to find the routing cluster associated with it in the first-level tree storage structure.
步骤20:在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由设备。Step 20: In the second-level tree-shaped storage structure formed by the multiple routing entries of the single routing device, the root node associated with the routing entry to be queried is searched to obtain the first routing device.
其中,第一级树形存储结构的叶子结点为第二级树形存储结构的根结点,路由表项为第二级树形存储结构的叶子结点;即路由设备既是第一级树形存储结构的叶子结点,又是第二级树形存储结构的根结点。也就是说,每个路由集群都形成一第一级树形存储结构,每个路由设备形成一第二级树形存储结构,这样在查找到第一路由集群后,可在第一路由集群下查找与该待查询路由表项相关联的第一路由设备。The leaf node of the first-level tree-shaped storage structure is the root node of the second-level tree-shaped storage structure, and the routing entry is the leaf node of the second-level tree-shaped storage structure; that is, the routing device is the first-level tree. The leaf node of the shape storage structure is the root node of the second level tree storage structure. That is to say, each routing cluster forms a first-level tree-shaped storage structure, and each routing device forms a second-level tree-shaped storage structure, so that after the first routing cluster is found, it can be under the first routing cluster. Finding a first routing device associated with the routing entry to be queried.
步骤30:在第二级树形存储结构的根结点下查找与待查询路由表项相同的叶子结点,并返回查询结果。Step 30: Search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
这里,在查找到对应的第一路由设备后,在第一路由设备中查找与待查询路由表项相同的叶子结点,即查找第一路由设备中是否存在待查询路由表项,若存在,则查找成功,若不存在,则查找失败。 Here, after the corresponding first routing device is found, the first routing device searches for the same leaf node as the routing entry to be queried, that is, whether the routing entry to be queried exists in the first routing device, and if so, The search succeeds, and if it does not exist, the search fails.
本实用新型实施例中的路由查询方法,基于预先创建的两级树形存储结构,在第一级树形存储结构中查找与待查询路由表项相关联的第一路由集群,再在第一路由集群下查找与待查询路由表项相关联的第一路由设备,然后再在第一路由设备下查找待查询路由表项,并返回查询结构,其中,第一路由设备是第一级树形存储结构中的叶子结点,又是第二级树形存储结构中的根结点。这样仅需要三次查找过程,即可得到待查询路由表项的查询结构,大大提高了路由的查询速度。The route query method in the embodiment of the present invention is based on the pre-created two-level tree storage structure, and searches for the first route cluster associated with the to-be-queried routing entry in the first-level tree-shaped storage structure, and then in the first The routing device searches for the first routing device associated with the routing entry to be queried, and then searches for the routing entry to be queried on the first routing device, and returns a query structure, where the first routing device is a first-level tree. The leaf node in the storage structure is the root node in the second-level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.
可选地,哈希树因其结构简单,并且查找速度快,又可以很方便的替换哈希算法,故而常常被用于存储关键的数据,基于以上优势,本发明实施例中可采用哈希树结构对路由进行存储。其中,步骤10具体可参照如图2所示的步骤实现:Optionally, the hash tree can be used in the embodiment of the present invention because the structure is simple, and the search speed is fast, and the hash algorithm can be replaced conveniently, so that it is often used to store key data. The tree structure stores the routes. Step 10 can be specifically implemented by referring to the steps shown in FIG. 2:
步骤11:在第一级树形存储结构中,以待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址。Step 11: In the first-level tree-shaped storage structure, the first hash address is obtained by using the routing entry to be queried as a key and performing calculation according to the first preset hash function.
这里,第一哈希地址中存储有与待查询路由表项相关联的路由集群;以待查询路由表项作为关键字K,并将K代入创建第一级树形存储结构的根结点时所采用的第一预设哈希函数H_1,计算出第一哈希地址H_1(K)。Here, the first hash address stores a routing cluster associated with the routing entry to be queried; when the routing entry to be queried is used as the key K, and K is substituted into the root node of the first-level tree storage structure The first preset hash function H_1 is used to calculate the first hash address H_1(K).
步骤12:第一哈希地址中读取对应的候选路由集群,若候选路由集群中包括待查询路由表项,则将候选路由集群作为第一路由集群。Step 12: The candidate routing cluster is read in the first hash address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
这里,在第一哈希地址H_1(K)中读取对应的候选路由集群,并判断该候选路由集群中是否存在待查询路由表项,若存在则将该候选路由集群作为第一路由集群。Here, the corresponding candidate routing cluster is read in the first hash address H_1(K), and it is determined whether there is a routing entry to be queried in the candidate routing cluster, and if present, the candidate routing cluster is used as the first routing cluster.
可选地,步骤20中查找第一路由设备的具体实现方式与步骤10中查找第一路由集群的具体实现方式类似,大致可参照如图3所示的步骤实现:Optionally, the specific implementation manner of searching for the first routing device in step 20 is similar to the specific implementation manner of searching for the first routing cluster in step 10, and may be implemented by referring to the steps shown in FIG. 3:
步骤21:在第二级树形存储结构中,以待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址。Step 21: In the second-level tree-shaped storage structure, the second hash address is obtained by using the routing entry to be queried as a key and performing calculation according to the second preset hash function.
这里,第二哈希地址中存储有与待查询路由表项相关联的路由设备;以待查询路由表项作为关键字K,并将K代入创建第一级树形存储结构的叶子结点或第二级树形存储结构的根结点时所采用的第二预设哈希函数H_2,计算出第二哈希地址H_2(K)。Here, the second hash address stores a routing device associated with the routing entry to be queried; the routing entry to be queried is used as the key K, and K is substituted into the leaf node that creates the first-level tree-shaped storage structure or The second preset hash function H_2 used in the root node of the second level tree storage structure calculates the second hash address H_2(K).
步骤22:在第二哈希地址中读取对应的候选路由设备,若候选路由设备中包括待查询路由表项,则将候选路由设备作为第一路由设备。Step 22: The corresponding routing device is read in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
这里,在第二哈希地址H_2(K)中读取对应的候选路由设备,并判断该候选路由设备中是否存在待查询路由表项,若存在则将该候选路由设备作为第一路由设备。 Here, the corresponding candidate routing device is read in the second hash address H_2(K), and it is determined whether there is a routing entry to be queried in the candidate routing device, and if present, the candidate routing device is used as the first routing device.
可选地,步骤30可具体参照如图4所示的步骤实现:Optionally, step 30 can be implemented by referring specifically to the steps shown in FIG. 4:
步骤31:在第一路由设备为根结点的第二级树形存储结构中,以待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址。Step 31: In the second-level tree-shaped storage structure in which the first routing device is the root node, use the routing entry to be queried as a key, and perform calculation according to the third preset hash function to obtain a third hash address. .
其中,第三哈希地址中存储有第一路由设备的全部路由表项,以待查询路由表项作为关键字K,并将K代入创建第二级树形存储结构的叶子结点时所采用的第三预设哈希函数H_3,计算出第三哈希地址H_3(K)All the routing entries of the first routing device are stored in the third hash address, and the routing entry to be queried is used as the key K, and the K is used to create the leaf node of the second-level tree storage structure. The third preset hash function H_3, calculate the third hash address H_3 (K)
步骤32:在第三哈希地址中读取对应的候选路由表项,若候选路由表项为待查询路由表项,则查找成功;否则,遍历线性链表查找待查询路由表项。Step 32: The corresponding candidate routing entry is read in the third hash address. If the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, the linear linked list is traversed to find the routing entry to be queried.
这里,在第三哈希地址H_3(K)中读取对应的路由表项,并将其与待查询路由表项作比较,若相等,则查找成功,并将查询结构反馈;若不相等,则按照创建树形存储结构时设定的处理冲突的方法查找下一个地址,直至查找到某一个地址中存储的路由表项与待查询的路由表项相同或查找到某一个地址未被占用时停止查找,本实施例中将存在冲突的路由表项存储于线性链表中,当查找到的路由表项与待查询路由表项不相等时,遍历线性链表查找。Here, the corresponding routing entry is read in the third hash address H_3(K) and compared with the routing entry to be queried. If they are equal, the search succeeds and the query structure is fed back; if not, Then, the next address is searched according to the method of processing conflicts when the tree storage structure is created, until the routing entry stored in an address is the same as the routing entry to be queried or when an address is not occupied. The search is stopped. In this embodiment, the conflicting routing entry is stored in the linear linked list. When the found routing entry is not equal to the routing entry to be queried, the linear linked list is traversed.
可选地,对于使用或查找频率较低的路由表项,亦可采用线性链表存储的方式,优选地,我们可以将查询或使用的频繁项以树形存储结构进行存储以提高查询速度,而对于非频繁项则以线性链表的存储方式进行存储,以降低路由查询的复杂度。基于以上,本发明实施例的路由查找方法,如图5所示,在步骤10之前,还可以包括:Optionally, for routing entries with lower frequency or lower frequency, a linear linked list storage manner may also be adopted. Preferably, we may store the frequently used items that are queried or used in a tree storage structure to improve the query speed, and For infrequent items, they are stored in a linear linked list to reduce the complexity of routing queries. Based on the above, the route search method of the embodiment of the present invention, as shown in FIG. 5, before step 10, may further include:
步骤01:获取待查询路由表项,并判断待查询路由表项是否为预设频繁项。Step 01: Obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent entry.
其中,预设频繁项为占有率高于预设阈值的路由表项,例如,我们可将预设阈值设置为0.001,这样当整个路由系统中包括10万条路由表项时,路由表项A出现的次数大于或等于100,那么路由表项A即为频繁项。The preset frequent item is a routing entry whose occupation rate is higher than a preset threshold. For example, we can set the preset threshold to 0.001, so that when the entire routing system includes 100,000 routing entries, the routing entry A If the number of occurrences is greater than or equal to 100, the routing entry A is a frequent entry.
步骤02:若不是,则遍历线性链表查找待查询路由表项;若是,则在第一级树形存储结构中查找第一路由集群。Step 02: If not, traverse the linear linked list to find the routing entry to be queried; if yes, look up the first routing cluster in the first-level tree storage structure.
可选地,在步骤10之前,还包括如图6所示的创建树形存储结构的步骤。Optionally, before step 10, the step of creating a tree storage structure as shown in FIG. 6 is further included.
步骤0A:获取单个路由集群下多个路由设备中的频繁项,并根据第一预设哈希函数,创建频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中。Step 0A: Acquire frequent items in multiple routing devices in a single routing cluster, and create a first-level tree storage structure of multiple routing devices in the routing cluster corresponding to the frequent items according to the first preset hash function, and The routing cluster is stored in the root node in the first level tree storage structure.
可选地,步骤0A具体可参照以下步骤实现: Optionally, step 0A can be specifically implemented by referring to the following steps:
以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的路由集群存储于第一哈希地址中。这里,第一预设哈希函数为H_1,将每一个频繁项K_i均代入第一预设哈希函数H_1中,得到第一哈希地址H_1(K_i),并将包括频繁项K_i的路由集群存储于第一哈希地址H_1(K_i)中。The frequent item is used as a key, and the calculation is performed according to the first preset hash function to obtain a first hash address, and the corresponding routing cluster is stored in the first hash address. Here, the first preset hash function is H_1, and each frequent item K_i is substituted into the first preset hash function H_1 to obtain a first hash address H_1(K_i), and the routing cluster including the frequent item K_i is obtained. Stored in the first hash address H_1 (K_i).
存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根结点。A plurality of first hash addresses storing different routing clusters are constructed as root nodes of the first level tree storage structure.
步骤0B:根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中。Step 0B: Create a second-level tree-shaped storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the leaf node in the first-level tree-shaped storage structure. Point or the root node of the second level tree storage structure.
可选地,步骤0B具体可参照以下步骤实现:Optionally, step 0B can be specifically implemented by referring to the following steps:
以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的路由设备存储于第二哈希地址中。这里,第二预设哈希函数为H_2,将每一个频繁项K_i均代入第二预设哈希函数H_2中,得到第二哈希地址H_2(K_i),并将包括频繁项K_i的路由集群存储于第二哈希地址H_2(K_i)中。Taking the frequent item as a key and performing calculation according to the second preset hash function, the second hash address is obtained, and the corresponding routing device is stored in the second hash address. Here, the second preset hash function is H_2, and each frequent item K_i is substituted into the second preset hash function H_2 to obtain a second hash address H_2(K_i), and the routing cluster including the frequent item K_i is obtained. Stored in the second hash address H_2(K_i).
存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。A plurality of second hash addresses storing different routing devices are constructed as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
步骤0C:根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中。Step 0C: Store the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function.
可选地,步骤0C具体可参照以下步骤实现:Optionally, step 0C can be specifically implemented by referring to the following steps:
以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于第三哈希地址中。这里,第三预设哈希函数为H_3,将每一个频繁项K_i均代入第三预设哈希函数H_3中,得到第三哈希地址H_3(K_i),并将包括频繁项K_i的路由集群存储于第三哈希地址H_3(K_i)中。The routing table entry is used as a key, and is calculated according to the third preset hash function to obtain a third hash address, and the corresponding routing entry is stored in the third hash address. Here, the third preset hash function is H_3, and each frequent item K_i is substituted into the third preset hash function H_3 to obtain a third hash address H_3 (K_i), and the routing cluster including the frequent item K_i is obtained. Stored in the third hash address H_3 (K_i).
存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。A plurality of third hash addresses storing different routing table entries are constructed as leaf nodes of the second level tree storage structure.
以上也就是说,单台路由设备的路由表项均通过树形结构方式存储,路由表项作为该树形结构的叶子结点,当查找到某一台路由设备上是否存在待查询路由表项K时,需要将K代入建树时采用的第三预设哈希函数H_3,计算出第三哈希地址H_3(K),并读取该地址下存储的路由表项,与待查询路由表项K作比较,若相等,则查询成功,否则遍历线性链表,直至查找失败或查找成功。 In other words, the routing entries of a single routing device are stored in a tree structure. The routing entry is used as the leaf node of the tree structure. If a routing entry is found on a routing device, In the case of K, the third preset hash function H_3, which is used when the K is built into the tree, is used to calculate the third hash address H_3(K), and the routing entry stored in the address is read, and the routing entry to be queried is read. K is compared. If they are equal, the query is successful. Otherwise, the linear list is traversed until the search fails or the search is successful.
将多个上述路由设备分为多个路由集群,对每个路由集群中的各个路由表项的支持度进行计数进行并行计算,得到支持度高于预设阈值的频繁项,并对频繁项支持度的高低进行降序排列,依据排序后的频繁项列表对路由设备进行分组,然后在分好的组内,依据路由表项K并根据第二预设哈希函数H_2计算第二哈希地址,并将对应的路由设备存储于第二哈希地址中,也就是说单独的每一个路由集群中都形成一个完整的树形存储结构。The above-mentioned routing devices are divided into multiple routing clusters, and the support degree of each routing entry in each routing cluster is counted and calculated in parallel, and frequent items with a support degree higher than a preset threshold are obtained, and frequent items are supported. Sorting the descending order of the degree, sorting the routing devices according to the sorted frequent items list, and then calculating the second hash address according to the routing table entry K and according to the second preset hash function H_2 in the divided group. The corresponding routing device is stored in the second hash address, that is, a complete tree storage structure is formed in each of the individual routing clusters.
将路由集群视为一个整体,将多个不同的路由集群通过预设第一哈希函数H_1存储于不同的第一哈希地址中。The routing cluster is regarded as a whole, and a plurality of different routing clusters are stored in different first hash addresses by using a preset first hash function H_1.
可选地,在建好树形存储结构后,当频繁项、路由设备或路由集群发生变化时,均会造成树形存储结构的变化,这样就涉及到树形存储结构的更新问题,以下将分别对于频繁项、路由设备或路由集群发生变化时树形存储结构的更新情况进行介绍。Optionally, after the tree storage structure is built, when frequent items, routing devices, or routing clusters change, the tree storage structure changes, which involves updating the tree storage structure. This section describes how to update the tree storage structure when frequent items, routing devices, or routing clusters change.
情况一:当频繁项发生变化时,删除旧频繁项映射关系下第一哈希地址、第二哈希地址和第三哈希地址中存储的数据,增加新频繁项映射关系下的第一哈希地址、第二哈希地址和第三哈希地址中存储的数据,以实现树形存储结构中数据的更新。具体可参照以下步骤实现:Case 1: When the frequent items change, the data stored in the first hash address, the second hash address, and the third hash address in the old frequent item mapping relationship is deleted, and the first hash under the new frequent item mapping relationship is added. Data stored in the hash address, the second hash address, and the third hash address to implement updating of data in the tree storage structure. Specifically, refer to the following steps:
1)计算〖L〗_Δ1=〖L〗_1'-L_1,式中,〖L〗_1'是新频繁项下原路由集群的频繁项路由表项1的项集,L_1是原阈值下原集群设备路由的频繁1-项集;1) Calculate 〖L〗_Δ1=〖L〗_1'-L_1, where 〖L〗_1' is the item set of the frequent item routing entry 1 of the original routing cluster under the new frequent item, and L_1 is the original threshold under the original cluster Frequent 1-item set of device routing;
2)判断差值〖L〗_Δ1是否为空集,是则执行步骤04),否则执行步骤03):2) Determine whether the difference 〖L〗_Δ1 is an empty set, if yes, go to step 04), otherwise go to step 03):
3)以差值〖L〗_Δ1更新第一级树形存储结构;3) updating the first level tree storage structure by the difference 〖L〗_Δ1;
4)第一级树形存储结构更新后与原第一级树形存储结构相同。4) The first-level tree storage structure is updated to be the same as the original first-level tree storage structure.
步骤3具体可参照以下方式进行:Step 3 can be specifically referred to as follows:
01)判断差集〖L〗_Δ1是否是空集,是则结束流程;01) Judging whether the difference set 〖L〗_Δ1 is an empty set, and then ending the process;
02)更新频繁项列表L_1'=L_1∪〖L〗_Δ1;02) Update frequent item list L_1'=L_1∪〖L〗_Δ1;
03)将更新后的频繁项列表L_1'降序排序;03) Sorting the updated frequent item list L_1' in descending order;
04)对原集群设备路由集中的任意事项t,执行nItem=L_1'∩t,取出待查询路由表项中与频繁项列表相交的路由表项;04) Execute nItem=L_1'∩t for any item t in the original cluster device route set, and take out the routing entry that intersects the frequent item list in the routing entry to be queried;
05)执行nNode=nItem∩〖L〗_Δ1,在频繁列表中出现的路由集中的待查询路由表项与差集〖L〗_Δ1相交,求出新nNode; 05) Execute nNode=nItem∩〖L〗_Δ1, and the routing entry to be queried in the route set appearing in the frequent list intersects the difference set 〖L〗_Δ1 to find a new nNode;
06)将新nNode插入到树形存储结构对应的地址中,更新结束。06) Insert the new nNode into the address corresponding to the tree storage structure, and the update ends.
情况二:当增加新路由集群时引起频繁项的变化时,获取新路由集群的频繁项,并以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于第一哈希地址中,更新第一级树形存储结构的根结点。首先,计算〖L〗_Δ2=L_█(DP1@)+L_dP1-L_1,式中,L_DP1是新频繁项下原路由集群中的路由表项1的项集,L_DP1是新频繁项下新增路由集群的路由表项1的项集,L_1是原频繁项下原路由集群的路由表项1的项集;然后以差值〖L〗_Δ2更新第一哈希地址中存储的路由集群。Case 2: When a new route cluster is added to cause frequent item changes, the frequent items of the new route cluster are obtained, and the frequent items are used as keywords, and the first preset hash function is used to calculate, and the first hash address is obtained. And storing the corresponding new routing cluster in the first hash address, and updating the root node of the first level tree storage structure. First, calculate [L]_Δ2=L_█(DP1@)+L_dP1-L_1, where L_DP1 is the item set of routing entry 1 in the original routing cluster under the new frequent item, and L_DP1 is the new route under the new frequent item. The item set of the routing entry 1 of the cluster, L_1 is the item set of the routing entry 1 of the original routing cluster under the original frequent item; and then the routing cluster stored in the first hashing address is updated by the difference [L]_Δ2.
这里,由于新增路由集群,可能会造成频繁项发生变化,这样需要再次获取频繁项,具体挖掘频繁项的步骤可参照以下介绍:Here, the new route cluster may cause frequent items to change. Therefore, you need to obtain frequent items again. For details about the frequent items, refer to the following:
11)初始化k=1;11) Initialize k=1;
12)令k=k+1,采用Apriori算法,通过新增路由集群的频繁项路由表项1的项集L_DP1,其中l=k-1,生成新增路由集的候选频繁项路由表项k的项集c_dk,判断新增路由集的候选频繁项路由表项k的项集c_dk是否为空集,是则挖掘结束;12) Let k=k+1, using the Apriori algorithm, by adding the item set L_DP1 of the frequent item routing entry 1 of the routing cluster, where l=k-1, generating a candidate frequent item routing entry k of the newly added routing set The item set c_dk determines whether the item set c_dk of the candidate frequent item routing table entry k of the newly added route set is an empty set, and the mining ends;
13)执行c_Δk=c_dk-L_k,求出新增路由集的候选频繁项路由表项k的项集c_dk与原频繁项下原路由集群频繁项路由表项k的项集L_k之差,判断差值c_Δk是否为空集,是则执行步骤15),否则执行步骤14);13) Execute c_Δk=c_dk-L_k, find the difference between the item set c_dk of the candidate frequent item routing entry k of the newly added routing set and the item set L_k of the original routing cluster frequent item routing entry k under the original frequent item, and judge the difference Whether the value c_Δk is an empty set, if yes, perform step 15), otherwise perform step 14);
14)对于步骤3)得到的差值c_Δk中的每个项,通过更新后的树形存储结构计算出各路径的支持数;通过判断c_Δk中的项的支持数是否不小于新阈值s′,得到新增的频繁项路由表项k的项集。14) For each of the difference c_Δk obtained in the step 3), the support number of each path is calculated by the updated tree storage structure; by determining whether the support number of the item in c_Δk is not less than the new threshold s', Get the item set of the new frequent item routing entry k.
15)通过判断c_dk中的项的支持数是否不小于新阈值s′,得到新增路由集群的频繁项路由表项k的项集L_dP1。15) By determining whether the supported number of items in c_dk is not less than the new threshold s', the item set L_dP1 of the frequent item routing entry k of the newly added routing cluster is obtained.
情况三:当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新第一级树形存储结构的根结点。Case 3: When the routing cluster is reduced, the routing cluster in the corresponding first hash address is deleted, and the root node of the first-level tree storage structure is updated.
情况四:当增加新路由设备时,获取新路由设备的频繁项;Case 4: When adding a new routing device, obtain frequent items of the new routing device;
以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于第二新哈希地址中,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。具体实现与情况二的实现方式类似,故在此不再赘述。 The frequent item is used as a key, and the second preset hash address is calculated according to the second preset hash function, and the corresponding new routing device is stored in the second new hash address to update the first level tree storage. The root node of the structure's leaf node or secondary tree storage structure. The specific implementation is similar to the implementation of Case 2, and therefore will not be described here.
情况五:当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。Case 5: When the routing device is reduced, the routing device stored in the corresponding second hash address is deleted, and the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
情况六:当增加新路由表项时,获取新路由表项的频繁项;Case 6: When a new routing entry is added, a frequent entry of a new routing entry is obtained;
以频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于第三哈希地址中,更新第二级树形存储结构的叶子结点。The frequent item is used as a key, and the third preset hash function is calculated according to the third preset hash function, and the corresponding new routing entry is stored in the third hash address, and the second level tree storage is updated. The structure of the leaf nodes.
情况七:当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新第二级树形存储结构的叶子结点。Case 7: When the routing entry is reduced, the routing entry stored in the corresponding third hash address is deleted, and the leaf node of the second-level tree storage structure is updated.
依据本发明实施例的另一个方面,还提供了一种路由查询装置,如图7所示,包括:According to another aspect of the embodiments of the present invention, a route query device, as shown in FIG. 7, includes:
第一查找模块101,设置为根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由集群;其中,路由集群为第一级树形存储结构的根结点,路由设备为第一级树形存储结构的叶子结点;The first search module 101 is configured to search for a root node associated with the routing entry to be queried in the first-level tree storage structure formed by multiple routing devices in a single routing cluster according to the routing entry to be queried. Obtaining a first routing cluster; wherein the routing cluster is a root node of the first-level tree-shaped storage structure, and the routing device is a leaf node of the first-level tree-shaped storage structure;
第二查找模块102,设置为在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与待查询路由表项相关联的根结点,得到第一路由设备;其中,第一级树形存储结构的叶子结点为第二级树形存储结构的根结点,路由表项为第二级树形存储结构的叶子结点;The second search module 102 is configured to search for a root node associated with the routing entry to be queried in the second-level tree storage structure formed by the multiple routing entries of the single routing device, to obtain the first routing device. Wherein, the leaf node of the first level tree storage structure is the root node of the second level tree storage structure, and the routing table entry is the leaf node of the second level tree storage structure;
第三查找模块103,设置为在第二级树形存储结构的根结点下查找与待查询路由表项相同的叶子结点,并返回查询结果。The third search module 103 is configured to search for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and return the query result.
可选地,第一查找模块101包括:Optionally, the first searching module 101 includes:
第一查找单元,设置为在第一级树形存储结构中,以待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址;其中,第一哈希地址中存储有与待查询路由表项相关联的路由集群;The first search unit is configured to perform, in the first-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the first preset hash function to obtain a first hash address; wherein, the first A hash cluster is stored with a route cluster associated with the routing entry to be queried;
第一读取单元,设置为在第一哈希地址中读取对应的候选路由集群,若候选路由集群中包括待查询路由表项,则将候选路由集群作为第一路由集群。The first reading unit is configured to read the corresponding candidate routing cluster in the first hashing address. If the candidate routing cluster includes the routing entry to be queried, the candidate routing cluster is used as the first routing cluster.
可选地,第二查找模块102包括:Optionally, the second search module 102 includes:
第二查找单元,设置为在第二级树形存储结构中,以待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址;其中,第二哈希地址中存储有与待查询路由表项相关联的路由设备; a second search unit is configured to perform, in the second-level tree storage structure, a routing entry to be queried as a key, and perform calculation according to the second preset hash function to obtain a second hash address; wherein, the second A routing device associated with the routing entry to be queried is stored in the hash address;
第二读取单元,设置为在第二哈希地址中读取对应的候选路由设备,若候选路由设备中包括待查询路由表项,则将候选路由设备作为第一路由设备。The second reading unit is configured to read the corresponding candidate routing device in the second hash address. If the candidate routing device includes the routing entry to be queried, the candidate routing device is used as the first routing device.
可选地,第三查找模块103包括:Optionally, the third lookup module 103 includes:
第三查找单元,设置为在第一路由设备为根结点的第二级树形存储结构中,以待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址;其中,第三哈希地址中存储有第一路由设备的全部路由表项;The third search unit is configured to use the routing entry to be queried as a key in the second-level tree storage structure of the first routing device as the root node, and perform calculation according to the third preset hash function to obtain the first a three-hash address; wherein the third hash address stores all routing entries of the first routing device;
第三读取单元,设置为在第三哈希地址中读取对应的候选路由表项,若候选路由表项为待查询路由表项,则查找成功;否则,遍历线性链表查找待查询路由表项。The third reading unit is configured to read the corresponding candidate routing entry in the third hash address, and if the candidate routing entry is the routing entry to be queried, the search succeeds; otherwise, traversing the linear linked list to find the routing table to be queried item.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
判断模块,设置为获取待查询路由表项,并判断待查询路由表项是否为预设频繁项;其中,预设频繁项为占有率高于预设阈值的路由表项;The determining module is configured to obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent item; wherein the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold;
若不是,则遍历线性链表查找待查询路由表项;If not, traverse the linear linked list to find the routing entry to be queried;
若是,则在第一级树形存储结构中查找第一路由集群。If so, the first routing cluster is looked up in the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第一创建模块,设置为获取单个路由集群下的多个路由设备中的频繁项,并根据第一预设哈希函数,创建频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将路由集群存储于第一级树形存储结构中的根结点中;The first creating module is configured to obtain a frequent item in multiple routing devices in a single routing cluster, and create a first-level tree of multiple routing devices in the routing cluster corresponding to the frequent item according to the first preset hash function. Storing the structure and storing the routing cluster in a root node in the first level tree storage structure;
第二创建模块,设置为根据第二预设哈希函数,创建频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将路由设备存储于第一级树形存储结构中的叶子结点或第二级树形存储结构的根结点中;The second creating module is configured to create a second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the first-level tree storage structure In the root node of the leaf node or the second level tree storage structure;
第三创建模块,设置为根据第三预设哈希函数,将路由表项存储于第二级树形存储结构的叶子结点中。The third creating module is configured to store the routing entry in the leaf node of the second level tree storage structure according to the third preset hash function.
可选地,第一创建模块包括:Optionally, the first creating module includes:
第一计算单元,设置为以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的路由集群存储于第一哈希地址中;The first calculating unit is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding routing cluster in the first hash address;
第一创建单元,设置为将存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根结点。The first creating unit is configured to construct a plurality of first hash addresses storing different routing clusters as root nodes of the first level tree storage structure.
可选地,第二创建模块包括: Optionally, the second creating module includes:
第二计算单元,设置为以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的路由设备存储于第二哈希地址中;a second calculating unit, configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding routing device in the second hash address;
第二创建单元,设置为将存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。The second creating unit is configured to construct a plurality of second hash addresses storing different routing devices as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
可选地,第三创建模块包括:Optionally, the third creating module includes:
第三计算单元,设置为以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于第三哈希地址中;The third calculating unit is configured to use the routing entry as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding routing entry in the third hash address;
第三创建单元,设置为将存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。The third creating unit is configured to construct a plurality of third hash addresses storing different routing table entries as leaf nodes of the second level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第一获取模块,设置为当增加新路由集群时,获取新路由集群的频繁项;The first obtaining module is configured to acquire frequent items of the new routing cluster when adding a new routing cluster;
第一更新模块,设置为以频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于第一哈希地址中,更新第一级树形存储结构的根结点。The first update module is configured to use a frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding new routing cluster in the first hash address, and update The root node of the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第二更新模块,设置为当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新第一级树形存储结构的根结点。The second update module is configured to: when the routing cluster is reduced, delete the routing cluster in the corresponding first hash address, and update the root node of the first level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第二获取模块,设置为当增加新路由设备时,获取新路由设备的频繁项;The second obtaining module is configured to acquire a frequent item of the new routing device when adding a new routing device;
第三更新模块,设置为以频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于第二新哈希地址中,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。The third update module is configured to use a frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding new routing device in the second new hash address. Update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第四更新模块,设置为当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新第一级树形存储结构的叶子结点或二级树形存储结构的根结点。The fourth update module is configured to: when the routing device is reduced, delete the routing device stored in the corresponding second hash address, and update the root node of the leaf node or the secondary tree storage structure of the first-level tree storage structure point.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第三获取模块,设置为当增加新路由表项时,获取新路由表项的频繁项; The third obtaining module is configured to acquire a frequent item of the new routing entry when the new routing entry is added;
第五更新模块,设置为以频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于第三哈希地址中,更新第二级树形存储结构的叶子结点。The fifth update module is configured to use a frequent item as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding new routing entry in the third hash address. Update the leaf nodes of the second level tree storage structure.
可选地,该路由查询装置还包括:Optionally, the route querying device further includes:
第六更新模块,设置为当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新第二级树形存储结构的叶子结点。The sixth update module is configured to: when the routing entry is reduced, delete the routing entry stored in the corresponding third hash address, and update the leaf node of the second-level tree storage structure.
需要说明的是,该路由查询装置是与上述路由查询方法对应的装置,上述方法实施例中所有实现方式均适设置为该装置的实施例中,也能达到相同的技术效果。It should be noted that the route querying device is a device corresponding to the above-mentioned route query method, and all the implementation manners in the foregoing method embodiments are suitable for the embodiment of the device, and the same technical effects can be achieved.
以上所述的是本发明的优选实施方式,应当指出对于本技术领域的普通人员来说,在不脱离本发明所述的原理前提下还可以作出若干改进和润饰,这些改进和润饰也在本发明的保护范围内。The above is a preferred embodiment of the present invention, and it should be noted that those skilled in the art can also make several improvements and retouchings without departing from the principles of the present invention. Within the scope of protection of the invention.
工业实用性Industrial applicability
本发明实施例提供的技术方案,应用于路由查询过程中,在该过程中采用了基于预先创建的两级树形存储结构,在第一级树形存储结构中查找与待查询路由表项相关联的第一路由集群,再在第一路由集群下查找与待查询路由表项相关联的第一路由设备,然后再在第一路由设备下查找待查询路由表项,并返回查询结构,其中,第一路由设备是第一级树形存储结构中的叶子结点,又是第二级树形存储结构中的根结点。这样仅需要三次查找过程,即可得到待查询路由表项的查询结构,大大提高了路由的查询速度。 The technical solution provided by the embodiment of the present invention is applied to a route query process, and a pre-created two-level tree storage structure is used in the process, and the first-level tree-shaped storage structure is searched for related to the to-be-queried routing entry. The first routing cluster is connected to the first routing device, and then the first routing device associated with the routing entry to be queried is searched for, and then the routing entry to be queried is searched for by the first routing device, and the query structure is returned. The first routing device is a leaf node in the first level tree storage structure and a root node in the second level tree storage structure. In this way, only three search processes are required, and the query structure of the routing entry to be queried can be obtained, which greatly improves the query speed of the route.

Claims (28)

  1. 一种路由查询方法,包括:A route query method includes:
    根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由集群;其中,路由集群为所述第一级树形存储结构的根结点,路由设备为所述第一级树形存储结构的叶子结点;According to the routing entry to be queried, in the first-level tree-shaped storage structure formed by the multiple routing devices in the single routing cluster, the root node associated with the routing entry to be queried is searched to obtain the first routing cluster. Wherein the routing cluster is a root node of the first level tree storage structure, and the routing device is a leaf node of the first level tree storage structure;
    在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由设备;其中,所述第一级树形存储结构的叶子结点为所述第二级树形存储结构的根结点,路由表项为所述第二级树形存储结构的叶子结点;In a second-level tree-shaped storage structure formed by a plurality of routing entries in a single routing device, searching for a root node associated with the routing entry to be queried, to obtain a first routing device; The leaf node of the first level tree storage structure is a root node of the second level tree storage structure, and the routing table entry is a leaf node of the second level tree storage structure;
    在所述第二级树形存储结构的根结点下查找与所述待查询路由表项相同的叶子结点,并返回查询结果。Searching for the same leaf node as the routing entry to be queried under the root node of the second-level tree storage structure, and returning the query result.
  2. 根据权利要求1所述的路由查询方法,其中,所述根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由集群的步骤包括:The route query method according to claim 1, wherein the searching and the to-be-queried are performed in a first-level tree-shaped storage structure formed by a plurality of routing devices under a single routing cluster according to the routing entry to be queried The root node associated with the routing entry, the steps of obtaining the first routing cluster include:
    在所述第一级树形存储结构中,以所述待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址;其中,所述第一哈希地址中存储有与所述待查询路由表项相关联的路由集群;In the first-level tree-shaped storage structure, the first hash address is obtained by using the to-be-queried routing entry as a key and calculating according to the first preset hash function; wherein, the first hash A routing cluster associated with the to-be-queried routing entry is stored in the hash address;
    在所述第一哈希地址中读取对应的候选路由集群,若所述候选路由集群中包括所述待查询路由表项,则将所述候选路由集群作为第一路由集群。The candidate routing cluster is read in the first hashing address. If the candidate routing cluster includes the to-be-queried routing entry, the candidate routing cluster is used as the first routing cluster.
  3. 根据权利要求1所述的路由查询方法,其中,在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由设备的步骤包括:The route query method according to claim 1, wherein in the second-level tree storage structure formed by the plurality of routing entries under the single routing device, the root node associated with the routing entry to be queried is searched for Point, the steps of obtaining the first routing device include:
    在所述第二级树形存储结构中,以所述待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址;其中,所述第二哈希地址中存储有与所述待查询路由表项相关联的路由设备;In the second-level tree-shaped storage structure, the second hash address is obtained by using the to-be-queried routing entry as a key and calculating according to the second preset hash function; wherein the second hash is obtained. A routing device associated with the to-be-queried routing entry is stored in the hash address;
    在所述第二哈希地址中读取对应的候选路由设备,若所述候选路由设备中包括所述待查询路由表项,则将所述候选路由设备作为第一路由设备。The candidate routing device is read in the second hash address. If the candidate routing device includes the to-be-queried routing entry, the candidate routing device is used as the first routing device.
  4. 根据权利要求1所述的路由查询方法,其中,在所述第二级树形存储结构的根结点下查找与所述待查询路由表项相同的叶子结点,并返回查询结构的步骤包括: The route query method according to claim 1, wherein the step of searching for the same leaf node as the to-be-queried routing entry under the root node of the second-level tree storage structure, and returning the query structure includes :
    在所述第一路由设备为根结点的第二级树形存储结构中,以所述待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址;其中,所述第三哈希地址中存储有所述第一路由设备的全部路由表项;In the second-level tree-shaped storage structure in which the first routing device is a root node, using the to-be-queried routing entry as a key, and performing calculation according to the third preset hash function, obtaining a third hash. An address; wherein all the routing entries of the first routing device are stored in the third hash address;
    在所述第三哈希地址中读取对应的候选路由表项,若所述候选路由表项为所述待查询路由表项,则查找成功;否则,遍历线性链表查找所述待查询路由表项。Reading the corresponding candidate routing entry in the third hash address, if the candidate routing entry is the to-be-queried routing entry, the search succeeds; otherwise, traversing the linear linked list to find the to-be-queried routing table item.
  5. 根据权利要求1所述的路由查询方法,其中,在根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由集群的步骤之前,还包括:The route query method according to claim 1, wherein in the first-level tree-shaped storage structure formed by a plurality of routing devices under a single routing cluster, the route to be queried is searched for according to the routing entry to be queried. Before the step of the first routing cluster is obtained, the root node associated with the entry includes:
    获取待查询路由表项,并判断所述待查询路由表项是否为预设频繁项;其中,所述预设频繁项为占有率高于预设阈值的路由表项;Obtaining a routing entry to be queried, and determining whether the routing entry to be queried is a preset frequent entry; wherein the preset frequent entry is a routing entry whose occupation rate is higher than a preset threshold;
    若不是,则遍历线性链表查找所述待查询路由表项;If not, traversing the linear linked list to find the routing entry to be queried;
    若是,则在所述第一级树形存储结构中查找第一路由集群。If yes, the first routing cluster is looked up in the first level tree storage structure.
  6. 根据权利要求1~5任一项所述的路由查询方法,其中,在根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由集群的步骤之前,还包括:The route query method according to any one of claims 1 to 5, wherein, in the first-level tree-shaped storage structure formed by a plurality of routing devices under a single routing cluster according to the routing entry to be queried, searching and Before the step of obtaining the first routing cluster, the root node associated with the routing entry to be queried includes:
    获取单个路由集群下多个路由设备中的频繁项,并根据第一预设哈希函数,创建所述频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将所述路由集群存储于所述第一级树形存储结构中的根结点中;Obtaining a frequent entry in a plurality of routing devices in a single routing cluster, and creating a first-level tree storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent items according to the first preset hash function, and The routing cluster is stored in a root node in the first level tree storage structure;
    根据第二预设哈希函数,创建所述频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将所述路由设备存储于所述第一级树形存储结构中的叶子结点或所述第二级树形存储结构的根结点中;Generating, according to the second preset hash function, a second level tree storage structure of the routing entry under the routing device corresponding to the frequent item, and storing the routing device in the first level tree storage structure a leaf node or a root node of the second level tree storage structure;
    根据第三预设哈希函数,将所述路由表项存储于所述第二级树形存储结构的叶子结点中。And storing, according to the third preset hash function, the routing table entry in a leaf node of the second level tree storage structure.
  7. 根据权利要求6所述的路由查询方法,其中,根据第一预设哈希函数,创建所述频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将所述路由集群存储于所述第一级树形存储结构中的根结点中的步骤包括:The route query method according to claim 6, wherein the first level tree storage structure of the plurality of routing devices in the routing cluster corresponding to the frequent item is created according to the first preset hash function, and the route is The steps of storing the cluster in a root node in the first level tree storage structure include:
    以所述频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的路由集群存储于所述第一哈希地址中;Taking the frequent item as a key, and performing calculation according to the first preset hash function, obtaining a first hash address, and storing the corresponding routing cluster in the first hash address;
    存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根 结点。Storing multiple first hash addresses of different routing clusters, constructing the root of the first-level tree storage structure Node.
  8. 根据权利要求6所述的路由查询方法,其中,根据第二预设哈希函数,创建所述频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将所述路由设备存储于所述第一级树形存储结构中的叶子结点或所述第二级树形存储结构的根结点中的步骤包括:The route query method according to claim 6, wherein the second level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the route is The step of storing the device in a leaf node in the first level tree storage structure or a root node in the second level tree storage structure includes:
    以所述频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的路由设备存储于所述第二哈希地址中;Taking the frequent item as a key, and performing calculation according to the second preset hash function, obtaining a second hash address, and storing the corresponding routing device in the second hash address;
    存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。A plurality of second hash addresses storing different routing devices are constructed as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  9. 根据权利要求6所述的路由查询方法,其中,根据第三预设哈希函数,将所述路由表项存储于所述第二级树形存储结构的叶子结点中的步骤包括:The route query method according to claim 6, wherein the storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function comprises:
    以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于所述第三哈希地址中;Taking a routing entry as a key, and performing calculation according to the third preset hash function, obtaining a third hash address, and storing the corresponding routing entry in the third hash address;
    存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。A plurality of third hash addresses storing different routing table entries are constructed as leaf nodes of the second level tree storage structure.
  10. 根据权利要求7所述的路由查询方法,其中,在根据第一预设哈希函数,创建所述频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将所述路由集群存储于所述第一级树形存储结构中的根结点中的步骤之后,还包括:The route query method according to claim 7, wherein the first level tree storage structure of the plurality of routing devices under the routing cluster corresponding to the frequent item is created according to the first preset hash function, and the After the step of storing the routing cluster in the root node in the first level tree storage structure, the method further includes:
    当增加新路由集群时,获取所述新路由集群的频繁项;Obtaining frequent items of the new routing cluster when adding a new routing cluster;
    以所述频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于所述第一哈希地址中,更新所述第一级树形存储结构的根结点。Taking the frequent item as a key, and performing calculation according to the first preset hash function, obtaining a first hash address, and storing the corresponding new routing cluster in the first hash address, updating the first The root node of the primary tree storage structure.
  11. 根据权利要求7所述的路由查询方法,其中,在根据第一预设哈希函数,创建所述频繁项对应的路由集群下的多个路由设备的第一级树形存储结构,并将所述路由集群存储于所述第一级树形存储结构中的根结点中的步骤之后,还包括:The route query method according to claim 7, wherein the first level tree storage structure of the plurality of routing devices under the routing cluster corresponding to the frequent items is created according to the first preset hash function, and the After the step of storing the routing cluster in the root node in the first-level tree storage structure, the method further includes:
    当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新所述第一级树形存储结构的根结点。When the routing cluster is reduced, the routing cluster in the corresponding first hash address is deleted, and the root node of the first-level tree storage structure is updated.
  12. 根据权利要求8所述的路由查询方法,其中,根据第二预设哈希函数,创建所述频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将所述路由设备 存储于所述第一级树形存储结构中的叶子结点或所述第二级树形存储结构的根结点中的步骤之后,还包括:The route query method according to claim 8, wherein the second level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the route is Equipment After the step of storing the leaf node in the first level tree storage structure or the root node of the second level tree storage structure, the method further includes:
    当增加新路由设备时,获取所述新路由设备的频繁项;Obtaining frequent items of the new routing device when adding a new routing device;
    以所述频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于所述第二新哈希地址中,更新所述第一级树形存储结构的叶子结点或所述二级树形存储结构的根结点。Taking the frequent item as a key, and performing calculation according to the second preset hash function, obtaining a second hash address, and storing the corresponding new routing device in the second new hash address, updating the The leaf node of the first level tree storage structure or the root node of the secondary tree storage structure.
  13. 根据权利要求8所述的路由查询方法,其中,在根据第二预设哈希函数,创建所述频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将所述路由设备存储于所述第一级树形存储结构中的叶子结点或所述第二级树形存储结构的根结点中的步骤之后,还包括:The route query method according to claim 8, wherein the second level tree storage structure of the routing entry under the routing device corresponding to the frequent item is created according to the second preset hash function, and the After the step of storing the routing device in the leaf node in the first level tree storage structure or the root node in the second level tree storage structure, the method further includes:
    当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新所述第一级树形存储结构的叶子结点或所述二级树形存储结构的根结点。When the routing device is reduced, the routing device stored in the corresponding second hash address is deleted, and the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
  14. 根据权利要求9所述的路由查询方法,其中,根据第三预设哈希函数,将所述路由表项存储于所述第二级树形存储结构的叶子结点中的步骤之后,还包括:The route query method according to claim 9, wherein after the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function, the method further includes :
    当增加新路由表项时,获取所述新路由表项的频繁项;When a new routing entry is added, the frequent entry of the new routing entry is obtained.
    以所述频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于所述第三哈希地址中,更新所述第二级树形存储结构的叶子结点。Taking the frequent item as a key, and performing calculation according to the third preset hash function, obtaining a third hash address, and storing the corresponding new routing entry in the third hash address, updating the The leaf node of the second level tree storage structure.
  15. 根据权利要求9所述的路由查询方法,其中,在根据第三预设哈希函数,将所述路由表项存储于所述第二级树形存储结构的叶子结点中的步骤之后,还包括:The route query method according to claim 9, wherein after the step of storing the routing entry in the leaf node of the second-level tree storage structure according to the third preset hash function, include:
    当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新所述第二级树形存储结构的叶子结点。When the routing entry is reduced, the routing entry stored in the corresponding third hash address is deleted, and the leaf node of the second-level tree storage structure is updated.
  16. 一种路由查询装置,包括:A route query device includes:
    第一查找模块,设置为根据待查询路由表项,在由单个路由集群下的多个路由设备形成的第一级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由集群;其中,路由集群为所述第一级树形存储结构的根结点,路由设备为所述第一级树形存储结构的叶子结点;The first search module is configured to search for a root node associated with the to-be-queried routing entry in a first-level tree storage structure formed by multiple routing devices in a single routing cluster according to the routing entry to be queried. Pointing, obtaining a first routing cluster; wherein the routing cluster is a root node of the first level tree storage structure, and the routing device is a leaf node of the first level tree storage structure;
    第二查找模块,设置为在由单个路由设备下的多个路由表项形成的第二级树形存储结构中,查找与所述待查询路由表项相关联的根结点,得到第一路由设备; 其中,所述第一级树形存储结构的叶子结点为所述第二级树形存储结构的根结点,路由表项为所述第二级树形存储结构的叶子结点;a second search module, configured to search for a root node associated with the to-be-queried routing entry in a second-level tree storage structure formed by a plurality of routing entries under a single routing device, to obtain a first route Equipment The leaf node of the first level tree storage structure is a root node of the second level tree storage structure, and the routing entry is a leaf node of the second level tree storage structure;
    第三查找模块,设置为在所述第二级树形存储结构的根结点下查找与所述待查询路由表项相同的叶子结点,并返回查询结果。The third search module is configured to search for a leaf node that is the same as the to-be-queried routing entry under the root node of the second-level tree storage structure, and return a query result.
  17. 根据权利要求16所述的路由查询装置,其中,所述第一查找模块包括:The route querying device according to claim 16, wherein the first lookup module comprises:
    第一查找单元,设置为在所述第一级树形存储结构中,以所述待查询路由表项作为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址;其中,所述第一哈希地址中存储有与所述待查询路由表项相关联的路由集群;a first search unit, configured to: in the first-level tree-shaped storage structure, use the to-be-queried routing entry as a key, and perform calculation according to the first preset hash function to obtain a first hash address; The first hash address stores a routing cluster associated with the to-be-queried routing entry.
    第一读取单元,设置为在所述第一哈希地址中读取对应的候选路由集群,若所述候选路由集群中包括所述待查询路由表项,则将所述候选路由集群作为第一路由集群。The first reading unit is configured to read the corresponding candidate routing cluster in the first hash address, and if the candidate routing cluster includes the to-be-queried routing entry, the candidate routing cluster is used as the first A routing cluster.
    根据权利要求16所述的路由查询装置,其中,所述第二查找模块包括:The route query device of claim 16, wherein the second lookup module comprises:
    第二查找单元,设置为在所述第二级树形存储结构中,以所述待查询路由表项作为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址;其中,所述第二哈希地址中存储有与所述待查询路由表项相关联的路由设备;a second search unit, configured to: in the second-level tree storage structure, use the to-be-queried routing entry as a key, and perform calculation according to the second preset hash function to obtain a second hash address; The routing device associated with the to-be-queried routing entry is stored in the second hash address;
    第二读取单元,设置为在所述第二哈希地址中读取对应的候选路由设备,若所述候选路由设备中包括所述待查询路由表项,则将所述候选路由设备作为第一路由设备。The second reading unit is configured to read the corresponding candidate routing device in the second hash address, and if the candidate routing device includes the to-be-queried routing entry, the candidate routing device is used as the first A routing device.
    根据权利要求16所述的路由查询装置,其中,所述第三查找模块包括:The route querying device according to claim 16, wherein the third lookup module comprises:
    第三查找单元,设置为在所述第一路由设备为根结点的第二级树形存储结构中,以所述待查询路由表项作为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址;其中,所述第三哈希地址中存储有所述第一路由设备的全部路由表项;a third search unit, configured to use the to-be-queried routing entry as a key in the second-level tree storage structure of the first routing device as a root node, and according to a third preset hash function Calculating, obtaining a third hash address, wherein all routing entries of the first routing device are stored in the third hash address;
    第三读取单元,设置为在所述第三哈希地址中读取对应的候选路由表项,若所述候选路由表项为所述待查询路由表项,则查找成功;否则,遍历线性链表查找所述待查询路由表项。The third reading unit is configured to read the corresponding candidate routing entry in the third hash address, and if the candidate routing entry is the to-be-queried routing entry, the search succeeds; otherwise, the traversal is linear The linked list searches for the routing entry to be queried.
  18. 根据权利要求16所述的路由查询装置,其中,还包括:The route query device of claim 16, further comprising:
    判断模块,设置为获取待查询路由表项,并判断所述待查询路由表项是否为预设频繁项;其中,所述预设频繁项为占有率高于预设阈值的路由表项; The determining module is configured to obtain a routing entry to be queried, and determine whether the routing entry to be queried is a preset frequent item; wherein the preset frequent item is a routing entry whose occupation rate is higher than a preset threshold;
    若不是,则遍历线性链表查找所述待查询路由表项;If not, traversing the linear linked list to find the routing entry to be queried;
    若是,则在所述第一级树形存储结构中查找第一路由集群。If yes, the first routing cluster is looked up in the first level tree storage structure.
  19. 根据权利要求16~20任一项所述的路由查询装置,其中,还包括:The route query device according to any one of claims 16 to 20, further comprising:
    第一创建模块,设置为获取单个路由集群下多个路由设备中的频繁项,并根据第一预设哈希函数,创建所述频繁项对应的路由集群下多个路由设备的第一级树形存储结构,并将所述路由集群存储于所述第一级树形存储结构中的根结点中;The first creating module is configured to obtain a frequent item in multiple routing devices in a single routing cluster, and create a first level tree of multiple routing devices in the routing cluster corresponding to the frequent item according to the first preset hash function. Forming a storage structure, and storing the routing cluster in a root node in the first level tree storage structure;
    第二创建模块,设置为根据第二预设哈希函数,创建所述频繁项对应的路由设备下的路由表项的第二级树形存储结构,并将所述路由设备存储于所述第一级树形存储结构中的叶子结点或所述第二级树形存储结构的根结点中;a second creation module, configured to create a second-level tree storage structure of the routing entry under the routing device corresponding to the frequent item according to the second preset hash function, and store the routing device in the first a leaf node in the primary tree storage structure or a root node of the second level tree storage structure;
    第三创建模块,设置为根据第三预设哈希函数,将所述路由表项存储于所述第二级树形存储结构的叶子结点中。The third creating module is configured to store the routing table entry in a leaf node of the second level tree storage structure according to a third preset hash function.
  20. 根据权利要求21所述的路由查询装置,其中,所述第一创建模块包括:The route query device according to claim 21, wherein the first creation module comprises:
    第一计算单元,设置为以所述频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的路由集群存储于所述第一哈希地址中;a first calculating unit, configured to use the frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding routing cluster in the first hash address in;
    第一创建单元,设置为将存储有不同路由集群的多个第一哈希地址,构建为第一级树形存储结构的根结点。The first creating unit is configured to construct a plurality of first hash addresses storing different routing clusters as root nodes of the first level tree storage structure.
  21. 根据权利要求21所述的路由查询装置,其中,所述第二创建模块包括:The route query device of claim 21, wherein the second creation module comprises:
    第二计算单元,设置为以所述频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的路由设备存储于所述第二哈希地址中;a second calculating unit, configured to use the frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding routing device in the second hash address in;
    第二创建单元,设置为将存储有不同的路由设备的多个第二哈希地址,构建为第一级树形存储结构的叶子结点或第二级树形存储结构的根结点。The second creating unit is configured to construct a plurality of second hash addresses storing different routing devices as a leaf node of the first level tree storage structure or a root node of the second level tree storage structure.
  22. 根据权利要求21所述的路由查询装置,其中,所述第三创建模块包括:The route query device according to claim 21, wherein the third creation module comprises:
    第三计算单元,设置为以路由表项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的路由表项存储于所述第三哈希地址中;The third calculating unit is configured to use the routing entry as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding routing entry in the third hash address. in;
    第三创建单元,设置为将存储有不同路由表项的多个第三哈希地址,构建为第二级树形存储结构的叶子结点。The third creating unit is configured to construct a plurality of third hash addresses storing different routing table entries as leaf nodes of the second level tree storage structure.
  23. 根据权利要求22所述的路由查询装置,其中,还包括: The route query device of claim 22, further comprising:
    第一获取模块,设置为当增加新路由集群时,获取所述新路由集群的频繁项;The first obtaining module is configured to acquire a frequent item of the new routing cluster when adding a new routing cluster;
    第一更新模块,设置为以所述频繁项为关键字,并根据第一预设哈希函数进行计算,得到第一哈希地址,并将对应的新路由集群存储于所述第一哈希地址中,更新所述第一级树形存储结构的根结点。The first update module is configured to use the frequent item as a key, and perform calculation according to the first preset hash function to obtain a first hash address, and store the corresponding new routing cluster in the first hash. In the address, the root node of the first level tree storage structure is updated.
  24. 根据权利要求22所述的路由查询装置,其中,还包括:The route query device of claim 22, further comprising:
    第二更新模块,设置为当路由集群减少时,将对应的第一哈希地址中的路由集群删除,更新所述第一级树形存储结构的根结点。The second update module is configured to: when the routing cluster is reduced, delete the routing cluster in the corresponding first hash address, and update the root node of the first-level tree storage structure.
  25. 根据权利要求23所述的路由查询装置,其中,还包括:The route query device of claim 23, further comprising:
    第二获取模块,设置为当增加新路由设备时,获取所述新路由设备的频繁项;a second obtaining module, configured to acquire a frequent item of the new routing device when adding a new routing device;
    第三更新模块,设置为以所述频繁项为关键字,并根据第二预设哈希函数进行计算,得到第二哈希地址,并将对应的新路由设备存储于所述第二新哈希地址中,更新所述第一级树形存储结构的叶子结点或所述二级树形存储结构的根结点。The third update module is configured to use the frequent item as a key, and perform calculation according to the second preset hash function to obtain a second hash address, and store the corresponding new routing device in the second new In the hash address, the leaf node of the first level tree storage structure or the root node of the secondary tree storage structure is updated.
  26. 根据权利要求23所述的路由查询装置,其中,还包括:The route query device of claim 23, further comprising:
    第四更新模块,设置为当路由设备减少时,将对应的第二哈希地址中存储的路由设备删除,更新所述第一级树形存储结构的叶子结点或所述二级树形存储结构的根结点。a fourth update module, configured to: when the routing device is reduced, delete the routing device stored in the corresponding second hash address, and update the leaf node or the secondary tree storage of the first level tree storage structure The root node of the structure.
  27. 根据权利要求24所述的路由查询装置,其中,还包括:The route query device according to claim 24, further comprising:
    第三获取模块,设置为当增加新路由表项时,获取所述新路由表项的频繁项;The third obtaining module is configured to acquire a frequent item of the new routing entry when adding a new routing entry;
    第五更新模块,设置为以所述频繁项为关键字,并根据第三预设哈希函数进行计算,得到第三哈希地址,并将对应的新路由表项存储于所述第三哈希地址中,更新所述第二级树形存储结构的叶子结点。The fifth update module is configured to use the frequent item as a key, and perform calculation according to the third preset hash function to obtain a third hash address, and store the corresponding new routing entry in the third In the hash address, the leaf node of the second level tree storage structure is updated.
  28. 根据权利要求24所述的路由查询装置,其中,还包括:The route query device according to claim 24, further comprising:
    第六更新模块,设置为当路由表项减少时,将对应的第三哈希地址中存储的路由表项删除,更新所述第二级树形存储结构的叶子结点。 The sixth update module is configured to: when the routing entry is reduced, delete the routing entry stored in the corresponding third hash address, and update the leaf node of the second-level tree storage structure.
PCT/CN2015/095448 2015-05-20 2015-11-24 Route lookup method and device WO2016184069A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510260256.0 2015-05-20
CN201510260256.0A CN106302178B (en) 2015-05-20 2015-05-20 Route query method and device

Publications (1)

Publication Number Publication Date
WO2016184069A1 true WO2016184069A1 (en) 2016-11-24

Family

ID=57319399

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/095448 WO2016184069A1 (en) 2015-05-20 2015-11-24 Route lookup method and device

Country Status (2)

Country Link
CN (1) CN106302178B (en)
WO (1) WO2016184069A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113886215A (en) * 2020-07-01 2022-01-04 深圳兆日科技股份有限公司 Interface test method, device and storage medium
CN114513449A (en) * 2022-02-23 2022-05-17 北京慧橙信息科技有限公司 Method and system for optimizing routing in domain

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109714347A (en) * 2018-12-29 2019-05-03 杭州迪普科技股份有限公司 Storage, querying method and the device of tactful hit results, equipment and medium
CN112749208A (en) * 2020-12-30 2021-05-04 普华云创科技(北京)有限公司 Distributed storage searching method and system based on secondary routing

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159658A (en) * 2007-11-02 2008-04-09 华为技术有限公司 Virtual private network routing search method and device
US20120033667A1 (en) * 2010-08-05 2012-02-09 Srikrishnan Venkataraman Method and apparatus for performing multicast traces in mpls networks
CN102511151A (en) * 2011-04-27 2012-06-20 华为技术有限公司 Router, virtual cluster router system and establishing method thereof
CN103107945A (en) * 2013-01-10 2013-05-15 中国科学院信息工程研究所 System and method of quick searching Internet protocol version 6 (IPV6) route

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7797348B2 (en) * 2003-05-01 2010-09-14 The Hong Kong Polytechnic University Data structure and system for IP address lookup and IP address lookup system
CN101902388A (en) * 2009-05-26 2010-12-01 北京风格九州文化传播有限公司 Expandable fast discovery technology for multi-stage sequencing resources
CN102571599B (en) * 2012-02-08 2014-12-10 福建三元达通讯股份有限公司 Rapid storage method of routing table entry
US9467302B2 (en) * 2013-10-07 2016-10-11 Avaya Inc. Quality of service aware hybrid multicast networks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159658A (en) * 2007-11-02 2008-04-09 华为技术有限公司 Virtual private network routing search method and device
US20120033667A1 (en) * 2010-08-05 2012-02-09 Srikrishnan Venkataraman Method and apparatus for performing multicast traces in mpls networks
CN102511151A (en) * 2011-04-27 2012-06-20 华为技术有限公司 Router, virtual cluster router system and establishing method thereof
CN103107945A (en) * 2013-01-10 2013-05-15 中国科学院信息工程研究所 System and method of quick searching Internet protocol version 6 (IPV6) route

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113886215A (en) * 2020-07-01 2022-01-04 深圳兆日科技股份有限公司 Interface test method, device and storage medium
CN114513449A (en) * 2022-02-23 2022-05-17 北京慧橙信息科技有限公司 Method and system for optimizing routing in domain
CN114513449B (en) * 2022-02-23 2024-04-26 北京慧橙信息科技有限公司 Intra-domain routing optimization method and system

Also Published As

Publication number Publication date
CN106302178A (en) 2017-01-04
CN106302178B (en) 2020-02-21

Similar Documents

Publication Publication Date Title
US9269411B2 (en) Organizing data in a hybrid memory for search operations
US7808929B2 (en) Efficient ACL lookup algorithms
US9537771B2 (en) Exact match hash lookup databases in network switch devices
US20060083247A1 (en) Prefix lookup using address-directed hash tables
CN104866502B (en) Data matching method and device
US20040255045A1 (en) IP address lookup method and hardware architecture using hashing
WO2016184069A1 (en) Route lookup method and device
WO2011127642A1 (en) Routing table construction method and device and routing table lookup method and device
JP5960863B1 (en) SEARCH DEVICE, SEARCH METHOD, PROGRAM, AND RECORDING MEDIUM
WO2016184029A1 (en) Storage and lookup methods and apparatuses supporting hash lookup and routing lookup, and storage medium
US20080133494A1 (en) Method and apparatus for searching forwarding table
WO2018068524A1 (en) Routing-table establishment and ip routing lookup method, device, and storage medium
WO2015188319A1 (en) Lookup device, lookup configuration method and lookup method
CN105357247A (en) Multi-dimensional cloud resource interval finding method based on hierarchical cloud peer-to-peer network
US20180145911A1 (en) Ip routing search
JP2017537566A (en) Routing table maintenance method, apparatus and storage medium
US7233579B1 (en) Routing table for forwarding Internet Protocol (IP) packets through a communications network
KR100999408B1 (en) Method for searching an ??? using hash tree
CN109754021B (en) Online packet classification method based on range tuple search
US20170012874A1 (en) Software router and methods for looking up routing table and for updating routing entry of the software router
CN110995876B (en) Method and device for storing and searching IP
CN115714752B (en) Packet classification method and device, forwarding chip and electronic equipment
CN113328947B (en) Variable-length route searching method and device based on application of controllable prefix extension bloom filter
Alimohammadi et al. Clustering-based many-field packet classification in software-defined networking
Bahrambeigy et al. Bloom-Bird: A scalable open source router based on Bloom filter

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: 15892443

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: 15892443

Country of ref document: EP

Kind code of ref document: A1