The sorting technique of net bag rule set and device
Technical field
The application relates to communication technical field, particularly relates to sorting technique and the device of a kind of net bag rule set.
Background technology
Along with the development of the Internet, traditional routing technology can not meet the demand of Network, therefore, net bag classification
Technology is arisen at the historic moment.Net bag sorting technique refers to according to the information in net bag, according to default net bag rule set (net bag rule set
Including multiple net bag rules) net is wrapped the process classified.Dividing by default rule set is entered of net bag classifying rules
Row pretreatment, generates multiple rules subset, net wraps when can be effectively improved net bag classification the lookup speed of rule, improves net
Bag classification performance.
But, the net bag rule in above-mentioned net bag rule set may contain asterisk wildcard.In correlation technique, when according to net bag
During asterisk wildcard node division classifying rules subset in rule, the rules subset that net bag rule is more can be generated, thus take relatively
Big memory space.
Summary of the invention
In view of this, the application provides sorting technique and the device of a kind of net bag rule set, solves net in correlation technique
The problem that packet classification method takies bigger memory space.
Specifically, the application is achieved by the following technical solution:
The application provides the sorting technique of a kind of net bag rule set, described net bag rule set to include some net bag rules, institute
The method of stating is applied on the network equipment, and described method includes:
Based on default coding rule, the net bag rule in net bag rule set is encoded;
After completing the coding of the net bag rule in described net bag rule set, based on the net in the net bag rule set after coding
Bag rule builds net bag rule set state machine;
According to described net bag rule set state machine, net bag rule set is classified.
Optionally, described based on default coding rule, the net bag rule in net bag rule set is encoded, including:
The character code described net being wrapped regular each dimension corresponding based on default mapping relations is by specific character
The character string of collection composition;
By the character string after each dimension coding of described net bag rule based on specifying sequential combination.
Optionally, described based on coding after net bag rule set build net bag rule set state machine, including:
Net bag rule set state machine is built successively according to the net bag rule after described coding.
Optionally, described based on coding after net bag rule set build net bag rule set state machine, including:
When the net bag rule after described coding has asterisk wildcard, the asterisk wildcard in the net bag rule after described coding is replaced
It is changed to preset value;
Net bag rule set state machine is built successively according to the net bag rule after described replacement asterisk wildcard.
Optionally, described based on coding after net bag rule set build net bag rule set state machine, including:
When the net bag rule in the net bag rule set after coding includes multiple bit, successively according to the net after described coding
Bag rule builds many Binets bag rule set state machine.
The application provides the sorter of a kind of net bag rule set, described net bag rule set to include some net bag rule simultaneously
Then, described method is applied on the network equipment, and described device includes:
Coding unit, for encoding the net bag rule in net bag rule set based on default coding rule;
Construction unit, after being used for the coding of the net bag rule in described net bag rule set, based on the net after coding
Net bag rule in bag rule set builds net bag rule set state machine;
Taxon, for classifying to net bag rule set according to described net bag rule set state machine.
Optionally, described coding unit specifically for:
The character code described net being wrapped regular each dimension corresponding based on default mapping relations is by specific character
The character string of collection composition;
By the character string after each dimension coding of described net bag rule based on specifying sequential combination.
Optionally, described construction unit specifically for:
Net bag rule set state machine is built successively according to the net bag rule after described coding.
Optionally, described construction unit specifically for:
When the net bag rule after described coding has asterisk wildcard, the asterisk wildcard in the net bag rule after described coding is replaced
It is changed to preset value;
Net bag rule set state machine is built successively according to the net bag rule after described replacement asterisk wildcard.
Optionally, described construction unit specifically for:
When the net bag rule in the net bag rule set after coding includes multiple bit, successively according to the net after described coding
Bag rule builds many Binets bag rule set state machine.
In this application, the net bag rule in net bag rule set can be carried out by the network equipment based on default coding rule
Coding, then after the coding of the net bag rule in completing this net bag rule set, can be based on the net bag rule set after coding
Build net bag rule set state machine, and according to this net bag rule set state machine, net bag rule set is classified.Application the application
Can be by dropping to one-dimensional build net bag rule set state machine from multidimensional by the net bag rule in net bag rule set, and according to structure
Net bag rule in net bag rule set is classified by the net bag rule set state machine built out, owing to can generate less net bag
Rule, the problem that therefore can solve correlation technique.
Accompanying drawing explanation
Fig. 1 is the embodiment flow chart of the sorting technique of a kind of net bag rule set shown in the application;
Fig. 2 is a kind of rule set state machine shown in the application;
Fig. 3 is the another kind of rule set state machine shown in the application;
Fig. 4 is the one many bit rules collection state machine shown in the application;
Fig. 5 is a kind of hardware structure diagram of the sorter place equipment of the application net bag rule set;
Fig. 6 is an embodiment block diagram of the sorter of the application net bag rule set.
Detailed description of the invention
Here will illustrate exemplary embodiment in detail, its example represents in the accompanying drawings.Explained below relates to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represents same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they are only with the most appended
The example of the apparatus and method that some aspects that described in detail in claims, the application are consistent.
It is only merely for describing the purpose of specific embodiment at term used in this application, and is not intended to be limiting the application.
" a kind of ", " described " and " being somebody's turn to do " of singulative used in the application and appended claims is also intended to include majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wraps
Any or all containing one or more projects of listing being associated may combination.
Although should be appreciated that in the application possible employing term first, second, third, etc. to describe various information, but this
A little information should not necessarily be limited by these terms.These terms are only used for same type of information is distinguished from each other out.Such as, without departing from
In the case of the application scope, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depend on linguistic context, word as used in this " if " can be construed to " ... time " or " when ...
Time " or " in response to determining ".
In correlation technique, net bag rule set can include some net bag rules, wherein, can contain in these some net bag rules
There is asterisk wildcard.When according to asterisk wildcard node division rules subset in net bag rule, the rule that net bag rule is more can be generated
Subset.
Such as, above-mentioned net bag rule set can be two-dimensional mesh bag rule set, wherein, and the desirable value 0 or 1 of every dimension is permissible
Assume that this net bag rule set includes 4 net bag rules, and these 4 net bag rules be respectively as follows: R1:0, *, R2:1,0, R3:1,1 with
And R4:*, 0.When this two-dimensional mesh bag rule set is divided, following result can be obtained: 0,0 group: R1 and R4;0,1
Group: R1;1,0 groups: R2 and R4;1,1 groups: R3.From this result, the regular sum that this net bag rule set is divided can be
6。
In another is assumed, the classifying rules in above-mentioned two-dimensional mesh bag rule set does not contains asterisk wildcard, and this net bag
4 net bag rules in rule set are respectively as follows: R1:0,1, R2:1,0, R3:1,1 and R4:1,0.Then when this two-dimensional mesh bag is advised
Then collection is when dividing, and can obtain following result: 0,0 group: nothing;0,1 group: R1;1,0 groups: R2 and R4;1,1 groups: R3.From
This result understands, and the regular sum that this net bag rule set is divided can be 4.
From above-mentioned two example, when according to asterisk wildcard node division rules subset in net bag rule, can generate
The rules subset that net bag rule is more, thus take bigger memory space.
The problem taking bigger memory space in order to solve net packet classifying method in correlation technique, the application provides a kind of net
The sorting technique of bag rule set and device.In this application, the network equipment can be based on default coding rule to net bag rule
The net bag rule concentrated encodes, then after the coding of the net bag rule in completing this net bag rule set, and can be based on
Net bag rule set after coding builds net bag rule set state machine, and enters net bag rule set according to this net bag rule set state machine
Row classification.Application the application can wrap rule by the net bag rule in net bag rule set is dropped to the one-dimensional net that builds from multidimensional
Collection state machine, and according to the net bag rule set state machine constructed, the net bag rule in net bag rule set is classified, due to
Less net bag rule, the problem that therefore can solve correlation technique can be generated.
Refer to Fig. 1, for the embodiment flow chart of the sorting technique of a kind of net bag rule set shown in the application, described side
Method is applied to the network equipment, comprises the following steps:
Step 101: the net bag rule in net bag rule set is encoded based on default coding rule.
In this application, the network equipment can be with pre-arranged code rule and regular to net bag according to this coding rule preset
The net bag rule concentrated encodes.
Specifically, the net in above-mentioned net bag rule set can be wrapped the every of rule based on default mapping relations by the network equipment
Character code corresponding to one dimension is the character string being made up of specific character collection, then by each dimension of this net bag rule
Character string after coding is based on specifying sequential combination.It should be noted that above-mentioned default mapping relations can be by User Defined
Arranging, for example, it is possible to be F (x)=X, the application is without limitation.Similarly, above-mentioned specific character collection and appointment order
Can also be arranged by User Defined, this is not limited by the application.
In the embodiment illustrated, it can be assumed that above-mentioned net bag rule set includes 4 net bag rules, and these 4 nets
Bag rule is respectively as follows: R1:0, *, R2:1,0, R3:1,1 and R4:*, and 0.Then the network equipment is to the net in this net bag rule set
During bag rule encodes, first based on default mapping relations, above-mentioned each net can be wrapped each dimension of rule
Corresponding character code is the character string being made up of specific character collection, it can be assumed that default mapping relations are F (x)=X, specific
Character set can be set { 0,1, * }, then above-mentioned each net is being wrapped each of rule based on above-mentioned mapping relations by the network equipment
After character code corresponding to individual dimension is the character string being combined into by above-mentioned collection, as follows 4 net bag rule can be obtained:
R1 ': 0, *, R2 ': 1,0, R3 ': 1,1 and R4 ': *, 0.Then, above-mentioned each net can be wrapped each of rule by the network equipment
Character string after dimension coding is based on specifying sequential combination, and in one embodiment, each dimension of above-mentioned 4 net bag rules is compiled
Character string after Ma based on specifying after sequential combination, 4 rules that can be as follows: R1 ": 0*, R2 ": 10, R3 ": 11 with
And R4 ": * 0.
Step 102: after completing the coding of the net bag rule in described net bag rule set, based on the net bag rule after coding
The net bag rule concentrated builds net bag rule set state machine.
In this application, the network equipment, can be with base after completing the coding of the net bag rule in above-mentioned net bag rule set
The net bag rule in net bag rule set after coding builds net bag rule set state machine.Specifically, the network equipment can be successively
Net bag rule set state machine is built according to net bag rule encoded in above-mentioned net bag rule set.
In one embodiment, the network equipment can be by by net bag rule encoded in above-mentioned net bag rule set one by one
Insert the mode of the state machine that character set is above-mentioned default characters to build above-mentioned net bag rule set state machine.
In the embodiment illustrated, it can be assumed that the net bag rule in net bag rule set after above-mentioned coding is:
R1 ": 0*, R2 ": 10, R3 ": 11 and R4 ": * 0, then the net bag rule after these 4 can be encoded by the network equipment is inserted one by one
Character set is in the state machine of { 0,1, * }, and then, the network equipment can obtain rule set state machine as shown in Figure 2.
In one embodiment, when the net bag rule after above-mentioned coding has asterisk wildcard, can be by the net after this coding
Asterisk wildcard in bag rule replaces with preset value, and wherein, this preset value can be arranged by User Defined, such as, can be above-mentioned
Specific character concentrates the character of non-asterisk wildcard, i.e. this preset value can be 1 or 0.After replacement completes, the network equipment can root successively
Net bag rule set state machine is built according to the net bag rule after replacing asterisk wildcard.Owing to building net bag rule set shape according to net bag rule
The process of state machine illustrates the most in the above-described embodiments, therefore the application does not repeats them here.
In the embodiment illustrated, it can be assumed that the net bag rule in net bag rule set after above-mentioned coding is:
R1 ' ': 0*, R2 ' ': 10, R3 ": 11 and R4 ": * 0.Due to net bag rule R1 " and R4 ' ' has asterisk wildcard, therefore, network
Equipment can net bag rule R1 ' ' and R4 " in asterisk wildcard replace with 0 or 1, and build according to the net bag rule after replacing
Rule set state machine as shown in Figure 3.
In one embodiment, when the net bag rule in the net bag rule set after coding includes multiple bit, network sets
For building many bit rules collection state machine according to the net bag rule after coding.
In the embodiment illustrated, it can be assumed that the net bag rule in net bag rule set after above-mentioned coding is:
R1 ' ': 0*, R2 ' ': 10, R3 ": 11 and R4 ": * 0.Owing to the net bag rule in above-mentioned net bag rule set includes 2 bits, because of
This, the network equipment can generate according to the net bag rule after replacing after the asterisk wildcard in net bag rule is replaced with preset value
Many Binets bag rule set state machine as shown in Figure 4.
Step 103: net bag rule set is classified according to described net bag rule set state machine.
In the application, the network equipment, after completing the structure to net bag rule set state machine, can be advised according to this net bag
Then collection state machine completes the classification to net bag rule set.
From above-described embodiment, when the net bag rule set state machine that the network equipment builds as shown in Figure 2 time, the network equipment
According to this net bag rule set state machine, net bag rule set can be divided, it can be assumed that net bag rule set is: R1:0, *,
R2:1,0, R3:1,1 and R4:*, 0, then the network equipment is after dividing this net bag rule set, can obtain as follows
4 net bag rule: r1:0*, r2:10, r3:11 and r4:*0;When net bag rule set state machine such as figure that the network equipment builds
Time shown in 3, above-mentioned net bag rule set can be divided into by the network equipment according to this net bag rule set state machine: r1 ': 00, r2 ':
01, r3 ': 10 and r4 ': 11 totally 4 net bag rule;When the network equipment builds many Binets bag rule set shape as shown in Figure 4
During state machine, above-mentioned net bag rule set can be divided into quickly by the network equipment according to this many Binets bag rule set state machine:
R1 ": 00, r2 ": 01, r3 ": 10 and r4 ": 11 totally 4 net bag rules.
In this application, the net bag rule in net bag rule set can be carried out by the network equipment based on default coding rule
Coding, then after the coding of the net bag rule in completing this net bag rule set, can be based on the net bag rule set after coding
Build net bag rule set state machine, and according to this net bag rule set state machine, net bag rule set is classified.Application the application
Can be by dropping to one-dimensional build net bag rule set state machine from multidimensional by the net bag rule in net bag rule set, and according to structure
Net bag rule in net bag rule set is classified by the net bag rule set state machine built out, owing to can generate less net bag
Rule, the problem that therefore can solve correlation technique.
Corresponding with the embodiment of the sorting technique of aforementioned net bag rule set, present invention also provides dividing of net bag rule set
The embodiment of class device.
The embodiment of the sorter of the application net bag rule set can be applied on network devices.Device embodiment is permissible
Realized by software, it is also possible to realize by the way of hardware or software and hardware combining.As a example by implemented in software, patrol as one
Collect the device in meaning, be that the processor by its place equipment is by computer program instructions corresponding in nonvolatile memory
Read and internal memory runs formation.For hardware view, as it is shown in figure 5, be the sorter of the application net bag rule set
A kind of hardware structure diagram of place equipment, except the processor shown in Fig. 5, internal memory, network interface and nonvolatile memory
Outside, in embodiment, the network equipment at device place generally can also include other hardware, such as the forwarding core of responsible process message
Sheet etc..
Refer to Fig. 6, be an embodiment block diagram of the sorter of the application net bag rule set.
This device may include that coding unit 610, construction unit 620 and taxon 630.
Wherein, coding unit 610, for compiling the net bag rule in net bag rule set based on default coding rule
Code;
Construction unit 620, after being used for the coding of the net bag rule in described net bag rule set, after coding
Net bag rule in net bag rule set builds net bag rule set state machine;
Taxon 630, for classifying to net bag rule set according to described net bag rule set state machine.
In an optional implementation, described coding unit 610 can be specifically for:
The character code described net being wrapped regular each dimension corresponding based on default mapping relations is by specific character
The character string of collection composition;
By the character string after each dimension coding of described net bag rule based on specifying sequential combination.
In an optional implementation, described construction unit 620 can be specifically for:
Net bag rule set state machine is built successively according to the net bag rule after described coding.
In an optional implementation, described construction unit 620 can be specifically for:
When the net bag rule after described coding has asterisk wildcard, the asterisk wildcard in the net bag rule after described coding is replaced
It is changed to preset value;
Net bag rule set state machine is built successively according to the net bag rule after described replacement asterisk wildcard.
In an optional implementation, described construction unit 620 can be specifically for:
When the net bag rule in the net bag rule set after coding includes multiple bit, successively according to the net after described coding
Bag rule builds many Binets bag rule set state machine.
In this application, the net bag rule in net bag rule set can be carried out by the network equipment based on default coding rule
Coding, then after the coding of the net bag rule in completing this net bag rule set, can be based on the net bag rule set after coding
Build net bag rule set state machine, and according to this net bag rule set state machine, net bag rule set is classified.Application the application
Can be by dropping to one-dimensional build net bag rule set state machine from multidimensional by the net bag rule in net bag rule set, and according to structure
Net bag rule in net bag rule set is classified by the net bag rule set state machine built out, owing to can generate less net bag
Rule, the problem that therefore can solve correlation technique.
In said apparatus, the function of unit and the process that realizes of effect specifically refer to corresponding step in said method
Realize process, do not repeat them here.
For device embodiment, owing to it corresponds essentially to embodiment of the method, so relevant part sees method in fact
The part executing example illustrates.Device embodiment described above is only schematically, wherein said as separating component
The unit illustrated can be or may not be physically separate, and the parts shown as unit can be or can also
It not physical location, i.e. may be located at a place, or can also be distributed on multiple NE.Can be according to reality
Need to select some or all of module therein to realize the purpose of the application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, i.e. it is appreciated that and implements.
The foregoing is only the preferred embodiment of the application, not in order to limit the application, all essences in the application
Within god and principle, any modification, equivalent substitution and improvement etc. done, should be included within the scope of the application protection.