On Wed, 21 Apr 2004, Fighting_the_war wrote:

> I've read the book from www.squid-cache.org and the book "Squid: The
> definitve guide" and FAQ of squid. But I can't understand the way how delay
> pools does it's jobs.
> I think the definition "bucket" have no mean in bandwidth shaping. In those
> books, it only is a threshold for squid to start it's bandwidth shaping.
> Anyone can tell me the way squid technically does bandwidth control?

The available bandwidth (measured in bytes) is monitored by Squid in
buckets. Each second Squid puts the configured amount of bytes into the
bucket, and if it overflows the configured limit the excess bytes are
thrown away.

Then when the user causes Internet traffic, the amount of bytes the user
have retreived from the Internet is substracted from his bucket of bytes.
When the bucket reaches 0 no more data is sent to the client until the
bucket has been refilled by Squid.

If there is multiple users contending for bytes in the same bucket Squid
tries to distribute the available bandwidth of that bucket more or less
fair among the contending users.

Depending on which delay pool class there may be 0 to 3 buckets involved.
The available bandwidth to the user is the least of all involved buckets,
and any delivered bandwidth is substracted from all involved buckets.

0, no delay pool assigned
1, a class 1 pool with a single bucket shared by all users of the pool
2, a class 2 pool with one global bucket shared by all and in addition
one bucket per user.
3, a class 3 pool. one global bucket shared by all users, one network
bucket per class C network, and one bucket per user.