CN1719769A - Method for classifying received data pocket in network apparatus - Google Patents
Method for classifying received data pocket in network apparatus Download PDFInfo
- Publication number
- CN1719769A CN1719769A CN 200410062372 CN200410062372A CN1719769A CN 1719769 A CN1719769 A CN 1719769A CN 200410062372 CN200410062372 CN 200410062372 CN 200410062372 A CN200410062372 A CN 200410062372A CN 1719769 A CN1719769 A CN 1719769A
- Authority
- CN
- China
- Prior art keywords
- address
- node
- mask
- next stage
- index value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 27
- 230000011218 segmentation Effects 0.000 claims description 16
- 238000012217 deletion Methods 0.000 claims description 12
- 230000037430 deletion Effects 0.000 claims description 12
- 238000013507 mapping Methods 0.000 claims description 5
- 238000003384 imaging method Methods 0.000 abstract 1
- 230000005540 biological transmission Effects 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
This invention discloses a method for sorting received data packets in network equipments used in storing the classified information corresponding to the original IP address/sub network mask including: 1, segmenting the original IP address/sub network mask address, each segment address is taken as the index value in each stage of index list, 2, setting up an index tree composed of connected multistage non-nodes and primary leaf sub-nodes imaged from root nodes to leaf sub-nodes, every non-node includes at least a primary index list and information of the next node pointed by each index value, the leaf sub-node includes sorted information, the tree expresses the image relations of each original IP address/mask address imaging to corresponding sort information stage by stage based on the segment address, 3, when receiving a data packet, the network device gets its IP address and segments it then to index said index tree to get sorted information to sort the data packet.
Description
Technical field
The present invention relates to communication network field, relate in particular to a kind of method of in the network equipment, the reception packet being classified.
Background technology
At present, based on the internet of IP agreement developed into largest in the world today, have the user at most, resource communication network the most widely.Industrywide standard on the IP agreement also therefore comes true, and, the main flow of communication network become thus based on the network of IP agreement.
The IP address is to be used for communication entity in the marked network, such as main frame, or the port of router, in addition, data packets for transmission is to use the IP address to identify in network.That is, each packet that is transmitted comprises a source IP address and a purpose IP address, and the network equipment always can be sent to packet and the corresponding communication entity in this purpose IP address according to purpose IP address.
Also have, the use of existing network is not free, and the service provider always adopts corresponding means to collect the charges.With CERNET (CERNET) is example, a lot of colleges and universities and middle school all are to enter the Internet by it, and CERNET charges by a charge on traffic system, promptly counts by the data traffic of user's (being also referred to as the charging object) actual transmissions.
When charge to as if during the communication entity with independent IP address, the charge on traffic system can charge according to this IP address, and charge to as if one when being the subnet of unit with school etc., the charge on traffic system can charge according to the subnet mask of this subnet correspondence.
See also Fig. 1, it is a charge on traffic system configuration schematic diagram.It comprises terminal 11, access switch 12, charging gateway 13 and server 14.Server 14 comprises Radius server and log server.
Access switch 12 connects some terminals 11, is used for transmitting fast packet.Access switch 12 can come out the traffic mirroring that inputs or outputs according to the linear speed ground, IP address of packet when transmitting packet.
Charging gateway 13 links to each other with some access switch 12 by an acquisition server, be used for flow that access switch 12 mirror images are come realize gathering, with each packet according to the IP address sort of notebook data bag correspondence Freight Basis in correspondence.
The charging way of taking owing to different charging object in the network may be different, so need obtain the kind of charging way in advance.Usually set in advance an information table in charging gateway 13, this information table is preserved the charging way of each charging object map correspondence, charges to identify with IP address or subnet mask address liking; Then, whenever receive a packet, packet is searched according to information table, obtain corresponding charging way, charge according to the IP address.If the transmission packet is searched information table according to the source IP address of packet,, then be purpose IP address search information table according to this packet if receive packet.
Server 14 is used for the expense according to each user terminal of Information Statistics of charging gateway 13 acquisitions, and the charge information that provides the user to surf the Net.
In above-mentioned charging gateway 13, need the reception packet is classified,, search information table, obtain its classified information according to this source data packet/purpose IP address.In fact, also need packet to be classified,, obtain destination network segment or corresponding transmission interface according to the purpose IP address of packet according to the IP address that receives packet at IP forwarding units such as router, three-tier switch.
Mainly be to take following steps packet to be classified in the prior art based on the IP address.
At first, obtain former IP address/subnet mask, and set up information table according to source IP address/subnet mask.
For charging gateway, former IP address/subnet mask is the IP address/subnet mask of each the charging object in the network, and for the IP forwarding unit, former IP address/subnet mask is transmitted the IP address/subnet mask of object for each.
The classified information that comprises each former IP address/subnet mask correspondence in this information table, for the IP forwarding unit, this classified information is destination network segment or corresponding transmission interface; For the charge on traffic system, classified information is a charging way
Then, receive the packet that needs classification;
At last, according to the IP address search information table of this packet, obtain corresponding classified information and classify.
The IP address of every acquisition packet needs the source IP address/mask in this IP address and the information table is compared successively, up to the former IP address/mask address that finds identical address.But,, directly use the IP address just to need each in the comparison address, thereby cause the speed of packet classification slow as the index value of searching classified information and each former IP address/mask address owing to totally 32 of IP addresses.
Thus, disclose another kind of method of this packet being classified according to the IP address of packet on this basis again, this method may further comprise the steps: at first: hash function is set; Then: each former IP address/subnet mask is carried out Hash operation, and the corresponding classified information of the former IP address/subnet mask of operation result and this is kept in the information table, (different former IP address/subnet masks are carried out Hash operation owing to there is hash-collision, obtain identical operation result), so preserve each former IP address/subnet mask that produces the identical operation result and corresponding classified information thereof after in information table, having the operation result of hash-collision; Then, acquisition needs the IP address of the packet of classification; At last, Hash operation is carried out in this IP address, the value of acquisition is retrieved above-mentioned information table as index value, obtains classified information.
Below lift an instantiation at said method.
Such as the hash function that is provided be: IP Di Zhi ﹠amp; 0xff (IP address and OxFF carry out AND operation).When retrieval IP address is the classified information of 1.1.1.1, calculate earlier and obtain index value (index value=1), index value is that 1 IP address is more, as 2.1.1.1,3.1.1.1.Be that different IP address is the same by the index value that Hash operation obtains, thereby exist hash-collision.Therefore, can only could obtain respective classified information by according to operation result in the retrieving information table of the IP address of packet successively being each concrete IP address of 1.
Owing to Hash operation need be carried out in the IP address of packet, and have hash-collision and make the index list item increase, efficient is the linear technical problem that reduces along with increasing of index list item thereby exist.
Summary of the invention
The problem that the present invention solves is based on the IP address packet is carried out the branch time-like and since need in the assorting process to the IP address carry out data operation and grow along with there is the classification time in increasing of index list item, inefficient technical problem.
For addressing the above problem, the invention discloses a kind of method of in the network equipment, the reception packet being classified, the described network equipment is used to preserve the classified information of former IP address/subnet mask correspondence, comprising:
1) segmentation is carried out in described former IP address/subnet mask address, each sector address is used for the index value as each grade concordance list;
2) set up the index tree that connects to form by multistage non-node and one-level leaf node that is mapped to leaf node from root node, at least the information that comprises each index value sensing next stage node in one-level concordance list and the described concordance list in each non-leaf node, comprise classified information in the described leaf node, described index tree reflects that each former IP address/mask address maps to the mapping relations of corresponding classified information step by step according to sectional address;
3) when receiving packet, the described network equipment obtains the IP address of described packet earlier, then segmentation is carried out in described IP address, then according to the described index tree of described sectional address index, therefrom obtain corresponding classified information, and then described packet is classified.
Step 2) also comprise:
21) definite former IP address hop count N that need be added in the described index tree;
22) take out first sector address in the former IP address, whether judgement exists the index value of identical address in the first order concordance list of described root node, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
23) from second sector address to the N sector address of former IP address, one sector address of the every acquisition of described network equipment IP address, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
24) classified information with described former IP address correspondence is kept in the next stage node of N sector address sensing.
Step B also comprises:
31) be added into the length of the subnet mask in the described index tree as required, determine the address hop count N of this subnet mask;
32) when described subnet mask is non-leap mask, from mask address, take out first sector address, whether judgement exists the index value of identical address in the first order concordance list of described root node, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
33) from second sector address to the N sector address of mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
34) classified information and the described mask-length with described mask address correspondence is kept at respectively in the next stage node of N sector address sensing.
Step B also comprises:
41) be added into the length of the subnet mask in the described index tree as required, determine the address hop count N of this subnet mask;
42) when described subnet mask is the leap mask, obtain all spanning values of N section;
43) from first sector address to the N-1 sector address of mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise be kept at described address in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to, and root node is first section a node at the corresponding levels;
44) judge whether each spanning value exists identical index value in the concordance list of described node at the corresponding levels, if the next stage node that finds described index value to point to as this node, carry out step 45 with the next stage node), otherwise carry out step 46);
45) judge that whether mask-length in the described node at the corresponding levels is greater than this subnet mask-length, if, set up the next stage node that this node points to, the classified information and the described mask-length of described mask address correspondence are kept at described next stage node respectively, otherwise, delete the next stage node that described index value points to, carry out step 46);
46) set up the next stage node that described index value points to, the classified information and the described mask-length of described mask address correspondence is kept at described next stage node respectively.
By judge described mask-length whether equal before the figure place sum of N sector address judge that crossing over mask also is non-leap mask, if then described subnet mask is non-leap mask, otherwise described subnet mask is to cross over mask.
By calculating the number that 2^P obtains described spanning value, wherein, the figure place-mask-length of N sector address before the P=.
Also comprise among the step B:
51) each sector address of acquisition former IP address of pre-deletion from described index tree;
51 according to the described index tree of described allocation index, finds final stage address node pointed, deletes described node.
Also comprise among the step B:
61) when the mask address of pre-deletion from described index tree is non-leap address, obtain the segmentation hop count N of described mask address;
62) according to the described index tree of described allocation index, find N sector address node pointed, judge whether described node is leaf node, if delete described node, otherwise delete classified information and the mask-length of preserving in the described node.
Also comprise among the step B:
71) mask address when pre-deletion from described index tree is when crossing over the address, obtains the segmentation hop count N of described mask address;
72) all spanning values of calculating N sector address;
73) according to the described index tree of described allocation index, find N-1 sector address node pointed, and find each index value identical of preserving in the concordance list of described node with described each spanning value, judge then whether the mask-length in the next stage node that described each index value points to is identical with this subnet mask-length, if inequality, the next stage node that finds this node that described next stage node points to carry out step 74 as the next stage node), if identical, directly carry out step 74)
74) continue to judge whether described next stage node exists the next stage node of this node, if, delete classified information and mask-length in the described node, otherwise, described next stage node deleted
The structure of described each node comprises nodal information, father node information, classified information and index table information, be used to store mask-length in the described nodal information, described index table information is used to store the directional information of index value and each index value sensing next stage node.
Compared with prior art, the present invention has the following advantages:
The present invention is divided into plurality of sections with the address, by setting up index tree, each former IP address/mask address is mapped in the corresponding classified information step by step according to sectional address, when obtaining packet, with this IP address segmentation, search corresponding classified information according to sectional address, need not to calculate and just can find respective classified information, improve classification effectiveness.
Description of drawings
Fig. 1 is the structural representation of charge system;
Fig. 2 is the flow chart that the present invention classifies to the reception packet in the network equipment;
Fig. 3 is the segmental structure schematic diagram in the embodiments of the invention;
Fig. 4 is the flow chart that index tree is set up in the specific embodiment of the present invention;
Fig. 5 is the node data structural representation;
Fig. 6 is the index tree structural representation after example 1 adds;
Fig. 7 is the index tree structural representation after example 2 adds;
Fig. 8 is the index tree structural representation after example 3 adds.
Embodiment
Below in conjunction with accompanying drawing, specify the present invention.
See also Fig. 2, it is the principle flow chart of method of in the network equipment reception packet being classified of the present invention.The network equipment is used to preserve the classified information of former IP address/subnet mask correspondence, and this method may further comprise the steps:
Division step: segmentation is carried out in former IP address/subnet mask address, and each sector address is used for as the index value of each grade concordance list (step S110);
Index tree establishment step: set up the index tree that connects to form by multistage non-node and one-level leaf node that is mapped to leaf node from root node, at least the information that comprises each index value sensing next stage node in one-level concordance list and the described concordance list in each non-leaf node, comprise classified information in the described leaf node, described index tree reflects that each former IP address/mask address maps to the mapping relations (step S120) of corresponding classified information step by step according to sectional address;
Index step: when receiving packet, the described network equipment obtains the IP address of described packet earlier, then segmentation is carried out according to same rule in described IP address, then according to the described index tree of described sectional address index, therefrom obtain corresponding classified information, and then with described packet classify (step S130).
In division step, determine segmentation hop count N earlier, then former IP address/subnet mask is segmented into first section successively from a high position to low level or from low level to a high position ... the N section.
In the index tree establishment step, mainly be to set up this index tree in the index tree by source IP address and mask address are added into successively.Wherein:
Former IP address is added into index tree and comprises the steps:
Definite needs are added into the former IP address hop count N in the described index tree;
From former IP address, take out first sector address, whether judgement exists the index value of identical address in the first order concordance list of the root node of index tree, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
Second sector address to the N sector address from former IP address, one sector address of the every acquisition of described network equipment IP address, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
The classified information of described former IP address correspondence is kept in the next stage node of N sector address sensing.
The subnet mask address is added into index tree and comprises the steps:
Be added into the length of the subnet mask in the described index tree as required, determine the address hop count N of this subnet mask;
Judge that then subnet mask is non-leap mask or leap mask, if leap mask, carry out the S1 process, otherwise carry out the S2 process, the network equipment be by judge described mask-length whether equal before the figure place sum of N sector address judge that crossing over mask also is non-leap mask, if then described subnet mask is non-leap mask, otherwise described subnet mask is to cross over mask.
The S1 process:
From mask address, take out first sector address, whether judgement exists the index value of identical address in the first order concordance list of described root node, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
Second sector address to the N sector address from mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
The classified information and the described mask-length of described mask address correspondence are kept at respectively in the next stage node of N sector address sensing.
The S2 process:
Obtain all spanning values of N section, wherein the network equipment is by calculating the number that 2 ∧ P obtain described spanning value, wherein, and the figure place-mask-length of N sector address before the P=;
First sector address to the N-1 sector address from mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise be kept at described address in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to, and root node is first section a node at the corresponding levels;
Judge whether each spanning value exists identical index value in the concordance list of described node at the corresponding levels, if the next stage node that finds described index value to point to as this node, carry out step 45 with the next stage node), otherwise carry out step 46);
45) judge that whether mask-length in the described node at the corresponding levels is greater than this subnet mask-length, if, set up the next stage node that this node points to, the classified information and the described mask-length of described mask address correspondence are kept at described next stage node respectively, otherwise, delete the next stage node that described index value points to, carry out step 46);
46) set up the next stage node that described index value points to, the classified information and the described mask-length of described mask address correspondence is kept at described next stage node respectively.
Below just lift a specific embodiment illustrate the present invention in the network equipment to receiving the method that packet is classified.
In division step, be to carry out segmentation (seeing also Fig. 3) according to following classifying rules, determine that the hop count of classification is 4 sections, the 16th to the 31st of former IP address/mask address is set at first sector address, as the index value of first order concordance list; The 8th to the 15th of former IP address/mask address is set at second sector address, as the index value of second level concordance list; The 0th to the 8th of former IP address/mask address is set at the 3rd sector address, as the index value of third level concordance list.
All there are three sector addresses in each former IP address, but, subnet mask is determined the address hop count according to mask-length, such as mask address is 1.2.3.4/16 (0,000 0,001 0,000 0,010 0,000 0,011 00000100), mask-length is 16, and promptly only there is first sector address (0,000 0,001 00000010) in this subnet mask.Such as mask address is 1.2.3.4/18 (0,000 0,001 0,000 0,010 0,000 0,011 00000100), the mask-length of this subnet mask is 18, promptly this subnet mask exists first sector address (0,000 00,010,000 0010) and second sector address (00** * * * *), the front two of second sector address is to obtain from mask address, and remaining several can be arbitrary value.
For index tree establishment step in the better explanation present embodiment, next introduce and cross over mask and these two notions of non-leap mask.When adding source subnet mask to index tree, this source subnet mask exists crosses over and two kinds of situations of non-leap, and the step that the subnet mask of both of these case is added in the index tree is different.What is to cross in following explanation earlier.
If add following address entries to index tree:
(1.1.1.1/12 12 of 0,000 0001.0000 0001.0000 0001.0000 0001 mask-lengths, categorical attribute are M)
First sector address that obtains is 0,000 0001.0000 0001.But the mask-length of route entry is 12, rather than 16 bit lengths of first order concordance list support, so last four bit can be arbitrary values, that is:
0000?0001.0000?xxxx
As:
0000?0001.0000?0001
0000?0001.0000?0010
0000?0001.0000?0011
0000?0001?0000?1111
The number of these addresses is 2^ (16-12)=16, and the classified information of those 16 addresses also should be M, so need to deposit M in the classified information unit with the node of those address correspondences in index tree.A mask address exists a plurality of nodes and its mapping in index tree, Here it is crosses over, and exists the mask address of crossing over to be the leap mask address, otherwise, a mask address only has a node and its mapping in index tree, this mask address is the non-mask address of striding more.
In the present embodiment, when mask-length less than 16 the time, in first concordance list, all leap can be arranged, the length of crossing over is 2^ (16-masklen), wherein, masklen is a mask-length, and this subnet mask has been crossed in first concordance list and has been 16 index value list items of 0x0100~0x010f.
Equally, in other concordance lists at different levels leap is arranged also, for example mask is 22, and it will cross over 2^ (24-22)=4 list item in the concordance list of the second level so, by that analogy.
When the mask address that adds during for not non-leap mask address, promptly mask-length is 16 or 24.
See also Fig. 4, it is how to carry out the flow chart that index tree is set up for present embodiment.
S210: the data structure of defined node, in the present embodiment, no matter be root node, leaf node still is other non-leaf node, and they adopt identical data structure.See also Fig. 5, the node data structure that it adopts for the present invention.
This node is made up of nodal information unit, father node pointer unit, four parts in classified information unit and concordance list unit.The nodal information unit is mainly used in the number that has effective index value in the concordance list unit of memory node type, mask-length and this node; Father node pointer unit is used to store the directional information of the father node that this node points to; The classified information unit is used to store the classified information of the subnet mask address or the IP address of this node correspondence, when this node does not have corresponding subnet mask address or IP address, this classified information unit is " NULL ", have only when this node exists corresponding subnet mask address or IP address, in this classified information unit, just have corresponding classified information; The concordance list unit is used for storing the index value of concordance list of this node and the directional information of the next stage node that each index value points to.
Carry out step S220 then, each former IP address and mask address are begun sectional address to be added into the index tree successively from root node.Below just lift several simple example, illustrate IP address, non-leap mask address respectively, cross over mask address is how to be added in the index tree.
Example 1: the classified information A that in empty index tree, adds address 80.6.0.0/16 correspondence.
The first step, according to the mask-length (16) of this address, determine its address hop count be 1 and this mask be non-leap mask;
Second step, taking out first sector address from subnet mask is 0,101 0,000 0,000 0110 (0X5006), judge the index value that in the first order concordance list of root node, whether has identical address then, obviously, the index value that does not have identical address, this first sector address (0X5006) is kept in the first order concordance list as index value, and sets up the next stage node that this address (0X5006) is pointed to;
The 3rd step, deposit corresponding classified information A in the classified information unit of this node, deposit mask-length in its nodal information unit in and be 16 mask information.(see also Fig. 6, be the index tree schematic diagram after example 1 interpolation.)
Example 2: the classified information of adding IP address (80.6.0.1) in the index tree that example 1 forms again is B
The first step: the segments of determining the IP address is three sections, and determines each sector address, and first sector address is 0X5006, and second sector address is 0X0000, and the 3rd sector address is 0X0001;
Second step: take out first sector address (0X5006), judge the index value that in the first order concordance list of root node, whether has identical address, obviously, exist, carried out for the 3rd step then;
The 3rd step: the next stage node that finds this index value to point to, continue to judge and in the concordance list of this node, whether have the index value identical with second sector address, obviously, there is not index value in the 0X5006 two-level node pointed, in two-level node, preserve the second sector address 0X0000, and set up this address 0X,000 three grades of nodes pointed;
The 4th step: the 3rd sector address 0X00001 of this IP address is placed in the concordance list of three grades of nodes, and sets up the 3rd sector address 0X00001 node pointed, classified information B is kept in the classified information unit of this node.(see also Fig. 7, be the index tree schematic diagram after example 2 interpolations.)
Example 3 is added the classified information C of address 80.6.0.0/12 again in the index tree that example 2 forms, step is as follows:
The first step: judge this subnet mask for crossing over mask by calculating (being uneven in length of subnet mask), obtain all spanning values (0X5000-0X5000F) in 16;
Second step: judge whether each spanning value exists identical address in the first order concordance list of root node, in this example 3, except 0X5006, other spanning value does not exist identical in first order concordance list.
The 3rd step: do not have the index value of identical address to add in the first order concordance list those, and set up a node, those index values are all pointed to this node, and classified information C and mask-length 12 are write on the classified information unit and the nodal information unit of this node respectively;
The 4th step: find the node of the index value sensing of 0X5006, therefrom obtain the mask-length of node, in the present embodiment, the length of each node acquiescence is 32, and obviously, this mask-length 12<32 points to this node so set up the father node of this node.(see also Fig. 8, be the index tree schematic diagram after example 3 interpolations.)
When receiving packet, obtain the IP address of this packet earlier, such as the IP address is 80.6.2.1, and this IP address carried out segmentation, first sector address is 0X5006, second sector address is 0X0002, the 3rd sector address is 0X0001, then according to the root node of first sector address search index tree, the second level node that finds its index value and this index value to point to searches in the concordance list of second level node whether 0X0002 is arranged then, does not have obviously, obtain the classified information B that stores in this node, packet classification is gone out according to this classified information.
Index tree can not change, and when former IP address/mask address is deleted from this network equipment, also needs this IP address/mask address is deleted away from index tree, and step is as follows particularly:
Deletion IP address and corresponding classified information thereof from index tree, step is as follows:
51) each sector address of acquisition former IP address of pre-deletion from described index tree;
51 according to the described index tree of described allocation index, finds final stage address node pointed, deletes described node.
Non-leap mask address of deletion and corresponding classified information thereof from index tree, step is as follows:
61) when the mask address of pre-deletion from described index tree is non-leap address, obtain the segmentation hop count N of described mask address;
62) according to the described index tree of described allocation index, find N sector address node pointed, judge whether described node is leaf node, if delete described node, otherwise delete classified information and the mask-length of preserving in the described node.
Mask address and corresponding classified information thereof are crossed in deletion from index tree, and step is as follows:
71) mask address when pre-deletion from described index tree is when crossing over the address, obtains the segmentation hop count N of described mask address;
72) all spanning values of calculating N sector address;
73) according to the described index tree of described allocation index, find N-1 sector address node pointed, and find each index value identical of preserving in the concordance list of described node with described each spanning value, judge then whether the mask-length in the next stage node that described each index value points to is identical with this subnet mask-length, if inequality, the next stage node that finds this node that described next stage node points to carry out step 74 as the next stage node), if identical, directly carry out step 74)
74) continue to judge whether described next stage node exists the next stage node of this node, if, delete classified information and mask-length in the described node, otherwise, described next stage node deleted.
On charging gateway, concrete application is as follows:
Different charging address classes need pre-configured which network segment or which IP address to belong to which kind of charging address on the charging gateway, because can be taked different charging ways.Belong to charging address class 1 such as network segment 1.0.0.0/8, network segment 21.1.0.0/16 and address 5.5.5.5 belong to charging address class 2.Charging gateway need come flow is classified when network flow calculation according to the purpose IP address of network packet so.Use the present invention, can use the external data of charging address class as information node the destination address of message directly in the classified index number, to search, carry out three times at most and search, just can find the charging address category information of destination address correspondence.
The method also can realize the routing table algorithm of router.The external data of the transmission interface of destination network segment or address correspondence as information node, when message is transmitted, in index tree, search by the purpose IP address of message, carry out three times at most and search, just can find transmission interface, message is sent.
More than disclosed only be several specific embodiment of the present invention, those skilled in the art can think variation all should drop in protection scope of the present invention.
Claims (10)
1, a kind of method of in the network equipment, the reception packet being classified, the described network equipment is used to preserve the classified information of former IP address/subnet mask correspondence, it is characterized in that, comprising:
1) segmentation is carried out in described former IP address/subnet mask address, each sector address is used for the index value as each grade concordance list;
2) set up the index tree that connects to form by multistage non-node and one-level leaf node that is mapped to leaf node from root node, at least the information that comprises each index value sensing next stage node in one-level concordance list and the described concordance list in each non-leaf node, comprise classified information in the described leaf node, described index tree reflects that each former IP address/mask address maps to the mapping relations of corresponding classified information step by step according to sectional address;
3) when receiving packet, the described network equipment obtains the IP address of described packet earlier, then segmentation is carried out in described IP address, then according to the described index tree of described sectional address index, therefrom obtain corresponding classified information, and then described packet is classified.
3, method of in the network equipment reception packet being classified as claimed in claim 1 is characterized in that step 2) also comprise:
21) definite former IP address hop count N that need be added in the described index tree;
22) take out first sector address in the former IP address, whether judgement exists the index value of identical address in the first order concordance list of described root node, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
23) from second sector address to the N sector address of former IP address, one sector address of the every acquisition of described network equipment IP address, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
24) classified information with described former IP address correspondence is kept in the next stage node of N sector address sensing.
3, method of in the network equipment reception packet being classified as claimed in claim 1 or 2 is characterized in that step B also comprises:
31) be added into the length of the subnet mask in the described index tree as required, determine the address hop count N of this subnet mask;
32) when described subnet mask is non-leap mask, from mask address, take out first sector address, whether judgement exists the index value of identical address in the first order concordance list of described root node, if, the next stage node that finds described index value to point to, otherwise described address is kept in the described first order concordance list as index value, and sets up the next stage node that described address is pointed to;
33) from second sector address to the N sector address of mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise described address is kept in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to;
34) classified information and the described mask-length with described mask address correspondence is kept at respectively in the next stage node of N sector address sensing.
4, as any one described method of in the network equipment, the reception packet being classified in the claim 1 to 3, it is characterized in that step B also comprises:
41) be added into the length of the subnet mask in the described index tree as required, determine the address hop count N of this subnet mask;
42) when described subnet mask is the leap mask, obtain all spanning values of N section;
43) from first sector address to the N-1 sector address of mask address, every acquisition one sector address of the described network equipment, find next stage node that the preceding paragraph address points to earlier and as node at the corresponding levels, judge again and in the concordance list of described node at the corresponding levels, whether have the index value identical with this sector address, if, the next stage node that finds described index value to point to, otherwise be kept at described address in the concordance list of node at the corresponding levels as index value, and set up the next stage node that described address is pointed to, and root node is first section a node at the corresponding levels;
44) judge whether each spanning value exists identical index value in the concordance list of described node at the corresponding levels, if the next stage node that finds described index value to point to as this node, carry out step 45 with the next stage node), otherwise carry out step 46);
45) judge that whether mask-length in the described node at the corresponding levels is greater than this subnet mask-length, if, set up the next stage node that this node points to, the classified information and the described mask-length of described mask address correspondence are kept at described next stage node respectively, otherwise, delete the next stage node that described index value points to, carry out step 46);
46) set up the next stage node that described index value points to, the classified information and the described mask-length of described mask address correspondence is kept at described next stage node respectively.
5, as claim 3 or 4 described methods of in the network equipment, the reception packet being classified, it is characterized in that, be by judge described mask-length whether equal before the figure place sum of N sector address judge that crossing over mask also is non-leap mask, if, then described subnet mask is non-leap mask, otherwise described subnet mask is to cross over mask.
6, method of in the network equipment reception packet being classified as claimed in claim 5 is characterized in that, by calculating the number that 2^P obtains described spanning value, wherein, the figure place-mask-length of N sector address before the P=.
7, method of in the network equipment reception packet being classified as claimed in claim 1 is characterized in that, also comprises among the step B:
51) each sector address of acquisition former IP address of pre-deletion from described index tree;
51 according to the described index tree of described allocation index, finds final stage address node pointed, deletes described node.
8, as claim 1 or 7 described methods of in the network equipment, the reception packet being classified, it is characterized in that, also comprise among the step B:
61) when the mask address of pre-deletion from described index tree is non-leap address, obtain the segmentation hop count N of described mask address;
62) according to the described index tree of described allocation index, find N sector address node pointed, judge whether described node is leaf node, if delete described node, otherwise delete classified information and the mask-length of preserving in the described node.
9, method of in the network equipment reception packet being classified as claimed in claim 1 is characterized in that, also comprises among the step B:
71) mask address when pre-deletion from described index tree is when crossing over the address, obtains the segmentation hop count N of described mask address;
72) all spanning values of calculating N sector address;
73) according to the described index tree of described allocation index, find N-1 sector address node pointed, and find each index value identical of preserving in the concordance list of described node with described each spanning value, judge then whether the mask-length in the next stage node that described each index value points to is identical with this subnet mask-length, if inequality, the next stage node that finds this node that described next stage node points to carry out step 74 as the next stage node), if identical, directly carry out step 74)
74) continue to judge whether described next stage node exists the next stage node of this node, if, delete classified information and mask-length in the described node, otherwise, described next stage node deleted
10, method of in the network equipment, the reception packet being classified as claimed in claim 1, it is characterized in that, the structure of described each node comprises nodal information, father node information, classified information and index table information, be used to store mask-length in the described nodal information, described index table information is used to store the directional information of index value and each index value sensing next stage node.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100623723A CN100397816C (en) | 2004-07-09 | 2004-07-09 | Method for classifying received data pocket in network apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100623723A CN100397816C (en) | 2004-07-09 | 2004-07-09 | Method for classifying received data pocket in network apparatus |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1719769A true CN1719769A (en) | 2006-01-11 |
CN100397816C CN100397816C (en) | 2008-06-25 |
Family
ID=35931502
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004100623723A Expired - Fee Related CN100397816C (en) | 2004-07-09 | 2004-07-09 | Method for classifying received data pocket in network apparatus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100397816C (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101159619B (en) * | 2007-11-20 | 2010-06-02 | 杭州华三通信技术有限公司 | Fast adding method, device and switching arrangement of ARP table |
CN101794150A (en) * | 2010-04-20 | 2010-08-04 | 杭州和利时自动化有限公司 | Data management method and system of fieldbus instrument management system |
CN101345707B (en) * | 2008-08-06 | 2010-12-08 | 北京邮电大学 | Method and apparatus for implementing IPv6 packet classification |
CN101594303B (en) * | 2009-07-10 | 2011-06-01 | 清华大学 | Rapid network packet classification method based on network traffic statistic information |
CN105978868A (en) * | 2016-05-05 | 2016-09-28 | 杭州迪普科技有限公司 | Method and apparatus for searching IP address authority |
CN106331214A (en) * | 2016-08-30 | 2017-01-11 | 成都科来软件有限公司 | Method and system for grouping IP addresses through combination of subnet masks |
WO2017157335A1 (en) * | 2016-03-18 | 2017-09-21 | 中兴通讯股份有限公司 | Message identification method and device |
CN108322394A (en) * | 2018-04-02 | 2018-07-24 | 京信通信系统(中国)有限公司 | Routing table is established, searched, deleting and Status Change method and apparatus |
CN108711074A (en) * | 2018-05-21 | 2018-10-26 | 阿里巴巴集团控股有限公司 | Business sorting technique, device, server and readable storage medium storing program for executing |
CN112817966A (en) * | 2020-07-24 | 2021-05-18 | 腾讯科技(深圳)有限公司 | Data retrieval method, data retrieval device, electronic equipment and storage medium |
CN113762424A (en) * | 2021-11-09 | 2021-12-07 | 鹏城实验室 | Bit selection decision tree balancing method, network packet classification method and related device |
CN114153400A (en) * | 2021-12-08 | 2022-03-08 | 国仪石油技术(无锡)有限公司 | Data storage method for logging instrument |
CN114268608A (en) * | 2021-12-20 | 2022-04-01 | 卓米私人有限公司 | Address segment retrieval method and device, electronic equipment and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5386413A (en) * | 1993-03-19 | 1995-01-31 | Bell Communications Research, Inc. | Fast multilevel hierarchical routing table lookup using content addressable memory |
US6876653B2 (en) * | 1998-07-08 | 2005-04-05 | Broadcom Corporation | Fast flexible filter processor based architecture for a network device |
AU2000279463A1 (en) * | 2000-10-04 | 2002-04-15 | Italtel S.P.A. | Method and device for routing or compressing packets destination address containing classless address |
KR20020053581A (en) * | 2000-12-27 | 2002-07-05 | 오길록 | Procedures for constructing QoS FEC and looking up packets on Emulated Leased Line Services in MPLS LERs |
US20020143787A1 (en) * | 2001-03-31 | 2002-10-03 | Simon Knee | Fast classless inter-domain routing (CIDR) lookups |
-
2004
- 2004-07-09 CN CNB2004100623723A patent/CN100397816C/en not_active Expired - Fee Related
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101159619B (en) * | 2007-11-20 | 2010-06-02 | 杭州华三通信技术有限公司 | Fast adding method, device and switching arrangement of ARP table |
CN101345707B (en) * | 2008-08-06 | 2010-12-08 | 北京邮电大学 | Method and apparatus for implementing IPv6 packet classification |
CN101594303B (en) * | 2009-07-10 | 2011-06-01 | 清华大学 | Rapid network packet classification method based on network traffic statistic information |
CN101794150A (en) * | 2010-04-20 | 2010-08-04 | 杭州和利时自动化有限公司 | Data management method and system of fieldbus instrument management system |
WO2017157335A1 (en) * | 2016-03-18 | 2017-09-21 | 中兴通讯股份有限公司 | Message identification method and device |
CN105978868A (en) * | 2016-05-05 | 2016-09-28 | 杭州迪普科技有限公司 | Method and apparatus for searching IP address authority |
CN106331214A (en) * | 2016-08-30 | 2017-01-11 | 成都科来软件有限公司 | Method and system for grouping IP addresses through combination of subnet masks |
CN108322394B (en) * | 2018-04-02 | 2021-01-01 | 京信通信系统(中国)有限公司 | Routing table establishing, searching, deleting and state changing method and device |
CN108322394A (en) * | 2018-04-02 | 2018-07-24 | 京信通信系统(中国)有限公司 | Routing table is established, searched, deleting and Status Change method and apparatus |
CN108711074A (en) * | 2018-05-21 | 2018-10-26 | 阿里巴巴集团控股有限公司 | Business sorting technique, device, server and readable storage medium storing program for executing |
CN108711074B (en) * | 2018-05-21 | 2021-08-24 | 创新先进技术有限公司 | Service classification method, device, server and readable storage medium |
CN112817966A (en) * | 2020-07-24 | 2021-05-18 | 腾讯科技(深圳)有限公司 | Data retrieval method, data retrieval device, electronic equipment and storage medium |
CN112817966B (en) * | 2020-07-24 | 2023-10-13 | 腾讯科技(深圳)有限公司 | Data retrieval method, device, electronic equipment and storage medium |
CN113762424A (en) * | 2021-11-09 | 2021-12-07 | 鹏城实验室 | Bit selection decision tree balancing method, network packet classification method and related device |
CN113762424B (en) * | 2021-11-09 | 2022-02-01 | 鹏城实验室 | Network packet classification method and related device |
CN114153400A (en) * | 2021-12-08 | 2022-03-08 | 国仪石油技术(无锡)有限公司 | Data storage method for logging instrument |
CN114153400B (en) * | 2021-12-08 | 2024-01-30 | 国仪石油技术(无锡)有限公司 | Data storage method for logging instrument |
CN114268608A (en) * | 2021-12-20 | 2022-04-01 | 卓米私人有限公司 | Address segment retrieval method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN100397816C (en) | 2008-06-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1282104C (en) | Selective routing of data flows using a tcam | |
US8732110B2 (en) | Method and device for classifying a packet | |
CN101068212A (en) | Network address switching retransmitting device and method | |
CN1863142A (en) | Method for providing different service quality tactics to data stream | |
US7684400B2 (en) | Logarithmic time range-based multifield-correlation packet classification | |
CN1719769A (en) | Method for classifying received data pocket in network apparatus | |
CN1404591A (en) | Apparatus and method for performing high-speed IP route lookup and managing routing/forwarding tables | |
CN1905523A (en) | Method for implementing multi-area stream classifying | |
CN1688140A (en) | High-speed multi-dimension message classifying algorithm design and realizing based on network processor | |
CN1710879A (en) | Packet forwarding device | |
CN1534942A (en) | Grouping classifying method and device of using haxibiao forest data structure | |
CN1898916A (en) | Method and apparatus for two-stage packet classification using most specific filter matching and transport level sharing | |
CN1543150A (en) | Packet classification apparatus and method using field level tries | |
CN101043695A (en) | Method for storing and maintaining user equipment information in mobile communication system | |
CN106874370A (en) | A kind of method for quickly retrieving of catalogue file | |
CN1901549A (en) | Data transmission method, device, data processing method and data transmission system | |
CN1744563A (en) | Method for realizing strate gic route in Ethernet switch | |
CN1992674A (en) | Method of multi-dimensional Packet Classification based on muti-bit segmentation | |
CN1703890A (en) | Method for protocol recognition and analysis in data networks | |
CN101650718A (en) | Method and device for matching character strings | |
CN1232146C (en) | Information communication terminal and method of classification storing information in such terminal | |
CN1477494A (en) | Data packet recursive flow sorting method | |
CN104253754A (en) | ACL (access control list) fast matching method and equipment | |
CN1852238A (en) | Fast indexing method | |
CN1941927A (en) | Data distribution to nodes of a telecommunication network |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address | ||
CP03 | Change of name, title or address |
Address after: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No. Patentee after: NEW H3C TECHNOLOGIES Co.,Ltd. Address before: 310053 Hangzhou hi tech Industrial Development Zone, Zhejiang province science and Technology Industrial Park, No. 310 and No. six road, HUAWEI, Hangzhou production base Patentee before: HANGZHOU H3C TECHNOLOGIES Co.,Ltd. |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20080625 |