TC-POLICE(8)
โจ NAME โจ
Okay bestie, this page is all about the police action, the Policing action in tc(8) ๐. It's basically police - policing action ๐
๐ฆ SYNOPSIS ๐ฆ
tc ... action police [ rate RATE burst BYTES[/BYTES] ] [ pkts_rate RATE
pkts_burst PACKETS] [ mtu BYTES[/BYTES] ] [ peakrate RATE ] [
overhead BYTES ] [ linklayer TYPE ] [ CONTROL ]
tc ... filter ... [ estimator SAMPLE AVERAGE ] action police avrate RATE
[ CONTROL ]
CONTROL := conform-exceed EXCEEDACT[/NOTEXCEEDACT
EXCEEDACT/NOTEXCEEDACT := { pipe | ok | reclassify | drop | continue |
goto chain CHAIN_INDEX }
๐ธ DESCRIPTION ๐ธ
Okay so the police action lets you cap how many bytes or packets per second get through the filter it's attached to. It's giving speed limit, but for your network ๐ฆโจ
There are two ways to measure the byte rate, and honestly both are iconic. The first one uses an internal dual token bucket, and you set it up with the rate, burst, mtu, peakrate, overhead and linklayer parameters. The second one uses an in-kernel sampling mechanism, and you can fine-tune it with the estimator filter parameter ๐
There's also one packet-rate algorithm, and it's basically a cousin of the first byte-rate one. You configure it with the pkt_rate and pkt_burst parameters ๐ง
Also, no cap: you have to set at least one of rate and pkt_rate ๐ซถ
๐ OPTIONS ๐
rate RATEโ The max byte rate for packets passing this action. Anything over it gets treated however yourconform-exceedoption says ๐burst BYTES[/BYTES]โ Sets the max allowed burst in bytes. You can optionally add a slash (/) and a cell size, which has to be a power of 2 ๐pkt_rate RATEโ The max packet rate for packets passing this action. Anything over it gets treated however yourconform-exceedoption says ๐pkt_burst PACKETSโ Sets the max allowed burst in packets โจmtu BYTES[/BYTES]โ The biggest packet size the policer will handle. Anything larger gets handled like it exceeded the configured rate ๐ญ Setting this correctly helps the scheduler be more precise. The value formatting is the same asburstabove. It defaults to unlimited ๐ฆpeakrate RATEโ Sets the max bucket depletion rate, which is the rate you're not allowed to go over ๐ฅavrate RATEโ Uses an in-kernel bandwidth rate estimator and matches the givenRATEagainst it ๐overhead BYTESโ Accounts for the protocol overhead of encapsulating output devices when computingrateandpeakrate๐linklayer TYPEโ Specifies the link layer type.TYPEcan beethernet(the default),atmoradsl, which are synonyms for each other. It's used to line up the precomputed rate tables with ATM cell sizes. Forethernet, nothing gets done ๐งestimator SAMPLE AVERAGEโ Fine-tunes the in-kernel packet rate estimator.SAMPLEandAVERAGEare time values. They control how often samples get taken and over what timespan the average gets built ๐ซงconform-exceed EXCEEDACT[/NOTEXCEEDACT]โ Decides what happens to packets that exceed or conform to the bandwidth limit. The possible values are:continueโ Does nothing, just moves on to the next action in line ๐ธdropโ Drops the packet immediately ๐shotโ A synonym fordrop๐okโ Accepts the packet. This is the default for conforming packets ๐passโ A synonym forok๐ซถreclassifyโ Treats the packet as not matching the filter this action is attached to, then continues with the next filter in line (if there is one). This is the default for exceeding packets ๐pipeโ Passes the packet to the next action in line โจ
๐ EXAMPLES ๐
A super typical use of the police action is enforcing your ingress traffic rate by dropping the packets that go over. Ideally you'd do this on the sender's side, especially when you don't have control over the peer (like with dial-up providers). But honestly, when latencies need to stay low under heavy load, this is often the best you can do ๐ญ The following sets input bandwidth policing to 1mbit/s using the ingress qdisc and a u32 filter:
# tc qdisc add dev eth0 handle ffff: ingress
# tc filter add dev eth0 parent ffff: u32 \
match u32 0 0 \
police rate 1mbit burst 100k
Here's the tea: an action can't live on its own. There always has to be a filter involved as the link between the qdisc and the action. The example above uses u32 for that, and it's set up to match basically any packet, which sends it into the police action ๐ง๐
๐ SEE ALSO ๐
tc(8) ๐ฆ
Okay that's the whole tea, bestie ๐ This page came from iproute2, dated 20 Jan 2015, and the manual name is Policing action in tc(8). Go forth and police responsibly ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms