Detailed Description
The following describes embodiments of the present invention in further detail with reference to the accompanying drawings.
Example one
In order to avoid the problems that the service cannot be transmitted or the packet is lost and the network resource is not reasonably utilized, the embodiment provides a token allocation method, please refer to fig. 1, which includes the following steps:
s101: and acquiring the number of tokens required to be consumed by each arrived service, wherein the service at least comprises a key service.
The key services include services such as VoIP (Voice over Internet Protocol), IPTV (Internet Protocol Television), and the like. In addition to being a critical service, a service may also include both a critical service and a non-critical service, and the non-critical service includes an Internet service and the like.
Before acquiring the number of tokens to be consumed by each service arriving, the method may further include: the arriving service is identified as being a critical service or comprising both critical and non-critical services.
S102: the number of tokens in the current token bucket is obtained.
The fixed token bucket can automatically and continuously add tokens at a constant rate, and each token in the token bucket represents one byte. If the token is not consumed or the consumed speed is less than the generated speed, the number of tokens is increased continuously until the token bucket is filled up, the tokens added later overflow from the token bucket, and finally the maximum number of tokens which can be stored in the token bucket never exceeds the size of the token bucket.
Before obtaining the number of tokens in the current token bucket, the method further comprises the following steps: and judging whether the time of the current data packet of the service reaching the token bucket and the time of the last data packet reaching the token bucket are greater than a set threshold value, for example, the set threshold value is 1 millisecond, if so, updating the number of tokens in the token bucket, and the updated number of tokens in the token bucket is the number of tokens in the current token bucket in S102. The number of tokens to be added to the token bucket may be determined according to the size of the time difference, for example, if the time difference is 2 milliseconds, 200 tokens are added to the token bucket. It should be understood that if the time difference between the current packet and the last packet is less than a certain set threshold, for example, the set threshold is 1 ms, it is not necessary to wait until the token bucket updates the number of tokens in the current token bucket, and if the number of tokens is enough for the current packet, the token is directly assigned to the current packet.
In order to ensure that the quantity of tokens in the token bucket is enough, the method for adding the tokens into the token bucket comprises at least one of the following methods:
the first method is as follows: judging whether the time of the current data packet of the service reaching the token bucket and the time of the last data packet reaching the token bucket are greater than a set threshold value or not, if so, adding tokens into the token bucket;
the second method comprises the following steps: tokens are added to the token bucket at a constant rate.
S103: and judging whether the number of tokens required to be consumed by the key service is larger than the number of tokens in the current token bucket, if so, entering S104, and if not, entering S105.
S104: and distributing all tokens in the current token bucket to the key services, distributing the parts which are not consumed by the key services after the number of the tokens in the token bucket is updated, and forwarding the key services through the main link.
Since the key service belongs to the service with higher priority and cannot be discarded, when the number of tokens to be consumed by the key service is greater than the number of tokens in the token bucket, the tokens to be consumed by the key service can be subtracted even if the current tokens in the token bucket are insufficient, the token bucket can have a red word as a negative number, and the lower limit is the negative value of the token bucket size.
The specific treatment process comprises the following steps: and when the service is a key service, all the tokens in the current token bucket are allocated to the key service. And after all the tokens are distributed, the token bucket is in a red word. The rest key services which are not distributed to the token currently wait for the updating of the number of the tokens in the token bucket, and distribute the updated tokens to the rest key services; the number of the distributed tokens is equal to the number of the tokens consumed by the rest key services, so that all the key services can be distributed to the tokens, all the key services can be forwarded through the main link, the key services cannot be lost, and network resources can be reasonably utilized. The main link includes a DSL (Digital Subscriber Line) link.
The token bucket algorithm can mark the color of the data packet according to the data flow, wherein the mark green does not exceed the rate, and the mark red is marked on the part exceeding the rate. Because the DSL link is used as the main link, the DSL negotiation rate or the reference rate of the token bucket based on the specified rate threshold is generally used, and the reference rate is used as the judgment basis for indicating green and red.
The key service belongs to the service with higher priority and can not be discarded, so the key service can not be subjected to color marking, tunnel encapsulation is not needed, and the key service is directly forwarded through a DSL link, thereby ensuring that the key service is not lost.
When the services simultaneously comprise key services and non-key services and the number of tokens consumed by the key services is larger than the number of tokens in the token bucket, the key services are processed according to the processing process. And after all the tokens are distributed, the token bucket is in a red word. As for the non-critical service, the token is not consumed, the number of tokens in the token bucket is not required to be updated, all the non-critical services are directly marked with red, and the non-critical services are transmitted through an auxiliary link after being subjected to tunnel encapsulation, so that network resources can be reasonably utilized, wherein the auxiliary link comprises an LTE (Long Term Evolution) link.
S105: and judging whether the services also comprise non-critical services, if not, entering S106, and if so, entering S107.
S106: distributing the tokens to the key services, wherein the quantity of the distributed tokens is equal to the quantity of the tokens consumed by the key services; and forward critical traffic over the primary link.
And when the service is a key service and the number of tokens required to be consumed by the key service is less than the number of tokens in the token bucket, distributing the tokens to the key service, wherein the number of the distributed tokens is equal to the number of the tokens required to be consumed by the key service. The key service belongs to the service with higher priority and can not be discarded, so the key service can not be subjected to color marking, tunnel encapsulation is not needed, and the key service is directly forwarded through the main link, thereby ensuring that the key service is not lost. The primary link comprises a DSL link.
S107: and judging whether the number of tokens which are required to be consumed by both the key service and the non-key service is larger than the number of tokens in the current token bucket, if so, entering S108, and if not, entering S109.
S108: preferentially distributing the number of tokens to be consumed by the key service to the key service, and forwarding the key service through a main link; distributing the number of the rest tokens in the current token bucket to non-critical services, and forwarding the non-critical services distributed to the tokens through a main link; and the part which is not enough for the consumption of the residual non-critical service is not distributed, and the non-critical service which is not distributed to the token is forwarded through the auxiliary link.
When the services comprise key services and non-key services, the number of tokens required to be consumed by the key services is smaller than the number of tokens in the current token bucket, and the number of tokens required to be consumed by the key services and the non-key services is larger than the number of tokens in the current token bucket, the number of tokens required to be consumed by the key services is preferentially distributed to the key services because the key services belong to services with higher priority and cannot be discarded, and the key services are forwarded through a main link so as to ensure the transmission of the key services. The key service can not be marked with color, does not need to be encapsulated by a tunnel, and can be directly forwarded through a DSL link.
Since the number of tokens to be consumed by the critical service is less than the number of tokens in the current token bucket, the tokens remain after the allocation of the tokens to the critical service.
And then all the residual token numbers in the current token bucket are distributed to non-critical services, the non-critical services distributed to the tokens are marked as green, tunnel encapsulation is carried out, and then forwarding is carried out through a main link, wherein the main link comprises a DSL link.
And after all the tokens are distributed, the token bucket is in a red word. And the part which is not consumed by the rest non-key service is not distributed, namely the non-key service which is not distributed to the token is not distributed any more, the non-key service which is not distributed to the token is marked as red, tunnel encapsulation is carried out, and then forwarding is carried out through an auxiliary link, wherein the auxiliary link comprises an LTE link, so that network resources can be reasonably utilized.
S109: and distributing the number of tokens to be consumed from the current token bucket to the key services and the non-key services, and forwarding the key services and the non-key services through the main link.
If the services comprise key services and non-key services, the number of tokens required to be consumed by the key services is less than the number of tokens in the current token bucket, and the number of tokens required to be consumed by the key services and the non-key services is less than the number of tokens in the current token bucket; distributing the number of tokens to be consumed from the current token bucket to the key services and the non-key services, and forwarding the key services and the non-key services through the main link. The key service is not marked with color, tunnel encapsulation is not needed, and forwarding can be directly carried out through a DSL link. Non-critical traffic is labeled green, tunneled, and then forwarded over the DSL link.
The key services of some operators are all systems which are already networked and mature under the DSL link before, so the key services cannot be sent out from the LTE link. The problem that key services cannot be forwarded through a DSL link and are forwarded through an LTE link to cause that the key services cannot be delivered or packet loss in the prior art is solved.
The embodiment further illustrates a specific example, and takes a user multi-service scenario as an example, where IPTV, VoIP, and Internet services are simultaneously developed, and an uplink includes an ADSL (Asymmetric Digital Subscriber Line) link and an LTE link, and the implementation process is described in detail.
Firstly, presetting needed information, such as a token adding rate, a token conversion table, a preset tunnel encapsulation rule and the like in a token bucket according to ADSL negotiation rate. Wherein the number of current tokens in the token bucket is determined by ADSL negotiation rate. The preset tunnel encapsulation rule is to tunnel encapsulate the Internet service, the IPTV service and the VoIP service are not tunnel encapsulated, and for the Internet service, the local side device needs to tunnel encapsulate in order to distinguish whether the DSL link or the LTE link. The token conversion table includes the size of the service and the number of tokens to be consumed.
Then starting IPTV and VoIP services, inquiring the number of tokens required to be consumed by the IPTV and VoIP services from the token conversion table according to the size of the IPTV and VoIP services, and then judging that the number of tokens required to be consumed by the IPTV and VoIP services is less than the number of tokens in the token bucket; distributing tokens in the token bucket to IPTV and VoIP services, wherein the quantity of the distributed tokens is equal to the quantity of the tokens consumed by the IPTV and VoIP services, forwarding the IPTV and VoIP services through an ADSL link, and the IPTV and VoIP services are not marked and not encapsulated by a tunnel; and detecting the consumption of the number of tokens in the current token bucket in real time, wherein the tokens are consumed in the token bucket and the deficit does not appear.
Then, the Internet service is added, and the data flow is gradually increased until the negotiation rate of the ADSL is exceeded, namely, the number of the tokens which are required to be consumed by the IPTV, VoIP and Internet services is inquired from the token conversion table according to the size of the IPTV, VoIP and Internet services, and then the number of the tokens which are required to be consumed by the IPTV, VoIP and Internet services is judged to exceed the number of the tokens in the current token bucket, so that the fact that the token bucket has a red word is observed, the IPTV and VoIP services are still forwarded from the ADSL link without marking colors and are not encapsulated by a tunnel. A portion of the Internet traffic, which is labeled green, forwarded from the ADSL link, and encapsulated in ADSL tunnel format, has tokens assigned to it. Another part of the Internet traffic is marked red, forwarded from the LTE link, encapsulated into LTE tunnel format, and this part of the Internet traffic is not assigned a token.
Then, the data flow of the Internet service is gradually reduced, and it can be observed that after a certain time, the number of tokens which are required to be consumed by the IPTV service, the VoIP service and the Internet service is less than the number of tokens in the current token bucket, and the condition that the token bucket is not in a word-deficit state exists, the IPTV service, the VoIP service and the Internet service can be distributed to the tokens and are all forwarded through an ADSL link, and the IPTV service and the VoIP service are not packaged in a tunnel, and the Internet service is packaged in a tunnel.
According to the scheme of the embodiment, on the premise of not influencing IPTV and VoIP services, the Internet service is routed, the Internet service is encapsulated through different tunnels, and a reasonable link is selected for forwarding, so that network resources are reasonably used.
When the link is congested, the method of this embodiment, based on the occurrence of the critical deficit of the token bucket, realizes shunting of the overloaded Internet service data to the LTE link, and ensures that the Internet service data stream is not discarded due to the limitation of the DSL bandwidth when the link is congested. The LTE link is generally charged according to flow, and the present embodiment is an effective decision charging scheme by using the rate based on the data packet as the decision criterion.
According to the token allocation method provided by the embodiment, the number of tokens required to be consumed by each service is acquired, and the service at least comprises key services; obtaining the number of tokens in a current token bucket; when the number of tokens to be consumed by the key service is larger than the number of tokens in the current token bucket, all tokens in the current token bucket are allocated to the key service, and the part which is not consumed by the key service is allocated after the number of tokens in the token bucket is updated and the key service is forwarded through the main link.
Example two
In order to avoid the problem that the service cannot be transmitted or the packet is lost, the present embodiment provides a token allocation apparatus, please refer to fig. 2, which includes:
an obtaining module 201, configured to obtain the number of tokens that need to be consumed by each service that arrives, where the service at least includes a key service; and obtaining the number of tokens in the current token bucket.
The key services include services such as VoIP and IPTV. In addition to being a critical service, a service may also include both a critical service and a non-critical service, and the non-critical service includes an Internet service and the like.
Before acquiring the number of tokens to be consumed by each service arriving, the method may further include: the arriving service is identified as being a critical service or comprising both critical and non-critical services.
The processing module 202 is configured to, when the number of tokens that the key service needs to consume is greater than the number of tokens in the current token bucket, allocate all tokens in the current token bucket to the key service, and when the number of tokens in the token bucket is not consumed, wait for the update of the number of tokens in the token bucket to allocate the tokens, and forward the key service through the main link.
The fixed token bucket can automatically and continuously add tokens at a constant rate, and each token in the token bucket represents one byte. If the token is not consumed or the consumed speed is less than the generated speed, the number of tokens is increased continuously until the token bucket is filled up, the tokens added later overflow from the token bucket, and finally the maximum number of tokens which can be stored in the token bucket never exceeds the size of the token bucket.
Further comprising: an updating module 203, configured to update the number of tokens in the token bucket if a time distance from a current packet of the service to the token bucket to a time when a previous packet arrives at the token bucket is greater than a set threshold, for example, the set threshold is 1 millisecond, before the obtaining module 201 obtains the number of tokens in the current token bucket. The updated number of tokens in the token bucket is the number of tokens in the current token bucket acquired by the acquisition module 201. The number of tokens to be added to the token bucket may be determined according to the size of the time difference, for example, if the time difference is 2 milliseconds, 200 tokens are added to the token bucket. It should be understood that if the time difference between the current packet and the previous packet is less than a certain set threshold, for example, the set threshold is 1 ms, the processing module 202 does not wait until the token bucket updates the number of tokens in the current token bucket, and if the number of tokens is enough for the current packet, the processing module directly assigns the token to the current packet.
In order to ensure that the quantity of tokens in the token bucket is enough, the method for adding the tokens into the token bucket comprises at least one of the following methods:
the first method is as follows: judging whether the time of the current data packet of the service reaching the token bucket and the time of the last data packet reaching the token bucket are greater than a set threshold value or not, if so, adding tokens into the token bucket;
the second method comprises the following steps: tokens are added to the token bucket at a constant rate.
Since the key service belongs to the service with higher priority and cannot be discarded, when the number of tokens to be consumed by the key service is greater than the number of tokens in the token bucket, the tokens to be consumed by the key service can be subtracted even if the current tokens in the token bucket are insufficient, the token bucket can have a red word as a negative number, and the lower limit is the negative value of the token bucket size.
The specific processing procedure of the processing module 202 is as follows: and when the service is a key service, all the tokens in the current token bucket are allocated to the key service. And after all the tokens are distributed, the token bucket is in a red word. The rest key services which are not distributed to the token currently wait for the updating of the number of the tokens in the token bucket, and distribute the updated tokens to the rest key services; the number of the distributed tokens is equal to the number of the tokens consumed by the rest key services, so that all the key services can be distributed to the tokens, all the key services can be forwarded through the main link, the key services cannot be lost, and network resources can be reasonably utilized. Wherein the primary link comprises a DSL link.
The token bucket algorithm can mark the color of the data packet according to the data flow, wherein the mark green does not exceed the rate, and the mark red is marked on the part exceeding the rate. Because the DSL link is used as the main link, the DSL negotiation rate or the reference rate of the token bucket based on the specified rate threshold is generally used, and the reference rate is used as the judgment basis for indicating green and red.
The key service belongs to the service with higher priority and can not be discarded, so the key service can not be subjected to color marking, tunnel encapsulation is not needed, and the key service is directly forwarded through a DSL link, thereby ensuring that the key service is not lost.
When the service includes both critical service and non-critical service, and the number of tokens to be consumed by the critical service is greater than the number of tokens in the token bucket, the processing module 202 processes the critical service according to the above processing procedure. And after all the tokens are distributed, the token bucket is in a red word. As for the non-critical services, tokens do not need to be consumed, the number of tokens in the token bucket does not need to be updated, all the non-critical services are directly marked with red, and the non-critical services are transmitted through an auxiliary link after being subjected to tunnel encapsulation, so that network resources can be reasonably utilized, and the auxiliary link comprises an LTE link.
The processing module 202 is configured to: if the service only comprises the key service and the number of tokens required to be consumed by the key service is less than the number of tokens in the current token bucket, distributing the tokens to the key service, wherein the number of the distributed tokens is equal to the number of the tokens required to be consumed by the key service; and forward critical traffic over the primary link. The key service belongs to the service with higher priority and can not be discarded, so the key service can not be subjected to color marking, tunnel encapsulation is not needed, and the key service is directly forwarded through the main link, thereby ensuring that the key service is not lost. The primary link comprises a DSL link.
The processing module 202 is configured to: if the services comprise key services and non-key services, the number of tokens required to be consumed by the key services is less than the number of tokens in the current token bucket, and the number of tokens required to be consumed by the key services and the non-key services is greater than the number of tokens in the current token bucket; the key service belongs to the service with higher priority and can not be discarded, so the token number consumed by the key service is preferentially distributed to the key service, and the key service is forwarded through the main link to ensure the transmission of the key service; the key service can not be marked with color, does not need to be encapsulated by a tunnel, and can be directly forwarded through a DSL link.
Since the number of tokens to be consumed by the critical service is less than the number of tokens in the current token bucket, the tokens remain after the allocation of the tokens to the critical service. And distributing the number of the remaining tokens in the current token bucket to non-critical services, marking the non-critical services distributed to the tokens as green, performing tunnel encapsulation, and then forwarding through a main link, wherein the main link comprises a DSL link.
And after all the tokens are distributed, the token bucket is in a red word. And the part which is not consumed by the rest non-key service is not distributed, namely the non-key service which is not distributed to the token is not distributed any more, the non-key service which is not distributed to the token is marked as red, tunnel encapsulation is carried out, and then forwarding is carried out through an auxiliary link, wherein the auxiliary link comprises an LTE link, so that network resources can be reasonably utilized.
The processing module 202 is configured to: if the services comprise key services and non-key services, the number of tokens required to be consumed by the key services is less than the number of tokens in the current token bucket, and the number of tokens required to be consumed by the key services and the non-key services is less than the number of tokens in the current token bucket; distributing the number of tokens to be consumed from the current token bucket to the key services and the non-key services, and forwarding the key services and the non-key services through the main link. The key service is not marked with color, tunnel encapsulation is not needed, and forwarding can be directly carried out through a DSL link. Non-critical traffic is labeled green, tunneled, and then forwarded over the DSL link.
The key services of some operators are all systems which are already networked and mature under the DSL link before, so the key services cannot be sent out from the LTE link. The problem that key services cannot be forwarded through a DSL link and are forwarded through an LTE link to cause that the key services cannot be delivered or packet loss in the prior art is solved.
The embodiment further illustrates a specific example, which takes a user multi-service scenario as an example, where IPTV, VoIP, and Internet services are simultaneously developed, and an uplink includes an ADSL link and an LTE link, which is specifically as follows:
firstly, presetting needed information, such as a token adding rate, a token conversion table, a preset tunnel encapsulation rule and the like in a token bucket according to ADSL negotiation rate. Wherein the number of current tokens in the token bucket is determined by ADSL negotiation rate. The preset tunnel encapsulation rule is to tunnel encapsulate the Internet service, the IPTV service and the VoIP service are not tunnel encapsulated, and for the Internet service, the local side device needs to tunnel encapsulate in order to distinguish whether the DSL link or the LTE link. The token conversion table includes the size of the service and the number of tokens to be consumed.
Then, IPTV and VoIP services are started, the acquisition module 201 inquires the number of tokens required to be consumed by the IPTV and VoIP services from the token conversion table according to the size of the IPTV and VoIP services, if the number of the tokens required to be consumed by the IPTV and VoIP services is smaller than the number of the tokens in the token bucket, the processing module 202 allocates the tokens in the token bucket to the IPTV and VoIP services, the number of the allocated tokens is equal to the number of the tokens required to be consumed by the IPTV and VoIP services, the IPTV and VoIP services are forwarded through an ADSL link, and the IPTV and VoIP services are not marked and are not encapsulated by a tunnel; and detecting the consumption of the number of tokens in the current token bucket in real time, wherein the tokens are consumed in the token bucket and the deficit does not appear.
Then, the Internet service is added, and the data flow is gradually increased until the ADSL negotiation rate is exceeded, that is, the obtaining module 201 queries the number of tokens that are required to be consumed by the IPTV, VoIP, and Internet services from the token conversion table according to the size of the IPTV, VoIP, and Internet services, and if the number of tokens that are required to be consumed by the IPTV, VoIP, and Internet services exceeds the number of tokens in the current token bucket, it is observed that a red word appears in the token bucket, and the processing module 202 forwards the IPTV and VoIP services from the ADSL link, without marking color, and without being encapsulated by a tunnel. A portion of the Internet traffic, which is labeled green, forwarded from the ADSL link, and encapsulated in ADSL tunnel format, has tokens assigned to it. Another part of the Internet traffic is marked red, forwarded from the LTE link, encapsulated into LTE tunnel format, and this part of the Internet traffic is not assigned a token.
Then, the data flow of the Internet service is gradually reduced, it can be observed that after a certain time, the number of tokens which are required to be consumed by the IPTV, VoIP and Internet services is smaller than the number of tokens in the current token bucket, and there is no condition that the token bucket is a red word, the processing module 202 allocates tokens to the IPTV, VoIP and Internet services, and the IPTV, VoIP and Internet services are all forwarded through ADSL links, and the IPTV, VoIP services have no tunnel encapsulation, and the Internet services have tunnel encapsulation.
According to the scheme of the embodiment, on the premise of not influencing IPTV and VoIP services, the Internet service is routed, the Internet service is encapsulated through different tunnels, and a reasonable link is selected for forwarding, so that network resources are reasonably used.
According to the token allocation apparatus provided by the embodiment, the number of tokens to be consumed by each service that arrives is obtained by the obtaining module 201, the service at least includes a key service, and the number of tokens in the current token bucket is obtained; when the number of tokens to be consumed by the key service is greater than the number of tokens in the current token bucket, the processing module 202 allocates all tokens in the current token bucket to the key service, and the portion that is not consumed by the key service is allocated after waiting for the update of the number of tokens in the token bucket, and forwards the key service through the main link. By adopting the scheme, all key services can be distributed to the tokens, and the key services are forwarded through the main link, so that the key services are not lost, and network resources can be reasonably utilized.
There is also provided in another embodiment a computer storage medium having computer-executable instructions stored therein for performing the token assignment method of any one of the embodiments.
It will be apparent to those skilled in the art that the modules or steps of the above-described embodiments of the present invention may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed over a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored on a storage medium (ROM/RAM, magnetic disk, optical disk) and executed by a computing device, and in some cases, the steps shown or described may be executed out of order from that shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The foregoing is a more detailed description of embodiments of the present invention, and the present invention is not to be considered limited to such descriptions. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.