next up previous contents
Next: Implementation limitations Up: Buckets Previous: Buckets   Contents

Metering primitives

The following metering primitives are available:

conform bucket
if the token bucket contains enough tokens for the current packet, conform returns 1, otherwise it returns 0.
count bucket
subtracts tokens for the current packet from the specified token bucket. If not enough tokens are available, count sets the bucket size to zero. count always returns 1.

The metering primitives can be used like any Boolean expression.

Examples:

// Typical two-rate meter

$p1 = bucket(rate 1Mbps,burst 20kB);
$p2 = bucket(rate 2Mbps,burst 2kB);

prio {
    class if conform $p1 && conform $p2 && count $p1 && count $p2;
    class if conform $p2 && count $p2;
    class if 1;
}

// Rate limiter

$p = bucket(rate 50kbps,burst 3kB,mpu 200B);

ingress {
    class (1) if conform $p && count $p;
    drop if 1;
}



Martin A. Brown 2003-11-06