{"id":2780,"date":"2022-12-20T15:17:17","date_gmt":"2022-12-20T18:17:17","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/policing-action-in-tc-man8\/"},"modified":"2022-12-20T15:17:17","modified_gmt":"2022-12-20T18:17:17","slug":"policing-action-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/policing-action-in-tc-man8\/","title":{"rendered":"Policing action in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">Policing action in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">police &#8211; policing action<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc<\/b> &#8230; <b>action police [ rate<\/b> <i>RATE<\/i> <b>burst<\/b> <i>BYTES<\/i>[<b>\/<\/b><i>BYTES<\/i>] ] [ <b>pkts_rate<\/b> <i>RATE<\/i> <b>pkts_burst<\/b> <i>PACKETS<\/i>] [ <b>mtu<\/b> <i>BYTES<\/i>[<b>\/<\/b><i>BYTES<\/i>] ] [ <b>peakrate<\/b> <i>RATE<\/i> ] [ <b>overhead<\/b> <i>BYTES<\/i> ] [ <b>linklayer<\/b> <i>TYPE<\/i> ] [ <i>CONTROL<\/i> ]<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc<\/b> &#8230; <b>filter<\/b> &#8230; [ <b>estimator<\/b> <i>SAMPLE AVERAGE<\/i> ] <b>action police avrate<\/b> <i>RATE<\/i> [ <i>CONTROL<\/i> ]<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>CONTROL<\/i> := <b>conform-exceed<\/b> <i>EXCEEDACT<\/i>[<b>\/<\/b><i>NOTEXCEEDACT<\/i><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>EXCEEDACT\/NOTEXCEEDACT<\/i> := { <b>pipe<\/b> | <b>ok<\/b> | <b>reclassify<\/b> | <b>drop<\/b> | <b>continue<\/b> | <b>goto chain CHAIN_INDEX<\/b> }<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>police<\/b> action allows limiting of the byte or packet rate of traffic matched by the filter it is attached to.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There are two different algorithms available to measure the byte rate: The first one uses an internal dual token bucket and is configured using the <b>rate<\/b>, <b>burst<\/b>, <b>mtu<\/b>, <b>peakrate<\/b>, <b>overhead<\/b> and <b>linklayer<\/b> parameters. The second one uses an in-kernel sampling mechanism. It can be fine-tuned using the <b>estimator<\/b> filter parameter.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There is one algorithm available to measure packet rate and it is similar to the first algorithm described for byte rate. It is configured using the <b>pkt_rate<\/b> and <b>pkt_burst<\/b> parameters.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">At least one of the <b>rate<\/b> and <b>pkt_rate<\/b> parameters must be configured.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>rate<\/b> <i>RATE<\/i><\/p>\n<p style=\"margin-left:22%;\">The maximum byte rate of packets passing this action. Those exceeding it will be treated as defined by the <b>conform-exceed<\/b> option.<\/p>\n<p style=\"margin-left:11%;\"><b>burst<\/b> <i>BYTES<\/i>[<b>\/<\/b><i>BYTES<\/i>]<\/p>\n<p style=\"margin-left:22%;\">Set the maximum allowed burst in bytes, optionally followed by a slash (\u2019\/\u2019) sign and cell size which must be a power of 2.<\/p>\n<p style=\"margin-left:11%;\"><b>pkt_rate<\/b> <i>RATE<\/i><\/p>\n<p style=\"margin-left:22%;\">The maximum packet rate or packets passing this action. Those exceeding it will be treated as defined by the <b>conform-exceed<\/b> option.<\/p>\n<p style=\"margin-left:11%;\"><b>pkt_burst<\/b> <i>PACKETS<\/i><\/p>\n<p style=\"margin-left:22%;\">Set the maximum allowed burst in packets.<\/p>\n<p style=\"margin-left:11%;\"><b>mtu<\/b> <i>BYTES<\/i>[<b>\/<\/b><i>BYTES<\/i>]<\/p>\n<p style=\"margin-left:22%;\">This is the maximum packet size handled by the policer (larger ones will be handled like they exceeded the configured rate). Setting this value correctly will improve the scheduler\u2019s precision. Value formatting is identical to <b>burst<\/b> above. Defaults to unlimited.<\/p>\n<p style=\"margin-left:11%;\"><b>peakrate<\/b> <i>RATE<\/i><\/p>\n<p style=\"margin-left:22%;\">Set the maximum bucket depletion rate, exceeding <b>rate<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>avrate<\/b> <i>RATE<\/i><\/p>\n<p style=\"margin-left:22%;\">Make use of an in-kernel bandwidth rate estimator and match the given <i>RATE<\/i> against it.<\/p>\n<p style=\"margin-left:11%;\"><b>overhead<\/b> <i>BYTES<\/i><\/p>\n<p style=\"margin-left:22%;\">Account for protocol overhead of encapsulating output devices when computing <b>rate<\/b> and <b>peakrate<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>linklayer<\/b> <i>TYPE<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify the link layer type. <i>TYPE<\/i> may be one of <b>ethernet<\/b> (the default), <b>atm<\/b> or <b>adsl<\/b> (which are synonyms). It is used to align the precomputed rate tables to ATM cell sizes, for <b>ethernet<\/b> no action is taken.<\/p>\n<p style=\"margin-left:11%;\"><b>estimator<\/b> <i>SAMPLE AVERAGE<\/i><\/p>\n<p style=\"margin-left:22%;\">Fine-tune the in-kernel packet rate estimator. <i>SAMPLE<\/i> and <i>AVERAGE<\/i> are time values and control the frequency in which samples are taken and over what timespan an average is built.<\/p>\n<p style=\"margin-left:11%;\"><b>conform-exceed<\/b> <i>EXCEEDACT<\/i>[<b>\/<\/b><i>NOTEXCEEDACT<\/i>]<\/p>\n<p style=\"margin-left:22%;\">Define how to handle packets which exceed or conform the configured bandwidth limit. Possible values are: <br \/> continue<\/p>\n<p style=\"margin-left:32%;\">Don\u2019t do anything, just continue with the next action in line.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>drop<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>Drop the packet immediately.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>shot<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>This is a synonym to <b>drop<\/b>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>ok<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>Accept the packet. This is the default for conforming packets.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>pass<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>This is a synonym to <b>ok<\/b>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\">reclassify<\/p>\n<p style=\"margin-left:32%;\">Treat the packet as non-matching to the filter this action is attached to and continue with the next filter in line (if any). This is the default for exceeding packets.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p>pipe<\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"66%\">\n<p>Pass the packet to the next action in line.<\/p>\n<\/td>\n<td width=\"2%\"> <\/td>\n<\/tr>\n<\/table>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A typical application of the police action is to enforce ingress traffic rate by dropping exceeding packets. Although better done on the sender\u2019s side, especially in scenarios with lack of peer control (e.g. with dial-up providers) this is often the best one can do in order to keep latencies low under high load. The following establishes input bandwidth policing to 1mbit\/s using the <b>ingress<\/b> qdisc and <b>u32<\/b> filter:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"># tc qdisc add dev eth0 handle ffff: ingress <br \/> # tc filter add dev eth0 parent ffff: u32 <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>match u32 0 0 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>police rate 1mbit burst 100k<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">As an action can not live on it\u2019s own, there always has to be a filter involved as link between qdisc and action. The example above uses <b>u32<\/b> for that, which is configured to effectively match any packet (passing it to the <b>police<\/b> action thereby).<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  police &#8211; policing action <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,134],"class_list":["post-2780","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-police"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=2780"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2780\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=2780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=2780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=2780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}