Barrel algorithm

xiaoxiao2021-03-05  45

1. What is a bucket algorithm? The barrel algorithm is a barrel with the length and width of the network communication; the data is not stopped at both ends of communication, this time can be regarded as the length, and from the start How long is the communication now, and the width is of course a network bandwidth; the product of the two can be seen as a barrel with a certain volume. As shown below:

2. Uses

The purpose of the bucket algorithm is to control the traffic volume of the transmitting end.

3. Principle

We assume that this bucket has a length of T (MS), with a wide bandwidth of B (Kbps), then the volume of this bucket:

V = T * b

Starting from a certain time T1, there is data constantly filling this bucket, but if the data is filled is not very fast, the traffic is less than the network bandwidth B, this bucket will always fill out, as shown in the following figure:

As shown in the figure, the volume of this barrel increases over time, from the V1 (B * (T1-T0)) at T1 (B * (T1-T0)) to the V2 (B * (T2-T0)), the volume of the barrel Increase B * (T2-T1), if the actual data traffic is less than this increment within this time, then the bucket always has an idle place, so that the barrel is not full, in this case The bucket algorithm is not controlled to traffic.

If the actual data traffic of the network is large within T2-T1, that is, the data will be filled with this capacity in a short period of time (less than T2-T1), then the bucket sub-algorithm begins to play the role of flow control.

When sending data, you need to detect the available size of the bucket. If the can be used by 0 to be 0 indicates that any data can no longer populate this barrel, you must wait for the barrel to restore to a certain volume before receiving data (we It is assumed to be a bucket of volume); when we recover, we can fill the data to this bucket, but if it is very full, then it must stop waiting for the bucket recovery. The bucket algorithm is to control traffic by hair stop. Of course, if you set the bandwidth setting, the volume of the barrel is bigger, it is not so easy to fill, and you can send data more quickly.

4. Pay attention to the bucket algorithm to pay attention to:

l The maximum volume of the barrel; this is determined by the time, we assume T, this value is also determined to send how much data can you send to the bucket, of course, this time is different in different network environments. Under some network, even if you set a lot, the following socket layers have no way to send faster.

l The use of recovery algorithm; the general bucket needs to wait for a while, if you set a time that makes the network not too long or caused the sudden peak of the data, it is not so important that the data keeps a beating, it is really important.

l This flow control can only be controlled within the physical bandwidth.

转载请注明原文地址:https://www.9cbs.com/read-31771.html

New Post(0)