CN102904812B - The storage means of route table items, lookup method, Apparatus and system - Google Patents

The storage means of route table items, lookup method, Apparatus and system Download PDF

Info

Publication number
CN102904812B
CN102904812B CN201210371642.3A CN201210371642A CN102904812B CN 102904812 B CN102904812 B CN 102904812B CN 201210371642 A CN201210371642 A CN 201210371642A CN 102904812 B CN102904812 B CN 102904812B
Authority
CN
China
Prior art keywords
address
section
routing
tail
prefix
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201210371642.3A
Other languages
Chinese (zh)
Other versions
CN102904812A (en
Inventor
洪荣峰
易毅
郭玲波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201210371642.3A priority Critical patent/CN102904812B/en
Publication of CN102904812A publication Critical patent/CN102904812A/en
Application granted granted Critical
Publication of CN102904812B publication Critical patent/CN102904812B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a kind of storage means of route table items, lookup method, Apparatus and system, belong to computer realm.Described lookup method comprises: inquire address is divided at least two address fields; First address section according to inquire address searches the first address section matched with it in the first binary tree; Using the address suffix of first address section that the finds address prefix as the tail address field of inquire address; In the second binary tree, address prefix and the tail address field of the tail address field matched with it is searched according to the address prefix of the tail address field of inquire address and tail address field; Lookup result is obtained according to the address prefix of the tail address field found and tail address field.The present invention, by by routing address fragmented storage and searching, relative to prior art, has saved memory space, can be applicable to the storage of the routing address of multiple bit wide more neatly and search, and improves and search speed.

Description

The storage means of route table items, lookup method, Apparatus and system
Technical field
The present invention relates to computer realm, particularly a kind of storage means, lookup method, Apparatus and system of route table items.
Background technology
In network data transmission process, router carries out the forwarding of data according to the lookup result of route table items.In order to reduce the storage of the network equipment, the direct lookup result of usual route table items is not forwarding behavior, but the index of lookup result, carries out linear list search and finally obtain forwarding behavior according to index.Along with the fast development of network, the quantity of route table items is increasing, and bit wide is more and more longer, and kind also gets more and more, to the memory space of route table items with search speed and have higher requirement.
In prior art, usually use based on the storage of the route table items of binary tree, lookup method.Each known routing address is resolved into a lower bound (low point) address and the upper bound (high point) address, according to the principle of " left large and right small " stored in binary tree, each node stores a boundary address.When searching, compared by inquire address (search key), binary tree traversal from the root node of binary tree, the position of the node that record is walked left for the last time, obtains the index of lookup result, uses this index can obtain corresponding forwarding behavior.Meanwhile, when needing the bit wide of the route table items storing and search to be greater than the bit wide of memory space, the change of hardware can only be made, such as, change the storage medium etc. of a larger bit wide.
Realizing in process of the present invention, inventor finds that prior art at least exists following problem:
In prior art, routing address needs to be decomposed into the upper bound and lower bound two addresses and stores, and takies memory space large, and it is not high to search speed.When the routing address needing contraposition to be wider than current memory space bit wide does route table items storage and searches, memory space will make hardware and change with the bit wide needs adapting to this network address.
Summary of the invention
In order to solve the problem of prior art, embodiments provide a kind of storage means of route table items, lookup method, Apparatus and system.Described technical scheme is as follows:
On the one hand, provide a kind of storage means of route table items, described method comprises:
Each routing address of route table items is divided at least two address fields according to preset length;
For the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of described each routing address as next address section;
The first address section of described each routing address is stored in the node of the first binary tree, and stores the address suffix of the first address section correspondence of described each routing address;
If described next address section is tail address field, then address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to described each routing address, the index of the lookup result that described each routing address is corresponding is corresponding with the address prefix of the tail address field of described each routing address and tail address field, and the corresponding lookup result of the index of each lookup result.
Alternatively, described each routing address of route table items is divided at least two address fields according to preset length after, also comprise:
For the address field of each type in each routing address of route table items distributes corresponding type identification, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items;
Wherein, the type of the address field of each routing address of described route table items at least comprises first address section and tail address field.
Alternatively, the described first address section by described each routing address is stored in the node of the first binary tree, specifically comprises:
The first address section of described each routing address is stored in the node of described first binary tree successively according to descending order.
Alternatively, described address prefix corresponding for the tail address field of described each routing address and tail address field to be stored in the node of the second binary tree in the lump, specifically to comprise:
Address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of described second binary tree successively according to descending order.
Alternatively, the type of the address field of each routing address of described route table items also comprises intermediate address section, described using the address suffix of the first address section of described each routing address as next address section address prefix after, also comprise:
If described next address section is intermediate address section, be then that the intermediate address section of described each routing address distributes corresponding address suffix, and using the address prefix of described address suffix as the next address section of described intermediate address section;
The address prefix of the intermediate address section correspondence of described each routing address and intermediate address section are stored in the node of the 3rd binary tree in the lump, and store the address suffix of the intermediate address section correspondence of described each routing address.
Alternatively, described the address prefix of the intermediate address section correspondence of described each routing address and intermediate address section to be stored in the node of the 3rd binary tree in the lump, specifically to comprise:
The address prefix of the intermediate address section correspondence of described each routing address and intermediate address section are stored in the node of described 3rd binary tree successively according to descending order.
Alternatively, if described each routing address has multiple intermediate address section, then be stored in the node of the 3rd different binary trees respectively by the address prefix of each intermediate address section correspondence of described each routing address and intermediate address section, the number of described 3rd binary tree is identical with the number of the intermediate address section of described each routing address.
Alternatively, described is that the first address section of each routing address distributes corresponding address suffix, specifically comprises:
If the first address section of at least two routing address is identical, then for the first address section of described at least two routing address distributes identical address suffix.
Alternatively, described is that the intermediate address section of described each routing address distributes corresponding address suffix, specifically comprises:
If the first address section of at least two routing address is all identical with intermediate address section, then for the intermediate address section of described at least two routing address distributes identical address suffix.
Alternatively, when deleting at least one routing address in described route table items, described method also comprises:
Address prefix and the tail address field of the tail address field of deleted routing address is deleted from the second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in described route table items, then in described first binary tree, retain first address section and the address suffix thereof of described deleted routing address, if and described deleted routing address has intermediate address section, the intermediate address section of described deleted routing address is identical with the intermediate address section of other routing address in described route table items, in described 3rd binary tree, then retain the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix, if the intermediate address section of described deleted routing address is not identical with the intermediate address section of other routing address in described route table items, the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix is deleted from described 3rd binary tree,
If the first address section of deleted routing address is different from the first address section of other routing address in described route table items, first address section and the address suffix thereof of described deleted routing address is deleted from described first binary tree, if and described deleted routing address has intermediate address section, from described 3rd binary tree, delete the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix.
On the other hand, additionally provide a kind of lookup method of route table items, described method comprises:
Inquire address is divided at least two address fields according to preset length;
First address section according to described inquire address searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of described first binary tree;
If find the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the tail address field of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the tail address field of described inquire address;
In the second binary tree, search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field, in the node of described second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items;
If find address prefix and the tail address field of the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in described second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of described lookup result.
Alternatively, described inquire address is divided at least two address fields according to preset length after, also comprise:
For the address field of each type in inquire address distributes corresponding type identification, determine the type of each address field of described inquire address with the type identification corresponding to each address field of inquire address;
Wherein, the type of the address field of described inquire address at least comprises first address section and tail address field.
Alternatively, the described first address section according to described inquire address searches the first address section matched with it in the first binary tree, specifically comprises:
From the root node of described first binary tree, the first address section of the first address section of described inquire address with each routing address of the route table items stored in described first binary tree is successively compared;
If the first address section of described inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of described inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of described inquire address;
If participate in there is not the first address section matched with the first address section of described inquire address in the first address section of the routing address compared, then search end.
Alternatively, the address prefix of the described tail address field according to described inquire address and tail address field search address prefix and the tail address field of the tail address field matched with it in the second binary tree, specifically comprise:
From the root node of described second binary tree, the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of each routing address of the route table items stored in described second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of described inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of described inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of described inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
Alternatively, the type of the address field of described inquire address also comprises intermediate address section, and the described first address section according to described inquire address also comprises search the first address section matched with it in the first binary tree after:
If find the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the intermediate address section of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of described inquire address;
According to address prefix and the intermediate address section of searching the intermediate address section matched with it in the address prefix of the intermediate address section of described inquire address and intermediate address Duan tri-binary tree, in the node of described 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items;
If find address prefix and the intermediate address section of the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in described 3rd binary tree, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of described inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field address prefix and tail address field.
Alternatively, search address prefix and the intermediate address section of the intermediate address section matched with it in the address prefix of the described intermediate address section according to described inquire address and intermediate address Duan tri-binary tree, specifically comprise:
From the root node of described 3rd binary tree, the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of each routing address of the route table items stored in described 3rd binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of described inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
Alternatively, if described inquire address has multiple intermediate address section, then in the 3rd binary tree of correspondence, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of described inquire address and intermediate address section.
On the other hand, additionally provide a kind of storage device of route table items, described device comprises:
Divide module, for each routing address of route table items is divided at least two address fields according to preset length;
Distribution module, the first address section for each routing address obtained for described division Module Division distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of described each routing address as next address section;
First memory module, the first address section for each routing address described division Module Division obtained is stored in the node of the first binary tree, and stores the address suffix of the first address section correspondence of each routing address of described module assigns;
Second memory module, if the next address section for the first address section of described each routing address is tail address field, then address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to described each routing address, the index of the lookup result that described each routing address is corresponding is corresponding with the address prefix of the tail address field of described each routing address and tail address field, and the corresponding lookup result of the index of each lookup result.
Alternatively, described distribution module, also distribute corresponding type identification for the address field for each type in each routing address of route table items, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items;
Wherein, the type of the address field of each routing address of described route table items at least comprises first address section and tail address field.
Alternatively, described first memory module, specifically for being stored to the first address section of described each routing address successively in the node of described first binary tree according to descending order.
Alternatively, described second memory module, specifically for being stored to address prefix corresponding for the tail address field of described each routing address and tail address field successively in the node of described second binary tree according to descending order.
Alternatively, the type of the address field of each routing address of the route table items of described division Module Division also comprises intermediate address section;
Described distribution module if be also intermediate address section for described next address section, is then that the intermediate address section of described each routing address distributes corresponding address suffix, and using the address prefix of described address suffix as the next address section of described intermediate address section;
Described device also comprises:
3rd memory module, is stored in the lump in the node of the 3rd binary tree for the address prefix of the intermediate address section correspondence by described each routing address and intermediate address section, and stores the address suffix of the intermediate address section correspondence of described each routing address.
Alternatively, described 3rd memory module, is stored in the node of described 3rd binary tree according to descending order successively specifically for the address prefix of the intermediate address section correspondence by described each routing address and intermediate address section.
Alternatively, described 3rd memory module, if have multiple intermediate address section for described each routing address, then be stored in the node of the 3rd different binary trees respectively by the address prefix of each intermediate address section correspondence of described each routing address and intermediate address section, the number of described interlude address field storing sub-units is identical with the number of the intermediate address section of described each routing address.
Alternatively, described distribution module, if identical for the first address section of at least two routing address, then for the first address section of described at least two routing address distributes identical address suffix.
Alternatively, described distribution module, if all identical with intermediate address section for the first address section of at least two routing address, then for the intermediate address section of described at least two routing address distributes identical address suffix.
Alternatively, described device also comprises:
Removing module, for deleting address prefix and the tail address field of the tail address field of deleted routing address from described second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in described route table items, then in described first binary tree, retain first address section and the address suffix thereof of described deleted routing address, if and described deleted routing address has intermediate address section, the intermediate address section of described deleted routing address is identical with the intermediate address section of other routing address in described route table items, in described 3rd binary tree, then retain the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix, if the intermediate address section of described deleted routing address is not identical with the intermediate address section of other routing address in described route table items, the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix is deleted from described 3rd binary tree,
If the first address section of deleted routing address is different from the first address section of other routing address in described route table items, first address section and the address suffix thereof of described deleted routing address is deleted from described first binary tree, if and described deleted routing address has intermediate address section, from described 3rd binary tree, delete the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix.
On the other hand, what additionally provide a kind of route table items searches device, and described device comprises:
Divide module, for inquire address is divided at least two address fields according to preset length;
First searches module, first address section for the inquire address obtained according to described division Module Division searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of described first binary tree;
First acquisition module, if search module for described first to find the first address section matched with the first address section of described inquire address in described first binary tree, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the next address section of described inquire address;
Second searches module, if the next address section for the first address section of described inquire address is tail address field, in the second binary tree, then search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field, in the node of described second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items;
Second acquisition module, if search for described second address prefix and the tail address field that module finds the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in described second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of described lookup result.
Alternatively, described device also comprises:
Distribution module, address field for each type in the inquire address that obtains for described division Module Division distributes corresponding type identification, determines the type of each address field of described inquire address with the type identification corresponding to each address field of inquire address;
Wherein, the type of the address field of described inquire address at least comprises first address section and tail address field.
Alternatively, described first searches module, specifically for the root node from described first binary tree, the first address section of the first address section of described inquire address with each routing address of the route table items stored in described first binary tree is successively compared;
If the first address section of described inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of described inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of described inquire address;
If participate in there is not the first address section matched with the first address section of described inquire address in the first address section of the routing address compared, then search end.
Alternatively, described second searches module, specifically for the root node from described second binary tree, the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of each routing address of the route table items stored in described second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of described inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of described inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of described inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
Alternatively, the type of the address field of inquire address that described division Module Division obtains also comprises intermediate address section;
Described device also comprises:
3rd acquisition module, if for finding the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the intermediate address section of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of described inquire address;
3rd searches module, for searching address prefix and the intermediate address section of the intermediate address section matched with it in the address prefix of the intermediate address section according to described inquire address and intermediate address Duan tri-binary tree, in the node of described 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items;
4th acquisition module, if for the address prefix and the intermediate address section that find the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in described 3rd binary tree, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of described inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field address prefix and tail address field.
Alternatively, described 3rd searches module, specifically for the root node from described 3rd binary tree, the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of each routing address of the route table items stored in described 3rd binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of described inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
Alternatively, described 3rd searches module, if have multiple intermediate address section for described inquire address, then in the 3rd binary tree of correspondence, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of described inquire address and intermediate address section.
On the other hand, additionally provide a kind of seeking system of route table items, described system comprises: the storage device of route table items and route table items search device;
Wherein, the storage device of the storage device of described route table items route table items as above;
Described route table items search device route table items as above search device.
On the other hand, additionally provide a kind of storage means of route table items, described method comprises:
Routing address to be stored is divided into first address section and tail address field according to preset length;
For described first address section allocation address suffix, be described tail address field allocation address prefix, between described address prefix and address suffix, meet default corresponding relation;
Described first address section is stored in the node of the first binary tree, and records the memory address of described first address section in described first binary tree and the corresponding relation of described address prefix;
Described address prefix and described tail address field are stored in the second binary tree, and the indexed results that record is corresponding with described address prefix and described tail address field.
The storage means of described route table items, also comprises: described address prefix is identical with described address suffix.
The storage means of described route table items, is describedly stored to the second binary tree by described address prefix and described tail address field and comprises:
Described address prefix and described tail address field are stored in the same node of described second binary tree.
On the other hand, additionally provide a kind of lookup method of routing address, described method comprises:
Obtain routing address to be found, and described routing address is divided into first address section and tail address field according to preset length;
In the first binary tree, search described first address section, and obtain the address suffix corresponding with described first address section;
According to the corresponding relation preset, according to described address suffix address acquisition prefix;
Search the second binary tree according to described address prefix and described tail address field, and obtain routing iinformation according to lookup result.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is:
By routing address is divided at least two address fields, and be stored to by each address field in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly; In addition, obtain lookup result by the mode of segment lookup, can improve and search speed.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, below the accompanying drawing used required in describing embodiment is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
The storage means flow chart of a kind of route table items that Fig. 1 provides for the embodiment of the present invention one;
The lookup method flow chart of a kind of route table items that Fig. 2 provides for the embodiment of the present invention one;
The storage means flow chart of a kind of route table items that Fig. 3 provides for the embodiment of the present invention two;
The storage binary tree structure figure of a kind of route table items that Fig. 4 provides for the embodiment of the present invention two;
The storage binary tree structure figure of the another kind of route table items that Fig. 5 provides for the embodiment of the present invention two;
The lookup method flow chart of a kind of route table items that Fig. 6 provides for the embodiment of the present invention three;
A kind of hardware schematic diagram storing and search route table items that Fig. 7 provides for the embodiment of the present invention three;
The structural representation of the storage device of a kind of route table items that Fig. 8 provides for the embodiment of the present invention four;
The structural representation of the storage device of the another kind of route table items that Fig. 9 provides for the embodiment of the present invention four;
The structural representation of the storage device of the another kind of route table items that Figure 10 provides for the embodiment of the present invention four;
The structural representation searching device of a kind of route table items that Figure 11 provides for the embodiment of the present invention five;
The structural representation searching device of the another kind of route table items that Figure 12 provides for the embodiment of the present invention five;
The structural representation searching device of the another kind of route table items that Figure 13 provides for the embodiment of the present invention five;
The structural representation of the seeking system of a kind of route table items that Figure 14 provides for the embodiment of the present invention six.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment one
Present embodiments provide a kind of storage means of route table items, the method, by the mode of fragmented storage, is saved the memory space of the binary tree storing routing address, and is realized the flexible storage of route table items.See Fig. 1, the storage means flow process of the route table items that the present embodiment provides is specific as follows:
101: each routing address of route table items is divided at least two address fields according to preset length;
102: for the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of each routing address as next address section;
103: the first address section of each routing address is stored in the node of the first binary tree, and the address suffix storing the first address section correspondence of each routing address;
104: if next address section is tail address field, then address prefix corresponding for the tail address field of each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to each routing address, address prefix and the tail address field of the index of the lookup result that each routing address is corresponding and the tail address field of each routing address are corresponding, and the corresponding lookup result of the index of each lookup result.
The present embodiment additionally provides a kind of lookup method of route table items, and for the mode of above-mentioned fragmented storage route table items, the present embodiment takes the method for segment lookup, thus improve route table items search speed.See Fig. 2, the lookup method flow process of the route table items that the present embodiment provides is specific as follows:
201: inquire address is divided at least two address fields according to preset length;
202: the first address section according to inquire address searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of the first binary tree;
203: if find the first address section matched with the first address section of inquire address in the first binary tree, and the next address section of the first address section of inquire address is the tail address field of inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the tail address field of inquire address;
204: in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field address prefix and tail address field, store address prefix and the tail address field of the tail address field of each routing address of route table items in the node of the second binary tree;
205: if find address prefix and the tail address field of the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of lookup result.
The method that the present embodiment provides, by routing address is divided at least two address fields, and each address field is stored in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly; In addition, obtain lookup result by the mode of segment lookup, can improve and search speed.
Embodiment two
Present embodiments provide a kind of storage means of route table items, in conjunction with the storage content of the route table items that above-described embodiment one provides, for convenience of explanation, the present embodiment, to store the routing address A to I of 16 bits in route table items, is illustrated the storage means of the route table items that the present embodiment provides.Wherein, routing address A to I is specific as follows:
Routing address A:1001001001000011
Routing address B:1001001010010111
Routing address C:1001001110001010
Routing address D:1001001111011101
Routing address E:1011011010101100
Routing address F:1011011010101111
Routing address G:1101011110001100
Routing address H:1101101110011010
Routing address I:1110010110111101
See Fig. 3, the storage means of the route table items that the present embodiment provides is when storing above-mentioned routing address A to I, and its method flow is specific as follows:
301: each routing address of route table items is divided at least two address fields according to preset length.
For this step, both preset length can be set to the half length of routing address, the equal address field of length is divided into by each routing address, also address field that can be different arranges different preset length respectively, by each routing address be divided into length not wait address field, the present embodiment does not limit the concrete size of preset length.
When each routing address of route table items is divided at least two address fields according to preset length, the present embodiment does not limit the number of the address field divided.For convenience of explanation, if be only divided into two address fields, address field called after first address section and the tail address field successively that the present embodiment will divide, if divide plural address field, then except first address section and tail address field, the present embodiment is by equal for the address field between first address section and tail address field called after intermediate address section, and wherein, the number of intermediate address section is one or more.
302: for the address field of each type in each routing address of route table items distributes corresponding type identification, determine the type of each address field with the type identification corresponding to each address field in each routing address of route table items.
Wherein, if each routing address is divided into two address fields by above-mentioned steps 301, then the type of the address field of each routing address of route table items comprises first address section and tail address field, when address field for each type distributes corresponding type identification, such as, can headed by address field distribute type identification 00, for tail address field distributes type identification 11, in addition, other marks can also be distributed, the present embodiment does not limit concrete type identification, can be known the type of each address field by the type mark.
If each routing address is divided into plural address field by above-mentioned steps 301, then the type of the address field of each routing address of route table items is except comprising first address section and tail address field, and the type of address field also comprises intermediate address section.The present embodiment does not limit the type identification distributed for intermediate address section equally, and the type identification ensureing according to this address field can determine the type of this address field.
303: for the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of each routing address as next address section.
For this step, be why that the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of each routing address as next address section, to search in the process of route table items follow-up, the next address section with the address prefix identical with this address suffix can be found according to the address suffix of last address field, thus meet default corresponding relation between the address suffix of first address section and the address prefix of next address section herein.For the specific address suffix distributed, the present embodiment does not do concrete restriction.In order to save memory space, when the first address section for each routing address distributes corresponding address suffix, if the first address section of at least two routing address is identical, then for the first address section of at least two routing address distributes identical address suffix.
If each routing address of route table items is divided into two address fields by above-mentioned steps 301, i.e. first address section and tail address field, then this step 303 is after the address suffix of first address section distribution correspondence of each routing address, the address suffix of the first address section of each routing address is namely as the address prefix of its tail address field, the routing address A to I of above-mentioned 16 bits to be divided into respectively the first address section high_A to high_I of 10 bits and the tail address field low_A to low_I of 6 bits, and headed by address field high_A to the high_I address suffix next_A to next_I that distributes 4 bits be example, shown in the information that then each routing address is corresponding is specific as follows:
high_A:1001001001 next_A:0010 low_A:000011
high_B:1001001010 next_B:0100 low_B:010111
high_C:1001001110 next_C:0110 low_C:001010
high_D:1001001111 next_D:1000 low_D:011101
high_E:1011011010 next_E:1010 low_E:101100
high_F:1011011010 next_F:1010 low_F:101111
high_G:1101011110 next_G:1100 low_G:001100
high_H:1101101110 next_H:1101 low_H:011010
high_I:1110010110 next_I:1110 low_I:111101
Concrete storage organization as shown in Figure 4, can be found out based on above-mentioned information, and the first address section of routing address E with F is identical, thus for it is assigned with identical address suffix 1010.When storing each routing address of route table items, said n ext_A to next_I can be used as address prefix corresponding to the tail address field low_A to low_I of routing address A to I, because the address suffix of last address field is identical with the address prefix of a rear address field, therefore, address prefix and address suffix can regard the association identification between two address fields as, enable subsequent embodiment find a complete routing address with this.
If each routing address of route table items is divided into plural address field by above-mentioned steps 301, namely comprise outside first address section and tail address field, also comprise intermediate address section, then this step 303 is after the address suffix of first address section distribution correspondence of each routing address, the address suffix of the first address section of each routing address is namely as the address prefix of next intermediate address section, and the intermediate address section that this step 303 is also required to be each routing address distributes corresponding address suffix, and using the address prefix of its address suffix as the next address section of this intermediate address section.Particularly, if each routing address only comprises an intermediate address section, then the next address section of this intermediate address section is tail address field; If each routing address comprises two and above intermediate address section, then the next address section of this intermediate address section is still intermediate address section, and the next address section of last intermediate address section is tail address field.And in order to save memory space, when distributing corresponding address suffix for the first address section of each routing address and intermediate address section, if the first address section of at least two routing address is identical, then for the first address section of at least two routing address distributes identical address suffix; If the first address section of at least two routing address is all identical with intermediate address section, then for the intermediate address section of at least two routing address distributes identical address suffix.
The routing address A to I of above-mentioned 16 bits to be divided into respectively the first address section High_A to High_I of 8 bits, the intermediate address section mid_A to mid_I of 4 bits and the tail address field Low_A to Low_I of 4 bits, and headed by address field High_A to High_I distribute the address suffix Next1_A to Next1_I of 4 bits, the address suffix Next2_A to Next2_I distributing 4 bits for intermediate address section mid_A to mid_I is example, then the information of each routing address is specific as follows:
High_A:10010010 Next1_A:0100 mid_A:0100 Next2_A:0010 Low_A:0011
High_B:10010010 Next1_B:0100 mid_B:1001 Next2_B:0100 Low_B:0111
High_C:10010011 Next1_C:1000 mid_C:1000 Next2_C:0110 Low_C:1010
High_D:10010011 Next1_D:1000 mid_D:1101 Next2_D:1000 Low_D:1101
High_E:10110110 Next1_E:1010 mid_E:1010 Next2_E:1010 Low_E:1100
High_F:10110110 Next1_F:1010 mid_F:1010 Next2_F:1010 Low_F:1111
High_G:11010111 Next1_G:1100 mid_G:1000 Next2_G:1100 Low_G:1100
High_H:11011011 Next1_H:1101 mid_H:1001 Next2_H:1101 Low_H:1010
High_I:11100101 Next1_I:1110 mid_I:1011 Next2_I:1110 Low_I:1101
Concrete storage organization as shown in Figure 5, can be found out based on above-mentioned information, and the first address section of routing address A with B is identical, thus for it is assigned with identical address suffix 0100; The first address section of routing address C with D is identical, thus for it is assigned with identical address suffix 1000; The first address section of routing address E with F is identical, thus for it is assigned with identical address suffix 1010.First address section due to routing address E with F is identical and intermediate address section is also identical, thus for the intermediate address section of routing address E and F is assigned with identical address suffix 1010.When storing each routing address of route table items, above-mentioned Next1_A to Next1_I can be used as address prefix corresponding to the intermediate address section mid_A to mid_I of routing address A to I, the address suffix Next2_A to Next2_I that intermediate address section mid_A to mid_I is corresponding can be used as address prefix corresponding to the tail address field Low_A to Low_I of routing address A to I, because the address suffix of last address field is identical with the address prefix of a rear address field, therefore, address prefix and address suffix can regard the association identification between two address fields equally as, a complete routing address is found with this.
304: the first address section of each routing address is stored in the node of the first binary tree, and the address suffix storing the first address section correspondence of each routing address.
For this step, when storing the first address section of each routing address, concrete storage mode includes but not limited to:
The first address section of all routing address is stored in the node of the first binary tree from left to right successively according to descending order.
Be illustrated in figure 4 example with the structure of the first binary tree storing the first address section of each routing address, first address section high_H is less than first address section high_I, in the node of the first binary tree, is positioned in the right node of the node of high_I; First address section high_G is less than first address section high_H, in the node of the first binary tree, is positioned in the right node of the node of high_H; First address section high_F is less than first address section high_G, in the node of the first binary tree, is positioned in the right node of the node of high_G; First address section high_E is identical with first address section high_F, and therefore these two first address sections are arranged in the first identical binary tree node; By that analogy, until all routing address are all stored in the first binary tree node.When storing the address suffix of first address section correspondence of each routing address, the present embodiment does not limit concrete storage mode, during concrete enforcement, the address suffix of all first address section correspondences can be stored at last one deck of the first binary tree, wherein first address section high_E is identical with first address section high_F, be stored in the first identical binary tree node, corresponding identical address suffix.
After the first address section of routing address and address suffix thereof being stored according to said process, if next address section is intermediate address section, then perform step 305, if next address section is tail address field, then directly perform step 306.
305: the address prefix of the intermediate address section correspondence of each routing address and intermediate address section are stored in the node of the 3rd binary tree in the lump, and store the address suffix of the intermediate address section correspondence of each routing address.
For this step, when the address prefix of the intermediate address section of each routing address and intermediate address section being stored in the lump in the node of the 3rd binary tree, concrete storage mode includes but not limited to:
The address prefix of the intermediate address section correspondence of each routing address and intermediate address section are stored in the node of the 3rd binary tree from left to right successively according to descending order.
After being divided into plural address field with routing address each in above-mentioned steps 303, for first address section and the intermediate address section allocation address suffix of routing address A to I, and it can be used as the address prefix of next address section to be example, the address prefix of intermediate address section and intermediate address section is identical to the method in the first binary tree with storage first address section stored in the storage means in the node of the 3rd binary tree, illustrate no longer one by one herein.For the storage mode of the address suffix of intermediate address section correspondence, the present embodiment does not do concrete restriction equally, during concrete enforcement, after can being stored in the 3rd binary tree according to order from big to small by the address prefix of the intermediate address section of each routing address and intermediate address section, store the address suffix of the intermediate address section correspondence of each routing address at last one deck of the 3rd binary tree from left to right.
It should be noted that, if each routing address has multiple intermediate address section, then the address prefix of each intermediate address section correspondence of each routing address and intermediate address section are stored in the node of the 3rd different binary trees respectively, that is, the number of the 3rd binary tree is identical with the number of the intermediate address section of each routing address.After the address prefix of the intermediate address section of each routing address and intermediate address section and address suffix being stored to the 3rd binary tree by said process, by performing step 306, realize the storage of the tail address field of each routing address.
306: address prefix corresponding for the tail address field of each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to each routing address, address prefix and the tail address field of the index of the lookup result that each routing address is corresponding and the tail address field of each routing address are corresponding, and the corresponding lookup result of the index of each lookup result.
For this step, when address prefix corresponding for the tail address field of each routing address and tail address field being stored in the lump in the node of the second binary tree, concrete storage mode includes but not limited to:
Address prefix corresponding for the tail address field of all routing address and tail address field are stored in the node of the second binary tree from left to right successively according to descending order.
After being divided into two address fields with routing address each in above-mentioned steps 303, for the first address section allocation address suffix of routing address A to I, and it can be used as the address prefix of tail address field to be example, the address suffix of address field high_A headed by the address prefix that the tail address field low_A of routing address A is corresponding, i.e. next_A, therefore need [next_A, low_A] to be stored in the node of the second binary tree, by that analogy.The storage means address prefix of tail address field and tail address field being stored in the lump the second binary tree is identical to the method in the first binary tree with storage first address section, illustrates no longer one by one herein.About the storage mode of the address suffix of tail address field, the present embodiment does not do concrete restriction, during concrete enforcement, after can the address prefix of the tail address field of each routing address and tail address field being stored in the second binary tree according to order from big to small from left to right, the index of lookup result corresponding to each routing address is stored at last one deck of the second binary tree, as shown in Figure 4, the present embodiment instead of example, can obtain lookup result corresponding to routing address according to the index of lookup result with the rope reference numerals 1 to 15 of lookup result.
No matter each routing address of route table items is divided into how many address fields, all can store in the manner described above.Further, the method that the present embodiment provides is after storing each routing address of route table items in the manner described above, and for the situation of at least one routing address deleted in route table items, the method that the present embodiment provides also comprises:
Address prefix and the tail address field of the tail address field of deleted routing address is deleted from the second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in route table items, then in the first binary tree, retain first address section and the address suffix thereof of deleted routing address; And if the intermediate address section of deleted routing address is identical with the intermediate address section of other routing address in route table items, in the 3rd binary tree, then retain the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix, if the intermediate address section of deleted routing address is not identical with the intermediate address section of other routing address in route table items, from the 3rd binary tree, delete the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix;
If the first address section of deleted routing address is different from the first address section of other routing address in route table items, first address section and the address suffix thereof of deleted routing address is deleted from the first binary tree, if and deleted routing address has intermediate address section, and from the 3rd binary tree, delete the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix.
For the ease of understanding, two address fields are divided into each routing address of route table items, the routing address A deleted in the manner described above in the route table items stored is example, then concrete delete step comprises: the tail address field low_A deleting routing address A in the second binary tree; The first address section high_A of routing address is not identical with the first address section high_B to high_I of other routing address B to I in route table items, then in the first binary tree, delete first address section high_A and the address suffix next_A thereof of routing address A.
Be divided into three address fields with each routing address of route table items, the routing address A deleted in the manner described above in the route table items stored is example, then concrete delete step comprises: the tail address field Low_A deleting routing address A in the second binary tree; The first address section High_A of routing address is identical with the first address section High_B of the routing address B in routing table, then the first address section High_A of reserved route address A and address suffix Next1_A thereof in the first binary tree; The intermediate address section mid_A of routing address is not identical with the intermediate address section mid_B to mid_I of other routing address B to I in route table items, then in the 3rd binary tree, delete intermediate address section mid_A and the address suffix Next2_A thereof of routing address A.
Be divided into three address fields with each routing address of route table items, the routing address G deleted in the manner described above in the route table items stored is example, then concrete delete step comprises: the tail address field Low_G deleting routing address G in the second binary tree; The first address section High_G of routing address is not identical with the first address section of other routing address in routing table, then in the first binary tree, delete first address section High_G and the address suffix Next1_G thereof of routing address G; Intermediate address section mid_G and the address suffix Next2_G thereof of routing address G is deleted in the 3rd binary tree.
The method that the present embodiment provides, by routing address is divided at least two address fields, and each address field is stored in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly.
Embodiment three
Present embodiments provide a kind of lookup method of route table items, in conjunction with the lookup method of the route table items that above-described embodiment one provides, to search inquire address a in the route table items of the routing address of 16 bits stored in above-described embodiment two, b, c, the lookup result that d is corresponding is example, is illustrated the lookup method of the route table items that the present embodiment provides.Wherein, inquire address a, b, c, d are specific as follows:
Inquire address a:1001001110001011
Inquire address b:1011011010101100
Inquire address c:1011011010111100
Inquire address d:1100101110011010
See Fig. 6, the lookup method of the route table items that the present embodiment provides is when searching lookup result corresponding to above-mentioned inquire address a to d, and its method flow is specific as follows:
601: inquire address is divided at least two address fields according to preset length.
Wherein, between the address field of the address field divided to make inquire address and the routing address of storage, there is comparativity, the length of inquire address should be consistent with the length of the routing address stored in above-described embodiment two, this step is when being divided into address field by inquire address, and the large I of its preset length chosen is determined according to the preset length chosen when dividing the address field of routing address in above-described embodiment two.
For the situation of the tail address field of the first address section and 6 bits that in above-described embodiment two, routing address are divided into 10 bits, inquire address can be divided into the first address section high_a to high_d of 10 bits and the tail address field low_a to low_b of 6 bits by this step equally, then the information of the inquire address after the division of this step is specific as follows:
high_a:1001001110 low_a:001010
high_b:1011011010 low_b:101100
high_c:1011011010 low_c:111100
high_d:1100101110 low_d:011010
For the first address section in above-described embodiment two, the routing address of above-mentioned 16 bits being divided into respectively 8 bits, the situation of the intermediate address section of 4 bits and the tail address field of 4 bits, then the information of the inquire address after the division of this step is specific as follows:
High_a:10010011 mid_a:1000 Low_a:1010
High_b:10110110 mid_b:1010 Low_b:1100
High_c:10110110 mid_c:1011 Low_c:1100
High_d:11001011 mid_d:1001 Low_d:1010
No matter inquire address is divided into two address fields, or plural address field, in order to distinguish the different address fields of inquire address, the method that the present embodiment provides, after inquire address is divided at least two address fields according to preset length, also comprises:
For the address field of each type in inquire address distributes corresponding type identification, with the type of each address field of the type identification determination inquire address corresponding to each address field of inquire address;
Wherein, if each inquire address is divided into two address fields by said process, then the type of the address field of each inquire address comprises first address section and tail address field; If each inquire address is divided into plural address field by said process, then the type of the address field of each inquire address is except comprising first address section and tail address field, and the type of address field also comprises intermediate address section.The present embodiment does not limit the type identification that the address field for every type distributes, and the type identification ensureing according to this address field can determine the type of the address field of this inquire address.
602: the first address section according to inquire address searches the first address section matched with it in the first binary tree, the first address section of each routing address of route table items is stored in the node of the first binary tree, if find the first address section of coupling, and the next address section of the first address section of inquire address is the intermediate address section of inquire address, then perform step 603, if find the first address section of coupling, and the next address section of the first address section of inquire address is the tail address field of inquire address, then perform step 606, if do not find the first address section of coupling, then flow process terminates.
For this step, when searching according to the first address section of inquire address the first address section matched with it in the first binary tree, specifically the mode of searching includes but not limited to:
From the root node of the first binary tree, the first address section of the first address section of inquire address with each routing address of the route table items stored in binary tree is successively compared;
If the first address section of inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of inquire address;
If participate in there is not the first address section matched with the first address section of inquire address in the first address section of the routing address compared, then search flow process and terminate.
The first address section high_a of above-mentioned inquire address a to be searched in the first binary tree shown in Fig. 4 the first address section of coupling, from root node, the first address section high_a of inquire address a is compared with the first address section high_D of routing address D, comparative result is that high_a is less than high_D, then the first address section high_B of the routing address B on the right side of high_a and high_D is compared, comparative result is that high_a is greater than high_B, then the first address section high_C of the routing address C on the left of high_a and high_B is compared, comparative result is coupling, then using first address section that the first address section high_C of routing address C matches as the first address section high_a with inquire address a.
The first address section high_b of above-mentioned inquire address b to be searched in the first binary tree shown in Fig. 4 the first address section of coupling, from root node, the first address section high_b of inquire address b is compared with the first address section high_D of routing address D, comparative result is that high_b is greater than high_D, then the first address section high_G of the routing address G on the left of high_b and high_D is compared, comparative result is that high_b is less than high_G, then the first address section high_E of the routing address E on the right side of high_b and high_G is compared, comparative result is coupling, then using first address section that the first address section high_E of routing address E matches as the first address section high_b with inquire address b.The first address section high_c of inquire address c is identical with the first address section high_b of inquire address b, then Query Result is also identical.
Due to above-mentioned inquire address a, the first address section high_a of b, c, high_b, high_c finds the first address section of coupling in the first binary tree shown in Fig. 4, and the next address section of the first address section of inquire address a, b, c is inquire address a, b, the tail address field of c, therefore, directly performs step 606.
The first address section high_d of above-mentioned inquire address d to be searched in the first binary tree shown in Fig. 4 the first address section of coupling, from root node, the first address section high_d of inquire address d is compared with the first address section high_D of routing address D, comparative result is that high_d is greater than high_D, then the first address section high_G of the routing address G on the left of high_d and high_D is compared, comparative result is that high_d is less than high_G, then the first address section high_E of the routing address E on the right side of high_d and high_G is compared, comparative result is that high_d is greater than high_E, therefore lookup result is not for mate, that is, the first address section participating in the routing address compared in first binary tree shown in first address section high_d and Fig. 4 of inquire address d is not mated, therefore illustrate in the route table items stored the binary tree shown in Fig. 4 there is not lookup result corresponding to inquire address d, therefore, terminate to search flow process, Output rusults is miss.
If when inquire address is divided into the address field of more than three or three, the first address section High_a of above-mentioned inquire address a to be searched in the first binary tree shown in Fig. 5 the first address section of coupling, mode of specifically searching is same as described above, and lookup result is mate with the first address section High_C of routing address C.First address section High_a due to above-mentioned inquire address a finds the first address section of coupling in the first binary tree shown in Fig. 5, and the next address section of the first address section of inquire address a is the intermediate address section of inquire address a, therefore, directly performs step 603.
The mode of searching of the first address section High_b to High_d of inquire address b to d is also identical with above-mentioned mode of searching, discuss no longer one by one at this, lookup result is respectively, inquire address b and inquire address c has identical first address section High_b and High_c, and that match with it is the first address section High_E of routing address E.Because the first address section High_b of above-mentioned inquire address b and inquire address c and High_c finds the first address section of coupling in the first binary tree shown in Fig. 5, and the next address section of the first address section of inquire address b and inquire address c is the intermediate address section of inquire address b and inquire address c, therefore, directly step 603 is performed.The first address section that the first address section High_d of inquire address d does not match with it in the first binary tree shown in Fig. 5, therefore illustrate in the route table items stored the binary tree shown in Fig. 5 there is not lookup result corresponding to inquire address d, therefore, terminate to search flow process, Output rusults is miss.
603: obtain the address suffix of first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of inquire address.
For this step, because above-described embodiment two is when storing the address suffix of first address section correspondence of routing address, be stored in last one deck of the first binary tree, therefore, after above-mentioned steps 602 finds the first address section matched with the first address section of inquire address in the first binary tree, the corresponding relation of the first address Duan Yuqi address suffix found by this, the address suffix of the first address section correspondence that this finds can be got from the correspondence position of the last one deck of the first binary tree, and using the address suffix that the gets address prefix as the intermediate address section of inquire address.That is, owing to meeting default corresponding relation between the address suffix of first address section correspondence that finds and the address prefix of intermediate address section, thus after the address suffix getting first address section correspondence, based on the corresponding relation preset, the address prefix of the intermediate address section of inquire address can be obtained according to the address suffix of the first address section correspondence found.
To obtain the address suffix of the first address section High_C matched with the first address section High_a of inquire address a found in the first binary tree shown in Fig. 5, the address suffix that High_C is corresponding is Next1_C, and therefore Next1_C can be used as the address prefix of the intermediate address section mid_a of inquire address a.
The first address section that the first address section High_b of inquire address b and the first address section High_c of inquire address c mates is High_E, the address suffix that High_E is corresponding is Next1_E, and therefore Next1_E can be used as the address prefix of the address prefix of the intermediate address section mid_b of inquire address b and the intermediate address section mid_c of inquire address c.
604: according to address prefix and the intermediate address section of searching the intermediate address section matched with it in the address prefix of the intermediate address section of inquire address and intermediate address Duan tri-binary tree, in the node of the 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items.
According to address prefix and the intermediate address section of searching the intermediate address section matched with it in the address prefix of the intermediate address section of inquire address and intermediate address Duan tri-binary tree, specifically comprise:
From the root node of the 3rd binary tree, the address prefix of the intermediate address section of each routing address of the route table items stored in the address prefix of the intermediate address section of inquire address and intermediate address Duan Yu tri-binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
To search address prefix and the intermediate address section of the intermediate address section matched with the address prefix Next1_C of the intermediate address section of inquire address a and intermediate address section mid_a in the 3rd binary tree shown in Fig. 5, from root node, by the address prefix Next1_C of the intermediate address section of inquire address a and intermediate address section mid_a, [Next1_C, mid_a], with [the Next1_D of routing address D, mid_D] compare, comparative result is [Next1_C, mid_a] be less than [Next1_D, mid_D]; Then [Next1_C, mid_a] compared with right side node [Next1_B, mid_B], comparative result is that [Next1_C, mid_a] is greater than [Next1_B, mid_B]; Then [Next1_B, mid_B] compared with left node [Next1_C, mid_C], comparative result is that [Next1_C, mid_a] mates with [Next1_C, mid_C].
To search address prefix and the intermediate address section of the intermediate address section matched with the address prefix Next1_E of the intermediate address section of inquire address b and intermediate address section mid_b in the 3rd binary tree shown in Fig. 5, concrete lookup method is same as described above, repeat no more, lookup result is that [Next1_E, the mid_E] in the address prefix Next1_E of the intermediate address section of inquire address b and intermediate address section mid_b and the 3rd binary tree matches.
To search address prefix and the intermediate address section of the intermediate address section matched with the address prefix Next1_E of the intermediate address section of inquire address c and intermediate address section mid_c in the 3rd binary tree shown in Fig. 5, concrete lookup method is same as described above, repeat no more, lookup result is address prefix and the intermediate address section of the intermediate address section that the address prefix Next1_E of the intermediate address section of inquire address c and intermediate address section mid_c do not match with it in the 3rd binary tree, therefore illustrate in the route table items stored the binary tree shown in Fig. 5 there is not lookup result corresponding to inquire address c, therefore, terminate to search flow process, Output rusults is miss.
It should be noted that, if inquire address has multiple intermediate address section, then in each 3rd binary tree, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of inquire address and intermediate address section.
605: obtain the address suffix of intermediate address section correspondence found, and using the address suffix that the gets address prefix as the tail address field of inquire address.
For this step, because above-described embodiment two is when storing the address suffix of intermediate address section correspondence of routing address, be stored in last one deck of the 3rd binary tree, therefore, after the address prefix that above-mentioned steps 604 finds the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the 3rd binary tree and intermediate address section, the corresponding relation of the intermediate address Duan Yuqi address suffix found by this, the address suffix of the intermediate address section correspondence that this finds can be got from the correspondence position of the last one deck of the 3rd binary tree, and using the address suffix that the gets address prefix as the tail address field of inquire address.That is, owing to meeting default corresponding relation between the address suffix of first address section correspondence that finds and the address prefix of tail address field, thus after the address suffix getting first address section correspondence, based on the corresponding relation preset, the address prefix of the tail address field of inquire address can be obtained according to the address suffix of the first address section correspondence found.
Especially, if inquire address has multiple intermediate address section, when the next address section of middle address field is intermediate address section, continue to perform step 603 and step 604, wherein need the address suffix obtaining the previous intermediate address section correspondence found in step 603, and using the address suffix that the gets address prefix as a rear intermediate address section of inquire address.
For the address prefix corresponding with the intermediate address section that address prefix Next1_C and the intermediate address section mid_C of the intermediate address section of inquire address a mate found in the 3rd binary tree shown in Fig. 5 and intermediate address section, with [the Next1_C of inquire address a, mid_a] that mate is intermediate address section [Next1_C, mid_C], corresponding address suffix is Next2_C, and therefore Next2_C can be used as the address prefix of the tail address field Low_a of inquire address a.
For the address prefix corresponding with the intermediate address section that address prefix Next1_E and the intermediate address section mid_E of the intermediate address section of inquire address b mate found in the 3rd binary tree shown in Fig. 5 and intermediate address section, with [the Next1_E of inquire address b, mid_b] what mate is intermediate address section, [Next1_E, mid_E], corresponding address suffix is Next2_E, and therefore Next2_E can be used as the address prefix of the tail address field Low_b of inquire address b.
606: in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field address prefix and tail address field, address prefix and the tail address field of the tail address field of each routing address of route table items is stored in the node of the second binary tree, if find address prefix and the tail address field of the tail address field of coupling, then perform step 607, otherwise flow process terminates.
For this step, when searching address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field in the second binary tree, specifically the mode of searching includes but not limited to:
From the root node of the second binary tree, the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of each routing address of the route table items stored in the second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search flow process and terminate.
For the ease of understanding, two address fields are divided into inquire address, in the second binary tree shown in Fig. 4, the address prefix of the tail address field mated with it is searched and tail address field is example according to the address prefix next_C of the tail address field of inquire address a and tail address field low_a, from root node, by [the next_C of inquire address a, low_a] with [next_E of routing address E, low_E], comparative result is [next_C, low_a] be less than [next_E, low_E], then by [next_C, low_a] and right side node [next_C, low_C] compare, comparative result is coupling, then perform step 607.
The address prefix and the tail address field that in second binary tree of Fig. 4, carry out the address prefix next_E of the tail address field of inquire address c and tail address field low_c searching the tail address field mated with it are example, from root node, by [the next_E of inquire address c, low_c] and routing address E [next_E, low_E] compare, comparative result is [next_E, low_c] be greater than [next_E, low_E], then by [next_E, low_c] and left node [next_G, low_G] compare, comparative result is [next_E, low_c] be less than [next_G, low_G], then by [next_E, low_c] and right side node [next_F, low_F] compare, comparative result is [next_E, low_c] be greater than [next_F, low_F], therefore lookup result is not for mate, illustrate store route table items in there is not inquire address c, search flow process to terminate.
If inquire address is divided into three address fields, in the second binary tree shown in Fig. 5, address prefix and the tail address field of the tail address field mated with it is searched for the address prefix Next2_C of the tail address field according to inquire address a and tail address field Low_a, from root node, by [the Next2_C of inquire address a, Low_a] compare with [Next2_E, the Low_E] of routing address E, comparative result is [Next2_C, Low_a] C is less than [Next2_E, Low_E]; Then [Next2_C, Low_a] compared with right side node [Next2_C, Low_C], comparative result is coupling, then perform step 607.
607: the index obtaining the address prefix of tail address field that finds and lookup result corresponding to tail address field, and obtain lookup result according to the index of lookup result, flow process terminates.
Particularly, because above-described embodiment two is when storing the tail address field of routing address, except the address prefix of the tail address field by routing address and tail address field are stored in except in the node of the second binary tree in the lump, the index of lookup result corresponding to this routing address is also stored at last one deck of the second binary tree, therefore, after the address prefix that above-mentioned steps 606 finds the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the second binary tree and tail address field, the address prefix of the tail address field found by this and the corresponding relation between tail address field and the index of lookup result, the index of lookup result corresponding to the routing address at the tail address field place that this finds can be got from the correspondence position of the last one deck of the second binary tree, and get lookup result with this.
For the lookup result that the address prefix next_C and tail address field low_a that obtain the tail address field of inquire address a are corresponding, that mate with the address prefix next_C of tail address field and tail address field low_a is tail address field address prefix next_C and the tail address field Low_C of routing address C, the lookup result index of its correspondence is index number 4, can obtain lookup result corresponding to inquire address a according to the index number 4 of lookup result.
In hardware system as shown in Figure 7, control inerface 701, for the interface operation of the storage and deletion that realize route table items, control inerface 701 is by CPU(Central Processing Unit, CPU) interface 705 with storage Lookup engine 704 be connected, described storage Lookup engine can be FPGA(Field-Programmable Gate Array, field programmable gate array), can also be ASIC(Application-Specific Integrated Circuit, application-specific integrated circuit (ASIC)), the methods of storage operating storing Lookup engine 704 concrete is identical with the storage means principle of the embodiment of the present invention two, external memorizer 702, for storing the routing address that control inerface 701 inputs, is connected with storage Lookup engine by cpu i/f, query interface 703, for input and the interface operation that returns results of inquire address, query interface 703 also by cpu i/f 705 with store Lookup engine and be connected, binary tree computing module 706, be used for each routing address respectively stored in corresponding binary tree when route table items stores, when route table items is searched for the coupling of the routing address of inquire address and storage, obtain matching result, result is turned back to query interface 703.
The method that the present embodiment provides, by the address field dividing mode of the routing address by route table items, inquire address is divided into address field, and in the binary tree storing various types of address field, the address field of coupling is searched respectively according to the address field of inquire address, and then obtain lookup result according to the address field of coupling, compared with prior art, can improve and search speed.
Embodiment four
Present embodiments provide a kind of storage device of route table items, the storage means of route table items of this device for performing above-described embodiment one or embodiment two and providing.See Fig. 8, this device comprises:
Divide module 801, for each routing address of route table items is divided at least two address fields according to preset length.
Distribution module 802, distributes corresponding address suffix for the first address section dividing each routing address obtained for dividing module 801, and using the address prefix of the address suffix of the first address section of each routing address as next address section.
First memory module 803, is stored in the node of the first binary tree for first address section division module 801 being divided each routing address obtained, and the address suffix of the first address section correspondence of each routing address of memory allocation module 802 distribution.
Second memory module 804, if the next address section for the first address section of each routing address is tail address field, then address prefix corresponding for the tail address field of each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to each routing address, address prefix and the tail address field of the index of the lookup result that each routing address is corresponding and the tail address field of each routing address are corresponding, and the corresponding lookup result of the index of each lookup result.
Further, distribution module 802, also distribute corresponding type identification for the address field for each type in each routing address of route table items, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items; Wherein, the type of the address field of each routing address of route table items at least comprises first address section and tail address field.
Wherein, the first memory module 803, specifically for being stored to the first address section of each routing address successively in the node of the first binary tree according to descending order.
Second memory module 804, the address prefix corresponding specifically for the tail address field by each routing address and tail address field are stored in the node of the second binary tree successively according to descending order.
Further, the type dividing the address field of each routing address of the route table items that module 801 divides also comprises intermediate address section;
Distribution module 802 if be also intermediate address section for next address section, is then that the intermediate address section of each routing address distributes corresponding address suffix, and using the address prefix of address suffix as the next address section of intermediate address section.
See Fig. 9, this device also comprises:
3rd memory module 805, is stored in the lump in the node of the 3rd binary tree for the address prefix of the intermediate address section correspondence by each routing address and intermediate address section, and stores the address suffix of the intermediate address section correspondence of each routing address.
Particularly, the 3rd memory module 805, is stored in the node of the 3rd binary tree according to descending order successively specifically for the address prefix of the intermediate address section correspondence by each routing address and intermediate address section.
Further, 3rd memory module 805, if have multiple intermediate address section for each routing address, then the address prefix of each intermediate address section correspondence of each routing address and intermediate address section are stored to respectively in the node of the 3rd different binary trees, the number of interlude address field storing sub-units is identical with the number of the intermediate address section of each routing address.
Further, distribution module 802, if identical for the first address section of at least two routing address, then for the first address section of at least two routing address distributes identical address suffix.
Further, distribution module 802, if all identical with intermediate address section for the first address section of at least two routing address, then for the intermediate address section of at least two routing address distributes identical address suffix.
See Figure 10, device also comprises:
Removing module 806, for deleting address prefix and the tail address field of the tail address field of deleted routing address from the second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in route table items, then in the first binary tree, retain first address section and the address suffix thereof of deleted routing address; And if the intermediate address section of deleted routing address is identical with the intermediate address section of other routing address in route table items, in the 3rd binary tree, then retain the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix, if the intermediate address section of deleted routing address is not identical with the intermediate address section of other routing address in route table items, from the 3rd binary tree, delete the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix;
If the first address section of deleted routing address is different from the first address section of other routing address in route table items, first address section and the address suffix thereof of deleted routing address is deleted from the first binary tree, if and deleted routing address has intermediate address section, from the 3rd binary tree, delete the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix.
The storage device that the present embodiment provides, by routing address is divided at least two address fields, and each address field is stored in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly.
Embodiment five
What present embodiments provide a kind of route table items searches device, the lookup method of route table items of this device for performing above-described embodiment one or embodiment three and providing.See Figure 11, this device comprises:
Divide module 1101, for inquire address is divided at least two address fields according to preset length.
First searches module 1102, first address section for dividing the inquire address obtained according to division module 1101 searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of the first binary tree.
First acquisition module 1103, if search module 1102 for first to find the first address section matched with the first address section of inquire address in the first binary tree, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the next address section of inquire address.
Second searches module 1104, if the next address section for the first address section of inquire address is tail address field, in the second binary tree, then search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field, in the node of the second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items.
Second acquisition module 1105, if search for second address prefix and the tail address field that module 1104 finds the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of lookup result.
See Figure 12, this device also comprises:
Distribution module 1106, address field for dividing each type in the inquire address obtained for dividing module 1101 distributes corresponding type identification, with the type of each address field of the type identification determination inquire address corresponding to each address field of inquire address; Wherein, the type of the address field of inquire address at least comprises first address section and tail address field.
Further, first searches module 1102, specifically for the root node from the first binary tree, the first address section of the first address section of inquire address with each routing address of the route table items stored in the first binary tree is successively compared;
If the first address section of inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of inquire address;
If participate in there is not the first address section matched with the first address section of inquire address in the first address section of the routing address compared, then search end.
Further, second searches module 1104, specifically for the root node from the second binary tree, the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of each routing address of the route table items stored in the second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
Further, divide the type that module 1101 divides the address field of the inquire address obtained and also comprise intermediate address section.
See Figure 13, device also comprises:
3rd acquisition module 1107, if for finding the first address section matched with the first address section of inquire address in the first binary tree, and the next address section of the first address section of inquire address is the intermediate address section of inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of inquire address.
3rd searches module 1108, for searching address prefix and the intermediate address section of the intermediate address section matched with it in the address prefix of the intermediate address section according to inquire address and intermediate address Duan tri-binary tree, in the node of the 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items.
4th acquisition module 1109, if for the address prefix that finds the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the 3rd binary tree and intermediate address section, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field address prefix and tail address field.
Further, 3rd searches module 1107, specifically for the root node from the 3rd binary tree, the address prefix of the intermediate address section of each routing address of the route table items stored in the address prefix of the intermediate address section of inquire address and intermediate address Duan Yu tri-binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
Further, 3rd searches module 1108, if have multiple intermediate address section for inquire address, then in the 3rd binary tree of correspondence, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of inquire address and intermediate address section.
What the present embodiment provided searches device, by the address field dividing mode of the routing address by route table items, inquire address is divided into address field, and in the binary tree storing various types of address field, the address field of coupling is searched respectively according to the address field of inquire address, and then obtain lookup result according to the address field of coupling, compared with prior art, can improve and search speed.
Embodiment six
Present embodiments provide a kind of seeking system of route table items, the storage means of route table items of this system for performing above-described embodiment one or embodiment two and providing, and the lookup method of route table items that embodiment one or embodiment three provide.See Figure 14, this system comprises: the storage device 1401 of route table items and route table items search device 1402;
Wherein, the storage device of route table items that provides as above-described embodiment four of the storage device 1401 of route table items;
Route table items search the route table items that device 1402 provides as above-described embodiment five search device.
The seeking system that the present embodiment provides, by the storage device of route table items, routing address is divided at least two address fields, and each address field is stored in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly; In addition, obtain lookup result by the device of searching of route table items in the mode of segment lookup, can improve and search speed.
Embodiment seven
Present embodiments provide a kind of memory device of route table items, for performing the storage means of the route table items that above-described embodiment one or embodiment two provide.
The memory device of this route table items comprises: processor;
Wherein, processor, for being divided at least two address fields by each routing address of route table items according to preset length; For the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of each routing address as next address section; The first address section of each routing address is stored in the node of the first binary tree, and stores the address suffix of the first address section correspondence of each routing address; If next address section is tail address field, then address prefix corresponding for the tail address field of each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to each routing address, address prefix and the tail address field of the index of the lookup result that each routing address is corresponding and the tail address field of each routing address are corresponding, and the corresponding lookup result of the index of each lookup result.
Further, this processor, also for after each routing address of route table items is divided at least two address fields according to preset length, for the address field of each type in each routing address of route table items distributes corresponding type identification, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items; Wherein, the type of the address field of each routing address of route table items at least comprises first address section and tail address field.
Further, this processor, specifically for being stored to the first address section of each routing address successively in the node of the first binary tree according to descending order.
Further, this processor, the address prefix corresponding specifically for the tail address field by each routing address and tail address field are stored in the node of the second binary tree successively according to descending order.
Further, the type of the address field of each routing address of route table items also comprises intermediate address section, this process, also for the first address section using each routing address address suffix as next address section address prefix after, if next address section is intermediate address section, be then the address suffix of the intermediate address section distribution correspondence of each routing address, and using the address prefix of address suffix as the next address section of intermediate address section; The address prefix of the intermediate address section correspondence of each routing address and intermediate address section are stored in the node of the 3rd binary tree in the lump, and store the address suffix of the intermediate address section correspondence of each routing address.
Further, this processor, is stored in the node of the 3rd binary tree according to descending order successively specifically for the address prefix of the intermediate address section correspondence by each routing address and intermediate address section.
Further, if each routing address has multiple intermediate address section, then this processor, also be stored to respectively in the node of the 3rd different binary trees for the address prefix of each intermediate address section correspondence by each routing address and intermediate address section, the number of the 3rd binary tree is identical with the number of the intermediate address section of each routing address.
Further, this processor, if identical specifically for the first address section of at least two routing address, then for the first address section of at least two routing address distributes identical address suffix.
Further, this processor, if all identical with intermediate address section specifically for the first address section of at least two routing address, then for the intermediate address section of at least two routing address distributes identical address suffix.
Further, this processor, time also for deleting at least one routing address in route table items, deletes address prefix and the tail address field of the tail address field of deleted routing address from the second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in route table items, then in the first binary tree, retain first address section and the address suffix thereof of deleted routing address, if and deleted routing address has intermediate address section, the intermediate address section of deleted routing address is identical with the intermediate address section of other routing address in route table items, in the 3rd binary tree, then retain the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix, if the intermediate address section of deleted routing address is not identical with the intermediate address section of other routing address in route table items, the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix is deleted from the 3rd binary tree,
If the first address section of deleted routing address is different from the first address section of other routing address in route table items, first address section and the address suffix thereof of deleted routing address is deleted from the first binary tree, if and deleted routing address has intermediate address section, from the 3rd binary tree, delete the address prefix of the intermediate address section of deleted routing address and intermediate address section and address suffix.
The memory device of the route table items that the present embodiment provides, by routing address is divided at least two address fields, and each address field is stored in corresponding binary tree, store the mode of two boundary values of a routing address compared to existing technology with two binary tree nodes, its memory space taken is less; And when the bit wide of the routing address stored is greater than the bit wide of memory space, routing address can be divided at least two sections to store, need the mode changing hardware memory space compared to existing technology, the storage of the routing address of multiple bit wide can be applicable to more neatly.
Embodiment eight
What present embodiments provide a kind of route table items searches equipment, for performing the lookup method of the route table items that above-described embodiment one or embodiment three provide.
This equipment comprises: processor;
This processor, for being divided at least two address fields by inquire address according to preset length; First address section according to inquire address searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of the first binary tree; If find the first address section matched with the first address section of inquire address in the first binary tree, and the next address section of the first address section of inquire address is the tail address field of inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the tail address field of inquire address; In the second binary tree, search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field, in the node of the second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items; If find address prefix and the tail address field of the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of lookup result.
Further, this processor, also for after inquire address is divided at least two address fields according to preset length, for the address field of each type in inquire address distributes corresponding type identification, with the type of each address field of the type identification determination inquire address corresponding to each address field of inquire address; Wherein, the type of the address field of inquire address at least comprises first address section and tail address field.
Further, this processor, specifically for the root node from the first binary tree, successively compares the first address section of the first address section of inquire address with each routing address of the route table items stored in the first binary tree;
If the first address section of inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of inquire address;
If participate in there is not the first address section matched with the first address section of inquire address in the first address section of the routing address compared, then search end.
Further, this processor, specifically for the root node from the second binary tree, the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of each routing address of the route table items stored in the second binary tree and tail address field are successively compared; If the address prefix of the tail address field of inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared; If the address prefix of the tail address field of inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared; The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of inquire address and tail address field; If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
Further, this processor, type also for the address field at inquire address also comprises intermediate address section, after searching according to the first address section of inquire address the first address section matched with it in the first binary tree, if find the first address section matched with the first address section of inquire address in the first binary tree, and the next address section of the first address section of inquire address is the intermediate address section of inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of inquire address; According to address prefix and the intermediate address section of searching the intermediate address section matched with it in the address prefix of the intermediate address section of inquire address and intermediate address Duan tri-binary tree, in the node of the 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items; If find address prefix and the intermediate address section of the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the 3rd binary tree, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of inquire address and tail address field address prefix and tail address field.
Further, this processor, specifically for the root node from the 3rd binary tree, the address prefix of the intermediate address section of each routing address of the route table items stored in the address prefix of the intermediate address section of inquire address and intermediate address Duan Yu tri-binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
Further, if inquire address has multiple intermediate address section, then this processor, also searches address prefix and the intermediate address section of the intermediate address section matched with it in the 3rd binary tree of correspondence for the address prefix of each intermediate address section according to inquire address and intermediate address section.
The equipment that the present embodiment provides, by the address field dividing mode of the routing address by route table items, inquire address is divided into address field, and in the binary tree storing various types of address field, the address field of coupling is searched respectively according to the address field of inquire address, and then obtain lookup result according to the address field of coupling, compared with prior art, can improve and search speed.
It should be noted that: the storage device of the route table items that above-described embodiment provides is when carrying out the storage of route table items, and route table items search device when carrying out the searching of route table items, only be illustrated with the division of above-mentioned each functional module, in practical application, can distribute as required and by above-mentioned functions and be completed by different functional modules, internal structure by device is divided into different functional modules, to complete all or part of function described above.In addition, the storage device of the route table items that above-described embodiment provides and the storage means embodiment of route table items belong to same design, the lookup method embodiment of searching device and route table items of route table items belongs to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that all or part of step realizing above-described embodiment can have been come by hardware, the hardware that also can carry out instruction relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium mentioned can be read-only memory, disk or CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (39)

1. a storage means for route table items, is characterized in that, described method comprises:
Each routing address of route table items is divided at least two address fields according to preset length;
For the first address section of each routing address distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of described each routing address as next address section;
The first address section of described each routing address is stored in the node of the first binary tree, and stores the address suffix of the first address section correspondence of described each routing address;
If described next address section is tail address field, then address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to described each routing address, the index of the lookup result that described each routing address is corresponding is corresponding with the address prefix of the tail address field of described each routing address and tail address field, and the corresponding lookup result of the index of each lookup result.
2. method according to claim 1, is characterized in that, described each routing address of route table items is divided at least two address fields according to preset length after, also comprise:
For the address field of each type in each routing address of route table items distributes corresponding type identification, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items;
Wherein, the type of the address field of each routing address of described route table items at least comprises first address section and tail address field.
3. method according to claim 1, is characterized in that, the described first address section by described each routing address is stored in the node of the first binary tree, specifically comprises:
The first address section of described each routing address is stored in the node of described first binary tree successively according to descending order.
4. method according to claim 1, is characterized in that, describedly address prefix corresponding for the tail address field of described each routing address and tail address field is stored in the lump in the node of the second binary tree, specifically comprises:
Address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of described second binary tree successively according to descending order.
5. method according to claim 1, it is characterized in that, the type of the address field of each routing address of described route table items also comprises intermediate address section, described using the address suffix of the first address section of described each routing address as next address section address prefix after, also comprise:
If described next address section is intermediate address section, be then that the intermediate address section of described each routing address distributes corresponding address suffix, and using the address prefix of described address suffix as the next address section of described intermediate address section;
The address prefix of the intermediate address section correspondence of described each routing address and intermediate address section are stored in the node of the 3rd binary tree in the lump, and store the address suffix of the intermediate address section correspondence of described each routing address.
6. method according to claim 5, is characterized in that, describedly the address prefix of the intermediate address section correspondence of described each routing address and intermediate address section is stored in the lump in the node of the 3rd binary tree, specifically comprises:
The address prefix of the intermediate address section correspondence of described each routing address and intermediate address section are stored in the node of described 3rd binary tree successively according to descending order.
7. method according to claim 5, it is characterized in that, if described each routing address has multiple intermediate address section, then be stored in the node of the 3rd different binary trees respectively by the address prefix of each intermediate address section correspondence of described each routing address and intermediate address section, the number of described 3rd binary tree is identical with the number of the intermediate address section of described each routing address.
8. method according to claim 1, is characterized in that, described is that the first address section of each routing address distributes corresponding address suffix, specifically comprises:
If the first address section of at least two routing address is identical, then for the first address section of described at least two routing address distributes identical address suffix.
9. method according to claim 5, is characterized in that, described is that the intermediate address section of described each routing address distributes corresponding address suffix, specifically comprises:
If the first address section of at least two routing address is all identical with intermediate address section, then for the intermediate address section of described at least two routing address distributes identical address suffix.
10. the method according to claim arbitrary in claim 5 to 7, is characterized in that, when deleting at least one routing address in described route table items, described method also comprises:
Address prefix and the tail address field of the tail address field of deleted routing address is deleted from the second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in described route table items, then in described first binary tree, retain first address section and the address suffix thereof of described deleted routing address, if and described deleted routing address has intermediate address section, the intermediate address section of described deleted routing address is identical with the intermediate address section of other routing address in described route table items, in described 3rd binary tree, then retain the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix, if the intermediate address section of described deleted routing address is not identical with the intermediate address section of other routing address in described route table items, the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix is deleted from described 3rd binary tree,
If the first address section of deleted routing address is different from the first address section of other routing address in described route table items, first address section and the address suffix thereof of described deleted routing address is deleted from described first binary tree, if and described deleted routing address has intermediate address section, from described 3rd binary tree, delete the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix.
The lookup method of 11. 1 kinds of route table items, is characterized in that, described method comprises:
Inquire address is divided at least two address fields according to preset length;
First address section according to described inquire address searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of described first binary tree;
If find the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the tail address field of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the tail address field of described inquire address;
In the second binary tree, search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field, in the node of described second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items;
If find address prefix and the tail address field of the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in described second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of described lookup result.
12. methods according to claim 11, is characterized in that, described inquire address is divided at least two address fields according to preset length after, also comprise:
For the address field of each type in inquire address distributes corresponding type identification, determine the type of each address field of described inquire address with the type identification corresponding to each address field of inquire address;
Wherein, the type of the address field of described inquire address at least comprises first address section and tail address field.
13. methods according to claim 11, is characterized in that, the described first address section according to described inquire address searches the first address section matched with it in the first binary tree, specifically comprises:
From the root node of described first binary tree, the first address section of the first address section of described inquire address with each routing address of the route table items stored in described first binary tree is successively compared;
If the first address section of described inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of described inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of described inquire address;
If participate in there is not the first address section matched with the first address section of described inquire address in the first address section of the routing address compared, then search end.
14. methods according to claim 11, is characterized in that, the address prefix of the described tail address field according to described inquire address and tail address field search address prefix and the tail address field of the tail address field matched with it in the second binary tree, specifically comprise:
From the root node of described second binary tree, the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of each routing address of the route table items stored in described second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of described inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of described inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of described inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
15. methods according to claim 11, it is characterized in that, the type of the address field of described inquire address also comprises intermediate address section, and the described first address section according to described inquire address also comprises search the first address section matched with it in the first binary tree after:
If find the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the intermediate address section of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of described inquire address;
According to address prefix and the intermediate address section of searching the intermediate address section matched with it in the address prefix of the intermediate address section of described inquire address and intermediate address Duan tri-binary tree, in the node of described 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items;
If find address prefix and the intermediate address section of the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in described 3rd binary tree, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of described inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field address prefix and tail address field.
16. methods according to claim 15, it is characterized in that, search address prefix and the intermediate address section of the intermediate address section matched with it in the address prefix of the described intermediate address section according to described inquire address and intermediate address Duan tri-binary tree, specifically comprise:
From the root node of described 3rd binary tree, the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of each routing address of the route table items stored in described 3rd binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of described inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
17. methods according to claim 16, it is characterized in that, if described inquire address has multiple intermediate address section, then in the 3rd binary tree of correspondence, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of described inquire address and intermediate address section.
The storage device of 18. 1 kinds of route table items, its feature is being, described device comprises:
Divide module, for each routing address of route table items is divided at least two address fields according to preset length;
Distribution module, the first address section for each routing address obtained for described division Module Division distributes corresponding address suffix, and using the address prefix of the address suffix of the first address section of described each routing address as next address section;
First memory module, the first address section for each routing address described division Module Division obtained is stored in the node of the first binary tree, and stores the address suffix of the first address section correspondence of each routing address of described module assigns;
Second memory module, if the next address section for the first address section of described each routing address is tail address field, then address prefix corresponding for the tail address field of described each routing address and tail address field are stored in the node of the second binary tree in the lump, and store the index of lookup result corresponding to described each routing address, the index of the lookup result that described each routing address is corresponding is corresponding with the address prefix of the tail address field of described each routing address and tail address field, and the corresponding lookup result of the index of each lookup result.
19. devices according to claim 18, it is characterized in that, described distribution module, also distribute corresponding type identification for the address field for each type in each routing address of route table items, determine the type of each address field with the type identification corresponding to each address field of each routing address according to route table items;
Wherein, the type of the address field of each routing address of described route table items at least comprises first address section and tail address field.
20. devices according to claim 18, is characterized in that, described first memory module, specifically for the first address section of described each routing address being stored to successively in the node of described first binary tree according to descending order.
21. devices according to claim 18, it is characterized in that, described second memory module, specifically for being stored to address prefix corresponding for the tail address field of described each routing address and tail address field successively in the node of described second binary tree according to descending order.
22. devices according to claim 18, is characterized in that, the type of the address field of each routing address of the route table items of described division Module Division also comprises intermediate address section;
Described distribution module if be also intermediate address section for described next address section, is then that the intermediate address section of described each routing address distributes corresponding address suffix, and using the address prefix of described address suffix as the next address section of described intermediate address section;
Described device also comprises:
3rd memory module, is stored in the lump in the node of the 3rd binary tree for the address prefix of the intermediate address section correspondence by described each routing address and intermediate address section, and stores the address suffix of the intermediate address section correspondence of described each routing address.
23. devices according to claim 22, it is characterized in that, described 3rd memory module, is stored in the node of described 3rd binary tree according to descending order successively specifically for the address prefix of the intermediate address section correspondence by described each routing address and intermediate address section.
24. devices according to claim 22, it is characterized in that, described 3rd memory module, if have multiple intermediate address section for described each routing address, then be stored in the node of the 3rd different binary trees respectively by the address prefix of each intermediate address section correspondence of described each routing address and intermediate address section, the number of described interlude address field storing sub-units is identical with the number of the intermediate address section of described each routing address.
25. devices according to claim 18, is characterized in that, described distribution module, if identical for the first address section of at least two routing address, then for the first address section of described at least two routing address distributes identical address suffix.
26. devices according to claim 22, it is characterized in that, described distribution module, if all identical with intermediate address section for the first address section of at least two routing address, then for the intermediate address section of described at least two routing address distributes identical address suffix.
27. devices according to claim arbitrary in claim 22 to 24, it is characterized in that, described device also comprises:
Removing module, for deleting address prefix and the tail address field of the tail address field of deleted routing address from described second binary tree;
If the first address section of deleted routing address is identical with the first address section of other routing address in described route table items, then in described first binary tree, retain first address section and the address suffix thereof of described deleted routing address, if and described deleted routing address has intermediate address section, the intermediate address section of described deleted routing address is identical with the intermediate address section of other routing address in described route table items, in described 3rd binary tree, then retain the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix, if the intermediate address section of described deleted routing address is not identical with the intermediate address section of other routing address in described route table items, the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix is deleted from described 3rd binary tree,
If the first address section of deleted routing address is different from the first address section of other routing address in described route table items, first address section and the address suffix thereof of described deleted routing address is deleted from described first binary tree, if and described deleted routing address has intermediate address section, from described 3rd binary tree, delete the address prefix of the intermediate address section of described deleted routing address and intermediate address section and address suffix.
28. 1 kinds of route table items search device, it is characterized in that, described device comprises:
Divide module, for inquire address is divided at least two address fields according to preset length;
First searches module, first address section for the inquire address obtained according to described division Module Division searches the first address section matched with it in the first binary tree, stores the first address section of each routing address of route table items in the node of described first binary tree;
First acquisition module, if search module for described first to find the first address section matched with the first address section of described inquire address in described first binary tree, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the next address section of described inquire address;
Second searches module, if the next address section for the first address section of described inquire address is tail address field, in the second binary tree, then search address prefix and the tail address field of the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field, in the node of described second binary tree, store address prefix and the tail address field of the tail address field of each routing address of route table items;
Second acquisition module, if search for described second address prefix and the tail address field that module finds the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in described second binary tree, then obtain the index of the address prefix of the tail address field found and lookup result corresponding to tail address field, and obtain lookup result according to the index of described lookup result.
29. devices according to claim 28, is characterized in that, described device also comprises:
Distribution module, address field for each type in the inquire address that obtains for described division Module Division distributes corresponding type identification, determines the type of each address field of described inquire address with the type identification corresponding to each address field of inquire address;
Wherein, the type of the address field of described inquire address at least comprises first address section and tail address field.
30. devices according to claim 28, it is characterized in that, described first searches module, specifically for the root node from described first binary tree, the first address section of the first address section of described inquire address with each routing address of the route table items stored in described first binary tree is successively compared;
If the first address section of described inquire address is more than or equal to the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the left of the first address section of the current routing address compared is compared;
If the first address section of described inquire address is less than the first address section of the routing address of current comparison, then the first address section of the first address section of described inquire address with the routing address on the right side of the first address section of the current routing address compared is compared;
The rest may be inferred, until draw the first address section of the routing address matched with the first address section of described inquire address;
If participate in there is not the first address section matched with the first address section of described inquire address in the first address section of the routing address compared, then search end.
31. devices according to claim 28, it is characterized in that, described second searches module, specifically for the root node from described second binary tree, the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of each routing address of the route table items stored in described second binary tree and tail address field are successively compared;
If the address prefix of the tail address field of described inquire address and tail address field are more than or equal to address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the left of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
If the address prefix of the tail address field of described inquire address and tail address field are less than address prefix and the tail address field of the tail address field of the routing address of current comparison, then the address prefix of the tail address field of the routing address on the right side of the address prefix of the address prefix of the tail address field of described inquire address and tail address field and the tail address field of the current routing address compared and tail address field and tail address field are compared;
The rest may be inferred, until draw address prefix and the tail address field of the tail address field of the routing address matched with the address prefix of the tail address field of described inquire address and tail address field;
If participate in the address prefix and the tail address field that there is not the tail address field matched with the address prefix of the tail address field of described inquire address and tail address field in the address prefix of the tail address field of routing address compared and tail address field, then search end.
32. devices according to claim 28, is characterized in that, the type of the address field of the inquire address that described division Module Division obtains also comprises intermediate address section;
Described device also comprises:
3rd acquisition module, if for finding the first address section matched with the first address section of described inquire address in described first binary tree, and the next address section of the first address section of described inquire address is the intermediate address section of described inquire address, then obtain the address suffix of the first address section correspondence found, and using the address suffix that the gets address prefix as the intermediate address section of described inquire address;
3rd searches module, for searching address prefix and the intermediate address section of the intermediate address section matched with it in the address prefix of the intermediate address section according to described inquire address and intermediate address Duan tri-binary tree, in the node of described 3rd binary tree, store address prefix and the intermediate address section of the intermediate address section of each routing address of route table items;
4th acquisition module, if for the address prefix and the intermediate address section that find the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in described 3rd binary tree, then obtain the address suffix of the intermediate address section correspondence found, using the address suffix that the gets address prefix as the tail address field of described inquire address, and continue to perform in the second binary tree, search the tail address field matched with it according to the address prefix of the tail address field of described inquire address and tail address field address prefix and tail address field.
33. devices according to claim 32, it is characterized in that, described 3rd searches module, specifically for the root node from described 3rd binary tree, the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of each routing address of the route table items stored in described 3rd binary tree and intermediate address section are successively compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are more than or equal to address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the left of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
If the address prefix of the intermediate address section of described inquire address and intermediate address section are less than address prefix and the intermediate address section of the intermediate address section of the routing address of current comparison, then the address prefix of the intermediate address section of the routing address on the right side of the address prefix of the address prefix of the intermediate address section of described inquire address and intermediate address section and the intermediate address section of the current routing address compared and intermediate address section and intermediate address section are compared;
The rest may be inferred, until draw address prefix and the intermediate address section of the intermediate address section of the routing address matched with the address prefix of the intermediate address section of described inquire address and intermediate address section;
If participate in the address prefix and the intermediate address section that there is not the intermediate address section matched with the address prefix of the intermediate address section of described inquire address and intermediate address section in the address prefix of the intermediate address section of routing address compared and intermediate address section, then search end.
34. devices according to claim 33, it is characterized in that, described 3rd searches module, if have multiple intermediate address section for described inquire address, then in the 3rd binary tree of correspondence, search address prefix and the intermediate address section of the intermediate address section matched with it according to the address prefix of each intermediate address section of described inquire address and intermediate address section.
The seeking system of 35. 1 kinds of route table items, is characterized in that, described system comprises: the storage device of route table items and route table items search device;
Wherein, described route table items storage device as described in the storage device of route table items in claim 18 to 27 as described in arbitrary claim;
Described route table items search device as described in route table items in claim 28 to 34 as described in arbitrary claim search device.
The storage means of 36. 1 kinds of route table items, is characterized in that, described method comprises:
Routing address to be stored is divided into first address section and tail address field according to preset length;
For described first address section allocation address suffix, be described tail address field allocation address prefix, between described address prefix and address suffix, meet default corresponding relation;
Described first address section is stored in the node of the first binary tree, and records the memory address of described first address section in described first binary tree and the corresponding relation of described address prefix;
Described address prefix and described tail address field are stored in the second binary tree, and the indexed results that record is corresponding with described address prefix and described tail address field.
The storage means of 37. route table items as claimed in claim 36, is characterized in that, also comprise: described address prefix is identical with described address suffix.
The storage means of 38. route table items as claimed in claim 36, is characterized in that, describedly described address prefix and described tail address field are stored to the second binary tree comprise:
Described address prefix and described tail address field are stored in the same node of described second binary tree.
The lookup method of 39. 1 kinds of routing address, is characterized in that, described method comprises:
Obtain routing address to be found, and described routing address is divided into first address section and tail address field according to preset length;
In the first binary tree, search described first address section, and obtain the address suffix corresponding with described first address section;
According to the corresponding relation preset, according to described address suffix address acquisition prefix;
Search the second binary tree according to described address prefix and described tail address field, and obtain routing iinformation according to lookup result.
CN201210371642.3A 2012-09-29 2012-09-29 The storage means of route table items, lookup method, Apparatus and system Active CN102904812B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210371642.3A CN102904812B (en) 2012-09-29 2012-09-29 The storage means of route table items, lookup method, Apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210371642.3A CN102904812B (en) 2012-09-29 2012-09-29 The storage means of route table items, lookup method, Apparatus and system

Publications (2)

Publication Number Publication Date
CN102904812A CN102904812A (en) 2013-01-30
CN102904812B true CN102904812B (en) 2015-07-29

Family

ID=47576855

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210371642.3A Active CN102904812B (en) 2012-09-29 2012-09-29 The storage means of route table items, lookup method, Apparatus and system

Country Status (1)

Country Link
CN (1) CN102904812B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104539537B (en) * 2014-12-25 2018-04-20 北京华为数字技术有限公司 A kind of method for searching route and device
CN106302177A (en) * 2016-08-23 2017-01-04 杭州迪普科技有限公司 The method for organizing of a kind of route filtering rule and device
CN108965136B (en) * 2018-07-16 2020-09-22 清华大学 Forwarding method and device based on spatial network hierarchical IP addressing
CN115543179A (en) * 2021-06-30 2022-12-30 中兴通讯股份有限公司 Table entry storage system, method, resource management unit and storage medium
CN115987888A (en) * 2022-12-20 2023-04-18 苏州盛科通信股份有限公司 Routing address storage method, device, network equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1507229A (en) * 2002-12-10 2004-06-23 ����ͨѶ�ɷ����޹�˾ Route list organizing and searching method
CN101388842A (en) * 2008-10-30 2009-03-18 华为技术有限公司 Storage method and apparatus
CN102682112A (en) * 2012-05-11 2012-09-19 华为技术有限公司 Storage method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100586461B1 (en) * 2003-10-15 2006-06-08 임혜숙 Method, Hardware Architecture and Recording Medium for Searching IP Address by Using Pipeline Binary Tree

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1507229A (en) * 2002-12-10 2004-06-23 ����ͨѶ�ɷ����޹�˾ Route list organizing and searching method
CN101388842A (en) * 2008-10-30 2009-03-18 华为技术有限公司 Storage method and apparatus
CN102682112A (en) * 2012-05-11 2012-09-19 华为技术有限公司 Storage method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于哈希策略的路由查找算法;张理阳;《长沙理工大学硕士学位论文》;20120515;全文 *

Also Published As

Publication number Publication date
CN102904812A (en) 2013-01-30

Similar Documents

Publication Publication Date Title
CN102904812B (en) The storage means of route table items, lookup method, Apparatus and system
US9269411B2 (en) Organizing data in a hybrid memory for search operations
US7565343B2 (en) Search apparatus and search management method for fixed-length data
EP2352258B1 (en) Storage method and apparatus
CN102484610B (en) Routing table construction method and device and routing table lookup method and device
CN107368527B (en) Multi-attribute index method based on data stream
CN102609446B (en) Distributed Bloom filter system and application method thereof
US20160294693A1 (en) Routing Lookup Method and Device, and Construction Method for B-tree Structure
US20100228914A1 (en) Data caching system and method for implementing large capacity cache
US20080133494A1 (en) Method and apparatus for searching forwarding table
CN107357843B (en) Massive network data searching method based on data stream structure
CN102739520B (en) Checking method and checking device
CN105677904B (en) Small documents storage method and device based on distributed file system
CN101594319A (en) List item lookup method and device
CN105515997B (en) The higher efficiency range matching process of zero scope expansion is realized based on BF_TCAM
CN106416152A (en) Lookup device, lookup configuration method and lookup method
CN105243027A (en) Method for storing data in storage device and memory controller
CN112235197B (en) Parallel route searching method and system
KR20170067804A (en) Method, apparatus for maintaining routing table and storage medium
WO2014047863A1 (en) Generating a shape graph for a routing table
CN110505322B (en) IP address field searching method and device
CN104038423A (en) Open flow flow table refreshing method and router device
CN110008030A (en) A kind of method of metadata access, system and equipment
WO2015192742A1 (en) Lookup device, lookup method and configuration method
CN102984071B (en) Method for organizing routing table of segment address route and method for checking route

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant