Summary of the invention
In view of this, main purpose of the present invention is to propose a kind of new method for routing, adopting plural route cache device, but each route cache device all only needs to store under the design of route prefix of a certain selected bit length, make the route prefix high-speed cache in fact.And because each route cache device all only needs to store the route prefix of a certain selected bit length, so each route cache device can be selected general binary content addressing holder (Binary ContentAddressable Memory) for use.
Another object of the present invention is to propose a kind of new route system, it has plural route cache device, utilize an above-mentioned new method for routing and a high-speed cache update method, with the real route prefix high-speed cache of doing, improve the utilance of route cache device by this, and accelerate the speed of network equipment routing inquiry.
For reaching above-mentioned purpose, the invention provides a kind of method for routing, it is used for a route system, and it comprises the following steps.At first, select m route prefix length, be respectively L
1Bit, L
2Bit, L
3Bit ..., L
mBit, wherein m, L
1, L
2, L
3..., L
mBe positive integer and L
1<L
2<L
3<...<L
mThen, the plural route prefix with this route system should be handled is divided into m group according to its route prefix length, is respectively 0~L
1Bit, L
1+ 1~L
2Bit, L
2+ 1~L
3Bit ..., L
M-1+ 1~L
mBit, and set up the 1st~the corresponding m routing table respectively; Wherein, when the route prefix length of the route prefix that should handle be the j bit, and between (L
I-1+ 1)~L
iBit, and when belonging to i group, use an expansion module that this route prefix is expanded to 2
Li-jIndividual L
iThe route prefix of bit, and with the route prefix route data corresponding with it after this expansion, this i routing table is gone in storage, wherein i and j are positive integer and 2≤i≤m, L
1+ 1≤j≤L
mIn addition, this route system is also kept a high-speed cache routing table simultaneously, and it is L that this high-speed cache routing table stores plural route prefix length
1The route prefix of bit and pairing plural route data thereof.
And receiving a L
mThe network packet of the destination address of bit is according to the preceding L of this destination address
1Bit is sought in this high-speed cache routing table and the preceding L of this destination address
1The route prefix that bit is identical; While is according to the preceding L of this destination address
2Bit is sought in this secondary route table and the preceding L of this destination address
2The route prefix that bit is identical; The rest may be inferred, and the while is according to all L of this destination address
mBit is sought in this m routing table and all L of this destination address
mThe route prefix that bit is identical.And when in above-mentioned search comparison, one or more route prefix that is consistent being arranged,, and take out its pairing route data, and this network packet is spread out of according to this route data then by selecting the tool longest equal length in these route prefix that are consistent.And when in above-mentioned search comparison, not having any one route prefix that is consistent, in this first routing table, search and take out the preceding L of this destination address
1The pairing route data of bit, and this network packet is spread out of according to this route data, and with the preceding L of this destination address
1Bit and this route data are transferred to this high-speed cache routing table and are stored.Perhaps, when in above-mentioned search comparison, not having any one route prefix that is consistent, search and take out this pairing route data in destination address in a full routing table, and according to this route data, this network packet is spread out of, and with the preceding L of this destination address
1Bit and this route data are transferred to this high-speed cache routing table and are stored.Wherein this full routing table store all these route systems plural route prefix and the pairing plural route data that should handle.
Cooperate above-mentioned method for routing, the present invention proposes a kind of route system in addition, and it comprises one first route device and a secondary route device.This first route device comprises a receiving element, route prefix length processor, plural route cache device, an expansion module and a selection delivery unit.The secondary route device comprises one first routing table or a full routing table.
Embodiment
The disclosed route cache device of the present invention is mainly used in the route technology of the network equipment, thus be called route cache device (routing cache), to be different from the Cache (Memory Cache) that generally is used for computer technology.Below cooperation is graphic, describes most preferred embodiment of the present invention in detail.
Fig. 1 represents to set up in the embodiment of the invention schematic diagram of the processing procedure of routing table.In this embodiment, select 3 route prefix length, 24,28 and 32 bits respectively, and set up first routing table 50, secondary route table 60 and Third Road respectively by table 70.At first, the plural route prefix { A that this route system should be handled
dSend into route prefix length processor 10,10 of route prefix length processors are according to route prefix { A
dBit length divide into groups.
As route prefix { A
dLength when being 0~24 bit, with route prefix { A
dAnd route data store up first routing table 50 in the route system.As route prefix { A
dLength when being 25~28 bits, via expansion module 12a with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 28 bits according to following rule: as route prefix { A
dLength when being 25 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 28 bits; As route prefix { A
dLength when being 26 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 28 bits; As route prefix { A
dLength when being 27 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 28 bits; As route prefix { A
dLength when being 28 bits, then need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 12a output is all the route prefix and the route prefix { A of 28 bits
dRoute data, secondary route table 60 is gone in storage.
And as route prefix { A
dLength when being 29~32 bits, via expansion module 12b with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 32 bits according to following rule: as route prefix { A
dLength when being 29 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 32 bits; As route prefix { A
dLength when being 30 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 32 bits; As route prefix { A
dLength when being 31 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 32 bits; As route prefix { A
dLength when being 32 bits, need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 12b output is all the route prefix and the route prefix { A of 32 bits
dRoute data, storage is gone into Third Road by table 70.
Fig. 2 represents the schematic diagram of processing procedure of the method for routing of the embodiment of the invention.At first, set up first routing table, 50 (not shown), secondary route table 60 and Third Road by table 70 according to the handling process of Fig. 1, and keep a high-speed cache routing table 80.High-speed cache routing table 80 stores the route prefix and the corresponding route data of plural 24 bits.High-speed cache routing table 80 adopts a route cache device, and this route cache device adopts a update algorithm (Algorithm) to upgrade high-speed cache routing table 80, and this update algorithm can be at most and does not use (Least-Recently-Used, LRU), (Random) or first-in first-out (First-In-First-Out, FIFO) scheduling algorithm at random.Secondary route table 60 and Third Road also adopt the route cache device respectively by table 70, but this two route caches device does not adopt update algorithm, and only can be upgraded by the expansion module 12a and the 12b of earlier figures 1 respectively.
Then, when route system receives a network packet, and the destination address 20 of this network packet is when being 32 bits, respectively with preceding 24 bits of this destination address 20, preceding 28 bits and all 32 bits, deliver to respectively high-speed cache routing table 80, secondary route table 60 and Third Road by table 70 to search.When in high-speed cache routing table 80, finding the identical route prefix of preceding 24 bits with this destination address 20, export the pairing route data R1 of this route prefix; And when in high-speed cache routing table 80, can not find the identical route prefix of preceding 24 bits with this destination address 20, do not export search result.When in secondary route table 60, finding the identical route prefix of preceding 28 bits with this destination address 20, export the pairing route data R2 of this route prefix; And when in secondary route table 60, can not find the identical route prefix of preceding 28 bits with this destination address 20, do not export search result.When at Third Road when finding the route prefix identical in the table 70 with this destination address 20 all 32 bits, export the pairing route data R3 of this route prefix; And when at Third Road when can not find the route prefix identical in the table 70 with this destination address 20 all 32 bits, do not export search result.
Then, with high-speed cache routing table 80, secondary route table 60 and Third Road search result by table 70, by select delivery unit 22 according to: Third Road is preferential by table 70, secondary route table 60 secondly, the last order of high-speed cache routing table 80, select the route data R of " the longest route prefix that meets " of this destination address
Cache, and according to this route data R
CacheThis network packet is spread out of.If at high-speed cache routing table 80, secondary route table 60 and Third Road by in the table 70, in the time of all can't finding the pairing route data in this destination address 20, that is when all not exporting search result, in first routing table 50 of this route system, search this destination address 20 pairing route datas (consulting the explanation of Fig. 3) so.
Fig. 3 represents in the embodiment of the invention, when at high-speed cache routing table 80, secondary route table 60 and Third Road by in the table 70, in the time of all can't finding the pairing route data in this destination address 20, the schematic diagram of its processing procedure.When high-speed cache routing table 80, secondary route table 60 and Third Road in Fig. 2 are not all exported search result by table 70, preceding 24 bits of this destination address 20 are delivered to first routing table 50 of this route system.Because it is plural route prefix and corresponding route data thereof between 0~24 bit that first routing table 50 has stored route prefix length, therefore in first routing table 50, search preceding 24 bits of this destination address 20, necessarily can find " the longest route prefix that meets " corresponding to preceding 24 bits of this destination address 20, and export the pairing route data R4 of this route prefix.And this network packet is spread out of (not shown) according to this route data R4.And preceding 24 bits and the route data R4 of this destination address 20 delivered to high-speed cache routing table 80, and whether the decision of the update algorithm of the route cache device that is adopted by high-speed cache routing table 80 should store these data, and this update algorithm can be at most and do not use, at random or the first-in first-out scheduling algorithm.
If this route system has a full routing table (not being shown among Fig. 1), and this full routing table to have stored route prefix length be (that is all route prefix length) all route prefix and corresponding route data thereof between 0~32 bit, then in Fig. 2, when at high-speed cache routing table 80, secondary route table 60 and Third Road by in the table 70, in the time of all can't finding the pairing route data in this destination address 20, also all 32 bits of destination address 20 can be delivered to this full routing table (this is not partly in this embodiment with illustration).Because it is all route prefix and corresponding route data thereof between 0~32 bit that this full routing table has stored route prefix length, therefore in this full routing table, search all 32 bits of this destination address 20, necessarily can find " the longest route prefix that meets " corresponding to all 32 bits of this destination address 20, and export the pairing route data of this route prefix.And this network packet is spread out of according to this route data.And preceding 24 bits and this route data of this destination address 20 delivered to high-speed cache routing table 80, and whether the update algorithm decision of the route cache device that is adopted by high-speed cache routing table 80 should store these data.
Fig. 4 represents the block diagram of route system one example of the embodiment of the invention.As shown in the figure, route system comprises the first router 400a and the second router 400b in this embodiment; The first router 400a comprises receiving element 402, selects delivery unit 404, route cache device 406a~406c, route prefix length processor 408 and expansion module 410; The second router 400b comprises first routing table 450.
In this embodiment, route cache device 406a~406c is binary content addressing holder (Binary Content Addressable Memory), and in binary content addressing holder 406a, there is secondary route table 460, in binary content addressing holder 406b, there is Third Road, in binary content addressing holder 406c, has high-speed cache routing table 480 by table 470.Binary content addressing holder 406c adopts a update algorithm upgrading the data that store in the high-speed cache routing table 480, this update algorithm can be at most and do not use, at random, update algorithm such as first-in first-out.But secondary route table 460 and Third Road are only built among binary content addressing holder 406a and the 406b by route prefix length processor 408 and expansion module 410 by table 470, and binary content addressing holder 406a and 406b do not determine whether to upgrade secondary route table 460 and Third Road by table 470.
408 of route prefix length processors are according to route prefix { A
dBit length divide into groups.As route prefix { A
dLength when being 0~24 bit, with route prefix { A
dAnd route data store up first routing table 450 into this route system.As route prefix { A
dLength when being 25~28 bits, via expansion module 410 with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 28 bits according to following rule: as route prefix { A
dLength when being 25 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 28 bits; As route prefix { A
dLength when being 26 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 28 bits; As route prefix { A
dLength when being 27 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 28 bits; As route prefix { A
dLength when being 28 bits, then need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 410 output is all the route prefix and the route prefix { A of 28 bits
dRoute data, secondary route table 460 is gone in storage.
And as route prefix { A
dLength when being 29~32 bits, via expansion module 410 with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 32 bits according to following rule: as route prefix { A
dLength when being 29 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 32 bits; As route prefix { A
dLength when being 30 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 32 bits; As route prefix { A
dLength when being 31 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 32 bits; As route prefix { A
dLength when being 32 bits, need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 410 output is all the route prefix and the route prefix { A of 32 bits
dRoute data, storage is gone into Third Road by table 470.
Receiving element 402 receives the IP packet of the destination address with 32 bits, and the destination address of IP packet is sent among binary content addressing holder 406a~406c.And in binary content addressing holder 406a~406c, respectively according to preceding 24 bits of this destination address, preceding 28 bits and all 32 bits, respectively high-speed cache routing table 480, secondary route table 460 and Third Road by in the table 470 inquiry.
Select delivery unit 404 to be coupled to binary content addressing holder 406a~406c, according to the search result of exporting by table 470 at high-speed cache routing table 480, secondary route table 460 and Third Road, by select delivery unit 404 according to: Third Road is preferential by table 470, secondary route table 460 secondly, the last order of high-speed cache routing table 480, select route data, and this network packet is spread out of according to this route data to " the longest route prefix that meets " that should the destination address.
When high-speed cache routing table 480, secondary route table 460 and Third Road all can't be found route data to " the longest route prefix that meets " that should the destination address by table 470, that is when all not exporting search result, in first routing table 450 of this route system, search route data to " the longest route prefix that meets " that should the destination address.This route system is delivered to first routing table 450 with preceding 24 bits of this destination address, and searches the pairing route data of preceding 24 bits of this destination address in first routing table 450, and according to the route data that searches this IP packet is spread out of.And with preceding 24 bits and this route data of this destination address, deliver to high-speed cache routing table 480, and whether the decision of the update algorithm of the route cache device that is adopted by high-speed cache routing table 480 should store these data, and this update algorithm can be at most and do not use, at random or the first-in first-out scheduling algorithm.
Fig. 5 represents the block diagram of another example of route system of the embodiment of the invention.As shown in the figure, route system comprises the first router 500a and the second router 500b in this embodiment; The first router 500a comprises receiving element 502, selects delivery unit 504, route cache device 506a~506c, route prefix length processor 508 and expansion module 510; The second router 500b comprises full routing table 550.
In this embodiment, route cache device 506a~506c is a binary content addressing holder, and in binary content addressing holder 506a, there is secondary route table 560, in binary content addressing holder 506b, there is Third Road, in binary content addressing holder 506c, has high-speed cache routing table 580 by table 570.
Binary content addressing holder 506c adopts a update algorithm upgrading the data that store in the high-speed cache routing table 580, this update algorithm can be at most and do not use, at random, update algorithm such as first-in first-out.But secondary route table 560 and Third Road are only built among binary content addressing holder 506a and the 506b by route prefix length processor 508 and expansion module 510 by table 570, and binary content addressing holder 506a and 506b do not determine whether to upgrade secondary route table 560 and Third Road by table 570.
Full routing table 550 is in order to store all route prefix and the corresponding route data thereof that route prefix length is (that is all route prefix length) between 0~32 bit.508 of route prefix length processors are according to route prefix { A
dBit length divide into groups.As route prefix { A
dLength when being 0~32 bit, with route prefix { A
dAnd route data store up full routing table 550 into this route system.As route prefix { A
dLength when being 25~28 bits, via expansion module 510 with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 28 bits according to following rule: as route prefix { A
dLength when being 25 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 28 bits; As route prefix { A
dLength when being 26 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 28 bits; As route prefix { A
dLength when being 27 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 28 bits; As route prefix { A
dLength when being 28 bits, then need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 510 output is all the route prefix and the route prefix { A of 28 bits
dRoute data, secondary route table 560 is gone in storage.
And as route prefix { A
dLength when being 29~32 bits, via expansion module 510 with route prefix { A
dTo expand to 1 to 8 length be the route prefix of 32 bits according to following rule: as route prefix { A
dLength when being 29 bits, in route prefix { A
dAdditional respectively 8 patterns that length is 3 bits of tail end, be respectively 000,001,010,011,100,101,110 and 111, and the route prefix that to become 8 length be 32 bits; As route prefix { A
dLength when being 30 bits, in route prefix { A
dAdditional respectively 4 patterns that length is 2 bits of tail end, be respectively 00,01,10 and 11, and the route prefix that to become 4 length be 32 bits; As route prefix { A
dLength when being 31 bits, in route prefix { A
dAdditional respectively 2 patterns that length is 1 bit of tail end, be respectively 0 and 1, and the route prefix that to become 2 length be 32 bits; As route prefix { A
dLength when being 32 bits, need not to carry out additional move, directly export this route prefix { A
d.And the length of expansion module 510 output is all the route prefix and the route prefix { A of 32 bits
dRoute data, storage is gone into Third Road by table 570.
Receiving element 502 receives the IP packet of the destination address with 32 bits, and the destination address of IP packet is sent among binary content addressing holder 506a~506c.And in binary content addressing holder 506a~506c, respectively according to preceding 24 bits of this destination address, preceding 28 bits and all 32 bits, respectively high-speed cache routing table 580, secondary route table 560 and Third Road by in the table 570 inquiry.
Select delivery unit 504 to be coupled to binary content addressing holder 506a~506c, according to the search result of exporting by table 570 at high-speed cache routing table 580, secondary route table 560 and Third Road, by select delivery unit 504 according to: Third Road is preferential by table 570, secondary route table 560 secondly, the last order of high-speed cache routing table 580, select route data, and this IP packet is spread out of according to this route data to " the longest route prefix that meets " that should the destination address.
When high-speed cache routing table 580, secondary route table 560 and Third Road all can't be found route data to " the longest route prefix that meets " that should the destination address by table 570, that is when all not exporting search result, in the full routing table 550 of this route system, search route data to " the longest route prefix that meets " that should the destination address.This route system is delivered to full routing table 550 with all 32 bits of this destination address, and searches the pairing route data of all 32 bits of this destination address in full routing table 550, and according to the route data that searches this IP packet is spread out of.And preceding 24 bits and this route data of this destination address delivered to high-speed cache routing table 580, and whether the decision of the update algorithm of the route cache device that is adopted by high-speed cache routing table 580 should store these data, and this update algorithm can be at most and do not use, at random or the first-in first-out scheduling algorithm.