Click
Loading...
Searching...
No Matches
Classes | Typedefs
tokenbucket.hh File Reference

Token bucket rate limiter templates. More...

#include <click/timestamp.hh>
#include <click/bigint.hh>

Go to the source code of this file.

Classes

class  TokenRateX< P >
 Token bucket rate template. More...
 
class  TokenCounterX< R >
 Token bucket counter template. More...
 
class  TokenBucketJiffyParameters< T >
 Helper class for token bucket rate limiter. More...
 
class  TokenBucketUsecParameters< T >
 Helper class for token bucket rate limiter. More...
 
class  TokenBucketX< P >
 Token bucket rate limiter. More...
 

Typedefs

typedef TokenRateX< TokenBucketUsecParameters< unsigned long long > > TokenRate
 
typedef TokenCounterX< TokenRate > TokenCounter
 
typedef TokenBucketX< TokenBucketUsecParameters< unsigned long long > > TokenBucket
 

Detailed Description

Token bucket rate limiter templates.

>

Related template classes that support token bucket rate limiters.

The TokenRateX template class represents a token bucket rate: a refill I<rate> in tokens per period, plus a I<capacity>, the maximum number of tokens allowed to accumulate.

The TokenCounterX template class represents an active count of tokens. Member functions are provided to update the count according to a particular TokenRateX argument. The counter will fill up with tokens according to the given rate, to a maximum of the capacity.

A TokenRateX object's state depends only on the rate and capacity, and thus may be shared by several distinct TokenCounterX objects. But for the common case that a single counter is paired with a unique rate, the TokenBucketX template class combines a TokenRateX and a TokenCounterX.

The token bucket templates divide time into discrete units called I<ticks>. Token counters are refilled up to once per tick. A tick may be less than a full period. For example, if periods and ticks are 1 second and 1 millisecond, respectively, then a TokenCounterX with associated rate 1000 tokens per second would be refilled at 1 token per millisecond. The TokenRateX template parameter P defines the time tick unit and frequency. The provided TokenBucketJiffyParameters class is designed to be used as TokenRateX's parameter; it measures ticks in units of jiffies. TokenBucketUsecParameters is also included, which measures ticks in units of microseconds.

See also
GapRate