A kind of matched method and apparatus of data search
Technical field
The present invention relates to field of communication technology more particularly to a kind of matched method and apparatus of data search.
Background technique
With the continuous development of network technology, various new network applications continue to bring out, such as sensitive to network service quality
Stream Media Application.Network provider has increasing need for wanting the transport services resource that they provide according to Client application
(such as requirement to transmission quality) is asked more reasonably to be managed and distributed.Network provider is also wanted to according to certain simultaneously
A little economic principles (such as payment principle) or safety regulation (such as preventing hacker) realize monitoring and management to the flow of network.These
It requires the network equipment and the ability that can carry out predictive calculation to Ethernet packet is provided.
During carrying out predictive calculation to Ethernet packet, network processing unit is extracted from the packet header of Ethernet packet first
Then the information of the type in the packet header is carried out matched and searched with the preset entry that matches by the information of the type in the packet header
Afterwards, the processing movement of the corresponding message in the packet header is obtained after successful match.In order to meet the needs of high bandwidth, using in tri-state
The type that content addressed register (Ternary Content Address Memory, TCAM) is used to parse the packet header is a kind of
Trend.Wherein, three-state content addressing register (Ternary Content Address Memory, TCAM) is a kind of based on interior
The memory for holding inquiry has the advantages that inquiry velocity is fast and query time is fixed.
Specifically, being stored with matching entry in each storage unit of TCAM.When 1 Ethernet packet arrives, at network
Reason device will extract one from the head of the Ethernet packet received and search matched key value (Search Key), at the same by this
Matched key value sends TCAM to, and the key value and all matching entries of storage are carried out searching at matching parallel by TCAM
Reason.
Following two is proposed in the prior art to carry out searching matched mode using TCAM:
One, matched scheme is searched using TCAM+SRAM, wherein TCAM and SRAM is stored with matching entry.At network
The key value of extraction is transmitted in TCAM or the SRAM by reason device carries out lookup matching.The corresponding movement of each matching entry
Instruction is stored in other memories.If successful match, it is corresponding the key value can be obtained in other memories
The action command of message, and then the message is handled according to the action command.
Two, matched scheme is searched using TCAM, all matching entries is wherein stored in TCAM.Wherein each matching
The corresponding action command of entry is stored in other memories.
However, since SRAM is in search procedure, by the way of Hash lookup, this to wrap using technical solution one
The time delay of head matched and searched is larger.It needs and owns since TCAM is searched in matching process each time using technical solution two
Matching entry it is parallel match, this makes the power consumption of TCAM larger.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of matched method and apparatus of data search, it can reduce data
The time delay of lookup, and can reduce the use power consumption of TCAM.
In order to achieve the above objectives, the embodiment of the present invention adopts the following technical scheme that
In a first aspect, the embodiment of the invention provides a kind of matched methods of data search, which comprises
Obtain the match-type field of data;
According to the match-type field of the data, it is corresponding that the matching match-type field is searched by first memory
Matching result, the first memory is stored with the first matching rule collection, and the first matching rule collection includes at least one
Matching rule, the matching rule include the corresponding relationship of match-type field and matching result, and the first memory is three
State content adressable memory TCAM;
If the TCAM matching is unsuccessful, is searched by second memory and match the corresponding matching of the match-type field
As a result, the second memory is stored with the second matching rule collection, the second matching rule collection includes at least one matching rule
Then;
If successful match, the match-type field and the corresponding matching result of the match-type field are stored to institute
It states in TCAM;
Matching result is obtained by the TCAM.
With reference to first aspect, in the first possible embodiment, the second memory is deposited for static random-access
Reservoir SRAM or other types of memory.
With reference to first aspect or the first possible embodiment, in second of possible embodiment, if described
TCAM matching is unsuccessful, should before searching the corresponding matching result of the matching match-type field by second memory
Method further include:
The corresponding matching result of the match-type field is matched by third memory look-up;
The corresponding matching result of the matching match-type field is searched by second memory to specifically include:
If the third memory look-up matching is unsuccessful, is searched by second memory and match the match-type field
Corresponding matching result.
With reference to first aspect or the first possible embodiment is to second of possible embodiment, possible at the third
Embodiment in, this method further include:
It is concentrated in the Second Rule of the second memory and increases new matching rule;
And/or
It is concentrated in the Second Rule of the second memory and deletes stored matching rule.
With reference to first aspect or the first possible embodiment is to the third possible embodiment, in the 4th kind of possibility
Embodiment in, this method further include:
If first matching rule is concentrated there are the first matching rule, first matching rule is stored in described
Second matching rule is concentrated, wherein first matching rule is to be matched matching of the successful number less than preset threshold to advise
Then.
With reference to first aspect or the first possible embodiment is to the 4th kind of possible embodiment, in the 5th kind of possibility
Embodiment in, if the match-type field of the data is the protocol type field of message, the matching rule includes
The processing of protocol type field message corresponding with the protocol type field acts index.
According to the 5th kind of possible embodiment, in the 6th kind of possible embodiment, if first matching rule
Collection and/or the second matching rule concentrate the length for the corresponding message of protocol type field for including to have N kind, then the matching rule
The processing of length field type and message including protocol type field message corresponding with the protocol type field acts rope
Draw.
Second aspect, the embodiment of the invention provides a kind of matched device of data search, which includes: the first acquisition
Unit, the first searching unit, the second searching unit, control unit and second acquisition unit;
The first acquisition unit, for obtaining the match-type field of data;
First searching unit passes through first memory lookup for the match-type field according to the data
With the corresponding matching result of the match-type field, the first memory is stored with the first matching rule collection, and described first
Matching rule collection includes at least one matching rule, and the matching rule, which includes that match-type field is corresponding with matching result, closes
System, the first memory are three-state content addressing memory TCAM;
Second searching unit is searched described in matching if unsuccessful for TCAM matching by second memory
The corresponding matching result of match-type field, the second memory are stored with the second matching rule collection, the second matching rule
Then collection includes at least one matching rule;
Described control unit, for the match-type field of successful match and the match-type field is corresponding
Matching result is stored into the TCAM;
The second acquisition unit, for obtaining the matching result by the TCAM.
In conjunction with second aspect, in the first possible embodiment, the second memory is deposited for static random-access
Reservoir SRAM or other types of memory.
In conjunction with second aspect or the first possible embodiment, in second of possible embodiment, if described
TCAM matching is unsuccessful, should before searching the corresponding matching result of the matching match-type field by second memory
Device further include:
The corresponding matching result of the match-type field is matched by third memory look-up;
The corresponding matching result of the matching match-type field is searched by second memory to specifically include:
If the third memory look-up matching is unsuccessful, is searched by second memory and match the match-type field
Corresponding matching result.
It is possible at the third in conjunction with second aspect or the first possible embodiment to second of possible embodiment
Embodiment in, the device further include:
It is concentrated in the Second Rule of the second memory and increases new matching rule;
And/or
It is concentrated in the Second Rule of the second memory and deletes stored matching rule.
In conjunction with second aspect or the first possible embodiment to the third possible embodiment, in the 4th kind of possibility
Embodiment in, the device further include:
If first matching rule is concentrated there are the first matching rule, first matching rule is stored in described
Second matching rule is concentrated, wherein first matching rule is to be matched matching of the successful number less than preset threshold to advise
Then.
In conjunction with second aspect or the first possible embodiment to the 4th kind of possible embodiment, in the 5th kind of possibility
Embodiment in, if the match-type field of the data is the protocol type field of message, the matching rule includes
The processing of protocol type field message corresponding with the protocol type field acts index.
According to the 5th kind of possible embodiment, in the 6th kind of possible embodiment, if first matching rule
Collection and/or the second matching rule concentrate the length for the corresponding message of protocol type field for including to have N kind, then the matching rule
The processing of length field type and message including protocol type field message corresponding with the protocol type field acts rope
Draw.
The embodiment of the invention provides a kind of matched method and apparatus of data search, which comprises described in acquisition
The match-type field of data;According to the match-type field of the data, is searched by first memory and match the matching
The corresponding matching result of type field, the first memory are stored with the first matching rule collection, the first matching rule collection
Including at least one matching rule, the matching rule includes the corresponding relationship of match-type field and matching result, and described
One memory is three-state content addressing memory TCAM;If the TCAM matching is unsuccessful, is searched and matched by second memory
The corresponding matching result of the match-type field, the second memory are stored with the second matching rule collection, and described second
It include at least one matching rule with rule set;If successful match, by the match-type field and the match-type field
Corresponding matching result is stored into the TCAM;Matching result is obtained by the TCAM.Based on the above-mentioned technical proposal, due to
Storage is distinguished to the matching rule collection of storage, the high matching rule collection of matching frequency is stored in first memory TCAM
In, lookup matching operation preferentially carried out by first memory, it, also will be described the even if the successful match in second memory
The matching entry of successful match is stored into the first memory TCAM in two memories;In this way during matched, mention
It is high that the probability of successful match is searched in the TCAM, and then can reduce the time delay of data search;Simultaneously because all
Matching entry is respectively stored in the TCAM and second memory, reduces the number of entries of PARALLEL MATCHING in TCAM in this way,
To reduce the use power consumption of TCAM.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
It obtains other drawings based on these drawings.
Fig. 1 is a kind of matched method flow schematic diagram of data search provided in an embodiment of the present invention;
Fig. 2 is a kind of ethernet packet format schematic diagram provided in an embodiment of the present invention;
Fig. 3 is a kind of Ethernet packet protocol tree schematic diagram provided in an embodiment of the present invention;
Fig. 4 is that a kind of Ethernet packet provided in an embodiment of the present invention searches matched method flow schematic diagram;
Fig. 5 is a kind of composed structure schematic diagram of data search coalignment provided in an embodiment of the present invention;
Fig. 6 is the composed structure schematic diagram of another data search coalignment provided in an embodiment of the present invention;
Fig. 7 is a kind of application scenarios schematic diagram of data search coalignment provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Embodiment one
The embodiment of the invention provides a kind of matched methods of data search, as shown in Figure 1, this method comprises:
101, the match-type field of the data is obtained.
Wherein, the TCAM memory its with fast parallel lookup, the simple advantage of access mode is widely used.Such as
Ethernet packet header prediction, accesses control list, routing table lookup etc..
Specifically, the match-type field can be message such as when using TCAM memory prediction Ethernet packet
Protocol type field.
Accesses control list is such as searched using TCAM memory, the match-type field is accesses control list key
Word.
102, it according to the match-type field of the data, is searched by first memory and matches the match-type field
Corresponding matching result, the first memory are stored with the first matching rule collection.
Wherein, the first matching rule collection includes at least one matching rule, and the matching rule includes match-type
The corresponding relationship of field and matching result, the first memory are TCAM memory.
It should be noted that it includes common matching rule, high such as matching frequency that first matching rule, which is concentrated,
With rule.Specifically, the first matching rule can be concentrated by the matching rule for including determines according to actual conditions.
If 103, the TCAM matching is unsuccessful, it is corresponding that the matching match-type field is searched by second memory
Matching result, the second memory are stored with the second matching rule collection, and the second matching rule collection includes at least one
With rule.
Wherein, it includes the matching rule being of little use, the low matching rule such as matching frequency that second matching rule, which is concentrated,.
Wherein, the second memory can be static random access memory (English: Static Random Access
Memory, referred to as: SRAM).
In order to reduce the matched power consumption of data search, the second memory can also be other types of memory, such as
Random access memory (English: Random Access Memory, referred to as: RAM) or TCAM memory.
It should be noted that it will be appreciated by persons skilled in the art that if the TCAM successful match, can directly lead to
It crosses the TCAM and obtains matching result.
If 104, successful match, the match-type field and the corresponding matching result of the match-type field are stored
To in the TCAM.
In order to reduce the time delay of match-type field lookup, if matching class described in successful match in the second memory
Type-word section then stores the match-type field and the corresponding matching result of the match-type field into the TCAM,
In order to which next time searches.
Certainly, it if TCAM matching is unsuccessful, is searched by the second memory and matches the match-type field
It is unsuccessful, then illustrate all corresponding without storing the match-type field in the first memory and the second memory
Matching result, such case is not in range described in the invention.
105, matching result is obtained by the TCAM.
The match-type field being matched to and the corresponding matching result of the match-type field are being promoted to institute
After stating TCAM, the TCAM, which is searched, matches the match-type field, and exports the matching result of lookup, in order to control
Device is performed corresponding processing according to the matching result.
It should be noted that if second memory is SRAM memory, since SRAM memory is carried out using hash mode
Matched data is searched, then the first matching rule concentration further includes the matching rule of hash-collision, of the hash-collision
Refer to the matching rule that its match-type field can not be searched using hash mode with rule.
Optionally, between first memory and second memory, single-level memory can also be increased, as third stores
Device, third memory are TCAM memory.In this way, it is unsuccessful in first memory matching, it can preferentially be stored in third
Lookup matching is carried out in device, if searching in third memory unsuccessful, then is searched in second memory and is matched the matching
The corresponding matching result of type field.That is, the matching frequency of the matching rule stored in first memory is greater than third memory
The matching frequency of the matching frequency of the matching rule of middle storage, the matching rule stored in third memory is greater than second memory
The matching frequency of the matching rule of middle storage.It carries out searching matched highest priority in the first memory, followed by exist
It carries out searching matched priority in third memory, it is minimum to search matched priority in second memory.Specifically, institute
It is unsuccessful to state first memory matching, matches the corresponding matching result of the match-type field searching by second memory
Before, this method further include: the corresponding matching result of the match-type field is matched by third memory look-up;
The corresponding matching result of the matching match-type field is searched by second memory to specifically include:
If the third memory look-up matching is unsuccessful, is searched by second memory and match the match-type field
Corresponding matching result.
Certainly, it according to actual application scenarios, is not limited to only with first memory, second memory and third memory
Third level storage is searched, and can also be searched using more than third level storage.Correspondingly, may refer to above-mentioned about three
The matching frequency of the setting of grade memory, the matching rule of memory storage not at the same level is different.
It optionally, is usually all described first since the matching frequency of the matching rule stored in second memory is low
Data search matching is carried out in memory.Based on this, carried out in data search matching process in first memory, it can be described
The Second Rule of second memory, which is concentrated, increases new matching rule;And/or it can be in the Second Rule of the second memory
It concentrates and deletes stored matching rule.
Optionally, with the variation of application scenarios, the matching frequency of the matching rule stored in first memory may also
It changes, in order to store the high matching rule of matching frequency, this method in the first memory as far as possible further include:
If first matching rule is concentrated there are the first matching rule, first matching rule is stored in described
Second matching rule is concentrated, wherein first matching rule is to be matched matching of the successful number less than preset threshold to advise
Then.
The embodiment of the invention provides a kind of matched methods of data search, this method comprises: obtaining of the data
With type field;According to the match-type field of the data, is searched by first memory and match the match-type field
Corresponding matching result, the first memory are stored with the first matching rule collection, and the first matching rule collection includes at least
One matching rule, the matching rule include the corresponding relationship of match-type field and matching result, the first memory
For three-state content addressing memory TCAM;If the TCAM matching is unsuccessful, is searched by second memory and match the matching
The corresponding matching result of type field, the second memory are stored with the second matching rule collection, the second matching rule collection
Including at least one matching rule;If successful match, by the match-type field and corresponding of the match-type field
It stores with result into the TCAM;Matching result is obtained by the TCAM.Based on the above-mentioned technical proposal, due to storage
Matching rule collection distinguishes storage, and the high matching rule collection of matching frequency is stored in first memory TCAM, preferential logical
It crosses first memory and carries out lookup matching operation, it, also will be in the second memory even if the successful match in second memory
The matching entry of middle successful match is stored into the TCAM;In this way during matched, improves and looked into the TCAM
The probability of successful match is looked for, and then can reduce the time delay of data search;Simultaneously because all matching entries are respectively stored in
In the TCAM and second memory, reduce the number of entries of PARALLEL MATCHING in TCAM in this way, to reduce making for TCAM
Use power consumption.
Embodiment two
The embodiment of the invention provides a kind of matched methods of data search, and this method is by taking Ethernet packet predictive calculation as an example
It is described in detail, wherein the match-type field is specially the protocol type field of message in Ethernet packet, the matching
Rule includes that the processing of protocol type field message corresponding with the protocol type field acts index.
As an example it is assumed that the content that an Ethernet packet includes is as shown in Figure 2 comprising the ethernet packet header of standard, 2
A IEEE802.1Q message, the 4th edition message of Internet protocol, transmission control protocol message and data payload.The ether of its Plays
The message length of net packet header and fixed length message IEEE802.1Q are fixed it is found that length information such as Fig. 2 is indicated;Internet protocol the 4th
Version and transmission control protocol are elongated message, and message length changes, no fixed value according to the data content actually carried;
And all messages carry the protocol type field of next type of message, format such as Fig. 2 is indicated.
Predictive calculation device execute predictive calculation method include:
It is shown according to the framework of Ethernet packet protocol tree, as shown in figure 3, the message that the packet header of standard ethernet follows closely below
It can be fixed length message IEEE802.1Q, be also possible to elongated message Internet protocol the 4th edition, as shown in Figure 3.It is assumed that standard ether
The message that the packet header of net follows closely below is fixed length message IEEE802.1Q, due to being fixed length message, message length fix it is foreseeable that
Predictive calculation 2 can be performed in predictive calculation device, i.e., two messages of predictive calculation, message length according to Fig.2, extract simultaneously
Deviate 12 bytes and 16 bytes storage next message protocol type field carry out lookup matching, if search successful match
The protocol type field for deviating 12 bytes and 16 bytes is the protocol type field 0x8100 of fixed length message IEEE802.1Q, with
Too the framework of net packet protocol tree coincide, as shown in figure 3, then predictive calculation has succeeded two messages explanation simultaneously.
It is assumed that the message that the packet header of standard ethernet follows closely below is elongated message Internet protocol the 4th edition, due to being elongated
Message, message length are changed according to the data content actually carried, and predictive calculation 1 can be performed in predictive calculation device, i.e., only
The operation of one message of predictive calculation is executed, extracts and carries out lookup matching in 12 byte protocol type fields of offset, if searched
The protocol type field of successful match is the protocol type field 0x0800 of elongated message Internet protocol the 4th edition, then illustrates to predict
Successfully resolved, and execute the message length field of the elongated message Internet protocol of predictive calculation the 4th edition.
Specifically, the prediction logic method that predictive calculation device executes is as follows:
If (type field1==Ethernet and type field2==802.1Q) then Continue
parsing 802.1Q
Else if (type field1==Ethernet and type field2==IP) then Continue
parsing IP Len
End if
First condition of logic performs predictive calculation 2, and second condition of logic performs predictive calculation 1.It is all
The protocol type field composition extracted searches matched key value and enters execution lookup matching in TCAM;It is obtained by searching for TCAM
Processing to message acts index, and the processing of the message is obtained in other memories by the processing movement index of the message
Action command and next time prediction instruction.
In order to facilitate the understanding of the present invention, the resolver introduced below for executing above-mentioned Ethernet packet predictive calculation, explanation
The process of Ethernet packet predictive calculation searches matching unit, instruction as shown in fig. 7, the predictive calculation device includes buffer
Memory, decoder etc..
Specifically, the buffer, for caching the Ethernet packet sent from network;
The lookup matching unit, for obtaining the match-type field of message in Ethernet packet, according to the data
Match-type field, which is searched, matches the corresponding matching result of the match-type field, and exports matching result and give instruction storage
Device;The wherein lookup matching unit, with use first memory TCAM, second memory SRAM second-level storage mode for
Example;Certainly, it according to actual application scenarios, is not limited to be looked into only with first memory, second memory second-level storage
It looks for, can also be searched using third level storage or more than third level storage.Correspondingly, may refer to embodiment one about
The matching frequency of the setting of third level storage, the matching rule of memory storage not at the same level is different.
Wherein, the matching result for searching matching unit output is that the processing of message acts index.
Described instruction memory, the processing movement for stored messages index corresponding next message protocol type field institute
Offset in position;The corresponding next message protocol class type-word of message of successful match is exported to decoder according to matching result
The offset of section position;
The decoder, for the corresponding next message protocol type field position of the message according to successful match
Offset uses the protocol type field position of next message of shifter to prediction;
The lookup matching unit, the match-type field for extracting next message of prediction, which executes, searches matching, this circulation
Continue to by the protocol type field of messages all in Ethernet packet to have parsed.
Specifically, the matched method of lookup for searching matching unit, as shown in figure 4, this method comprises:
401, the protocol type field in packet header is obtained.
Specifically, when there is the arrival of Ethernet packet, searching the controller of matching unit will be from the head of the Ethernet packet received
Portion extracts the protocol type field in packet header.
402, it according to the protocol type field in the packet header, is searched by first memory and matches the protocol type field
Corresponding matching result.
Wherein, the first memory is stored with the first matching rule collection, and the first matching rule collection includes at least one
A matching rule, the matching rule include the processing movement rope of protocol type field message corresponding with the protocol type field
Draw, the first memory is TCAM memory.
Wherein, the protocol type field stored in the first memory is to execute to search matching under the network application scene
The high protocol type field of frequency.So the highest priority of the first memory, is preferentially looked into the first memory
It looks for.Correspondingly, the probability of the successful match of the protocol type field of the message is larger in the first memory, so as to the greatest extent may be used
The time delay of the reduction predictive calculation Ethernet packet of energy.
Wherein, after searching the protocol type field that the controller in matching unit extracts the message, by this agreement
Type field sends TCAM to, which is preferentially concentrated all matchings with the first matching rule of storage by TCAM
Regular full parellel carries out lookup matching treatment.
For example, it is assumed that the protocol type field that the matched protocol type field of lookup extracted is IEEE802.1Q
0x8100 then carries out the centrally stored all protocol type fields of the protocol type field and the first matching rule of TCAM complete
Parallel search matching treatment;If lookup is matched to 0x8100, successful match is assert, and export matching result.If not searching
It is matched to 0x8100, then assert that matching is unsuccessful.
If 403, the TCAM matching is unsuccessful, the protocol type field for matching the packet header is searched by second memory
Corresponding matching result.
Wherein, the second memory is stored with the second matching rule collection, and the second matching rule collection includes at least one
A matching rule.
Wherein, the protocol type field of the second memory storage is to execute to search matching frequency under the network application scene
Lookup matching frequency of the rate lower than the protocol type field of first memory storage.
If the TCAM matching is unsuccessful, searches the controller in matching unit and then send the protocol type field
To second memory, indicate that the second memory carries out lookup matching to the protocol type field in the packet header.
Wherein, the second memory is SRAM, and the SRAM carries out lookup matching using hash mode.
Further, since the second memory SRAM is to carry out lookup matching using hash mode, so first deposits
The matching rule stored in reservoir TCAM further includes having the matching rule of hash-collision.
If 404, successful match, the match-type field and the corresponding matching result of the match-type field are stored
To in the TCAM.
Wherein, the matching result is that the processing of the corresponding message of match-type field of the message acts index.
If successful match, the protocol type field being matched to and the corresponding matching of the protocol type field are tied
Fruit is promoted to the first memory, in order to next time can in the first memory message described in successful match agreement
Type field searches matching time delay so as to reduce.
405, the matching result is obtained by the TCAM.
The protocol type field being matched to and the corresponding matching result of the match-type field are being promoted to institute
After stating TCAM, the TCAM matches the protocol type field, and exports the matching result.
It include the protocol type field and corresponding message of all storages under practical application scene, in TCAM and SRAM
Processing movement index, wherein message can be divided into fixed length message and elongated message by length type, and fixed length message refers to using fixation
Length remove the message indicated, elongated message then refers to that the length of message is changed according to the data content that carries every time
's.
Specifically, it is corresponding that the matching rule further comprises protocol type field if the message is elongated message
The length field of elongated message is used to indicate the message length of elongated message.
, such as elongated message Internet protocol the 4th edition (Internet Protocol Version 4, IPV4) for example
Message length field comprising 4 bits, minimum length are 20 bytes, and maximum length is 60 bytes, in total N kind length type, because
This stores IPV4 matching rule in first memory and/or second memory, according to matching frequency or actual conditions one by one,
Wherein the matching rule includes the place of protocol type field and protocol type field corresponding length field type and message
Reason movement index.
Specifically, the matching rule of the IPV4 is as follows:
1, IPV4 protocol type field, the first message length field, Message processing movement index;
2, IPV4 protocol type field, second of message length field, Message processing movement index;
3, IPV4 protocol type field, the third message length field, Message processing movement index;
And so on, N kind message length field type and corresponding protocol type and Message processing movement index is whole
It is stored in first memory and/or second memory.
It optionally, is usually all described since the matching frequency of the matching rule stored in second memory SRAM is low
Lookup matching is carried out in first memory TCAM.Based on this, carried out in lookup matching process in first memory TCAM, Ke Yixiang
The second memory SRAM sends configuration-direct, concentrates in Second Rule and increases new matching rule;And/or it can be described
The Second Rule of second memory, which is concentrated, deletes stored matching rule.
Optionally, with the variation of application scenarios, the matching that is stored in first memory TCAM or third memory TCAM
The matching frequency of rule is it can also happen that change, in order to store high of matching frequency as far as possible in first memory TCAM
With rule, matching time delay is searched so as to reduce, will can be matched successful number in first memory TCAM in real time
Matching rule less than the first preset threshold is removed from first memory TCAM, is stored into second memory SRAM.
Certainly, according to the degree of load of network scenarios, multi-level store can be set, wherein first memory is TCAM storage
Device searches the high matching rule of matching frequency for storing, and third to N memory may be TCAM memory, successively
For storing the different matching rules for searching matching frequency, the minimum matching rule of matching frequency is searched in second memory storage.
Due to distinguishing storage to the matching rule collection of storage, the high matching rule collection of matching frequency is stored in first
In memory TCAM, lookup matching operation is preferentially carried out by first memory, even if the successful match in second memory,
The matching entry of the successful match in the second memory is stored into the TCAM;In this way during matched, mention
It is high that the probability of successful match is searched in the TCAM, and then can reduce the time delay of data search;Simultaneously because all
Matching entry is respectively stored in the TCAM and second memory, reduces the number of entries of PARALLEL MATCHING in TCAM in this way,
To reduce the use power consumption of TCAM.
Embodiment three
In view of this, the embodiment of the invention provides a kind of matched devices of data search, as shown in figure 5, the device packet
It includes: first acquisition unit 501, the first searching unit 502, the second searching unit 503, control unit 504 and second acquisition unit
505;
The first acquisition unit 501, for obtaining the match-type field of the data;
First searching unit 502 is searched for the match-type field according to the data by first memory
Match the corresponding matching result of the match-type field;
Wherein, the first memory is stored with the first matching rule collection, and the first matching rule collection includes at least one
A matching rule, the matching rule include the corresponding relationship of match-type field and matching result, and the first memory is
Three-state content addressing memory TCAM;
Second searching unit 503 passes through second memory and searches matching institute if unsuccessful for TCAM matching
State the corresponding matching result of match-type field;
Wherein, the second memory is stored with the second matching rule collection, and the second matching rule collection includes at least one
A matching rule;
Described control unit 504, for by the match-type field and the match-type field pair of successful match
The matching result answered is stored into the TCAM;
The second acquisition unit 505, for obtaining the matching result by the TCAM.
Specifically, the second memory in described device is SRAM memory or other types of memory.
Optionally, according to actual application scenarios, described device may be not limited to deposit only with first memory and second
Reservoir second-level storage is searched, and can also be searched using three-level or more than third level storage.
For example, it can also increase level-one between first memory and second memory in said device
Memory, such as third memory, third memory is TCAM memory.In this way, it is unsuccessful in first memory matching, it can
Preferentially to carry out lookup matching in third memory, if searched in third memory it is unsuccessful, then in second memory
It searches and matches the corresponding matching result of the match-type field.That is, the matching frequency of the matching rule stored in first memory
Rate is greater than the matching frequency of the matching rule stored in third memory, the matching frequency of the matching rule stored in third memory
Rate is greater than the matching frequency of the matching rule stored in second memory.It carries out searching in the first memory matched preferential
Grade highest, followed by carries out searching matched priority in third memory, searches matched priority in second memory
It is minimum.
Specifically, searching matching described by second memory if first memory TCAM matching is unsuccessful
Before the corresponding matching result of type field, the device further include:
The corresponding matching result of the match-type field is matched by third memory look-up;
The corresponding matching result of the matching match-type field is searched by second memory to specifically include:
If the third memory look-up matching is unsuccessful, is searched by second memory and match the match-type field
Corresponding matching result.
Certainly, according to actual application scenarios, described device is not limited to be searched using more than third level storage.Accordingly
, it may refer to the above-mentioned setting about third level storage, the matching frequency of the matching rule of memory storage not at the same level is different.
It optionally, is usually all described first since the matching frequency of the matching rule stored in second memory is low
Data search matching is carried out in memory.Based on this, described device further include: first memory carry out data search matched
Cheng Zhong can be concentrated in the Second Rule of the second memory and be increased new matching rule;And/or it can be deposited described second
The Second Rule of reservoir, which is concentrated, deletes stored matching rule.
Optionally, with the variation of application scenarios, the matching frequency of the matching rule stored in first memory may also
It changes, in order to store the high matching rule of matching frequency, described device in the first memory as far as possible further include:
If first matching rule is concentrated there are the first matching rule, first matching rule is stored in described
Second matching rule is concentrated, wherein first matching rule is to be matched matching of the successful number less than preset threshold to advise
Then.
The embodiment of the invention provides a kind of matched device of data search, the device include: first acquisition unit 501,
First searching unit 502, the second searching unit 503, control unit 504 and second acquisition unit 505;The first acquisition unit
501, for obtaining the match-type field of the data;First searching unit 502, for the matching according to the data
Type field is searched by first memory and matches the corresponding matching result of the match-type field;Wherein, it described first deposits
Reservoir is stored with the first matching rule collection, and the first matching rule collection includes at least one matching rule, the matching rule
Corresponding relationship including match-type field and matching result, the first memory are three-state content addressing memory TCAM;
Second searching unit 503 passes through second memory and searches the matching matching class if unsuccessful for TCAM matching
The corresponding matching result of type-word section;Wherein, the second memory is stored with the second matching rule collection, second matching rule
Collection includes at least one matching rule;Described control unit 504, for by the match-type field of successful match and described
The corresponding matching result of match-type field is stored into the TCAM;The second acquisition unit 505, for by described
TCAM obtains the matching result.Based on the above-mentioned technical proposal, due to distinguishing storage, general to the matching rule collection of storage
It is stored in first memory TCAM with the high matching rule collection of frequency, it is preferential to carry out searching matching behaviour by first memory
Make, even if the successful match in second memory, also by the second memory matching entry storage of successful match arrive
In the TCAM;In this way during matched, the probability that successful match is searched in the TCAM is improved, and then can drop
The time delay of low data search;Simultaneously because all matching entries are respectively stored in the TCAM and second memory, in this way
Reduce the number of entries of PARALLEL MATCHING in TCAM, to reduce the use power consumption of TCAM.
Example IV
A kind of matched method of data search provided based on the above embodiment, the embodiment of the invention also provides a kind of numbers
It is investigated that coalignment is looked for, as shown in fig. 6, the device includes: receiver 601, processor 602, transmitter 603, first memory
604, second memory 605, third memory 606, controller 607 and the first communication bus 608, for realizing these devices it
Between connection communication.
Wherein, processor 602 may be a central processing unit (Central Processing Unit, referred to as
CPU) or specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC),
Or it is arranged to implement one or more integrated circuits of the embodiment of the present invention.
Processor 602 is for executing the executable program code stored in third memory 606, such as computer program
Run program corresponding with executable code.
For third memory 606 for storing executable program code, which includes computer operation instruction.Third
Memory 606 may include high speed RAM memory, it is also possible to further include nonvolatile memory (non-volatile
Memory), a for example, at least magnetic disk storage.
First communication bus 608 can be industry standard architecture (Industry Standard Architecture,
Referred to as ISA) bus, external equipment interconnection (Peripheral Component, referred to as PCI) bus or extension industrial standard
Architecture (Extended Industry Standard Architecture, referred to as EISA) bus etc..The bus 608
Address bus, data/address bus, control bus etc. can be divided into.Only to be indicated with a thick line in Fig. 6, but not convenient for indicating
Indicate only have a bus or a type of bus.
Specifically, the receiver 601, for receiving the match-type field of the data;
According to the match-type field of the data, is sent by the controller 607 and search matching instruction, deposited first
It is searched in reservoir 604 and matches the corresponding matching result of the match-type field;
Wherein, the first memory 604 is stored with the first matching rule collection, and the first matching rule collection includes at least
One matching rule, the matching rule include the corresponding relationship of match-type field and matching result, the first memory
604 be three-state content addressing memory TCAM;
If the TCAM matching is unsuccessful, is sent by the controller 607 and search matching instruction, in second memory
It is searched in 605 and matches the corresponding matching result of the match-type field;
Wherein, the second memory 605 is stored with the second matching rule collection, and the second matching rule collection includes at least
One matching rule;
The processor 602 is also used to the match-type field and the match-type field pair of successful match
The matching result answered is stored into the TCAM;
The transmitter 603, for sending the matching result of the TCAM output.
Specifically, the second memory 605 can be SRAM memory or other types of memory.
Optionally, according to actual application scenarios, described device may be not limited to only with first memory 604 and second
605 second-level storage of memory is searched, and can also be searched using three-level or more than third level storage.
For example, it can also increase level-one between first memory and second memory in said device
Memory, such as third memory, third memory is TCAM memory.In this way, the first memory 604 matching not at
Function can preferentially carry out lookup matching in third memory, if searched in third memory it is unsuccessful, then second storage
It is searched in device 605 and matches the corresponding matching result of the match-type field.That is, the matching rule stored in first memory 604
Matching frequency then is greater than the matching frequency of the matching rule stored in third memory, the matching rule stored in third memory
Matching frequency then is greater than the matching frequency of the matching rule stored in second memory 605.I.e. in first memory 604 into
Row searches matched highest priority, followed by carries out searching matched priority in third memory, in second memory
The 605 matched priority of lookup are minimum.
Specifically, matching the match-type word searching by second memory 605 if TCAM matching is unsuccessful
Before the corresponding matching result of section, described device further include:
The corresponding matching result of the match-type field is matched by third memory look-up;
The corresponding matching result of the matching match-type field is searched by second memory 605 to specifically include:
If the third memory look-up matching is unsuccessful, is searched by second memory 605 and match the match-type
The corresponding matching result of field.
Certainly, according to actual application scenarios, described device is not limited to be searched using more than third level storage.Accordingly
, it may refer to the above-mentioned setting about third level storage, the matching frequency of the matching rule of memory storage not at the same level is different.
It optionally, is usually all described since the matching frequency of the matching rule stored in second memory 605 is low
Data search matching is carried out in one memory 604.Based on this, described device further include: first memory 604 carry out data look into
It looks in matching process, can be concentrated in the Second Rule of the second memory 605 and increase new matching rule;And/or it can be with
It is concentrated in the Second Rule of the second memory 605 and deletes stored matching rule.
Optionally, with the variation of application scenarios, the matching frequency of the matching rule stored in first memory 604 can also
It can change, in order to store the high matching rule of matching frequency as far as possible in first memory 604, described device is also wrapped
Include: if first matching rule is concentrated, there are the first matching rules, and first matching rule is stored in described second
Matching rule is concentrated, wherein first matching rule is the matching rule for being matched successful number and being less than preset threshold.
The embodiment of the invention provides a kind of matched device of data search, which includes: receiver 601, processor
602, transmitter 603, first memory 604, second memory 605, third memory 606, controller 607 and the first communication are total
Line 608.The receiver 601, for receiving the match-type field of the data;According to the match-type word of the data
Section is sent by the controller 605 and searches matching instruction, searches match the match-type field pair in the first memory
The matching result answered;Wherein, the first memory 604 is stored with the first matching rule collection, the first matching rule Ji Bao
Including at least one matching rule, the matching rule includes the corresponding relationship of match-type field and matching result, and described first
Memory 604 is three-state content addressing memory TCAM;If the TCAM matching is unsuccessful, sent by the controller 605
Matching instruction is searched, is searched in second memory 605 and matches the corresponding matching result of the match-type field;Wherein, institute
It states second memory 605 and is stored with the second matching rule collection, the second matching rule collection includes at least one matching rule;Institute
Processor 602 is stated, is also used to the match-type field of successful match and the corresponding matching knot of the match-type field
Fruit stores into the TCAM;The transmitter 603, for sending the matching result of the TCAM output.Based on above-mentioned technology
The high matching rule collection of matching frequency is stored in first and deposited by scheme due to distinguishing storage to the matching rule collection of storage
In reservoir TCAM, lookup matching operation is preferentially carried out by first memory, even if the successful match in second memory, also will
The matching entry of successful match is stored into the TCAM in the second memory;In this way during matched, improve
The probability of successful match is searched in the TCAM, and then can reduce the time delay of data search;Simultaneously because all
It is respectively stored in the TCAM and second memory with entry, reduces the number of entries of PARALLEL MATCHING in TCAM in this way, from
And reduce the use power consumption of TCAM.
In several embodiments provided herein, it should be understood that disclosed device and method can pass through it
Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the unit, only
Only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components can be tied
Another system is closed or is desirably integrated into, or some features can be ignored or not executed.Another point, it is shown or discussed
Mutual coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or logical of device or unit
Letter connection can be electrical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that the independent physics of each unit includes, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of hardware adds SFU software functional unit.
The above-mentioned integrated unit being realized in the form of SFU software functional unit can store and computer-readable deposit at one
In storage media.Above-mentioned SFU software functional unit is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the portion of each embodiment the method for the present invention
Step by step.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (Read-Only Memory, abbreviation
ROM), random access memory (Random Access Memory, abbreviation RAM), magnetic or disk etc. are various can store
The medium of program code.
Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: it still may be used
To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features;
And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and
Range.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.