p Conceptually, tokens accumulate in a bucket at the average .Ar tokenrate , up to the .Ar bucketsize . The driver can dequeue packets as long as there are positive amount of tokens, and the length of the dequeued packet is subtracted from the remaining tokens. Tokens can be negative as a deficit, and packets are not dequeued from the interface queue until the tokens become positive again. The .Ar tokenrate limits the average rate, and the .Ar bucketsize limits the maximum burst size.
p Limiting the burst size is essential to packet scheduling, since the scheduler schedules packets backlogged at the network interface. Limiting the burst size is also needed for drivers which dequeues more packets than they can send and end up with discarding excess packets.
p When the .Ar tokenrate is set to higher than the actual transmission rate, the transmission complete interrupt will trigger the next dequeue. On the other hand, when the .Ar tokenrate is set to lower than the actual transmission rate, the transmission complete interrupt would occur before the tokens become positive. In this case, the next dequeue will be triggered by a timer event. Because the kernel timer has a limited granularity, a larger .Ar bucketsize is required for a higher .Ar tokenrate .
p The .Ar interface parameter is a string of the form .Dq name unit , for example, .Dq en0 .
p The .Ar tokenrate parameter specifies the average rate in bits per second, and .Dq K or .Dq M can be appended to .Ar tokenrate as a short hand of .Dq Kilo-bps or .Dq Mega-bps , respectively. When .Ar tokenrate is omitted, .Nm displays the current parameter values.
p The .Ar bucketsize parameter specifies the bucket size in bytes, and .Dq K can be appended to .Ar bucketsize as a short hand of .Dq Kilo-bytes . When .Ar bucketsize is omitted, .Nm assumes the regulator is driven by transmission complete interrupts and, using heuristics, assigns a small bucket size according to the .Ar tokenrate . When the keyword .Dq auto is given as .Ar bucketsize , .Nm assumes the regulator is driven by the kernel timer, and computes the bucket size from .Ar tokenrate and the kernel clock frequency.
p If the .Fl d flag is passed before an interface name, .Nm will remove the token bucket regulator for the specified interface.
p Optionally, the .Fl a flag may be used instead of an interface name. This flag instructs .Nm to display information about all interfaces in the system. .Sh EXAMPLES To configure a token bucket regulator for the interface en0 with 10Mbps token rate and 8KB bucket size, d -literal -offset indent # tbrconfig en0 10M 8K .Ed
p To rate-limit the interface en0 up to 3Mbps, d -literal -offset indent # tbrconfig en0 3M auto .Ed .Sh SEE ALSO .Xr altq.conf 5 , .Xr altqd 8 .Sh HISTORY The .Nm command first appeared in WIDE/KAME IPv6 protocol stack kit as part of ALTQ tools.