A kind of method and apparatus of traffic shaping
Technical field
The present invention relates to the communications field, particularly a kind of method and apparatus of traffic shaping.
Background technology
Can send packet by communication process chip in the communications field, communication process chip generally includes scheduler, memory, queue management module and traffic shaping module.
Wherein, traffic shaping module can realize traffic shaping function, and traffic shaping function can make communication process chip send packet according to the bandwidth pre-set.
One or more relatively independent memory space is had in memory, each memory space can be called a transmit queue, transmit queue is used for the packet that buffer memory needs to send, the corresponding token bucket of each transmit queue or leaky bucket, token bucket is for storing token, and leaky bucket is for storing the flow of the packet of transmission; When a packet is transmitted, scheduler dispatches transmit queue from memory, queue management module goes out group packet from this transmit queue and sends out the packet of team, simultaneously traffic shaping module deducts the token of certain flow or add flow in leaky bucket corresponding to this transmit queue from token bucket corresponding to this transmit queue, and traffic shaping module deduct the flow of token, interpolation flow equal with the flow that queue management module goes out group packet from this transmit queue respectively.
In addition, traffic shaping module needs to refresh according to the bandwidth in advance for the setting of this transmit queue the flow stored in the token that stores in token bucket corresponding to this transmit queue or leaky bucket corresponding to this transmit queue.Such as, the token bucket that in the periodic refresh memory of traffic shaping module, each transmit queue is corresponding, when flushing to token bucket corresponding to certain transmit queue, calculate the token amount needing to add in token bucket corresponding to this transmit queue according to the length gauge of bandwidth sum refresh cycle arranged for this transmit queue in advance, add token according to the token amount calculated to the token bucket that this transmit queue is corresponding; Or, the traffic shaping module leaky bucket that periodically each transmit queue is corresponding in refresh memory, when flushing to leaky bucket corresponding to certain transmit queue, calculate the flow needing to deduct from leaky bucket corresponding to this transmit queue according to the length gauge of bandwidth sum refresh cycle arranged for this transmit queue in advance, from the leaky bucket that this transmit queue is corresponding, deduct the flow calculated.
But, in existing scheme, because the access bandwidth of memory is limited, if the transmit queue number in memory be greater than memory allow within a refresh cycle access number of times time, traffic shaping module just cannot flush to token bucket corresponding to each transmit queue or leaky bucket when doing traffic shaping function within a refresh cycle.
Summary of the invention
In order to reduce the refreshing frequency of token bucket corresponding to each transmit queue or leaky bucket and ensure that the token bucket that each transmit queue is corresponding or leaky bucket can be refreshed, embodiments provide a kind of method and apparatus of traffic shaping.Described technical scheme is as follows:
A method for traffic shaping, described method comprises:
First packet goes out team from the transmit queue communication process chip;
According to the very first time, the second time and be in advance described transmit queue arrange bandwidth, refresh token bucket corresponding to described transmit queue or leaky bucket, wherein, the described very first time is described first packet goes out team time from this transmit queue, described second time is that the second packet goes out the time of team from described transmit queue, described second packet is before described first packet goes out team from described transmit queue, and the last time goes out the packet of team.
An equipment for traffic shaping, described equipment comprises:
Go out group module, for the first packet is gone out team from the transmit queue communication process chip;
Refresh module, for refreshing token bucket corresponding to described transmit queue or leaky bucket according to the very first time, the second time and the bandwidth that arranges for described transmit queue in advance, wherein, the described very first time is described first packet goes out team time from this transmit queue, described second time is that the second packet goes out the time of team from described transmit queue, described second packet is before described first packet goes out team from described transmit queue, and the last time goes out the packet of team.
In the present invention, first packet goes out team from transmit queue, and according to the very first time, the second time and in advance for this transmit queue arrange bandwidth refresh token bucket corresponding to this transmit queue or leaky bucket, the very first time is the time going out team from this transmit queue of the first packet, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team.Because the team that goes out of packet all will according to token bucket or leaky bucket with transmission, therefore, the equipment provided according to the embodiment of the present invention carries out the refreshing of token bucket or leaky bucket, just can reduce the number of times and frequency that refresh token bucket corresponding to each transmit queue or leaky bucket, realize traffic shaping.
Accompanying drawing explanation
Fig. 1 ~ 10 are several flow charts of the method for the traffic shaping that the embodiment of the present invention 1 provides;
Figure 11 is the method flow diagram of a kind of traffic shaping that the embodiment of the present invention 2 provides;
Figure 12 is the method flow diagram of a kind of traffic shaping that the embodiment of the present invention 3 provides;
Figure 13 ~ 20 are several schematic diagrames of the equipment of the traffic shaping that the embodiment of the present invention 4 provides.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment 1
As shown in Figure 1, embodiments provide a kind of method of traffic shaping, comprising:
101: the first packets go out team from transmit queue;
102: according to the very first time, the second time and be in advance this transmit queue arrange bandwidth, refresh token bucket corresponding to this transmit queue or leaky bucket; Wherein, the very first time is described first packet goes out team time from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, and the second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team.
Optionally, as shown in Figure 2,102 can specifically comprise:
1021: the time difference calculating the very first time and the second time;
1022: according to the time difference calculated be the bandwidth that this transmit queue is arranged in advance, calculate the token amount needing to add to token bucket corresponding to this transmit queue;
1023: according to the token amount calculated, the token bucket corresponding to this transmit queue adds token, to refresh token bucket corresponding to this transmit queue.
Optionally, as shown in Figure 3, after 102, the method also comprises:
103: the numerical value utilizing the very first time, upgraded for the second time.
Optionally, as shown in Figure 4, after 102, the method also comprises:
104: according to the first token amount, the second token amount and the 3rd token amount, calculate token bucket corresponding to this transmit queue be refreshed after token amount.
Wherein, before the first token amount refers to that the first packet goes out team from this transmit queue, the token amount in the token bucket that this transmit queue is corresponding; When second token amount refers to that the first packet to go out group from this transmit queue, the token amount deducted from the token bucket that this transmit queue is corresponding, usually, the second token amount is equal with the first data packet flow; After 3rd token amount refers to that the first packet goes out team from this transmit queue, when refreshing token bucket corresponding to this transmit queue, to the token amount that the token bucket that this transmit queue is corresponding adds.
Optionally, as shown in Figure 5, after 104, the method also comprises:
105: if token bucket corresponding to this transmit queue be refreshed after token amount be less than default first threshold, then the dispatch state of this transmit queue is set to the state of non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.
Such as, if when the first data contract out group from deducting too much token token bucket, after refreshing, the token amount of token bucket is still very little, assuming that be less than default first threshold, then need upper once refresh token bucket corresponding to this transmit queue time add more token amount.Therefore, by the dispatch state of this transmit queue is set to non-scheduling state, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state, can increase the time difference of the above-mentioned very first time and the second time, thus the needs calculated also can be more to the token amount that the token bucket that this transmit queue is corresponding adds.
Optionally, as shown in Figure 6, after 104, the method also comprises:
106: the numerical value of the token amount after the token bucket that this transmit queue that utilization calculates is corresponding is refreshed, upgrades the first token amount.
Optionally, as shown in Figure 7,102 can comprise:
1024: the time difference calculating the very first time and the second time;
1025: according to the time difference calculated be the bandwidth of this transmit queue setting in advance, calculate the flow that needs deduct from leaky bucket corresponding to this transmit queue;
1026: from the leaky bucket that this transmit queue is corresponding, deduct the flow calculated, to refresh leaky bucket corresponding to this transmit queue.
Optionally, as shown in Figure 8, after 102, the method also comprises:
107: according to first flow, the second flow and the 3rd flow, calculate leaky bucket corresponding to this transmit queue be refreshed after flow.
Wherein, first flow is before the first packet goes out team from this transmit queue, the flow in the leaky bucket that this transmit queue is corresponding; Second flow is when to be the first packet to go out group from this transmit queue, the flow added in the leaky bucket that this transmit queue is corresponding; 3rd flow is the flow needing to deduct from leaky bucket corresponding to this transmit queue.
Optionally, as shown in Figure 9, after 107, the method also comprises:
108: if leaky bucket corresponding to this transmit queue be refreshed after flow be greater than default Second Threshold, then the dispatch state of this transmit queue is set to the state of non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.
Such as, if when the first data contract out group to the flow that the interpolation in leaky bucket is too much, the flow or too much of leaky bucket after refreshing, assuming that be greater than default Second Threshold, then need upper once refresh leaky bucket corresponding to this transmit queue time deduct more flow.Therefore, by the dispatch state of this transmit queue is set to non-scheduling state, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state, can increase the time difference of the above-mentioned very first time and the second time, thus the flow that the needs calculated deduct from leaky bucket corresponding to this transmit queue also can be more.
Optionally, as shown in Figure 10, after 107, also comprise:
109: the numerical value of the flow after the leaky bucket that this transmit queue that utilization calculates is corresponding is refreshed, upgrade first flow.
In embodiments of the present invention, the first packet goes out team from transmit queue, deducts token or add flow to the leaky bucket that this transmit queue is corresponding according to the flow of the first packet from the token bucket that this transmit queue is corresponding; And according to the very first time, the second time and in advance for this transmit queue arrange bandwidth refresh token bucket corresponding to this transmit queue or leaky bucket, the very first time is the time going out team from this transmit queue of the first packet, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team.Because the team that goes out of packet all will according to token bucket or leaky bucket with transmission, therefore, the method provided according to the embodiment of the present invention carries out the refreshing of token bucket or leaky bucket, just can reduce the number of times and frequency that refresh token bucket corresponding to each transmit queue or leaky bucket, realize traffic shaping.
Embodiment 2
As shown in figure 11, embodiments provide a kind of method of traffic shaping, comprising:
201: the first packets go out team from the transmit queue communication process chip;
Such as, when needs send packet, transmit queue in scheduler schedules memory in communication process chip, first data go out team from from this transmit queue, and be sent out away, simultaneously the traffic shaping module of communication process chip is according to the flow of the first packet going out team from this transmit queue, from the token bucket that this transmit queue is corresponding, deduct token, wherein, the token amount that deducts of traffic shaping module is equal with the first data packet flow.
Optionally, in advance can a timer be set in communication process chip, when the first packet to go out group from this transmit queue, current time during this timer can be read, and using the current time that reads as the very first time.
Wherein, in the present embodiment, communication process chip each reset restart after, the token amount of the token bucket that in the memory of communication process chip, each transmit queue is corresponding can equal 0, be greater than 0 or be less than 0.
202: the time difference calculating the very first time and the second time, wherein, the very first time is that the first packet goes out the time of team from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team;
Optionally, can buffer memory above-mentioned second time, when each communication process chip reset restarts, the second time of buffer memory can be set to 0.
203: according to calculate time difference and be in advance this transmit queue setting bandwidth, refresh the token bucket that this transmit queue is corresponding;
Particularly, according to calculate time difference and be in advance this transmit queue setting bandwidth, calculate the token amount needing to add token in token bucket corresponding to this transmit queue, in token bucket corresponding to this transmit queue, add token according to the token amount calculated, so achieve the token bucket corresponding to this transmit queue and refresh.
Optionally, the time difference of calculating and the bandwidth arranged for this transmit queue in advance can be done the token amount that product calculation obtains needing to add token in token bucket corresponding to this transmit queue.
204: obtain token bucket corresponding to this transmit queue be refreshed after token amount, if be less than default first threshold, then perform 205:
Such as, before the first packet is gone out team from this transmit queue, the token amount in the token bucket that this transmit queue is corresponding is labeled as old_tokenbucket; When to be gone out group from this transmit queue by the first packet, the token amount deducted from the token bucket that this transmit queue is corresponding is labeled as plen; After first packet is gone out team from this transmit queue, when refreshing token bucket corresponding to this transmit queue, the token amount that the token bucket to this transmit queue adds is labeled as △ token.Then according to following formula (1) calculate token bucket corresponding to this transmit queue be refreshed after token amount new_tokenbucket:
new_tokenbucket=old_tokentbucket+△token-plen……(1)
If the token amount new_tokenbucket after refreshing is less than default first threshold, then perform 205.Wherein, the first threshold preset can be greater than 0, be less than 0 or equal 0.
Further, old_tokenbucket can be upgraded with the numerical value of new_tokenbucket.
Wherein, if token amount new_tokenbucket is more than or equal to default first threshold after refreshing, then, when this transmit queue is scheduled again and go out group packet from this transmit queue, returns 201 and restart to carry out.
205: the state dispatch state of this transmit queue being set to non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.
Particularly, the dispatch state of this transmit queue is set to the state of non-scheduling, and starts timing, when the time of timing reaches the default time, the dispatch state of this transmit queue is set to schedulable state.
Wherein, after the dispatch state of this transmit queue being set to the state of non-scheduling, scheduler cannot dispatch this transmit queue, so that cannot go out group packet from this transmit queue, traffic shaping module also cannot deduct token from token bucket corresponding to this transmit queue.After the dispatch state of this transmit queue is set to schedulable state, the device scheduling if this transmit queue is scheduled again also, when going out group packet from this transmit queue, can return execution 201.
Optionally, k bit can be reserved for identifying dispatch state in this transmit queue, k be more than or equal to 1 integer.
Wherein, for each transmit queue in the memory of communication process chip, all press the flow process of above-mentioned 201-205, just refresh token bucket corresponding to transmit queue when packet to go out group from transmit queue.
Wherein, the memory of communication process chip is owing to being subject to the restriction of access bandwidth, allow out the number of the transmit queue of group packet to be less than or equal to the number of times of memory permission each second access in each second, and in the present invention, when going out group packet from transmit queue, the token bucket corresponding to the transmit queue going out group packet refreshes, therefore the number of times carrying out refreshing per second with per second go out the number of times of group packet identical, the number of times of refreshing token bucket per second is made to be less than or equal to the memory number of times allowing access per second, and the number of times of refreshing token bucket is by the restriction of the number of the transmit queue in the restriction of access bandwidth of memory and memory, thus significantly reduce the refreshing frequency of token bucket, therefore, as long as go out group packet from each transmit queue memory, just can flush to each transmit queue in memory.
In embodiments of the present invention, the first packet goes out team from transmit queue, and the flow according to the first packet deducts token from the token bucket that this transmit queue is corresponding; Calculate the time difference of the very first time and the second time, the very first time is that the first packet goes out the time of team from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, second packet is that the first packet goes out from this transmit queue the packet that the last time before team goes out team, according to the time difference calculated and in advance for the bandwidth meter of this transmit queue setting calculates the token amount needing to add, add token according to the token amount calculated to the token bucket that this transmit queue is corresponding.Because the team that goes out of packet all will according to token bucket with transmission, therefore, the method provided according to the embodiment of the present invention carries out the refreshing of token bucket, just can reduce the number of times and frequency that refresh token bucket corresponding to each transmit queue, realize traffic shaping.
Embodiment 3
As shown in figure 12, embodiments provide a kind of method of traffic shaping, comprising:
301: the first packets go out team from the transmit queue communication process chip;
Wherein, when needs send packet, transmit queue in scheduler schedules memory in communication process chip, first packet goes out team and is sent out away from this transmit queue, the traffic shaping module of communication process chip goes out the flow of the first packet of team according to this transmit queue simultaneously, in the leaky bucket that this transmit queue is corresponding, add flow, wherein, the flow that traffic shaping module is added is equal with the flow of the first packet.
Optionally, in advance can a timer be set in communication process chip, when the first packet to go out group from this transmit queue, current time during this timer can be read, and using the current time that reads as the very first time.
302: the time difference calculating the very first time and the second time, wherein, the very first time is the time going out team first packet from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, the last packet going out team from this transmit queue;
Optionally, can buffer memory above-mentioned second time, when each communication process chip reset restarts, buffer memory second time can be set to 0.
303: according to calculate time difference and be in advance this transmit queue setting bandwidth, refresh the leaky bucket that this transmit queue is corresponding;
Particularly, according to calculate time difference and be in advance this transmit queue setting bandwidth, calculate the flow needing to deduct from leaky bucket corresponding to this transmit queue, from the leaky bucket that this transmit queue is corresponding, deduct the flow calculated, so achieve the leaky bucket corresponding to this transmit queue and refresh.
Optionally, the time difference of calculating and the bandwidth arranged for this transmit queue in advance can be done product calculation, obtain the flow needing to deduct from leaky bucket corresponding to this transmit queue.
304: obtain the flow that leaky bucket corresponding to this transmit queue is refreshed rear storage, if exceed default Second Threshold, then perform 305:
Such as, before the first packet is gone out team from this transmit queue, the flux scale stored in the leaky bucket that this transmit queue is corresponding is designated as old_leakybucket; When to be gone out group from this transmit queue by the first packet, the flux scale added in the leaky bucket that this transmit queue is corresponding is designated as addflow; After first packet is gone out team from this transmit queue, when refreshing leaky bucket corresponding to this transmit queue, the flux scale deducted from the leaky bucket of this transmit queue is designated as decreaseflow.Then calculate according to following formula (2) the flow new_leakybucket that leaky bucket corresponding to this transmit queue is refreshed rear storage:
new_leakybucket=old_leakybucket+addflow-decreaseflow……(2)
If the flow new_leakybucket after refreshing is greater than default Second Threshold, then perform 305.Wherein, the Second Threshold preset can be greater than 0.
Further, old_leakybucket can be upgraded with the numerical value of new_leakybucket.
Wherein, if token amount new_leakybucket is less than or equal to default Second Threshold after refreshing, then, when this transmit queue is scheduled again and go out group packet from this transmit queue, returns 301 and restart to carry out.
305: the state dispatch state of this transmit queue being set to non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.
Particularly, the dispatch state of this transmit queue is set to the state of non-scheduling, and starts timing, when the time of timing reaches the default time, the dispatch state of this transmit queue is set to schedulable state.
Wherein, after the dispatch state of this transmit queue being set to the state of non-scheduling, scheduler cannot dispatch this transmit queue, so that cannot go out group packet from this transmit queue, traffic shaping module also cannot add flow in leaky bucket corresponding to this transmit queue.After the dispatch state of this transmit queue is set to schedulable state, the device scheduling if this transmit queue is scheduled again also, when going out group packet from this transmit queue, can return execution 301.
Optionally, k bit can be reserved for identifying dispatch state in this transmit queue, k be more than or equal to 1 integer.
Wherein, for each transmit queue in the memory of communication process chip, all press the flow process of above-mentioned 301-305, just refresh leaky bucket corresponding to transmit queue when packet to go out group from transmit queue.
Wherein, the memory of communication process chip is owing to being subject to the restriction of access bandwidth, allow out the number of the transmit queue of group packet to be less than or equal to the number of times of memory permission each second access in each second, and in the present invention, when going out group packet from transmit queue, the leaky bucket corresponding to the transmit queue going out group packet refreshes, therefore the number of times carrying out refreshing per second with per second go out the number of times of group packet identical, the number of times of refreshing leaky bucket per second is made to be less than or equal to the memory number of times allowing access per second, and the number of times refreshing leaky bucket is by the restriction of the number of the transmit queue in the restriction of access bandwidth of memory and memory, thus significantly reduce the refreshing frequency of leaky bucket, therefore, as long as each transmit queue in memory carries out data contract out team, just can flush to each transmit queue in memory.
In embodiments of the present invention, the first packet goes out team from transmit queue, and the flow according to the first packet adds flow to the leaky bucket that this transmit queue is corresponding; Calculate the time difference of the very first time and the second time, the very first time is the time going out team first packet from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, second packet is that the first packet goes out from this transmit queue the packet that the last time before team goes out team, according to the time difference calculated and in advance for the bandwidth meter of this transmit queue setting calculates the flow needing to deduct, deduct the flow of calculating from the leaky bucket that this transmit queue is corresponding.Because the team that goes out of packet all will according to leaky bucket with transmission, therefore, the method provided according to the embodiment of the present invention carries out the refreshing of leaky bucket, just can reduce the number of times and frequency that refresh leaky bucket corresponding to each transmit queue, realize traffic shaping.
Embodiment 4
As shown in figure 13, embodiments provide a kind of equipment of traffic shaping, comprising:
Go out group module 401, for the first packet is gone out team from transmit queue;
Refresh module 402, for according to the very first time, the second time and in advance for this transmit queue arrange bandwidth refresh token bucket corresponding to this transmit queue, the very first time is described first packet goes out team time from this transmit queue, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team.
Optionally, as shown in figure 14, refresh module 402 comprises:
First computing unit 4021, for calculating the time difference of the very first time and the second time;
Second computing unit 4022, the time difference calculated for basis and the bandwidth meter arranged for this transmit queue in advance calculate the token amount needing to add to the token bucket that this transmit queue is corresponding;
First refresh unit 4023, for adding token, to refresh token bucket corresponding to this transmit queue according to the token amount calculated to the token bucket that this transmit queue is corresponding.
Optionally, as shown in figure 15, this equipment also comprises:
First computing module 503, for according to the first token amount, the second token amount and the 3rd token amount, calculate token bucket corresponding to this transmit queue be refreshed after token amount; Wherein, the first token amount is before the first packet goes out team from this transmit queue, the token amount in the token bucket that this transmit queue is corresponding; Second token amount is when to be the first packet to go out group from this transmit queue, the token amount deducted from the token bucket that this transmit queue is corresponding; 3rd token amount is the token amount that described needs add to the token bucket that this transmit queue is corresponding.
Further alternatively, (for easy, illustrate only following two simultaneous situations of module in figure) as shown in figure 16, this equipment also comprises:
First arranges mould 504 pieces, if the token amount being refreshed rear storage for the token bucket that this transmit queue is corresponding is less than default first threshold, then the dispatch state of this transmit queue is set to the state of non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.And/or
First update module 505, the numerical value of the token amount after the token bucket for utilizing this transmit queue of calculating corresponding is refreshed, upgrades the first token amount.
Optionally, as shown in figure 17, refresh module 402 comprises:
3rd computing unit 4024, for calculating the time difference of the very first time and the second time;
4th computing unit 4025, for according to the time difference calculated be the bandwidth of this transmit queue setting in advance, calculates the flow that needs deduct from leaky bucket corresponding to this transmit queue;
Second refresh unit 4026, for deducting the flow calculated, to refresh leaky bucket corresponding to this transmit queue from leaky bucket corresponding to this transmit queue.
Optionally, as shown in figure 18, this equipment also comprises:
Second computing module 603, for according to first flow, the second flow and the 3rd flow, calculate leaky bucket corresponding to this transmit queue be refreshed after flow; Wherein, first flow is before team first packet goes out from this transmit queue, the flow in the leaky bucket that this transmit queue is corresponding; Second flow is when to be the first packet to go out group from this transmit queue, the flow added in the leaky bucket that this transmit queue is corresponding; 3rd flow is the flow needing to deduct from leaky bucket corresponding to this transmit queue.
Further alternatively, (for easy, illustrate only following two simultaneous situations of module in figure) as shown in figure 19, this equipment also comprises:
Second arranges module 604, if be greater than default Second Threshold for the flow after the leaky bucket that this transmit queue is corresponding is refreshed, then the dispatch state of this transmit queue is set to the state of non-scheduling, and after a preset amount of time the dispatch state of this transmit queue is set to schedulable state.And/or
Second update module 605, the numerical value of the flow after the leaky bucket for utilizing this transmit queue of calculating corresponding is refreshed, upgrades first flow.
Optionally, as shown in figure 20, this equipment also comprises:
3rd update module 403, for utilizing the numerical value of the very first time, upgraded for the second time.
In embodiments of the present invention, first packet goes out team from transmit queue, and according to the very first time, the second time and in advance for this transmit queue arrange bandwidth refresh token bucket corresponding to this transmit queue or leaky bucket, the very first time is the time going out team from this transmit queue of the first packet, second time was that the second packet goes out the time of team from this transmit queue, second packet is before the first packet goes out team from this transmit queue, and the last time goes out the packet of team.Because the team that goes out of packet all will according to token bucket or leaky bucket with transmission, therefore, the equipment provided according to the embodiment of the present invention carries out the refreshing of token bucket or leaky bucket, just can reduce the number of times and frequency that refresh token bucket corresponding to each transmit queue or leaky bucket, realize traffic shaping.
It should be noted that: the equipment of a kind of traffic shaping that above-described embodiment provides is when refreshing token bucket corresponding to transmit queue or leaky bucket, only be illustrated with the division of above-mentioned each functional module, in practical application, can distribute as required and by above-mentioned functions and be completed by different functional modules, internal structure by equipment is divided into different functional modules, to complete all or part of function described above.In addition, above-described embodiment provides the equipment of traffic shaping and the embodiment of the method for traffic shaping to belong to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
One of ordinary skill in the art will appreciate that all or part of step realizing above-described embodiment can have been come by hardware, the hardware that also can carry out instruction relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium mentioned can be read-only memory, disk or CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.