Blame man/man8/tc-police.8

Packit d3f73b
.TH "Policing action in tc" 8 "20 Jan 2015" "iproute2" "Linux"
Packit d3f73b
Packit d3f73b
.SH NAME
Packit d3f73b
police - policing action
Packit d3f73b
.SH SYNOPSIS
Packit d3f73b
.in +8
Packit d3f73b
.ti -8
Packit d3f73b
.BR tc " ... " "action police"
Packit d3f73b
.BI rate " RATE " burst
Packit d3f73b
.IR BYTES [\fB/ BYTES "] ["
Packit d3f73b
.B mtu
Packit d3f73b
.IR BYTES [\fB/ BYTES "] ] ["
Packit d3f73b
.BI peakrate " RATE"
Packit d3f73b
] [
Packit d3f73b
.BI overhead " BYTES"
Packit d3f73b
] [
Packit d3f73b
.BI linklayer " TYPE"
Packit d3f73b
] [
Packit d3f73b
.IR CONTROL " ]"
Packit d3f73b
Packit d3f73b
.ti -8
Packit d3f73b
.BR tc " ... " filter " ... [ " estimator
Packit d3f73b
.IR "SAMPLE AVERAGE " ]
Packit d3f73b
.BR "action police avrate"
Packit d3f73b
.IR RATE " [ " CONTROL " ]"
Packit d3f73b
Packit d3f73b
.ti -8
Packit d3f73b
.IR CONTROL " :="
Packit d3f73b
.BI conform-exceed " EXCEEDACT\fR[\fB/\fINOTEXCEEDACT"
Packit d3f73b
Packit d3f73b
.ti -8
Packit d3f73b
.IR EXCEEDACT/NOTEXCEEDACT " := { "
Packit d3f73b
.BR pipe " | " ok " | " reclassify " | " drop " | " continue " | " goto " " chain " " CHAIN_INDEX " }"
Packit d3f73b
.SH DESCRIPTION
Packit d3f73b
The
Packit d3f73b
.B police
Packit d3f73b
action allows to limit bandwidth of traffic matched by the filter it is
Packit d3f73b
attached to. Basically there are two different algorithms available to measure
Packit d3f73b
the packet rate: The first one uses an internal dual token bucket and is
Packit d3f73b
configured using the
Packit d3f73b
.BR rate ", " burst ", " mtu ", " peakrate ", " overhead " and " linklayer
Packit d3f73b
parameters. The second one uses an in-kernel sampling mechanism. It can be
Packit d3f73b
fine-tuned using the
Packit d3f73b
.B estimator
Packit d3f73b
filter parameter.
Packit d3f73b
.SH OPTIONS
Packit d3f73b
.TP
Packit d3f73b
.BI rate " RATE"
Packit d3f73b
The maximum traffic rate of packets passing this action. Those exceeding it will
Packit d3f73b
be treated as defined by the
Packit d3f73b
.B conform-exceed
Packit d3f73b
option.
Packit d3f73b
.TP
Packit d3f73b
.BI burst " BYTES\fR[\fB/\fIBYTES\fR]"
Packit d3f73b
Set the maximum allowed burst in bytes, optionally followed by a slash ('/')
Packit d3f73b
sign and cell size which must be a power of 2.
Packit d3f73b
.TP
Packit d3f73b
.BI mtu " BYTES\fR[\fB/\fIBYTES\fR]"
Packit d3f73b
This is the maximum packet size handled by the policer (larger ones will be
Packit d3f73b
handled like they exceeded the configured rate). Setting this value correctly
Packit d3f73b
will improve the scheduler's precision.
Packit d3f73b
Value formatting is identical to
Packit d3f73b
.B burst
Packit d3f73b
above. Defaults to unlimited.
Packit d3f73b
.TP
Packit d3f73b
.BI peakrate " RATE"
Packit d3f73b
Set the maximum bucket depletion rate, exceeding
Packit d3f73b
.BR rate .
Packit d3f73b
.TP
Packit d3f73b
.BI avrate " RATE"
Packit d3f73b
Make use of an in-kernel bandwidth rate estimator and match the given
Packit d3f73b
.I RATE
Packit d3f73b
against it.
Packit d3f73b
.TP
Packit d3f73b
.BI overhead " BYTES"
Packit d3f73b
Account for protocol overhead of encapsulating output devices when computing
Packit d3f73b
.BR rate " and " peakrate .
Packit d3f73b
.TP
Packit d3f73b
.BI linklayer " TYPE"
Packit d3f73b
Specify the link layer type.
Packit d3f73b
.I TYPE
Packit d3f73b
may be one of
Packit d3f73b
.B ethernet
Packit d3f73b
(the default),
Packit d3f73b
.BR atm " or " adsl
Packit d3f73b
(which are synonyms). It is used to align the precomputed rate tables to ATM
Packit d3f73b
cell sizes, for
Packit d3f73b
.B ethernet
Packit d3f73b
no action is taken.
Packit d3f73b
.TP
Packit d3f73b
.BI estimator " SAMPLE AVERAGE"
Packit d3f73b
Fine-tune the in-kernel packet rate estimator.
Packit d3f73b
.IR SAMPLE " and " AVERAGE
Packit d3f73b
are time values and control the frequency in which samples are taken and over
Packit d3f73b
what timespan an average is built.
Packit d3f73b
.TP
Packit d3f73b
.BI conform-exceed " EXCEEDACT\fR[\fB/\fINOTEXCEEDACT\fR]"
Packit d3f73b
Define how to handle packets which exceed or conform the
Packit d3f73b
configured bandwidth limit. Possible values are:
Packit d3f73b
.RS
Packit d3f73b
.IP continue
Packit d3f73b
Don't do anything, just continue with the next action in line.
Packit d3f73b
.IP drop
Packit d3f73b
Drop the packet immediately.
Packit d3f73b
.IP shot
Packit d3f73b
This is a synonym to
Packit d3f73b
.BR drop .
Packit d3f73b
.IP ok
Packit d3f73b
Accept the packet. This is the default for conforming packets.
Packit d3f73b
.IP pass
Packit d3f73b
This is a synonym to
Packit d3f73b
.BR ok .
Packit d3f73b
.IP reclassify
Packit d3f73b
Treat the packet as non-matching to the filter this action is attached to and
Packit d3f73b
continue with the next filter in line (if any). This is the default for
Packit d3f73b
exceeding packets.
Packit d3f73b
.IP pipe
Packit d3f73b
Pass the packet to the next action in line.
Packit d3f73b
.SH EXAMPLES
Packit d3f73b
A typical application of the police action is to enforce ingress traffic rate
Packit d3f73b
by dropping exceeding packets. Although better done on the sender's side,
Packit d3f73b
especially in scenarios with lack of peer control (e.g. with dial-up providers)
Packit d3f73b
this is often the best one can do in order to keep latencies low under high
Packit d3f73b
load. The following establishes input bandwidth policing to 1mbit/s using the
Packit d3f73b
.B ingress
Packit d3f73b
qdisc and
Packit d3f73b
.B u32
Packit d3f73b
filter:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
# tc qdisc add dev eth0 handle ffff: ingress
Packit d3f73b
# tc filter add dev eth0 parent ffff: u32 \\
Packit d3f73b
	match u32 0 0 \\
Packit d3f73b
	police rate 1mbit burst 100k
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
As an action can not live on it's own, there always has to be a filter involved as link between qdisc and action. The example above uses
Packit d3f73b
.B u32
Packit d3f73b
for that, which is configured to effectively match any packet (passing it to the
Packit d3f73b
.B police
Packit d3f73b
action thereby).
Packit d3f73b
Packit d3f73b
.SH SEE ALSO
Packit d3f73b
.BR tc (8)