Summary of the invention
The purpose of this invention is to provide a kind of attribute set type 2-D message classification and lookup method and equipment, can make full use of polycaryon processor technology popular in the present network processing unit and realize the 2-D message Fast Classification, to improve the message classification speed in the network processes.
Another object of the present invention provides a kind of attribute set type 2-D message classification and lookup method and equipment, can not change original polycaryon processor core design, and the bidimensional rule base be done simple preliminary treatment and realize the access management of 2-D message rule by a kind of simple device.
To achieve these goals,, proposed a kind of attribute set type 2-D message classification and lookup method, having comprised: the rule at message of bidimensional rule base has been divided into prefix sets, and each prefix sets is divided into the sign set according to the present invention; Utilize sign, the dimension information of sign set and merge string information and set up look-up table; And when incoming message when searching, the sign set that the matched rule that utilizes described look-up table to search described message should be located is to obtain the matched rule of described message.
Preferably, the step that the rule at message of described bidimensional rule base is divided into prefix sets comprises: with the bidimensional rule base be divided into prefix sets at the rule of message according to the combination of the prefix length of first peacekeeping, second dimension of described rule, and distribute a corresponding hash function for each prefix sets.
Preferably, the rule in the same prefix sets has same prefix length combination.
Preferably, the step that each prefix sets is divided into the sign set comprises: the mode according to " when long dimension was inequality, its feature string was also inequality " is divided into the sign set with each prefix sets, and each sign set has different signs.
Preferably, described look-up table comprises that the first dimension information searching table, the second dimension information searching table, the two dimensions of information of rule merge the string look-up table.
Preferably, described look-up table has first storage organization of searching of the information of first peacekeeping, second dimension that is used for rule, and is used for second storage organization of searching that regular first peacekeeping, second dimension merges the information of string.
Preferably, the described step of setting up look-up table also comprises: set up with first storage organization is corresponding and searches the coupling tree, and set up with the corresponding coupling of searching of second storage organization and set.
Preferably, the set of sign that the matched rule that utilizes described look-up table to search described message should be located comprises with the step of the matched rule that obtains described message: take out the first dimension information, the second dimension information of message, the merging string information of bidimensional respectively; According to the keyword of look-up table, first dimension of parallel work-flow data message prefix matching rule, second dimension, the merging string information of bidimensional; According to the sign set that look-up table comprises, first dimension, second dimension, the bidimensional that obtain the longest prefix match rule respectively merge the sign set that string information is comprised; According to resulting three sign set, try to achieve their common factor; Utilize the two dimensions of information of the sign that has limit priority in the described common factor and message to obtain the matched rule of described message.
To achieve these goals, a kind of equipment that is used for the attribute set type 2-D message classification and searches has also been proposed, comprise: the 2-D message classification device, be used for the rule at message of bidimensional rule base is divided into prefix sets, and each prefix sets is divided into the sign set, and utilizes sign, the dimension information of sign set and merge string information and set up look-up table; External memory storage is used for hash and deposits the pairing hash function of each sign set grouping; And polycaryon processor, be used for when incoming message when searching, control so that the sign that the matched rule that utilizes the look-up table of being set up in the 2-D message classification device to search described message should be located set, to obtain the matched rule of described message.
Preferably, described 2-D message classification device comprises: input interface circuit, and the data-interface that provides rule to import is so that the rule that will import is sent to bidimensional rule base pretreatment unit circuit; Bidimensional rule base pretreatment unit circuit, have look-up table stores unit and pre-process circuit, described pre-process circuit is divided into prefix sets with the rule at message of bidimensional rule base, and each prefix sets is divided into the sign set, and utilizes sign, the dimension information of sign set and merge string information and set up look-up table; Hash function administrative unit circuit is used for determining the pairing hash function of each sign set grouping, and is saved in described external memory storage; And the processor interface circuit and the memory interface circuit that carry out interface respectively with described polycaryon processor and described external memory storage.
Embodiment
For the ease of the elaboration of back, do following agreement and definition:
(1) matching domain of the rule of bidimensional rule base part all is converted into the Bit String form of network prefix;
(2) two Bit String A, B, wherein the length of B is length 〉=h of h and A, when the h seat of A string is identical with B, then claims A prefix matching B;
(3) in the bidimensional rule, the long dimension of prefix length is called long dimension, the short dimension of prefix is called short dimension;
(4) p position equipotential merging string is the two-value Bit String (a that is respectively m (m 〉=p 〉=0), n (n 〉=p 〉=0) by length
1a
2a
3A
N-1a
m), (b
1b
2b
3B
N-1b
n) the new two-value Bit String (a that forms
1b
1a
2b
2a
3b
3A
P-1b
P-1a
pb
p);
(5) Gui Ze merging string is exactly that first peacekeeping, second dimension is merged string by the equipotential that short dimension length merges;
(6) k seat string (a
1a
2a
3A
P-1a
k) be two-value Bit String A (a
1a
2a
3A
M-1a
m) first to the k position partial bit string of (m 〉=k>0), be designated as substring (k, A);
(7) substring of the short dimension length of long dimension is called the feature string of long dimension.As (110,111000), long dimension is second dimension, and short dimension is first dimension, and its length is 3, and then the feature string of long dimension be that go here and there at 3 seats of (111000), promptly 111;
(8) length combination according to the bidimensional rule is divided into some set to rule, and each set is exactly a prefix sets, is designated as T (m, n), wherein m is the length of first dimension, and n is the length of second dimension, and the rule that belongs to same prefix sets has same prefix length combination.All belong to prefix sets T (3,2) as (111,11) and (100,10), they all have same prefix length combination, and (111,11) and (10,100) just do not belong to same prefix sets, because the length combination difference.
The preferred embodiments of the present invention are described below with reference to the accompanying drawings.The architecture of 2-D message classification device of the present invention mainly is made up of following several circuit and interface as shown in Figure 1:
(1) input interface circuit (1-1): the data-interface of rule input is provided, is responsible for data are sent to bidimensional rule base pretreatment unit circuit.
(2) bidimensional rule base pretreatment unit circuit (1-2): look-up table (1-3) that is made of memory cell and the pre-process circuit (1-4) that the bidimensional rule base is handled are formed, this circuit is responsible for finishing the division of prefix sets regular in the rule base and sign set and is deposited, and sets up the look-up table that is used to search;
(3) processor interface circuit (1-5): the interface that is provided for the polycaryon processor of network processes;
(4) hash function administrative unit (1-6): the hash function table (1-7) and the hash function inlet marker circuit (1-8) that are made of memory cell constitute, and this circuit is in charge of the Hash access function corresponding with prefix sets;
(5) memory interface circuit (1-9): the memory interface of depositing the bidimensional rule base is provided.
Particularly, wherein said bidimensional rule base pretreatment unit circuit (1-2) mainly is to comprise the following circuit that can be realized by programmable gate array (FPGA) and memory:
(1) pre-process circuit (1-4): the rule in the bidimensional rule base is carried out preliminary treatment, and the criteria for classifying of gathering according to sign is divided into the sign set, and provides information for setting up look-up table;
(2) look-up table (1-3): the information table that is used to deposit rule searching.
In addition, wherein said hash function administrative unit circuit (1-6) mainly is to be made of memory, deposits the hash function that is used for access rule, and can take out corresponding hash function according to the identification number of hash function, comprising:
(1) hash function table (1-7): deposit the corresponding hash function of sign set;
(2) hash function inlet marker circuit (1-8): hash function inlet sign is made up of the sign of prefix sets, by this circuit, can read the hash function corresponding with prefix sets.
The annexation of above-mentioned each circuit is: when new bidimensional rule base adds fashionable, be entered into bidimensional rule base pretreatment unit (1-2) by input interface circuit (1-1), carry out the processing of prefix sets and sign set at pre-process circuit (1-4), utilize the prefix information of rule, the sign of Bit String information that the bidimensional prefix merges and the set of the sign at its place is set up look-up table, and leave in the look-up table (1-3), rule after the processing obtains Hash hash function by the hash function marker circuit (1-8) that enters the mouth in hash function table (1-7) inquiry with the prefix sets at regular place by hash function administrative unit (1-6), utilizes the Hash hash function by memory interface circuit (1-9) rule to be stored in the external memory storage.
2-D message classification device of the present invention and the annexation that is used for the polycaryon processor of network processes and memory cell are as shown in Figure 2.The title of each several part is:
(1) attribute set type 2-D message classification device (2-1): concrete structure as shown in Figure 1;
(2) be used for the polycaryon processor (2-2) of network processes, be used for when incoming message when searching, control so that the sign that the matched rule that utilizes described look-up table to search described message should be located set, to obtain the matched rule of described message.
(3) external memory storage (2-3): the memory of depositing the bidimensional rule base of dividing according to the sign set;
The annexation of above-mentioned each module is: attribute set type 2-D message classification device (2-1) divides into groups according to the sign set according to the 2-D message rule base of input, and each grouping is stored in external memory storage (2-3) according to the hash function hash of correspondence.When searching, the polycaryon processor (2-2) that is used for network processes determines to comprise the sign set of matched rule according to the included look-up table of grader (2-1) that reads.
The processing procedure that attribute set type 2-D message classification of the present invention and lookup method relate to comprises: the partition process of sign set, the process of setting up and the search procedure of look-up table.
The criteria for classifying of at first described sign set comprises:
(1) rule to each prefix sets is divided into the sign set, and require the rule in each sign set to satisfy condition: when long dimension was inequality, its feature string was also inequality;
(2) can prove: if first dimension of data message, the information of second dimension can both prefix matching be present in the rule in certain sign set, and their merging string information also can prefix matching the merging string that comprises of this sign set, this attribute set unification contains the matched rule of this data message surely so.
The partition process of described sign set is carried out according to following steps:
(1) rule of bidimensional rule base is divided into prefix sets according to the combination of the prefix length of its first dimension, second dimension, the rule in the same prefix sets has same prefix length combination;
(2) the corresponding hash function of each prefix sets is stored in the external memory storage by hash function administrative unit hash according to hash function;
(3) criteria for classifying that each prefix sets is gathered according to above-mentioned sign is divided into the sign set;
Prefix information and sign according to the rule in each sign set are created as look-up table.
Particularly, partition process such as Fig. 3 of sign set.
At first, in step 301, will not be input in the pretreatment unit in the rule base through dividing the new regulation of handling.Then, in step 303, seek the corresponding prefix sets of this combination according to the prefix length combination that first peacekeeping second of this rule is tieed up.Then, judge whether this prefix sets exists in step 305, and the situation execution in step 307 or the step 309 that whether exist according to prefix sets.If this prefix sets exists, then execution in step 307, and step 307 is finished the process that this new regulation is joined this prefix sets; If this prefix sets does not exist, then execution in step 309, in this step, create a new prefix sets, and should make up by this rule decision by the corresponding prefix length of set, simultaneously this rule joined in this newly-built prefix sets.In step 311, check whether the strictly all rules in the rule base all is divided in the different prefix sets, if also there is the rule that does not have division, then take out a rule that does not have to divide as new input, get back to step 301; If all dividing, rule finishes, then execution in step 313 down.In step 313, at certain prefix sets, with the information of the rule in its set according to its long dimension, descending or ascending order rearrangement.Then, in step 315 li, from taking out a rule to the sign set to be allocated in the sorted prefix sets.This rule to sign set to be allocated is in step 317 li, compare respectively with the long dimension information and the feature string information of the last rule of the ordering in the sign set that has existed in this prefix sets, and the result that will compare delivers to step 319.In step 319, if long dimension information equates or long dimension information is unequal and feature string information when also unequal, then execution in step 325, otherwise execution in step 321.In step 321, check whether have the sign set of relatively crossing or not, if having, then with the sign set execution in step of crossing without comparison 317; If have, illustrate and all sign set not carrying out comparisons, then execution in step 323 down.In step 323 li, set up a new sign set.In step 325 li, be to join in the sign set from the result of step 319 or step 323 li, for the result of step 319, be the sign set of adding the existence of this rule to one, and step 323 is that this rule is added in the newly-built sign set of step 323.Then, execution in step 327 mainly is to check whether the rule in this prefix sets has all made to be divided into the handling process of sign set, if not, then the rule that does not wherein have to handle is carried out from the flow process of step 315 beginning, if, execution in step 329 down then.In step 329, mainly be to check whether all prefix sets all to have been carried out from the processing procedure of the sign set division of step 313 beginning, if not, then the prefix sets that does not wherein have to handle is carried out from the handling process of step 313 beginning, if, all prefix sets that rule base then is described are all passed through processing, and then the entire process flow process finishes.
The pretreatment unit circuit contains 3 look-up tables altogether, is respectively that the first dimension information searching table, the second dimension information searching table, the two dimensions of information of rule merges the string look-up table.Look-up table is searched the table that the unit is formed by some, search the unit two kinds of structures are arranged, first kind of structure is used for the searching of information of first peacekeeping, second dimension of rule, form by four parts, wherein address number is the address of searching the unit, keyword is a position information on the Bit String information, because each position only can value 0 or 1, therefore be divided into next keyword and be 0 address number and next keyword and be 1 address number, the 4th part is the information of the tag unit that comprises when finding this unit, as shown in Figure 4.First peacekeeping, second dimension that second kind of structure is used for rule merges the searching of information of string, be made up of six parts: address number, next keyword are the address number of " 11 " and attribute set the compile in collaboration with number that comprise for the address number of " 01 ", next keyword for the address number of " 10 ", next keyword for the address number of " 00 ", next keyword, as shown in Figure 5.
Then, set up the coupling of searching of first peacekeeping, second dimension according to the prefix information of first dimension, second dimension respectively and set, the nodal information of tree is according to first kind of above-mentioned storage organization storage;
Afterwards, set up the coupling of searching of first peacekeeping, the second dimension equipotential merging string and set, the nodal information of tree is according to second kind of above-mentioned storage organization storage;
Fig. 6 shows the flow chart according to the matched rule search procedure of the embodiment of the invention.
As shown in Figure 6, in step 601, take out the first dimension information, the second dimension information of message, the merging string information of bidimensional respectively.In step 603, according to the keyword of look-up table, first dimension of parallel work-flow data message prefix matching rule, second dimension, the merging string information of bidimensional.Then, in step 605, according to the sign set that look-up table comprises, first dimension, second dimension, the bidimensional that obtain the longest prefix match rule respectively merge the sign set that string information is comprised.In step 607,, try to achieve their common factor according to resulting three sign set.In step 609, the pairing sign set of occuring simultaneously all comprises the rule of message coupling, according to the priority of sign set, with the sign of the sign set of the limit priority sign as Hash lookup.At last, give the hash function administrative unit with the two dimensions of information of searching sign and message, Hash lookup is to matched rule.
Illustrate these processes below with reference to Fig. 7 to 10.
The simplification bidimensional rule base that contains 9 rules as shown in Figure 7 (for simplicity, supposing that regular prefix length is 5 bits to the maximum).
According to the present invention, at first indicate the division of set, set up look-up table then.
(1) combination according to prefix length is divided into prefix sets with rule, and the corresponding hash function of each prefix sets, utilizes hash function that these regular hash are stored in the memory, as shown in Figure 8;
(2) in each prefix sets, principle according to " when long dimension is inequality; its feature string is also inequality " is divided into the sign set to each prefix sets, as shown in Figure 9, each sign set has unique sign, utilize the dimension information of sign, rule simultaneously and merge the information of going here and there and set up look-up table, the logical relation and the search tree of look-up table are similar, specifically as shown in figure 10.As shown in figure 10, the information that marks on each node limit is exactly to leave in to search the sign aggregate information that comprises in the unit, the pairing keyword of this node of the Information sign in the node, and node branch points to the address number of next different keywords respectively.
When searching, follow these steps to carry out.
Suppose a two-dimensional data message P (11000,11011).The first dimension information 11000 is searched at the look-up table of first dimension, and the second dimension information 11011 is searched at the look-up table of second dimension, and the merging string information (11 11 00 01 01) of bidimensional is searched at the look-up table that bidimensional merges string.These three search procedures are carried out simultaneously.
The attribute set that obtains comprising respectively is combined into { T1_1, T2_1, T3_1}, { T3_1, T1_2, T2_2} and { T1_1, T2_1, T3_1}.The common factor of getting them is { T3_1}.
Because the hash function of sign set T31 correspondence is F3.Give the hash function administrative unit F3 and two dimensions of information (11000,11011), readable taking-up rule D (110,11) is the matched rule of message.
Although below show the present invention in conjunction with the preferred embodiments of the present invention, one skilled in the art will appreciate that under the situation that does not break away from the spirit and scope of the present invention, can carry out various modifications, replacement and change to the present invention.Therefore, the present invention should not limited by the foregoing description, and should be limited by claims and equivalent thereof.