Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Method embodiment one
A kind of aged rule maintenance method; The executive agent of the embodiment of the invention is based on all that the equipment of TCAM carries out; This equipment can be field programmable gate array (FPGA)+TCAM framework, also can be network processing unit (NP)+TCAM framework, can also be central processing unit (CPU)+TCAM framework; Method flow is as shown in Figure 1, comprising:
Step 101, reception message comprise address information in the said message;
The address information here can comprise IP address, port information etc., generally is that the stem at message carries address information.
Step 102, address information in the said message and expressway are mated by the rule in requestor (being called for short TCAM in the following file) the rale store space; Rule in confirming said TCAM rale store space does not comprise said address information, and said TCAM rale store space is full, and then execution in step 103;
Be appreciated that the rule in TCAM rale store space is address information, two communication equipments can store the address information of two equipment in based on the rale store space of the equipment of TCAM in the process that communicates.And every rule is after the rale store space stores, and all to a storage address should be arranged, these rules can be to be stored in the storage address successively according to the sequencing that receives new regulation; In the process that rule is being stored; Information such as storage address in the time of also can writing down the corresponding time that stores this rule or just begin in rale store space rule for storing based on the equipment of TCAM, such as: the size in rale store space is 65535, is in 0 to 65534 at storage address n then; Can store 65535 rules; When rule for storing, can be that 0 storage address begins to store from n, when receiving new address information; Then can new rule be stored into n and be in 1 the storage address, in 65535 regular storage addresses, all store rule like this.
Here TCAM rale store space has been full of finger and in all storage addresses in rale store space, is all depositing rule.
Step 103, cover in the said TCAM rule space the longest rule memory time with said address information.
Here, can obtain with the difference of current time memory time according to the corresponding time of rule when storing, and memory time, the longest rule was the rule of the maximum correspondence of said difference; Memory time, the longest rule also can obtain according to the storage address that when just beginning in this rule parking space rule for storing, writes down, and can also obtain through other method, and this is not construed as limiting the invention.
When covering, specifically be that this address information is stored in the storage address of the longest rule correspondence memory time, simultaneously, delete this memory time of the longest rule with said address information.
Be appreciated that the rule in the said TCAM rale store space of coupling in the step 102 comprises said address information, then execution in step 104;
Whether satisfy step 104, the memory time of judging the said address information that comprises in the said TCAM rale store space condition that presets; If; And confirm that said TCAM rale store space is full; Then return execution in step 103, and delete the original said address information that stores in the said TCAM rale store space; If not, then can not make amendment to the rale store in rale store space;
Be appreciated that; In another concrete embodiment,, and confirm that said TCAM rale store space is full if judgement is in step 104; Can also directly upgrade said expressway, originally the memory time of the said address information of storage by in the requestor TCAM rale store space.
Wherein, If the rule that matches in the rale store space comprises the address information that newly receives in the message; Judge further then whether satisfy the condition that presets the memory time when storing this address information at that time, the condition that presets here comprises: this address information memory time needs apart from the longest storage time in the preset time scope etc.; The user can regulate the size of preset time scope through the equipment based on TCAM.
Be appreciated that memory time that when judging, specifically can obtain this address information earlier and compare, confirm that again difference between them is whether in the preset time scope with the longest storage time.
It is thus clear that in the present embodiment, aged rule maintenance method is after receiving new message; The rule in address information and the TCAM rale store space that comprises in the message is mated, if the rule in the rale store space does not comprise this address information, and definite rale store space is full; Then cover the longest rule and the corresponding rule of available technology adopting reception FIN bag deletion of memory time, thereby the maintenance of aged rule is compared with this address information; In the embodiment of the invention,, just cover the oldest rule with new rule as long as the rale store space is full; The situation that some rule is never deleted can not appear; Reduced the waste of efficient resource and the accumulation of regular rubbish fragment, and maintenance process is fairly simple, reduces the consumption of resource;
In addition, if the rule in the rale store space comprises this address information, then further confirm the time location of this address information storage; If the time of storage is more of a specified duration; And the rale store space is full, then covers old rule with this address information, and original this address information that stores of deletion.
The aged rule maintenance method of the embodiment of the invention is described through concrete implementation method below:
Method embodiment two
A kind of aged rule maintenance method; The executive agent of the embodiment of the invention is based on all that the equipment of TCAM carries out, and this equipment can be FPGA+TCAM structure framework, also can be the NP+TCAM framework; It can also be the CPU+TCAM framework; Suppose that rale store space size is 65535 rules in the present embodiment, flow process is as shown in Figure 2, comprising:
Step 201, in the process of the storage address that rule is stored into TCAM rale store space, writing down memory time in the said TCAM rale store space the shortest corresponding storage address of rule is B;
In the present embodiment, in regular storage process, be to be stored into successively in the storage address in said rale store space according to the time order and function order; After regular i is stored into storage address I; Receive new regular k again, then rule is stored among the storage address I+1, then storage address B brings in constant renewal in; As long as there is new rule to deposit in the rale store space, then B will be updated to the corresponding storage address of this new regulation.
If when rule for storing, do not begin to store from storage address 0; Then after rule had been stored in the storage address 65534, next new regulation then was stored in the storage address 0; TCAM rale store space just is a ring in the present embodiment like this, is called for short the rule ring.
Step 202, the new message of reception comprise address information in the said message;
Step 203, the rule in address information in the said message and the TCAM rale store space is mated; Rule in said TCAM rale store space does not comprise said address information, and confirms that said TCAM rale store space is full, and then execution in step 204; Rule in said TCAM rale store space comprises said address information, and then execution in step 205;
Step 204, use said address information, cover memory time of self record the shortest regular corresponding storage address, the rule in the previous storage address; And upgrade the shortest regular corresponding storage address B memory time in the said TCAM rale store space;
Be appreciated that; Because TCAM rale store space is full, then from storage address 0 to 65534, is all depositing rule, again owing in regular storage process, be stored in the storage address successively according to the time order and function order; The corresponding previous storage address of rule of then lacking most memory time; The previous storage address that is storage address B is among the B+1, is depositing the longest rule memory time, and visible this step comes down to cover the longest rule of storage time with address information.
The corresponding storage address of said address information that comprises in step 205, the said TCAM rale store of the judgement space; Whether in the corresponding top n storage address of the shortest rule memory time; If; And confirm that said TCAM rale store space is full, then return execution in step 204, and delete the said address information of original storage in the said TCAM rale store space; If not, then need not make amendment to the rule in the rale store space.
Be appreciated that; The shortest rule is the rule of depositing among the storage address B memory time in this step; And memory time, the shortest corresponding top n storage address of rule was storage address B+N; Because the rule that this N storage address is deposited all is long rule memory time, will be called aging district in the present embodiment from the rale store space of a storage address B N forward storage address.Then this step comes down to judge whether address information is stored in the aging district, if, with regard to execution in step 204, cover, and in the rale store space to repeating storage rule, this address information deletion that then will store originally.
Need to prove; The user can be through regulating the size in aging district based on the equipment of TCAM; The N value is set; And need record said memory time of the shortest corresponding storage address B N+1 the storage address A forward of rule before the judgement in step 205, be critical storage address with aging district; Because the size in aging district is preset in the equipment; Then after covering the rule in the previous storage address of storage address B with address information; Also need upgrade critical storage address with aging district; Be the shortest corresponding storage address B of rule of updated stored time, reach said memory time of the shortest corresponding storage address B N+1 the storage address A forward of rule, be about to storage address A and be updated to B+N+1.
With reference to shown in Figure 3; Structural representation for rule ring in the present embodiment; The corresponding storage address B=1000 of rule that lack memory time most among the figure; The part of filling oblique line in the rule ring between two dotted lines is aging district, shows among the figure that N is 49, then the memory time of record the shortest corresponding storage address B N+1 the storage address A=1050 forward of rule.Be appreciated that; After receiving message; Be not included in the rule ring if obtain address information in the message, and when in 65535 storage addresses, all depositing rule, then cover the rule of depositing in storage address 1001 with this address information through overmatching; And storage address B is updated to 1001, and storage address A is updated to 1051; If the address information that obtains in the message through overmatching is included in the storage address 1032 in the aging district; And when in 65535 storage addresses, all depositing rule; Then cover the rule of depositing in the storage address 1001 with this address information; And storage address B is updated to 1001, and storage address A is updated to 1051, and need the rule in the deletion storage address 1032; If address information is included in the zone outside the regular aging district that encircles, the rule of then the rule ring being deposited is not made amendment.
It is thus clear that; In the present embodiment; Through the relation of the corresponding storage address of rule, confirm the position of the rule that memory time is the longest, if promptly the rale store space is full; Then memory time the longest rule and memory time the shortest rule storage address adjacent, this method implements fairly simple and directly perceived.And reduced the waste of efficient resource and the accumulation of regular rubbish fragment, and maintenance process is fairly simple, reduces the consumption of resource.
Apparatus embodiments one
A kind of expressway is by requestor TCAM, and this equipment can be the FPGA+TCAM framework, also can be the NP+TCAM framework, can also be the CPU+TCAM framework, and structural representation is as shown in Figure 4, comprising:
Message receiving element 10 is used to receive message, comprises address information in the said message;
Matching unit 11, the address information and the expressway of the message that is used for said message receiving element 10 is received are mated by the rule in the requestor TCAM rale store space;
First capping unit 12; Be used for not comprising said address information by the rule in requestor TCAM rale store space when the expressway of said matching unit 11 couplings; And confirm that said expressway is full by requestor TCAM rale store space, with said address information cover said expressway by in the requestor TCAM rule space memory time the longest rule.
Can obtain with the difference of current time memory time according to the corresponding time of rule when storing, and memory time, the longest rule was the rule of the maximum correspondence of said difference; Memory time, the longest rule also can obtain according to the storage address that when just beginning in this rule parking space rule for storing, writes down, and can also obtain through other method, and this is not construed as limiting the invention.
Be appreciated that in other embodiment, a kind of expressway is also comprised by requestor TCAM:
Time judging unit 13; Be used for comprising said address information by the rule in requestor TCAM rale store space when the expressway of said matching unit 11 couplings; Judge whether said expressway meets the condition that presets by the memory time of the said address information that comprises in the requestor TCAM rale store space, and the said condition that presets comprises that memory time in the longest storage time of distance of said address information is in the preset time scope;
Second capping unit 14; The result who is used for judging when said time judging unit 13 is for being; And confirm that said expressway is full by requestor TCAM rale store space; Then with said address information cover said expressway by in the requestor TCAM rale store space memory time the longest rule, and delete the said address information of said expressway by original storage in the requestor TCAM rale store space; Or upgrade said expressway by in the requestor TCAM rale store space, the memory time of the said address information of originally storing.
Be appreciated that memory time that when judging, specifically can obtain this address information earlier and compare, confirm that again difference between them is whether in the preset time scope with the longest storage time.
It is thus clear that the expressway of present embodiment is by after message receiving element 10 receives new message among the requestor TCAM, matching unit 11 matees the rule in address information and the TCAM rale store space that comprises in the message; If the rule in the rale store space does not comprise this address information, and definite rale store space is full, and then this address information of first capping unit, 12 usefulness covers the longest rule memory time; Receive the corresponding rule of FIN bag deletion with available technology adopting, thereby the maintenance of aged rule is compared, in the embodiment of the invention; As long as the rale store space is full; Just cover the oldest rule, the situation that some rule is never deleted can not occur, reduced the waste of efficient resource and the accumulation of regular rubbish fragment with new rule; And maintenance process is fairly simple, reduces the consumption of resource;
In addition; If the rule in the rale store space comprises this address information; Then time judging unit 13 is further confirmed the time location of this address information storage, if the time of storage is more of a specified duration, and the rale store space is full; Then this address information of second capping unit, 14 usefulness covers old rule, and original this address information that stores of deletion.
Apparatus embodiments two
A kind of expressway is by requestor TCAM; This equipment can be the FPGA+TCAM framework; Also can be the NP+TCAM framework, can also be the CPU+TCAM framework, and the expressway in the present embodiment is to be stored into successively in the storage address in said rale store space according to the time order and function order by the rule in the requestor TCAM rale store space; Structural representation is as shown in Figure 5, comprising:
The first address record cell 20 is used for writing down said expressway by the requestor TCAM rale store space the shortest corresponding storage address of rule memory time;
Message receiving element 21 is used to receive message, comprises address information in the said message;
Matching unit 22, the address information and the expressway of the message that is used for said message receiving element 21 is received are mated by the rule in the requestor TCAM rale store space;
First capping unit 23; Be used for not comprising said address information by the rule in requestor TCAM rale store space when the expressway of said matching unit 22 couplings; And confirm that said expressway is full by requestor TCAM rale store space; Use said address information, cover memory time of the said first address record cell 20 record the shortest regular corresponding storage address, the rule in the previous storage address; Promptly with said address information cover said expressway by in the requestor TCAM rule space memory time the longest rule;
First updating block 24 is used for after said first capping unit advances 23 row coverings, and the expressway of upgrading the said first address record cell, 20 records is by the shortest corresponding storage address of rule memory time in the requestor TCAM rale store space.
Be appreciated that the expressway is also comprised by requestor TCAM in other concrete embodiment:
Address judging unit 25; Be used for comprising said address information by the rule in requestor TCAM rale store space when the expressway of said matching unit 22 couplings; Judge said expressway by the corresponding storage address of the said address information that comprises in the requestor TCAM rale store space, whether in the corresponding top n storage address of the shortest rule memory time of said record;
The 3rd capping unit 26; Be used for being judged as when being when said address judging unit 25; And confirm that said expressway is full by requestor TCAM rale store space; Then cover the rule in the corresponding previous storage address of said memory time of the shortest rule, and delete the said address information of said expressway by original storage in the requestor TCAM rale store space with said address information.
Need to prove, can also comprise in the equipment of the embodiment of the invention: the second address record cell 27 and second updating block 28; The said second address record cell 27 is used to write down corresponding N+1 the preceding storage address of storage address of said memory time of the shortest rule; Said second updating block 28; Be used for covering the rule of the previous storage address of said memory time of the shortest rule correspondence, upgrade said memory time of the shortest corresponding N+1 the preceding storage address of storage address of rule of the said second address record cell, 28 records when the said address information of said the 3rd capping unit 26 usefulness.
It is thus clear that the expressway of present embodiment is by among the requestor TCAM, through the relation of the corresponding storage address of rule; Confirm the position of the rule that memory time is the longest; If promptly the rale store space is full, then memory time the longest rule and memory time the shortest rule storage address adjacent, make win capping unit 23 and the 3rd capping unit 26 carry out rule when covering; Be easy to find the rule that needs covering, implement fairly simple and directly perceived.And reduced the waste of efficient resource and the accumulation of regular rubbish fragment, and maintenance process is fairly simple, reduces the consumption of resource.
It is thus clear that in the present embodiment, aged rule maintenance method is after receiving new message; The rule in address information and the TCAM rale store space that comprises in the message is mated, if the rule in the rale store space does not comprise this address information, and definite rale store space is full; Then cover the longest rule and the corresponding rule of available technology adopting reception FIN bag deletion of memory time, thereby the maintenance of aged rule is compared with this address information; In the embodiment of the invention,, just cover the oldest rule with new rule as long as the rale store space is full; The situation that some rule is never deleted can not appear; Reduced the waste of efficient resource and the accumulation of regular rubbish fragment, and maintenance process is fairly simple, reduces the consumption of resource.
One of ordinary skill in the art will appreciate that all or part of step in the whole bag of tricks of the foregoing description is to instruct relevant hardware to accomplish through program; This program can be stored in the computer-readable recording medium, and storage medium can comprise: read-only memory (ROM), random-access memory (ram), disk or CD etc.
More than to aged rule maintenance method and equipment that the embodiment of the invention provided; Carried out detailed introduction; Used concrete example among this paper principle of the present invention and execution mode are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that on embodiment and range of application, all can change, in sum, this description should not be construed as limitation of the present invention.