Background technology
In the QoS of network (Quality of Service, service quality) technology, the effect of Traffic Policing (traffic policing) is that restriction enters or flow out the flow rate of a certain connection of a certain network.For example the message flow of certain connection is excessive, and traffic policing can be taked to handle action to this message, as dropping packets, or resets priority of messages etc., thereby reaches the purpose of limited flow.
Whether traffic policing uses CAR (Committed Access Rate, committed access rate) mechanism to limit the flow of certain class message usually, and CAR adopts token bucket algorithm, E-Packet according to the token number decision in the current bucket.As shown in Figure 1, message is classified according to predefined matched rule, for the message that does not have the regulation feature, directly sends, and handles otherwise message enters token bucket.The message length of supposing to enter token bucket is B, and the token number in the current bucket is T, if B is greater than T, and dropping packets then; Otherwise message passes through, and continues to transmit, and deduct B with the token number in the bucket this moment, that is to say that this message has consumed B token.When message consumed token, token also was added in the token bucket with predetermined speed, and this speed is called CIR (Committed Information Rate, committed information rate, unit is bps), the message rate of finally passing through is consistent with CIR, and CIR is preestablished by the user.
Usually the packet of transmission over networks all has the restriction of maximum length, is called MTU (MaximumTransmission Unit, MTU), and when message entered certain network, message size need satisfy the MTU restriction of this network.If message length greater than MTU, then utilizes burst mechanism that message is divided into some, every length all is less than or equal to MTU, after all bursts all arrive the destination, recombinates again, and all bursts are assembled into original message.MTU is configured in the outgoing interface attribute list.Real network is in service, may need fragment message is carried out flow restriction, as shown in Figure 2.Equipment R access network N, the message length that mails to N from R will satisfy the MTU of network N, may need the long message burst this moment, simultaneously excessive for the flow that prevents to flow to N, and when the upstream device of R does not possess the inlet flow rate limitation function, just need enable restriction in the outlet of R, abandon the burst that exceeds bandwidth.
For accurate rate of discharge bandwidth is provided, flow restriction usually need be in the conventional treatment of message (comprise look into transmit, burst, link layer packaging etc.) just carry out after executing, message has been finished burst and has been handled when just being CAR, as shown in Figure 3.
In realizing process of the present invention, the inventor finds that there is following shortcoming in prior art:
In the prior art, article one, flow corresponding CAR token bucket, even the message of certain bar stream is divided into multi-disc, all sheets also all belong to same stream, can enter same token bucket and handle, consume the token resource of same bucket, when certain burst enters in the bucket, if token number is not enough in the current bucket, just abandon this burst.Because CAR abandons and has certain randomness, therefore occurring those bursts that are dropped probably belongs to different messages.Can't recombinate owing to lack the message of sheet, therefore become invalid fragment,, also can be dropped, take link bandwidth in vain even arrived destination device.Consequent result is, though surperficial upper outlet flow meets preset bandwidth, real effectively message flow is far smaller than bandwidth, that is to say that the bandwidth of setting has lost practical significance.
Embodiment
The embodiment of the invention provides a kind of flow limitation method and device of fragment message, can accurately guarantee that the burst that transmits on the link all is effective in the current limliting.
Below in conjunction with drawings and Examples, the specific embodiment of the present invention is described in further detail:
The embodiment of the invention provides a kind of flow limitation method of fragment message, as shown in Figure 4, comprising:
Step S401, the burst that has the same slice side-play amount in the data flow is classified as a class generate divides a laminar flow.
Concrete, a data flow has the message of a plurality of equal length, and this message can be subdivided into a plurality of bursts according to the MTU of interface, and the burst situation of all messages in data flow is identical, and promptly the number of burst and every length is identical.According to the Fragment Offset in the fragment message head (sheet skew) field, the burst that will have the same slice side-play amount is classified as a class, forms to divide laminar flow.Wherein, described offset field is to be used for identifying the position of this burst at whole message.Certainly,, also can carry out burst and handle, and the burst that will have a same slice amount of bias is classified as a class, form and divide a laminar flow message if having the message of different length in data flow.
Step S402, according to the ratio of the message length of the branch leaf length of described minute laminar flow and described data flow, token bucket is divided into the sub-token bucket that is complementary with described minute laminar flow.
Concrete, the branch leaf length of minute laminar flow and the message length in the data flow are compared, draw both ratios, and token bucket is segmented according to this ratio, generate and the sub-token bucket that divides laminar flow to be complementary.
Step S403, described burst flow to into the described sub-token bucket that is complementary and handle.Concrete, burst spread deliver to the sub-token bucket that is complementary with it, promptly divide the ratio of message length of the branch leaf length of laminar flow and data flow identical with the ratio of sub-token bucket and token bucket.Owing to belong to each burst time interval in transport process very little (nanosecond) of same message, for the token interpolation speed of sub-token bucket, this can ignore at interval, therefore can think that each burst almost enters sub-token bucket simultaneously, each sub-token bucket is handled the corresponding burst of a message simultaneously.Meanwhile, each sub-token bucket is again to add token with the corresponding minute proportional speed of leaf length.Therefore, when in sub-token bucket, handling simultaneously for all bursts of a message, the token resource of each sub-token bucket or all enough, perhaps all not enough, the effect that reaches thus is all bursts of a message or all abandons, perhaps all pass through, thereby the burst of guaranteeing to send on the link all is effective.
The method that provides by the foregoing description, the burst that will have the same slice side-play amount is classified as a class and forms different branch laminar flows, again burst is spread to deliver in the sub-token bucket that is complementary and handle, the resource allocation of this sub-token bucket is by the ratio decision of minute leaf length and message length.Can make the burst of same message be abandoned simultaneously or pass through like this, complete available to guarantee the message on the link.
As shown in Figure 5, structure for the IP fragmentation heading, wherein protocol number (Protoco1), TCP/UDP source port number, the TCP/UDP destination slogan in source IP address (Source Address), purpose IP address (Destination Address), the message IP head is the five-tuple sign of a data flow, and this five-tuple is five territories of IP message; Wherein Fragment Offset field is the burst side-play amount, identifies the position of this burst in whole message.Further embodiment of this invention provides a kind of flow limitation method of fragment message according to the burst side-play amount, as shown in Figure 6, may further comprise the steps:
Step S601, data flow is subdivided into the branch laminar flow according to the burst side-play amount.
Generally, the length of each data message is consistent in data flow, and outlet and interface determine that also therefore for satisfying interface attributes MTU, burst quantity, every leaf length of each message are also fixed.As shown in Figure 7, each message is divided into three, and length is respectively L1, L2 and L3, L1=L2=MTU wherein, and cauda length L 3 is generally less than MTU.Based on the burst side-play amount of each burst, the burst that all burst side-play amounts are identical is classified as class stream, promptly is classified as a class (P11, P21, P31...) to all first, and the burst side-play amount is 0; All second is classified as a class (P12, P22, P32...), and the burst side-play amount is L1; All the 3rd is classified as a class (P13, P23, P33...), and the burst side-play amount is L1+L2; Just a stream is subdivided into 3 streams again.In the same way,, just a stream is subdivided into N bar stream, is called " branch laminar flow " if message has been divided into the N sheet.Certainly,, also can carry out burst and handle, and the burst that will have a same slice amount of bias is classified as a class, form and divide a laminar flow message if having the message of different length in data flow.
Step S602, be every burst flow distribution token bucket resource.
Concrete, a data flow is subdivided into after the N bar divides laminar flow, be sub-token bucket of every burst flow distribution according to the ratio of the message length of the branch leaf length of minute laminar flow and data flow.Speed summation after every burst stream is handled through sub-token bucket separately is the set rate of original data stream, and the speed of each sub-token bucket is determined by the ratio that correspondence branch leaf length accounts for the message total length.As shown in Figure 8, message is divided into three, then derives three sub-token buckets by an original token bucket, and the burst of each message is distributed to respectively in three sub-token buckets.
The CIR of three token buckets is respectively
Wherein totallength is the total length (equaling L1+L2+L3 in this example) of message, and CIR is the total bandwidth of being scheduled to.That is, for n token bucket, its value is
Step S603, burst spread deliver to the sub-token bucket that is complementary.
Generally, a message by burst after, each burst time interval in transport process very little (nanosecond), for the token interpolation speed of token bucket, this can ignore at interval, therefore can think that each burst almost enters token bucket simultaneously, each barrel handled the corresponding burst of a message simultaneously, as shown in Figure 8, a certain moment P11, P12 and P13 enter bucket 1 simultaneously respectively, bucket 2 and bucket 3, next is P21 constantly, P22 and P23 also enter bucket 1 simultaneously respectively, bucket 2 and bucket 3, next moment P31 again, P32 and P33 also enter bucket 1 simultaneously respectively, bucket 2 and bucket 3.Meanwhile, each token bucket is again to add token with the corresponding minute proportional speed of leaf length.Therefore, for all bursts of a message, when carrying out the token bucket processing at the same time, the token resource of each barrel or all enough is perhaps all not enough.The effect that reaches thus is exactly, and all bursts of a message or all abandon perhaps all pass through, thereby the burst of guaranteeing to send on the link all are effective.
Divide the generation of laminar flow and the distribution of token bucket resource to realize that fully dynamically the user need not to participate in the above-mentioned steps.In actual applications, usually only specify outlet bandwidth by the stream of five-tuple sign, and the message of being indifferent to this stream burst whether, that is to say from user perspective to have only a stream and a token bucket.Therefore, rule generation and the token bucket distribution for " branch laminar flow " need dynamically be realized not perception of user by equipment self.
The embodiment of the invention also provides a kind of flow rate limiting device of fragment message, with the method that realizes that the embodiment of the invention provides.Fig. 9 is a module diagram in the embodiment of the invention, as shown in the figure, specifically comprises:
Diverter module 10 is used for that the burst that data flow has a same slice side-play amount is classified as a class and generates and divide a laminar flow;
Token bucket distribution module 20 is used for the ratio according to the message length of the branch leaf length of described minute laminar flow and described data flow, token bucket is divided into the sub-token bucket that is complementary with described minute laminar flow;
Delivery module 30 is used for the burst that described diverter module 10 is divided into spread and delivers to the sub-token bucket that the described token bucket distribution module that is complementary is divided into and handle.
Described diverter module 10 comprises:
The burst side-play amount is obtained submodule 11, is used for obtaining according to the identification field of data stream message head the burst side-play amount of each burst in the message;
Divide laminar flow to generate submodule 12, be used for that the burst side-play amount is obtained the burst with same slice side-play amount that submodule 11 obtains and be classified as a class and generate and divide a laminar flow.
Described token bucket distribution module 20 comprises:
Obtain ratio submodule 21, be used to obtain the branch leaf length of the branch laminar flow that described diverter module 10 is divided into and the ratio of described data flow message length;
Sub-token bucket generates submodule 22, is used for obtaining the ratio that ratio submodule 21 obtains token bucket being divided into sub-token bucket according to described.
The flow limitation method and the device of the fragment message that provides by the embodiment of the invention, according to the burst side-play amount data flow is divided into the branch laminar flow, and burst spread to deliver in the sub-token bucket with its coupling handle, efficiently solve because the invalid fragment problems that flow restriction causes is accurately guaranteeing that the burst that transmits on the link all is effective in the current limliting.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by hardware, also can realize based on such understanding by the mode that software adds necessary general hardware platform, technical scheme of the present invention can embody with the form of software product, it (can be CD-ROM that this software product can be stored in a non-volatile memory medium, USB flash disk, portable hard drive etc.) in, comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be looked protection scope of the present invention.