Two-Rate Rate-Limits ! 91
Chapter 3: Creating Rate-Limit Profiles
! t = time
! T(t) = number of tokens in token bucket at time t
Two-Rate Rate-Limits
The two-rate rate limiter enables you to build tiered rate-limit services and to
specify different treatments for packets at different rates.
Token buckets control how many packets per second are accepted at each of the
configured rates and provide flexibility in dealing with the bursty nature of data
traffic. At the beginning of each sample period, the two buckets are filled with
tokens based on the configured burst sizes and rates. Traffic is metered to measure
its volume. When traffic is received, if tokens remain in both buckets, one token is
removed from each bucket for every byte of data processed. As long as tokens are
still in the committed burst bucket, the traffic is treated as committed.
When the committed burst token bucket is empty but tokens remain in the peak
burst bucket, traffic is treated as conformed. When the peak burst token bucket is
empty, traffic is treated as exceeded.
Table 9: TCP-friendly One-Rate Rate-Limit Profile Algorithms
Step Result
if not color aware, use green as the
incoming packet color, otherwise use the
actual packet color
if incoming packet color is green
if T(t) > = B
! Packet is colored green
! T(t) is decremented by B
if T(t) < B and CD is incremented by
B ā T(t)
if CD < Extended Burst and T(t) < B
! Packet is colored yellow
! T(t) is decremented by B (allow T(t) < 0, if
necessary)
if CD > = Extended Burst B and T(t) < B
! Packet is colored red
! CD is reset to 0
if incoming packet color is yellow (only
occurs in color-aware operation)
if T(t) < B and CD is incremented
by Bā T(t)
if CD < Extended Burst
! Packet is colored yellow
! T(t) is decremented by B (allow T(t) < 0, if
necessary)
if CD >= Extended Burst
! Packet is colored red
! CD is reset to 0
if incoming packet color is red (only
occurs in color-aware operation)
! Packet is colored red