Traffic evaluation and token buckets
Token bucket features
A token bucket is analogous to a container that holds a certain number of tokens. Each token represents a certain forwarding capacity. The system puts tokens into the bucket at a constant rate. When the token bucket is full, the extra tokens cause the token bucket to overflow.
Evaluating traffic with the token bucket
A token bucket mechanism evaluates traffic by looking at the number of tokens in the bucket. If the number of tokens in the bucket is enough for forwarding the packets:
The traffic conforms to the specification (called conforming traffic).
The corresponding tokens are taken away from the bucket.
Otherwise, the traffic does not conform to the specification (called excess traffic).
A token bucket has the following configurable parameters:
Mean rate at which tokens are put into the bucket, which is the permitted average rate of traffic. It is usually set to the committed information rate (CIR).
Burst size or the capacity of the token bucket. It is the maximum traffic size permitted in each burst. It is usually set to the committed burst size (CBS). The set burst size must be greater than the maximum packet size.
Each arriving packet is evaluated.
Complicated evaluation
You can set two token buckets, bucket C and bucket E, to evaluate traffic in a more complicated environment and achieve more policing flexibility. For example, traffic policing uses the following mechanisms:
Single rate two color—Uses one token bucket and the following parameters:
CIR—Rate at which tokens are put into bucket C. It sets the average packet transmission or forwarding rate allowed by bucket C.
CBS—Size of bucket C, which specifies the transient burst of traffic that bucket C can forward.
When a packet arrives, the following rules apply:
If bucket C has enough tokens to forward the packet, the packet is colored green.
Otherwise, the packet is colored red.
Single rate three color—Uses two token buckets and the following parameters:
CIR—Rate at which tokens are put into bucket C. It sets the average packet transmission or forwarding rate allowed by bucket C.
CBS—Size of bucket C, which specifies the transient burst of traffic that bucket C can forward.
EBS—Size of bucket E minus size of bucket C, which specifies the transient burst of traffic that bucket E can forward. The EBS cannot be 0. The size of E bucket is the sum of the CBS and EBS.
When a packet arrives, the following rules apply:
If bucket C has enough tokens, the packet is colored green.
If bucket C does not have enough tokens but bucket E has enough tokens, the packet is colored yellow.
If neither bucket C nor bucket E has sufficient tokens, the packet is colored red.
Two rate three color—Uses two token buckets and the following parameters:
CIR—Rate at which tokens are put into bucket C. It sets the average packet transmission or forwarding rate allowed by bucket C.
CBS—Size of bucket C, which specifies the transient burst of traffic that bucket C can forward.
PIR—Rate at which tokens are put into bucket E, which specifies the average packet transmission or forwarding rate allowed by bucket E.
EBS—Size of bucket E, which specifies the transient burst of traffic that bucket E can forward.
When a packet arrives, the following rules apply:
If bucket C has enough tokens, the packet is colored green.
If bucket C does not have enough tokens but bucket E has enough tokens, the packet is colored yellow.
If neither bucket C nor bucket E has sufficient tokens, the packet is colored red.