1 .TH "Packet sample action in tc" 8 "31 Jan 2017" "iproute2" "Linux"
4 sample - packet sampling tc action
9 .BR tc " ... " "action sample rate"
19 .BR tc " ... " "action sample index "
26 action allows sampling packets matching classifier.
28 The packets are chosen randomly according to the
30 parameter, and are sampled using the
32 generic netlink channel. The user can also specify packet truncation to save
33 user-kernel traffic. Each sample includes some informative metadata about the
34 original packet, which is sent using netlink attributes, alongside the original
37 The user can either specify the sample action parameters as presented in the
38 first form above, or use an existing sample action using its index, as presented
41 .SH SAMPLED PACKETS METADATA FIELDS
42 The metadata are delivered to userspace applications using the
44 generic netlink channel, where each sample includes the following netlink
47 .BI PSAMPLE_ATTR_IIFINDEX
48 The input interface index of the packet, if there is one.
50 .BI PSAMPLE_ATTR_OIFINDEX
51 The output interface index of the packet. This field is not relevant on ingress
54 .BI PSAMPLE_ATTR_ORIGSIZE
55 The size of the original packet (before truncation)
57 .BI PSAMPLE_ATTR_SAMPLE_GROUP
60 group the packet was sent to
62 .BI PSAMPLE_ATTR_GROUP_SEQ
63 A sequence number of the sampled packet. This number is incremented with each
64 sampled packet of the current
68 .BI PSAMPLE_ATTR_SAMPLE_RATE
69 The rate the packet was sampled with
75 The packet sample rate.
77 is the expected ratio between observed packets and sampled packets. For example,
79 of 100 will lead to an average of one sampled packet out of every 100 observed.
82 Upon set, defines the maximum size of the sampled packets, and causes truncation
88 group the packet will be sent to. The
90 module defines the concept of groups, which allows the user to match specific
91 sampled packets in the case of multiple sampling rules, thus identify only the
92 packets that came from a specific rule.
95 Is a unique ID for an action. When creating new action instance, this parameter
96 allows to set the new action index. When using existing action, this parameter
97 allows to specify the existing action index. The index must 32bit unsigned
98 integer greater than zero.
100 Sample one of every 100 packets flowing into interface eth0 to psample group 12:
104 tc qdisc add dev eth0 handle ffff: ingress
105 tc filter add dev eth0 parent ffff: matchall \\
106 action sample rate 100 group 12 index 19
110 Use the same action instance to sample eth1 too:
114 tc qdisc add dev eth1 handle ffff: ingress
115 tc filter add dev eth1 parent ffff: matchall \\
116 action sample index 19