frame rate limiting per day/minute not working (bug ?)
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______
this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "ping_ip4 from LAN > rate_limit_d DROP: " drop;
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/day
frames # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
A somewhat inconsistent behaviour with x/minute value, e.g.
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 13/minute } log flags all prefix "ping_ip4 from LAN > rate_limit_d DROP: " drop;
produces on the client side:
ping -4 -n 20 google.com
Pinging google.com [216.58.208.110] with 32 bytes of data:
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=15ms TTL=114 Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=154ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=32ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114
Ping statistics for 216.58.208.110:
Packets: Sent = 20, Received = 14, Lost = 6 (30% loss), Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 154ms, Average = 26ms
Whilst the count is matching the rule it is not clear why not all 13 initial frames are passing through consistently and the excess being dropped consistently but instead the first being dropped is earlier?
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;
Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Quoted 41 lines
A somewhat inconsistent behaviour with x/minute value, e.g.
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 13/minute } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;produces on the client side:
ping -4 -n 20 google.com
Pinging google.com [216.58.208.110] with 32 bytes of data:
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=15ms TTL=114 Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=154ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=32ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114Ping statistics for 216.58.208.110:
Packets: Sent = 20, Received = 14, Lost = 6 (30% loss),
Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 154ms, Average = 26msWhilst the count is matching the rule it is not clear why not all 13 initial frames are passing through consistently and the excess being dropped consistently but instead the first being dropped is earlier?
Signature · 1 line
Kerin Millar
Quoted 18 lines · On 24/11/2020 23:08, [email protected] wrote:
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
Quoted 8 lines
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Thank you for your valuable thoughts. I am not sure however that the default bust limit is the cause here, for two reasons:
the outcome is the same with:
limit rate over 44/day
limit rate over 300/day
and should not be however. The other reason is that it should be the same outcome with limit rate over X/minute but it is not.
Quoted 43 lines
Quoted 42 lines
A somewhat inconsistent behaviour with x/minute value, e.g.
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 13/minute } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;produces on the client side:
ping -4 -n 20 google.com
Pinging google.com [216.58.208.110] with 32 bytes of data:
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=15ms TTL=114 Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=154ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=32ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114Ping statistics for 216.58.208.110:
Packets: Sent = 20, Received = 14, Lost = 6 (30% loss), Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 154ms, Average = 26msWhilst the count is matching the rule it is not clear why not all 13 initial frames are passing through consistently and the excess being dropped consistently but instead the first being dropped is earlier?
Quoted 24 lines · ѽ҉ᶬḳ℠
Quoted 23 lines · On 24/11/2020 23:08, [email protected] wrote:
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Quoted 6 lines
Quoted 3 lines
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Thank you for your valuable thoughts. I am not sure however that the default bust limit is the cause here, for two reasons:
It explains the cause of the initial five packets being permitted before running up against any limit. Given 2 as a numerator, try with lower burst values.
Take "2/min burst 1 packets" as an example. The bucket will have a capacity of just one token and will be initialised with one upon loading the ruleset. The bucket will be topped up with one token every 30 seconds, but never beyond its capacity. The result should be that one packet is allowed to pass at rigid 30 second intervals.
Specifying "2/min burst 2 packets" will result in the bucket being initialised with - and having a capacity of - two tokens. Within the first 30 second delta, it will be possible for two packets to pass before the limit applies. Still, the bucket is topped up at the same rate of one token every 30 seconds.
Quoted 4 lines
the outcome is the same with:
limit rate over 44/day
On average, this should allow for 44 a day by recharging the bucket at a rate of one token every 24/44*60 = 32.73 minutes.
Quoted 1 line
limit rate over 300/day
In this case, by recharging the bucket at a rate of one token every 4.8 minutes. You would need to run your test case for at least that long to observe a difference and for at least 24 hours to prove whether or not the overall rate is maintained.
Quoted 2 lines
and should not be however. The other reason is that it should be the same outcome with limit rate over X/minute but it is not
For the benefit of anyone investigating, could you define a test case that concretely demonstrates the problem?
Quoted 46 lines
Quoted 44 lines
Quoted 43 lines
A somewhat inconsistent behaviour with x/minute value, e.g.
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 13/minute } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;produces on the client side:
ping -4 -n 20 google.com
Pinging google.com [216.58.208.110] with 32 bytes of data:
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=15ms TTL=114 Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=154ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=32ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114Ping statistics for 216.58.208.110:
Packets: Sent = 20, Received = 14, Lost = 6 (30% loss), Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 154ms, Average = 26msWhilst the count is matching the rule it is not clear why not all 13 initial frames are passing through consistently and the excess being dropped consistently but instead the first being dropped is earlier?
Signature · 1 line
Kerin Millar
Quoted 41 lines · On 25/11/2020 11:48, [email protected] wrote:
Quoted 24 lines · ѽ҉ᶬḳ℠
Quoted 23 lines · On 24/11/2020 23:08, [email protected] wrote:
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Quoted 6 lines
Quoted 3 lines
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Thank you for your valuable thoughts. I am not sure however that the default bust limit is the cause here, for two reasons:
It explains the cause of the initial five packets being permitted before running up against any limit. Given 2 as a numerator, try with lower burst values.
Take "2/min burst 1 packets" as an example. The bucket will have a capacity of just one token and will be initialised with one upon loading the ruleset. The bucket will be topped up with one token every 30 seconds, but never beyond its capacity. The result should be that one packet is allowed to pass at rigid 30 second intervals.
Specifying "2/min burst 2 packets" will result in the bucket being initialised with - and having a capacity of - two tokens. Within the first 30 second delta, it will be possible for two packets to pass before the limit applies. Still, the bucket is topped up at the same rate of one token every 30 seconds.
Quoted 3 lines
the outcome is the same with:
Quoted 7 lines
Quoted 1 line
limit rate over 44/day
On average, this should allow for 44 a day by recharging the bucket at a rate of one token every 24/44*60 = 32.73 minutes.
Quoted 1 line
limit rate over 300/day
In this case, by recharging the bucket at a rate of one token every 4.8 minutes. You would need to run your test case for at least that long to observe a difference and for at least 24 hours to prove whether or not the overall rate is maintained.
Thank you for the extensive explanation(s). To test your theory I removed the default burst of 5 packets from the equation with:
limit rate over 300/day burst 0 packets
In which case I would expect the bucket credit of 300 to be burned prior rejecting frame #301 from the source, however the frames are being dropped as of frame count #6:
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12
Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 5, Lost = 15 (75% loss), Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
---------------
Then adjusted to:
limit rate over 300/day burst 10 packets:
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12
Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=4ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=3ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 10, Lost = 10 (50% loss), Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 4ms, Average = 1ms
Now 10 frames being passed through (matching the burst value) but as of count # 11 being dropped.
This seems to be indicative of:
* burst value below the default (of 5) being disregarded entirely
* limit rate over X/day being disregarded and only the burst token applied.
Quoted 6 lines
Quoted 4 lines
and should not be however. The other reason is that it should be the same outcome with limit rate over X/minute but it is not
For the benefit of anyone investigating, could you define a test case that concretely demonstrates the problem?
see below
Quoted 48 lines
Quoted 47 lines
Quoted 45 lines
Quoted 44 lines
A somewhat inconsistent behaviour with x/minute value, e.g.
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 13/minute } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;produces on the client side:
ping -4 -n 20 google.com
Pinging google.com [216.58.208.110] with 32 bytes of data:
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=15ms TTL=114 Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=18ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=16ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=154ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=32ms TTL=114 Reply from 216.58.208.110: bytes=32 time=13ms TTL=114 Request timed out.
Reply from 216.58.208.110: bytes=32 time=14ms TTL=114Ping statistics for 216.58.208.110:
Packets: Sent = 20, Received = 14, Lost = 6 (30% loss), Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 154ms, Average = 26msWhilst the count is matching the rule it is not clear why not all 13 initial frames are passing through consistently and the excess being dropped consistently but instead the first being dropped is earlier?
Quoted 47 lines · ѽ҉ᶬḳ℠
Quoted 45 lines · On 25/11/2020 11:48, [email protected] wrote:
Quoted 24 lines · ѽ҉ᶬḳ℠
Quoted 23 lines · On 24/11/2020 23:08, [email protected] wrote:
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Quoted 6 lines
Quoted 3 lines
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Thank you for your valuable thoughts. I am not sure however that the default bust limit is the cause here, for two reasons:
It explains the cause of the initial five packets being permitted before running up against any limit. Given 2 as a numerator, try with lower burst values.
Take "2/min burst 1 packets" as an example. The bucket will have a capacity of just one token and will be initialised with one upon loading the ruleset. The bucket will be topped up with one token every 30 seconds, but never beyond its capacity. The result should be that one packet is allowed to pass at rigid 30 second intervals.
Specifying "2/min burst 2 packets" will result in the bucket being initialised with - and having a capacity of - two tokens. Within the first 30 second delta, it will be possible for two packets to pass before the limit applies. Still, the bucket is topped up at the same rate of one token every 30 seconds.
Quoted 4 lines
the outcome is the same with:
limit rate over 44/day
On average, this should allow for 44 a day by recharging the bucket at a rate of one token every 24/44*60 = 32.73 minutes.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
limit rate over 300/day
In this case, by recharging the bucket at a rate of one token every 4.8 minutes. You would need to run your test case for at least that long to observe a difference and for at least 24 hours to prove whether or not the overall rate is maintained.
Thank you for the extensive explanation(s). To test your theory I removed the default burst of 5 packets from the equation with:
limit rate over 300/day burst 0 packets
0 isn't a legal value. A token bucket must have a capacity of at least 1. A bucket with no capacity would be no bucket at all. I would prefer for the parser to reject this. Instead, the value is disregarded, resulting in the default of 5.
Quoted 2 lines
In which case I would expect the bucket credit of 300 to be burned prior
The credit is 5, not 300, and will never be any higher, unless you define a legal burst value to that end. Effectively, 300/day defines the top-up rate. Keep in mind that 300/day is the very definition of a rate. It is not merely an upper bound, unlike the burst value.
Quoted 1 line
rejecting frame #301 from the source, however the frames are being
To be able to burn through as many as 300 before even the first 4.8 minutes has elapsed, you would have to define a burst value of 300 packets.
Quoted 1 line
dropped as of frame count #6:
This is the point at which the initial five tokens have been drained. It does not prove that the defined rate isn't maintained over the course of one day (your chosen denominator).
Quoted 52 lines
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Request timed out > Request timed out. Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 5, Lost = 15 (75% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms---------------
Then adjusted to:
limit rate over 300/day burst 10 packets:
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=4ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=3ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Request timed out.
Request timed out.
Quoted 8 lines
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
To burn through as many as 20 before the first 4.8 minutes has elapsed, you would have to define a burst value of 20 packets.
Quoted 7 lines
Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 10, Lost = 10 (50% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 4ms, Average = 1ms
Quoted 6 lines
Now 10 frames being passed through (matching the burst value) but as of count # 11 being dropped.
This seems to be indicative of:
* burst value below the default (of 5) being disregarded entirely
Only 0, because it would be impossible to honour. I'll file a bug requesting that it be treated as fatal by the parser.
Quoted 1 line
* limit rate over X/day being disregarded and only the burst token applied.
It doesn't prove any such thing. Your test case ran for little more than 20 seconds, which is not enough time for the bucket to have acquired a new token having been drained. At the very least, please conduct your test for 2 x 4.8 minutes.
Signature · 1 line
Kerin Millar
Quoted 54 lines · On 25/11/2020 13:49, [email protected] wrote:
Quoted 53 lines · ѽ҉ᶬḳ℠
Quoted 41 lines · On 25/11/2020 11:48, [email protected] wrote:
Quoted 24 lines · ѽ҉ᶬḳ℠
Quoted 23 lines · On 24/11/2020 23:08, [email protected] wrote:
Quoted 9 lines · ѽ҉ᶬḳ℠
host: armv7l GNU/Linux
kernel: 5.10.0-rc3-next-20201113
nftables: v0.9.6
______this rule in a > inet filter prerouting chain:
icmp type 8 add @b_sa4_lan_pinger { ip saddr limit rate over 2/day } log flags all prefix "
ping_ip4from LAN >rate_limit_dDROP: " drop;Quoted 7 lines
Having tried different values, e.g.
limit rate over 2/day
limit rate over 44/day
limit rate over 300/dayframes # 1 -5 are always passing through but as of frame count # 6 the frames always being dropped, no matter the x/day value.
That's probably because the default burst value is 5, not that anyone would know this by reading the nft documentation. The terse explanation of the limit module in iptables-extensions(8) applies but there is a better explanation to be found here:
https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
Quoted 6 lines
Quoted 3 lines
Given 2/day, the initial five tokens are being taken from the bucket, following which no token is added until 12 hours have elapsed. Try repeating your experiments with the burst value specified as 1.
Documentation aside, it doesn't help that both iptables/xt_limit and nft/limit fail to report the burst value unless it was explicitly defined.
Thank you for your valuable thoughts. I am not sure however that the default bust limit is the cause here, for two reasons:
It explains the cause of the initial five packets being permitted before running up against any limit. Given 2 as a numerator, try with lower burst values.
Take "2/min burst 1 packets" as an example. The bucket will have a capacity of just one token and will be initialised with one upon loading the ruleset. The bucket will be topped up with one token every 30 seconds, but never beyond its capacity. The result should be that one packet is allowed to pass at rigid 30 second intervals.
Specifying "2/min burst 2 packets" will result in the bucket being initialised with - and having a capacity of - two tokens. Within the first 30 second delta, it will be possible for two packets to pass before the limit applies. Still, the bucket is topped up at the same rate of one token every 30 seconds.
Quoted 3 lines
the outcome is the same with:
Quoted 7 lines
Quoted 1 line
limit rate over 44/day
On average, this should allow for 44 a day by recharging the bucket at a rate of one token every 24/44*60 = 32.73 minutes.
Quoted 1 line
limit rate over 300/day
In this case, by recharging the bucket at a rate of one token every 4.8 minutes. You would need to run your test case for at least that long to observe a difference and for at least 24 hours to prove whether or not the overall rate is maintained.
Thank you for the extensive explanation(s). To test your theory I removed the default burst of 5 packets from the equation with:
Quoted 8 lines
Quoted 1 line
limit rate over 300/day burst 0 packets
0 isn't a legal value. A token bucket must have a capacity of at least 1. A bucket with no capacity would be no bucket at all. I would prefer for the parser to reject this. Instead, the value is disregarded, resulting in the default of 5.
Quoted 2 lines
In which case I would expect the bucket credit of 300 to be burned prior
The credit is 5, not 300, and will never be any higher, unless you define a legal burst value to that end. Effectively, 300/day defines the top-up rate. Keep in mind that 300/day is the very definition of a rate. It is not merely an upper bound, unlike the burst value.
Alright, penny finally dropped - burst value = amount of tokens in the bucket and limit rate over X/period = times the bucket can be refilled over period...
I had it that limit rate X/period = token in bucket for period and burst = amount of tokens to exceed, e.g. 300/day would max out at 305...
So if I want 300/day then I go with > limit rate over 1/day burst 300 packets
Thank you once more for the taking the time and making the effort.
Quoted 92 lines
Quoted 2 lines
rejecting frame #301 from the source, however the frames are being
To be able to burn through as many as 300 before even the first 4.8 minutes has elapsed, you would have to define a burst value of 300 packets.
Quoted 1 line
dropped as of frame count #6:
This is the point at which the initial five tokens have been drained. It does not prove that the defined rate isn't maintained over the course of one day (your chosen denominator).
Quoted 52 lines
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Request timed out > Request timed out. Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 5, Lost = 15 (75% loss), Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms---------------
Then adjusted to:
limit rate over 300/day burst 10 packets:
# ping -6 -n 20 fd30:d64c:1eed:4c3a::12Pinging fd30:d64c:1eed:4c3a::12 with 32 bytes of data:
Reply from fd30:d64c:1eed:4c3a::12: time=4ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=1ms Reply from fd30:d64c:1eed:4c3a::12: time=3ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Reply from fd30:d64c:1eed:4c3a::12: time=2ms Request timed out.
Request timed out.Quoted 8 lines
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.To burn through as many as 20 before the first 4.8 minutes has elapsed, you would have to define a burst value of 20 packets.
Quoted 7 lines
Ping statistics for fd30:d64c:1eed:4c3a::12:
Packets: Sent = 20, Received = 10, Lost = 10 (50% loss), Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 4ms, Average = 1msQuoted 6 lines
Now 10 frames being passed through (matching the burst value) but as of count # 11 being dropped.
This seems to be indicative of:
* burst value below the default (of 5) being disregarded entirely
Only 0, because it would be impossible to honour. I'll file a bug requesting that it be treated as fatal by the parser.
Quoted 1 line
* limit rate over X/day being disregarded and only the burst token applied.
It doesn't prove any such thing. Your test case ran for little more than 20 seconds, which is not enough time for the bucket to have acquired a new token having been drained. At the very least, please conduct your test for 2 x 4.8 minutes.