Summary of the invention
The objective of the invention is to overcome the deficiencies in the prior art part, a kind of fast resolving method of packet is provided, this method can realize the fast processing to packet, and its autgmentability is strong.
In order to realize the foregoing invention purpose, the fast resolving method of a kind of packet provided by the invention may further comprise the steps:
(1) to the parsing in data packet header and the extraction of information, concrete steps comprise:
(1) protocol header of each grade of initialization location and information extraction table, protocol mapping table, lower-layer protocols concordance list and search key create-rule table; Wherein, protocol header location and information extraction table are used for depositing the processing method to packet variety of protocol head, localization method and data packet head information extraction method comprising original position, protocol mapping table is used for the coding of the variety of protocol that storage system can support, the lower-layer protocols concordance list is used for depositing the index value of all kinds of lower-layer protocols at protocol header location and information extraction table; Search key create-rule table is used to deposit the generation method of search key;
(2) judge whether processed protocol header is first protocol header of packet, if then get the initializtion protocol head type index value and the initializtion protocol head positional value of system default; Otherwise, take out the positional value of the lower-layer protocols head that when handling the upper-layer protocol head, obtains and the index value of lower-layer protocols head;
(3) index value with the resulting protocol head removes to search protocol header location and information extraction table, obtains the processing rule of current data packet;
(4) if the value identification process of the global operation list item in the table is finished, then packet is resolved and the data pick-up EO, enters step (two), otherwise, carry out step (5), (6) and (7) simultaneously;
(5) give lower-layer protocols head location according to locating rule, its step is as follows:
(5.1) judge whether the agreement length field exists in the protocol header, if exist, then extract the data of this length field, otherwise, according to the content in the form in two kinds of situation, the one, multi protocol label switching protocol adopts special-purpose processing mode, the 2nd, the agreement of regular length is then got the protocol header length that pre-defines;
(5.2) according to the original position of following formula (1) calculating lower-layer protocols head, enter step (2);
(5.2) according to the original position of following formula (1) calculating lower-layer protocols head, enter step (2); A lower-layer protocols start bit=this layer protocol head start bit+this layer protocol head length degree (1)
(6) determine the type of lower-layer protocols, the steps include:
(6.1) judge whether the lower layer protocol type territory exists in the protocol header, the protocol header index that does not exist then employing to pre-define enters step (3); Otherwise extract the data in protocol type territory, and continue to carry out following steps (6.2), step (6.3) and step (6.4):
(6.2) the data search protocol mapping table in the protocol type territory that obtains with step (6.1) obtains the mapping value a of agreement, b, c, d;
(6.3) agreement mapping value a, b, c, d calculates offset address by formula (2):
offset=a*2^α+b*2^β+c*2^λ+d*2^μ (2)
Wherein, α, β, λ, μ obtains by searching protocol header location and information extraction table;
(6.4) the plot list item addition in above-mentioned offset address and protocol header location and the information extraction table is obtained an absolute address`, search the lower-layer protocols concordance list, obtain a lower-layer protocols index value, enter step (2) with this absolute address`;
(7) protocol header information extraction, concrete steps are as follows:
(7.1) judge whether extraction information byte mask is 0, if, then no longer extract information, end step (7), otherwise continue to carry out following operation;
(7.2) extract the protocol header relevant information according to extracting the information byte mask;
(7.3) information that extracts is inserted the correspondence position of packet information keyword;
(7.4) revise packet information keyword identification code according to message identification code, enter step (2);
(2) generate search key
According to the search key create-rule sign that in protocol header location and information extraction table, obtains for the last time, in search key create-rule table, find corresponding search key generation method, then, according to packet information keyword and packet information keyword identification code, generate search key according to above-mentioned search key generation method.
How packet being carried out dissection process adopts fully by searching the respective rule table and determines, therefore, can reach concrete analytic method and the definition new protocol header type of process method of modification to packet by the corresponding contents of revising rule list, its flexibility and extensibility are very strong.Simultaneously, adopt the mode of multi-stage pipeline parallel processing, reduced the dissection process cycle of packet to a great extent, obtained high speed processing the data message.
Embodiment
At first the symbol shown in a pair of Figure of description of employing is illustrated.
Table one
For convenience of explanation, the content of employing table two pair protocol header location and information extraction table is illustrated.
Contents in table |
Action Specification |
Global operation (OP0) |
The global operation indication, use different value representations respectively: finishing dealing with abandons this layer data packet header and abandons total packet for IP fragmentation, the processing of lower floor's packet index value |
Length computation (OP1) |
This layer protocol head length calculation method represents with different value: do not do any operation and get low 4 of length field in this layer protocol head with predefined regular length and take advantage of 4 high 4 of getting length field in this layer protocol head to take advantage of 4 to be used for the multi protocol label switching protocol head |
Index operation (OP2) |
Lower floor's index operation, different value is represented: do not do any operation and adopt the PT thresholding computation of table lookup of this layer head to adopt predefined index to be used for the Ethernet protocol head, lower layer protocol type value<=0x05DC: finish dealing with; Lower layer protocol type value>0x05DC: with its lower layer protocol type value computation of table lookup |
Regular length |
Predefined protocol header length |
Offset address |
The offset address of protocol header length field |
Width |
The length of protocol header length field |
The agreement index |
The lower layer protocol type index, pre-defined |
The agreement skew |
Lower layer protocol type territory offset address |
The agreement width |
The length in lower layer protocol type territory |
The protocol header sign |
Be used to write down the data packet head of having resolved |
Extract the information byte mask |
Which byte will be extracted in this layer of head |
Search key create-rule sign |
Identify the create-rule of the search key of this packet |
Message identification code |
Show the information that has extracted |
Plot |
The base address of this protocol header in the lower-layer protocols concordance list |
A |
The possible maximum of preceding 4 bits in the lower layer protocol type territory |
B |
The possible maximum of time 4 bits in the lower layer protocol type territory |
C |
The possible maximum of the 3rd 4 bits in the lower layer protocol type territory |
D |
The possible maximum of last 4 bits in the lower layer protocol type territory |
α |
Calculate a lower-layer protocols index address: the weights of preceding 4 bits in the lower-layer protocols territory (the α position moves to left) |
β |
Calculate a lower-layer protocols index address: the weights (the β position moves to left) of time 4 bits in the lower-layer protocols territory |
λ |
Calculate a lower-layer protocols index address: the weights of the 3rd 4 bits in the lower-layer protocols territory (the λ position moves to left) |
μ |
Value is 0 |
1 explanation packet is resolved the pipeline processes framework at first, in conjunction with the accompanying drawings:
As shown in Figure 1, at a multi-layer protocol combining structure of packet on the network, adopt multi-stage pipeline arrangement successively every layer protocol header parsing to be handled.Each of streamline grade identical integrated circuit structure special of employing is finished identical function.Different is that every level production line all has location, a sets of data packet header and information extraction operation table separately, has disposed data parsing and the information extraction processing rule of finishing this layer protocol head in the table.Adopt the processing method of multi-stage pipeline, improved processing data packets speed.The specific descriptions of pipeline processes are as follows:
(1) according to data packet head architectural feature on the network, each level of pipeline processes is finished identical functions, and its hardware structure is the same.
(2) each level production line is finished following work: the data message that extracts this layer protocol head; Calculate the original position of next layer protocol head; Obtain the types value of lower-layer protocols head, and obtain this lower-layer protocols head at the protocol header location of following level production line and the index value in the information extraction table, obtain the rule of its subordinate's pipeline processes by searching protocol mapping table and lower-layer protocols concordance list.
(3) progression of streamline does not have fixing requirement, and for the structure of current network data pack protocol head, designing 5 level production lines can meet the demands.When in a single day dedicated IC chip is decided, its pipeline series also just has been fixed up.Each level all has corresponding data packet head location and information extraction operation table.The user can revise the content of table as required, to support the dissection process of novel protocol header.
Specify the step of packet fast resolving below again:
The first step is to the parsing in data packet header and the extraction of information.Whole process is to carry out according to the rule of data packet head location and the definition of information extraction operation table.
In conjunction with the accompanying drawings 2, packet is resolved and the concrete steps of information extraction are described below:
(1) data packet head of each grade of initialization location and information extraction operation table (comprising protocol header location and information extraction table, protocol mapping table and lower-layer protocols concordance list) and search key create-rule table.
Whether be first protocol header of data, be initializtion protocol head type index value and the initializtion protocol head positional value of then getting system default if (2) judging processed; Otherwise, take out the index value of the lower-layer protocols head that when handling the upper-layer protocol head, obtains and the positional value of lower-layer protocols head.
(3) index value with the protocol header that obtains in the step (2) removes to search protocol header location and information extraction table, obtains the processing rule of current data packet.
(4) if the value identification process of the global operation list item in the table is finished, then packet is resolved and the data pick-up EO, otherwise, carry out the operation in (5), (6) and (7) step simultaneously.
(5) give lower-layer protocols head location according to locating rule.Its concrete steps are as follows:
(a) judge whether the agreement length field exists in the protocol header, have the data that then extract this length field, otherwise, in two kinds of situation, the one, multi protocol label switching protocol adopts special-purpose processing mode, the 2nd, the agreement of regular length is then got the protocol header length that pre-defines.
(b) the following formula (1) of foundation calculates the original position of lower-layer protocols head:
A lower-layer protocols start bit=this layer protocol head start bit+this layer protocol head length degree (1)
(6) determine the type of lower-layer protocols, its concrete steps are as follows:
(a) judge whether the lower layer protocol type territory exists in the protocol header, the protocol header index that does not exist then employing to pre-define; Otherwise extract the data in protocol type territory, and continue to carry out following steps (b), step (c) and step (d).
(b) the data search protocol mapping table in the protocol type territory that obtains with step (a) obtains the mapping value a of agreement, b, c, d, wherein a, b, c, d are respectively first in the lower layer protocol type territory, two, three, four 4 bit values are searched protocol mapping table successively, the agreement mapping value that obtains, when the lower-layer protocols types value does not have 16 bit long, a, the b value is 0.
(c) utilize formula (2) to calculate offset address.
offset=a*2^α+b*2^β+c*2^λ+d*2^μ (2)
(d) add that with this offset address the plot list item in protocol header location and the information extraction table obtains an absolute address`, search the lower-layer protocols concordance list, obtain a lower-layer protocols index value with this absolute address`.
(7) protocol header information extraction, concrete steps are as follows:
(a) judge whether extraction information byte mask is 0, is the information that then no longer extracts; Otherwise the operation below continuing to carry out.
(b) extract the protocol header relevant information according to extracting the information byte mask
(c) information that extracts is inserted the correspondence position of packet information keyword
(d) revise packet information keyword identification code according to message identification code
In second step, generate search key
According to the search key create-rule sign that in protocol header location and information extraction table, obtains for the last time, in search key create-rule table, find corresponding search key generation method, then, according to packet information keyword and packet information keyword identification code, generate search key according to above-mentioned search key generation method.
Table two has been listed the contents in table of search key create-rule table.
Contents in table |
Explanation |
Search rule |
Expression search operation rule, comprise following several aspect: whether the search key conversion operations is opened.Opening will two search key of triggering for generating: normal search key and the search key of having changed, Content Addressable Memory is done twice search operation.If twice search operation all do not found, whether current search key is learned into Content Addressable Memory.Whether whether record transmits is upgraded identification field search rule enable bit after the operation of control protocol tag lookup is finished |
Content Addressable Memory table block number |
The table block that will search in the chosen content addressable memory |
Global mask |
Search mask, be used for the behaviour that searches of Content Addressable Memory |
|
Do |
Search key byte mask |
How indication generates search key |
Search key conversion mask 1 |
Search key source mask |
Search key conversion mask 2 |
Search key purpose mask |
Table two
The protocol header length calculation is described as follows:
For different protocol header, its length calculation method may be different.The agreement that has has fixing length; The length that has changes, and is provided by the length field in the protocol header; What also have will obtain by certain special-purpose computational methods, as multi protocol label switching protocol.Specifically describe as follows:
(1) for the regular length agreement, the value in the regular length territory of configuration protocol head location and information extraction table is its length value, and the value of OP1 is joined for adopting predefined regular length.Like this, application-specific integrated circuit (ASIC) can be according to this value of OP1 be got in the table fixed-length value as the length of its protocol header when handling.
(2) variable-length agreement, this quasi-protocol length can be obtained by the length field in its protocol header, is offset agreement width territory according to the good agreement of concrete protocol configuration in protocol header location and information extraction table.The value of OP1 is joined for getting low 4 or high 4 of length field in this layer protocol head and is taken advantage of 4.Transmission control protocol and Internet protocol belong to this quasi-protocol;
(3) multi protocol label switching protocol, its length have special-purpose computational methods.The value of OP1 is joined for being used for the multi protocol label switching protocol head, and can be used as multilayer multi protocol label switching protocol head stack is that a special protocol header is handled.The method of hardware using is by detecting the s territory (1 bit) in the multi protocol label switching protocol head, at the bottom of being the stack that was illustrated in the multilayer multi protocol label switching protocol head stack at 1 o'clock, just obtain the length of whole multi protocol label switching protocol protocol header by the statistical value of this protocol header number.
The structure of 3 pairs of protocol mapping tables describes in conjunction with the accompanying drawings:
Protocol mapping table is that a width is 16 bits, and the degree of depth is 16 form.For convenience of description, protocol mapping table is equally divided into 4 row, is named as Table A, table B, table C and table D successively, first, second and third and four 4 bit values of being respectively applied for the protocol class offset shine upon.The content of Table A is to determine like this: first 4 bit value of required all the protocol class offsets to be processed of Table A, it is one or several numeral that drops in 0 to 0x0F, we are index value the relevant position in Table A of these several numerals as the degree of depth, insert successively since 0 Digital ID it, f is filled out in other positions.Table B, table C adopt identical method construct with table D.
Be the computing formula and the explanation thereof of offset address in the lower-layer protocols concordance list below:
offset=a*2^α+b*2^β+c*2^λ+d*2^μ (2)
Wherein, a, b, c, d first, second, third and fourth 4 bit mapping value among Table A, table B, table C and the table D in protocol mapping table respectively of being followed successively by protocol type territory in this layer protocol head.α and β and λ can find in protocol header location and information extraction table, and its value is calculated with following formula by protocol mapping table:
μ=0,
min{2^λ>Max(d)*2^μ}=>λ
min{2^β>Max(c)*2^λ+Max(d)*2^μ}=>β
min{2^α>Max(b)*2^β+Max(c)*2^λ+Max(d)*2^μ}=>α
Being described as follows of plot list item in protocol header location and the information extraction table:
The depth calculation formula that data packet header is occupied in the lower-layer protocols concordance list is:
depth=Max(a)*2^α+Max(b)*2^β+Max(c)*2^λ+Max(d)*2^μ
So in protocol header location and information extraction table, the plot list item value of first stature is that the base value of 0, the second stature is the depth of 0+ first stature, the base value of the 3rd stature be the front head depth value with, the rest may be inferred.
In conjunction with the accompanying drawings 4, a lower-layer protocols concordance list is described below:
Content in the lower-layer protocols concordance list is the index of various protocol types in subordinate protocol header location and information extraction table.This layer of each protocol header of being supported has a size respectively and is the continuum of depth in a lower-layer protocols concordance list, the index value of storing the lower layer protocol type that it supports in this zone.
Be described as follows extracting the information byte mask in conjunction with Fig. 5:
Defined extraction information byte mask entry in protocol header location and information extraction table, it is to be used for showing how from the protocol header extracted data.When extracting information byte mask list item employing binary representation, each bit when this binary digit is that this byte is extracted in 1 expression, is that 0 expression is not extracted corresponding to a byte of data packet head.The extraction information byte mask list item of 32 bits can be handled the protocol header that reaches 32 byte wides, if protocol header length less than 32 bytes, we mend 0 in the mask back of this protocol header, benefit 0 in this protocol header not relevant corresponding byte.Mask value is 0xFFF00000 in the accompanying drawing 5, extracts destination address and source address information in the protocol header.
In conjunction with the accompanying drawings 6 and Fig. 7 as follows to data package informatin keyword and message identification code identifier declaration:
The packet information key length is 32 bytes, is used for storing data packet head information.When data packet header was resolved, extraction information and when inserting the packet information keyword was carried out record by message identification code to this.In the accompanying drawing 7, need to extract the SIP of IP head, DIP, information such as ID extract the corresponding SIP of information byte mask, and DIP, the mask value in ID territory are 1, and other thresholdings are 0.Accordingly, store SIP in the packet information keyword, DIP, the message identification code of the relevant position of ID is set at 1 and identifies.