Summary of the invention
In view of this; The object of the present invention is to provide a kind of data transmission method and a kind of volume control device based on token bucket algorithm; In dependable flow precise control property; Can the data message that application produced that real-time is had relatively high expectations be sent in real time, thereby improve the real-time of this application, and then improve user experience.
For realizing above-mentioned purpose, the present invention provides following technical scheme:
A kind of data transmission method based on token bucket algorithm comprises:
After receiving data message, judge the priority of said data message;
When said data message is the high-priority data message, send said high-priority data message, confirm the first shared token number of said high-priority data message afterwards, and utilize said first token number to upgrade the token total amount in the said token bucket;
When said data message is the lower-priority data message; Confirm second token number that said lower-priority data message is shared; The token total amount of more said afterwards second token number and the said token bucket of current time; If said second token number is not more than the token total amount of the said token bucket of said current time, then sends said lower-priority data message, and utilize said second token number to upgrade the token sum of said token bucket; Otherwise, handle said lower-priority data message according to preset strategy.
Preferably, in said method, the priority of the said data message of said judgement comprises:
Confirm to produce the application of said data message;
Judge whether said application belongs to preset high-priority applications,, confirm that then said data message is the high-priority data message if said application belongs to said high-priority applications, otherwise, confirm that said data message is the lower-priority data message.
Preferably, in said method, the priority of the said data message of said judgement comprises:
Extract the characteristic of said data message;
Whether the characteristic of judging said data message is contained in the feature database that prestores; If the characteristic of said data message is contained in said feature database; Confirm that then said data message is the high-priority data message, otherwise, confirm that said data message is the lower-priority data message.
Preferably, in said method, the priority of the said data message of said judgement comprises:
Extract the characteristic of said data message;
The characteristic of said data message is mated with the recognition engine that prestores,, confirm that then said data message is the high-priority data message if the characteristic matching of said data message is hit, otherwise, confirm that said data message is the lower-priority data message.
Preferably, in said method, the characteristic of said data message comprises single bag characteristic and/or wraps long sequence signature continuously.
A kind of volume control device comprises token bucket, priority judging unit, first processing unit, second processing unit and Token Control unit;
Said token bucket is used to store token;
Said priority judging unit is used to judge the priority of the data message that receives;
Said first processing unit is used to send the high-priority data message, confirms first token number that said high-priority data message takies, and said first token number is sent to said Token Control unit;
Said second processing unit; Be used for second token number that definite lower-priority data message takies; When said second token number is not more than the token total amount of current time token bucket; Send said lower-priority data message, and said second token number be sent to said Token Control unit, during greater than the token total amount of current time token bucket, handle said lower-priority data message according to preset strategy at said second token number;
Said Token Control unit; Be used to receive said first token number and second token number; Utilize said first token number and second token number to upgrade the token total amount of said token bucket, also be used to obtain the token total amount of said token bucket and be sent to said second processing unit.
Preferably, in above-mentioned volume control device, said priority judging unit comprises:
Use and confirm the unit, be used for confirming to produce the application of said data message;
First judging unit is used to judge whether said application belongs to preset high-priority applications, if, confirm that then said data message is the high-priority data message, otherwise, confirm that said data message is the lower-priority data message.
Preferably, in above-mentioned volume control device, said priority judging unit comprises:
Feature extraction unit is used to extract the characteristic of said data message;
Second judging unit is used to judge whether the characteristic of said data message is contained in the feature database that prestores, if, confirm that then said data message is the high-priority data message, otherwise, confirm that said data message is the lower-priority data message.
Preferably, in above-mentioned volume control device, said priority judging unit comprises:
Feature extraction unit is used to extract the characteristic of said data message;
The 3rd judging unit is used to judge whether the characteristic of said data message matees with the recognition engine that prestores, if coupling confirms that then said data message is the high-priority data message, otherwise, confirm that said data message is the lower-priority data message.
This shows; Beneficial effect of the present invention is: in the method disclosed by the invention; No matter whether the quantity of token has reached the required token number that takies of high-priority data message in the token bucket, all this high-priority data message is sent, guarantee that the data message that application produced that real-time is had relatively high expectations sends in real time; Thereby improve the real-time of this application, and then improve user experience; Simultaneously; After sending the high-priority data message, utilize the token total amount of the required token number renewal token bucket that takies of high-priority data message, and for the lower-priority data message; The token total amount of having only token bucket is more than or equal to after the required token number of this lower-priority data message; Just it is sent, therefore, when the shared token number of this high-priority data message during more than the token sum of current time token bucket; Can in the process of sending the lower-priority data message, compensate the token of respective numbers, thus the accuracy of dependable flow control.
Embodiment
For the purpose, technical scheme and the advantage that make the embodiment of the invention clearer; To combine the accompanying drawing in the embodiment of the invention below; Technical scheme in the embodiment of the invention is carried out clear, intactly description; Obviously, described embodiment 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.
The invention discloses a kind of data transmission method based on token bucket algorithm; This method is applied to volume control device; In dependable flow precise control property; Can the data message that application produced that real-time is had relatively high expectations be sent in real time, thereby improve the real-time of this application, and then improve user experience.
Basic ideas are: the data message that the application that real-time is had relatively high expectations produces is defined as high priority; When receiving the high-priority data message; No matter whether the quantity of token can reach the required token number of this high-priority data message in the token bucket, all this high-priority data message is sent, guarantee that the data message that application produced that real-time is had relatively high expectations sends in real time; Thereby improve the real-time of this application, and then improve user experience; Simultaneously, when the shared token number of this high-priority data message during more than the token sum of current time token bucket, the token of compensation respective numbers in the process of sending the lower-priority data message, thereby the accuracy of dependable flow control.
Referring to Fig. 1, Fig. 1 is the flow chart of a kind of data transmission method based on token bucket algorithm disclosed by the invention.Comprise:
Step S1: receiving data packets.
Step S2: judge whether this data message is the high-priority data message, if, execution in step S3 then, otherwise, execution in step S6.
In practical application, the priority of data message can be set in volume control device, also can be after user side be set with related information transmission to volume control device.Usually, the data message that can the application that real-time is had relatively high expectations be produced is defined as high priority, for example, can the data message that MSN (like QQ, MSN) produces be defined as high priority.In the enforcement, can perhaps confirm its priority according to definite its priority that should be used for that produces data message according to the characteristic of data message.
Step S3: send this high-priority data message.
When the data message of confirming to receive has high priority,, all it is sent no matter whether the token quantity in the current time token bucket can satisfy the demand of this data message.
Step S4: confirm first token number that this high-priority data message takies.
Each token allows to send the data of specific quantity, after the data volume of specified data message, can confirm the token number that this data message takies.For example, each token allows to send the data of 1 byte, and when sending the data message of K byte, this data message takies K token.When data message is the high-priority data message, its token number that takies is designated as first token number.
Step S5: utilize first token number to upgrade the token total amount of token bucket.
The process of upgrading is specially, and before sending this high-priority data message, confirms the token total amount of token bucket, and the computational token total amount and first token number is poor afterwards, with the token total amount of this difference as new token bucket.
Step S6: confirm second token number that this lower-priority data message takies.
Step S7: the token total amount of obtaining the current time token bucket.
Step S8: judge second token number whether greater than the token total amount of token bucket, if, execution in step S10 then, otherwise, execution in step S9.
Step S9: send this lower-priority data message, utilize second token number to upgrade the token total amount of token bucket.
Step S10: handle this lower-priority data message according to preset strategy.
When the data message that receives is the lower-priority data message, it is handled according to conventional method.Handling the lower-priority data message according to preset strategy can be to abandon this data message, can be that it is emitted in the formation, so that when running up to abundant token in the token bucket, transmit, perhaps also can carry out sending behind the special marking to it again.
In above-mentioned disclosed method; No matter whether the quantity of token has reached the required token number that takies of high-priority data message in the token bucket; All this high-priority data message is sent; The data message that application produced that real-time is had relatively high expectations in assurance sends in real time, thereby improves the real-time of this application, and then improves user experience; Simultaneously; After sending the high-priority data message, utilize the token total amount of the required token number renewal token bucket that takies of high-priority data message, and for the lower-priority data message; The token total amount of having only token bucket is more than or equal to after the required token number of this lower-priority data message; Just it is sent, therefore, when the shared token number of this high-priority data message during more than the token sum of current time token bucket; Can in the process of sending the lower-priority data message, compensate the token of respective numbers, thus the accuracy of dependable flow control.
In the enforcement, can adopt multiple mode judgment data priority of messages.Describe respectively below in conjunction with Fig. 2, Fig. 3 and Fig. 4.
Referring to Fig. 2, Fig. 2 is the flow chart of the method for a kind of judgment data message priority disclosed by the invention.Comprise:
Step S211: the application of confirming to produce data message;
Step S212: judge whether this application belongs to preset high-priority applications, if, execution in step S213 then, otherwise, execution in step S214;
Step S213: confirm that this data message is the high-priority data message;
Step S214: confirm that this data message is the lower-priority data message.
The data message that in communication network, transmits comes from polytype application; The data message that different application produces can there are differences; For example there is different identifiers, therefore can confirms its source, promptly confirm to produce the application of data message according to the difference of each data message.When the application that produces this data message had high priority, then this data message also had high priority.Can set the priority of various application at volume control device; Also can be in the priority of user side or the various application of server sets; Inform volume control device with the mode of communication afterwards, by each preset application of flow controller storage with high priority.
Referring to Fig. 3, Fig. 3 is the flow chart of the method for a kind of judgment data message priority disclosed by the invention.Comprise:
Step S221: the characteristic of extracting data message;
Step S222: whether the characteristic of judging this data message is contained in the feature database that prestores, if, execution in step S223 then, otherwise, execution in step S224;
Step S223: confirm that this data message is the high-priority data message;
Step S224: confirm that this data message is the lower-priority data message.
The data message that different application produces takes on a different character, and can distinguish various data messages through the characteristic of comparison data message.In the enforcement; For being set at data message, extracting its characteristic in advance and it is stored in feature database, when receiving data message with high priority; As long as the characteristic of this data message and the characteristic in the feature database are compared, just can judge the priority of this data message.
Need to prove that the characteristic of data message can be single bag characteristic, the long sequence signature of bag or both combinations continuously.Accordingly, single bag characteristic of the various high-priority data messages of storage, the long sequence signature of bag or both combinations continuously in the feature database.
Referring to Fig. 4, Fig. 4 is the flow chart of the method for a kind of judgment data message priority disclosed by the invention.Comprise:
Step S231: the characteristic of extracting data message;
Step S232: the characteristic of this data message and the recognition engine that prestores are mated, if the characteristic matching of this data message hits, execution in step S233 then, otherwise, execution in step S234;
Step S233: confirm that this data message is the high-priority data message;
Step S234: confirm that this data message is the lower-priority data message.
The difference of method shown in Figure 4 and method shown in Figure 3 is; Extract various characteristics in advance with data message of high priority; The characteristic that will extract various data messages afterwards is abstracted into recognition engine; After receiving data message, this data message and this recognition engine are mated, if match hit then confirm that this data message is the high-priority data message.In the enforcement, this recognition engine can be embedded in the token bucket algorithm, need not to carry out human configuration this moment.
Need to prove that the characteristic of data message can be single bag characteristic, the long sequence signature of bag or both combinations continuously.Accordingly, extract single bag characteristic, the long sequence signature of bag or both combinations continuously of various high-priority data messages, to form recognition engine.
The invention also discloses a kind of volume control device of using said method; Utilize in the process of this volume control device control flow; Can guarantee the data message that application produced that real-time is had relatively high expectations is sent in real time; Thereby improve the real-time of this application, and then improve user experience, the accuracy of dependable flow control simultaneously.
Referring to Fig. 5, Fig. 5 is the structural representation of a kind of volume control device disclosed by the invention.This volume control device comprises token bucket 1,priority judging unit 2,first processing unit 3,second processing unit 4 and Token Control unit 5.Wherein:
Token bucket 1 is used to store token;
Priority judging unit 2 is used to judge the priority of the data message that receives;
First processing unit 3 is used to send the high-priority data message, confirms first token number that the high-priority data message takies, and first token number is sent to Token Control unit 5;
Second processing unit 4; Be used for second token number that definite lower-priority data message takies; When second token number is not more than the token total amount of current time token bucket; Send the lower-priority data message and second token number is sent to Token Control unit 5, during greater than the token total amount of current time token bucket, handle the lower-priority data message according to preset strategy at second token number;
Token Control unit 5 is used to receive first token number and second token number, utilizes first token number and second token number to upgrade the token total amount of token bucket, also is used to obtain the token total amount of token bucket and is sent tosecond processing unit 4.
In the enforcement, the priority judging unit can adopt multiple structure.Describe respectively below in conjunction with Fig. 6, Fig. 7 and Fig. 8.
Referring to Fig. 6, Fig. 6 is a kind of structural representation of Fig. 5 medium priority judging unit.This priority judging unit comprises using confirms theunit 211 and first judging unit 212.Wherein:
Use and confirmunit 211, be used for confirming to produce the application of data message;
First judgingunit 212 is used to judge whether application belongs to preset high-priority applications, if then the specified data message is the high-priority data message, otherwise the specified data message is the lower-priority data message.
Referring to Fig. 7, Fig. 7 is the another kind of structural representation of Fig. 5 medium priority judging unit.This priority judging unit comprises thefeature extraction unit 221 and second judging unit 222.Wherein:
Feature extraction unit 221 is used to extract the characteristic of data message;
Second judging unit 222, whether the characteristic that is used for the judgment data message is contained in the feature database that prestores, if then the specified data message is the high-priority data message, otherwise the specified data message is the lower-priority data message.
Referring to Fig. 8, Fig. 8 is the another kind of structural representation of Fig. 5 medium priority judging unit.This priority judging unit comprisesfeature extraction unit 221 and the 3rd judging unit 232.Wherein:
Feature extraction unit 221 is used to extract the characteristic of data message;
The 3rd judging unit 232, whether the characteristic that is used for the judgment data message matees with the recognition engine that prestores, if coupling, then the specified data message is the high-priority data message, otherwise the specified data message is the lower-priority data message.
Each embodiment adopts the mode of going forward one by one to describe in this specification, and what each embodiment stressed all is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.For the disclosed device of embodiment, because it is corresponding with the embodiment disclosed method, so description is fairly simple, relevant part is partly explained referring to method and is got final product.
The professional can also further recognize; The unit and the algorithm steps of each example of describing in conjunction with embodiment disclosed herein; Can realize with electronic hardware, computer software or the combination of the two; For the interchangeability of hardware and software clearly is described, the composition and the step of each example described prevailingly according to function in above-mentioned explanation.These functions still are that software mode is carried out with hardware actually, depend on the application-specific and the design constraint of technical scheme.The professional and technical personnel can use distinct methods to realize described function to each certain applications, but this realization should not thought and exceeds scope of the present invention.
The method of describing in conjunction with embodiment disclosed herein or the step of algorithm can be directly with the software modules of hardware, processor execution, and perhaps the combination of the two is implemented.Software module can place the storage medium of any other form known in random asccess memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or the technical field.
To the above-mentioned explanation of the disclosed embodiments, make this area professional and technical personnel can realize or use the present invention.Multiple modification to these embodiment will be conspicuous concerning those skilled in the art, and defined General Principle can realize under the situation that does not break away from the spirit or scope of the present invention in other embodiments among this paper.Therefore, the present invention will can not be restricted to these embodiment shown in this paper, but will meet and principle disclosed herein and features of novelty the wideest corresponding to scope.