Blame man/man8/tc-sample.8

Packit d3f73b
.TH "Packet sample action in tc" 8 "31 Jan 2017" "iproute2" "Linux"
Packit d3f73b
Packit d3f73b
.SH NAME
Packit d3f73b
sample - packet sampling tc action
Packit d3f73b
.SH SYNOPSIS
Packit d3f73b
.in +8
Packit d3f73b
.ti -8
Packit d3f73b
Packit d3f73b
.BR tc " ... " "action sample rate"
Packit d3f73b
.I RATE
Packit d3f73b
.BR "group"
Packit d3f73b
.I GROUP
Packit d3f73b
.RB "[ " trunc
Packit d3f73b
.IR SIZE " ] "
Packit d3f73b
.RB "[ " index
Packit d3f73b
.IR INDEX " ] "
Packit d3f73b
.ti -8
Packit d3f73b
Packit d3f73b
.BR tc " ... " "action sample index "
Packit d3f73b
.I INDEX
Packit d3f73b
.ti -8
Packit d3f73b
Packit d3f73b
.SH DESCRIPTION
Packit d3f73b
The
Packit d3f73b
.B sample
Packit d3f73b
action allows sampling packets matching classifier.
Packit d3f73b
Packit d3f73b
The packets are chosen randomly according to the
Packit d3f73b
.B rate
Packit d3f73b
parameter, and are sampled using the
Packit d3f73b
.B psample
Packit d3f73b
generic netlink channel. The user can also specify packet truncation to save
Packit d3f73b
user-kernel traffic. Each sample includes some informative metadata about the
Packit d3f73b
original packet, which is sent using netlink attributes, alongside the original
Packit d3f73b
packet data.
Packit d3f73b
Packit d3f73b
The user can either specify the sample action parameters as presented in the
Packit d3f73b
first form above, or use an existing sample action using its index, as presented
Packit d3f73b
in the second form.
Packit d3f73b
Packit d3f73b
.SH SAMPLED PACKETS METADATA FIELDS
Packit d3f73b
The metadata are delivered to userspace applications using the
Packit d3f73b
.B psample
Packit d3f73b
generic netlink channel, where each sample includes the following netlink
Packit d3f73b
attributes:
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_IIFINDEX
Packit d3f73b
The input interface index of the packet, if there is one.
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_OIFINDEX
Packit d3f73b
The output interface index of the packet. This field is not relevant on ingress
Packit d3f73b
sampling
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_ORIGSIZE
Packit d3f73b
The size of the original packet (before truncation)
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_SAMPLE_GROUP
Packit d3f73b
The
Packit d3f73b
.B psample
Packit d3f73b
group the packet was sent to
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_GROUP_SEQ
Packit d3f73b
A sequence number of the sampled packet. This number is incremented with each
Packit d3f73b
sampled packet of the current
Packit d3f73b
.B psample
Packit d3f73b
group
Packit d3f73b
.TP
Packit d3f73b
.BI PSAMPLE_ATTR_SAMPLE_RATE
Packit d3f73b
The rate the packet was sampled with
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
.SH OPTIONS
Packit d3f73b
.TP
Packit d3f73b
.BI rate " RATE"
Packit d3f73b
The packet sample rate.
Packit d3f73b
.I "RATE"
Packit d3f73b
is the expected ratio between observed packets and sampled packets. For example,
Packit d3f73b
.I "RATE"
Packit d3f73b
of 100 will lead to an average of one sampled packet out of every 100 observed.
Packit d3f73b
.TP
Packit d3f73b
.BI trunc " SIZE"
Packit d3f73b
Upon set, defines the maximum size of the sampled packets, and causes truncation
Packit d3f73b
if needed
Packit d3f73b
.TP
Packit d3f73b
.BI group " GROUP"
Packit d3f73b
The
Packit d3f73b
.B psample
Packit d3f73b
group the packet will be sent to. The
Packit d3f73b
.B psample
Packit d3f73b
module defines the concept of groups, which allows the user to match specific
Packit d3f73b
sampled packets in the case of multiple sampling rules, thus identify only the
Packit d3f73b
packets that came from a specific rule.
Packit d3f73b
.TP
Packit d3f73b
.BI index " INDEX"
Packit d3f73b
Is a unique ID for an action. When creating new action instance, this parameter
Packit d3f73b
allows to set the new action index. When using existing action, this parameter
Packit d3f73b
allows to specify the existing action index.  The index must 32bit unsigned
Packit d3f73b
integer greater than zero.
Packit d3f73b
.SH EXAMPLES
Packit d3f73b
Sample one of every 100 packets flowing into interface eth0 to psample group 12:
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: matchall \\
Packit d3f73b
     action sample rate 100 group 12 index 19
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
Use the same action instance to sample eth1 too:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
tc qdisc add dev eth1 handle ffff: ingress
Packit d3f73b
tc filter add dev eth1 parent ffff: matchall \\
Packit d3f73b
     action sample index 19
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
.SH SEE ALSO
Packit d3f73b
.BR tc (8),
Packit d3f73b
.BR tc-matchall (8)
Packit d3f73b
.BR psample (1)