Skip to contentSkip to conversation

setting up throughput threshold indications to userspace

RFC Luciano Coelho 4 participants 14 messages Jul 16, 2010 – Aug 17, 2010 netfilter

lore
Share & tools
lore
#0 lore raw

Hi all,

I've been trying to set up some rules that will send indications to the userspace about the current throughput of a certain interface. The idea is to let the userspace enable or disable WLAN PS mode accordingly (the validity of this idea is another subject ;).

This is related to the discussion we had in the thread about the NFNOTIF thread.

I'm thinking about having this kind of ruleset:

-A INPUT -j throughput
-A above -m connmark --mark 0x1 -j RETURN
-A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j LOG --log-prefix "ABOVE" -A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j CONNMARK --set-xmark 0x1/0xffffffff -A below -m connmark --mark 0x2 -j RETURN
-A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j LOG --log-prefix "BELOW" -A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j CONNMARK --set-xmark 0x2/0xffffffff -A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
-A throughput -j above
-A throughput -j below

I'm using a normal LOG just for simplicity reasons, in real life I'd use NFLOG instead.

The idea here is that all packets would be collected by RATEEST for rate estimation and then I'd check whether the throughput is above the threshold. If it is, I mark it as such and print the log. Same thing for below the threshold. The RETURN rules are there to prevent more LOG messages from being printed (what I need is to know only when the throughput "crosses" the threshold).

Do you think this works?

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Signature · 2 lines
Cheers,
Luca.
#1 lore raw

Am 16.07.2010 10:20, schrieb Luciano Coelho:

Quoted 26 lines

Hi all,

I've been trying to set up some rules that will send indications to the userspace about the current throughput of a certain interface. The idea is to let the userspace enable or disable WLAN PS mode accordingly (the validity of this idea is another subject ;).

This is related to the discussion we had in the thread about the NFNOTIF thread.

I'm thinking about having this kind of ruleset:

(quoted diff) +0 -10
-A INPUT -j throughput 
-A above -m connmark --mark 0x1 -j RETURN 
-A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j LOG --log-prefix "ABOVE" 
-A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j CONNMARK --set-xmark 0x1/0xffffffff 
-A below -m connmark --mark 0x2 -j RETURN 
-A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j LOG --log-prefix "BELOW" 
-A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j CONNMARK --set-xmark 0x2/0xffffffff 
-A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms 
-A throughput -j above 
-A throughput -j below 

I'm using a normal LOG just for simplicity reasons, in real life I'd use NFLOG instead.

Quoted 8 lines

The idea here is that all packets would be collected by RATEEST for rate estimation and then I'd check whether the throughput is above the threshold. If it is, I mark it as such and print the log. Same thing for below the threshold. The RETURN rules are there to prevent more LOG messages from being printed (what I need is to know only when the throughput "crosses" the threshold).

Do you think this works?

Looks reasonable, but you could probably simplify it a bit by adding RETURN rules to the above/below chains when the threshold is below/ above the specified value. That way you only need a single rateest match.

Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Sounds useful.

#2 lore raw
Quoted 24 lines · ext Patrick McHardy

Am 16.07.2010 10:20, schrieb Luciano Coelho:

Quoted 23 lines

I'm thinking about having this kind of ruleset:

(quoted diff) +0 -10
-A INPUT -j throughput 
-A above -m connmark --mark 0x1 -j RETURN 
-A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j LOG --log-prefix "ABOVE" 
-A above -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-gt -j CONNMARK --set-xmark 0x1/0xffffffff 
-A below -m connmark --mark 0x2 -j RETURN 
-A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j LOG --log-prefix "BELOW" 
-A below -m rateest --rateest throughput --rateest-bps1 0bit --rateest-bps2 1000bit --rateest-lt -j CONNMARK --set-xmark 0x2/0xffffffff 
-A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms 
-A throughput -j above 
-A throughput -j below 

I'm using a normal LOG just for simplicity reasons, in real life I'd use NFLOG instead.

The idea here is that all packets would be collected by RATEEST for rate estimation and then I'd check whether the throughput is above the threshold. If it is, I mark it as such and print the log. Same thing for below the threshold. The RETURN rules are there to prevent more LOG messages from being printed (what I need is to know only when the throughput "crosses" the threshold).

Quoted 6 lines
Quoted 1 line

Do you think this works?

Looks reasonable, but you could probably simplify it a bit by adding RETURN rules to the above/below chains when the threshold is below/ above the specified value. That way you only need a single rateest match.

Right, that would certainly make it simpler.

Quoted 11 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Sounds useful.

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

Thanks for your comments!

Signature · 2 lines
Cheers,
Luca.
#3 lore raw
Quoted 10 lines · Luciano Coelho
Quoted 10 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Quoted 4 lines
Quoted 1 line

Sounds useful.

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

My suggestion to have it combined with xt_condition.

#4 lore raw
Quoted 11 lines · ext Jan Engelhardt
Quoted 10 lines · Luciano Coelho
Quoted 10 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Sounds useful.

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

My suggestion to have it combined with xt_condition.

Yes, I also think that is the best idea. I'll implement a CONDITION target that will work together with the condition match. For now I'll use the non-final version you submitted some time ago.

Signature · 2 lines
Cheers,
Luca.
#5 lore raw

Hello,

Quoted 14 lines · Coelho Luciano (Nokia-MS/Helsinki)
Quoted 13 lines · ext Jan Engelhardt
Quoted 12 lines · Luciano Coelho
Quoted 11 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Sounds useful.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

My suggestion to have it combined with xt_condition.

Yes, I also think that is the best idea. I'll implement a CONDITION target that will work together with the condition match. For now I'll use the non-final version you submitted some time ago.

Now that I have implemented the changes needed in the condition module so that it has a target which can be used to set the condition, I came up with the following rules to inform the userspace about the throughput of a specific interface (in this case wlan0):

iptables -N throughput
iptables -N test_above
iptables -N test_below
iptables -A INPUT -i wlan0 -j throughput
iptables -A OUTPUT -o wlan0 -j throughput
iptables -A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
iptables -A throughput -m condition --name throughput ! --value 1 -j test_above
iptables -A throughput -m condition --name throughput ! --value 2 -j test_below
iptables -A test_above -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-gt -j CONDITION --value 1 --name throughput iptables -A test_above -m condition --name "throughput" --value 1 -j NFLOG --nflog-prefix "ABOVE "
iptables -A test_below -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-lt -j CONDITION --value 2 --name throughput iptables -A test_below -m condition --name "throughput" --value 2 -j NFLOG --nflog-prefix "BELOW "

This is just a proof of concept and I'm sure it can be optimized (I'll look into it once it works fully).

Anyway, my problem now, is that the rate estimator targets are only reached when there are packets coming through (for obvious reasons). What is happening is that, if the last packet sent through this interface is sent as part of a high throughput burst, the last signal the userspace will get is "ABOVE". After that, the interface becomes idle and the "BELOW" signal is never sent, even though we will be transmitting at 0 bps.

Does anyone have an idea on how I could solve this problem?

I have been considering using the IDLETIMER target and activate it when the throughput goes to HIGH. Then if this timer expires, it would inform the userspace that now there's no data going through. But this sounds very artificial to me and will add one more dependency on the userspace, since the IDLETIMER is using sysfs to inform userspace, instead of netlink.

Any other suggestions?

Signature · 2 lines
Cheers,
Luca.
#6 lore raw
Quoted 58 lines · Luciano Coelho

Hello,

Quoted 14 lines · Coelho Luciano (Nokia-MS/Helsinki)
Quoted 13 lines · ext Jan Engelhardt
Quoted 12 lines · Luciano Coelho
Quoted 11 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK).  This is not exactly what I want.  I need to have this on a per-ruleset basis.  For that, I need to have a MARK (variable?) which can be set independently of connections or packets.  This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file.  This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Sounds useful.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

My suggestion to have it combined with xt_condition.

Yes, I also think that is the best idea.  I'll implement a CONDITION target that will work together with the condition match.  For now I'll use the non-final version you submitted some time ago.

Now that I have implemented the changes needed in the condition module so that it has a target which can be used to set the condition, I came up with the following rules to inform the userspace about the throughput of a specific interface (in this case wlan0):

iptables -N throughput
iptables -N test_above
iptables -N test_below
iptables -A INPUT -i wlan0 -j throughput
iptables -A OUTPUT -o wlan0 -j throughput
iptables -A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
iptables -A throughput -m condition --name throughput ! --value 1 -j test_above
iptables -A throughput -m condition --name throughput ! --value 2 -j test_below
iptables -A test_above -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-gt -j CONDITION --value 1 --name throughput iptables -A test_above -m condition --name "throughput" --value 1 -j NFLOG --nflog-prefix "ABOVE "
iptables -A test_below -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-lt -j CONDITION --value 2 --name throughput iptables -A test_below -m condition --name "throughput" --value 2 -j NFLOG --nflog-prefix "BELOW "

This is just a proof of concept and I'm sure it can be optimized (I'll look into it once it works fully).

Anyway, my problem now, is that the rate estimator targets are only reached when there are packets coming through (for obvious reasons). What is happening is that, if the last packet sent through this interface is sent as part of a high throughput burst, the last signal the userspace will get is "ABOVE".  After that, the interface becomes idle and the "BELOW" signal is never sent, even though we will be transmitting at 0 bps.

Does anyone have an idea on how I could solve this problem?

Quoted 9 lines

I have been considering using the IDLETIMER target and activate it when the throughput goes to HIGH.  Then if this timer expires, it would inform the userspace that now there's no data going through.  But this sounds very artificial to me and will add one more dependency on the userspace, since the IDLETIMER is using sysfs to inform userspace, instead of netlink.

Any other suggestions?

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw
Quoted 67 lines · ext Changli Gao
Quoted 65 lines · Luciano Coelho

Hello,

Quoted 14 lines · Coelho Luciano (Nokia-MS/Helsinki)
Quoted 13 lines · ext Jan Engelhardt
Quoted 12 lines · Luciano Coelho
Quoted 11 lines
Quoted 9 lines

There is one problem with this solution, which is that it works in a per-connection basis (due to CONNMARK). This is not exactly what I want. I need to have this on a per-ruleset basis. For that, I need to have a MARK (variable?) which can be set independently of connections or packets. This is similar to the proposed condition match, but what is missing there is a way to set the condition with iptables itself, without requiring the userspace to change the procfs file. This could probably be achieved with a "CONDITION" target or something similar. Any ideas?

Sounds useful.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Okay, this was the kind of confirmation I wanted before jumping into the implementation. ;) I'll implement this target soon.

My suggestion to have it combined with xt_condition.

Yes, I also think that is the best idea. I'll implement a CONDITION target that will work together with the condition match. For now I'll use the non-final version you submitted some time ago.

Now that I have implemented the changes needed in the condition module so that it has a target which can be used to set the condition, I came up with the following rules to inform the userspace about the throughput of a specific interface (in this case wlan0):

iptables -N throughput
iptables -N test_above
iptables -N test_below
iptables -A INPUT -i wlan0 -j throughput
iptables -A OUTPUT -o wlan0 -j throughput
iptables -A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
iptables -A throughput -m condition --name throughput ! --value 1 -j test_above
iptables -A throughput -m condition --name throughput ! --value 2 -j test_below
iptables -A test_above -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-gt -j CONDITION --value 1 --name throughput iptables -A test_above -m condition --name "throughput" --value 1 -j NFLOG --nflog-prefix "ABOVE "
iptables -A test_below -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-lt -j CONDITION --value 2 --name throughput iptables -A test_below -m condition --name "throughput" --value 2 -j NFLOG --nflog-prefix "BELOW "

This is just a proof of concept and I'm sure it can be optimized (I'll look into it once it works fully).

Anyway, my problem now, is that the rate estimator targets are only reached when there are packets coming through (for obvious reasons). What is happening is that, if the last packet sent through this interface is sent as part of a high throughput burst, the last signal the userspace will get is "ABOVE". After that, the interface becomes idle and the "BELOW" signal is never sent, even though we will be transmitting at 0 bps.

Does anyone have an idea on how I could solve this problem?

I have been considering using the IDLETIMER target and activate it when the throughput goes to HIGH. Then if this timer expires, it would inform the userspace that now there's no data going through. But this sounds very artificial to me and will add one more dependency on the userspace, since the IDLETIMER is using sysfs to inform userspace, instead of netlink.

Quoted 6 lines
Quoted 2 lines

Any other suggestions?

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

We don't want to use polling from userspace. That's the reason why we decided to use iptables instead. The idea is that we will only notify the userspace when the throughput crosses the threshold line. And the rules I defined above are working rather well, except for this "detail" that the BELOW signal is not sent when there's no data flowing.

Thanks for your suggestion anyway, we will reconsider the idea of polling, but still I would prefer to fix the 0 bps problem (if possible). ;)

Signature · 2 lines
Cheers,
Luca.
#8 lore raw
Quoted 6 lines · Luciano Coelho
Quoted 4 lines · ext Changli Gao

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

Quoted 6 lines

We don't want to use polling from userspace.  That's the reason why we decided to use iptables instead.  The idea is that we will only notify the userspace when the throughput crosses the threshold line.  And the rules I defined above are working rather well, except for this "detail" that the BELOW signal is not sent when there's no data flowing.

There is a daemon watching the ABOVE signal in any way. How about staring a timer, which is used to check if there is no packet transfered in a period, in this daemon when receiving the ABOVE signal, and stopping this timer when receiving the BELOW signal? It is like the implementation of IDLETIMER in user space.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
Quoted 15 lines · ext Changli Gao
Quoted 6 lines · Luciano Coelho
Quoted 4 lines · ext Changli Gao

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

Quoted 6 lines

We don't want to use polling from userspace. That's the reason why we decided to use iptables instead. The idea is that we will only notify the userspace when the throughput crosses the threshold line. And the rules I defined above are working rather well, except for this "detail" that the BELOW signal is not sent when there's no data flowing.

Quoted 5 lines

There is a daemon watching the ABOVE signal in any way. How about staring a timer, which is used to check if there is no packet transfered in a period, in this daemon when receiving the ABOVE signal, and stopping this timer when receiving the BELOW signal? It is like the implementation of IDLETIMER in user space.

Yeah, we do have a daemon listening to it. This idea is actually good and might work. As you say, it's very similar to IDLETIMER, but in userspace. I'll ask our userspace guy which one he prefers to use (ie. either making the timer himself, or listening to IDLETIMER's sysfs indication).

Of course, it is also possible to implement a netfilter interface for the idletimer target as well (as Samuel has already suggested), so that dependencies in userspace would be simplified. ;)

Signature · 2 lines
Cheers,
Luca.
#12 lore raw
In reply to Luciano Coelho
Quoted 30 lines · Luciano Coelho

Now that I have implemented the changes needed in the condition module so that it has a target which can be used to set the condition, I came up with the following rules to inform the userspace about the throughput of a specific interface (in this case wlan0):

iptables -N throughput
iptables -N test_above
iptables -N test_below
iptables -A INPUT -i wlan0 -j throughput
iptables -A OUTPUT -o wlan0 -j throughput
iptables -A throughput -j RATEEST --rateest-name throughput --rateest-interval 250.0ms --rateest-ewmalog 500.0ms
iptables -A throughput -m condition --name throughput ! --value 1 -j test_above
iptables -A throughput -m condition --name throughput ! --value 2 -j test_below
iptables -A test_above -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-gt -j CONDITION --value 1 --name throughput iptables -A test_above -m condition --name "throughput" --value 1 -j NFLOG --nflog-prefix "ABOVE "
iptables -A test_below -m rateest --rateest1 throughput --rateest-bps1 0 --rateest-bps2 512bps --rateest-lt -j CONDITION --value 2 --name throughput iptables -A test_below -m condition --name "throughput" --value 2 -j NFLOG --nflog-prefix "BELOW "

This is just a proof of concept and I'm sure it can be optimized (I'll look into it once it works fully).

Anyway, my problem now, is that the rate estimator targets are only reached when there are packets coming through (for obvious reasons). What is happening is that, if the last packet sent through this interface is sent as part of a high throughput burst, the last signal the userspace will get is "ABOVE".  After that, the interface becomes idle and the "BELOW" signal is never sent, even though we will be transmitting at 0 bps.

Quoted 9 lines

Does anyone have an idea on how I could solve this problem?

I have been considering using the IDLETIMER target and activate it when the throughput goes to HIGH.  Then if this timer expires, it would inform the userspace that now there's no data going through.  But this sounds very artificial to me and will add one more dependency on the userspace, since the IDLETIMER is using sysfs to inform userspace, instead of netlink.

Read the code of IDLETIMER again, and I notice that IDLETIMER will wake up all the sleepers on the corresponding sysfs files. So no polling is needed, what you need do is watching another files for read. You can use select/poll/epoll. It should be no very difficult.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw
Quoted 12 lines · ext Changli Gao
Quoted 9 lines · Luciano Coelho

Does anyone have an idea on how I could solve this problem?

I have been considering using the IDLETIMER target and activate it when the throughput goes to HIGH. Then if this timer expires, it would inform the userspace that now there's no data going through. But this sounds very artificial to me and will add one more dependency on the userspace, since the IDLETIMER is using sysfs to inform userspace, instead of netlink.

Quoted 4 lines

Read the code of IDLETIMER again, and I notice that IDLETIMER will wake up all the sleepers on the corresponding sysfs files. So no polling is needed, what you need do is watching another files for read. You can use select/poll/epoll. It should be no very difficult.

Yes, I know. I have reworked the IDLETIMER for upstream inclusion, so I should know this after all. ;) It was just the idea of having the daemon have one more interface with the kernel that seemed a bit ugly...

Signature · 2 lines
Cheers,
Luca.
#10 lore raw
In reply to Luciano Coelho
Quoted 9 lines · Luciano Coelho
Quoted 3 lines

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

We don't want to use polling from userspace. That's the reason why we decided to use iptables instead. The idea is that we will only notify the userspace when the throughput crosses the threshold line. And the rules I defined above are working rather well, except for this "detail" that the BELOW signal is not sent when there's no data flowing.

Without data, the turing machine won't finish, so you can't say for sure that you reached below. That is sort of a halting problem, which is known to be unsolvable.

#11 lore raw
Quoted 11 lines · ext Jan Engelhardt
Quoted 9 lines · Luciano Coelho
Quoted 3 lines

You can implement a daemon: which samples the statistics data of NIC periodically, calculates the average bandwidth in a period, and change the condition variables accordingly.

We don't want to use polling from userspace. That's the reason why we decided to use iptables instead. The idea is that we will only notify the userspace when the throughput crosses the threshold line. And the rules I defined above are working rather well, except for this "detail" that the BELOW signal is not sent when there's no data flowing.

Quoted 3 lines

Without data, the turing machine won't finish, so you can't say for sure that you reached below. That is sort of a halting problem, which is known to be unsolvable.

Yes, that's the theoretical way to put it. :) In practice I see that without data the rules won't be traversed and therefore we can't make any rate calculations.

But if I add an idletimer (which uses a timer to trigger execution, regardless of the availability of packets to process) with a timeout equal to the estimator's measurement averaging interval (ewmalog), I can be sure that the rate went to 0 bps if the timer expires. Ie. no packets at all during the measurement interval means 0 bps, right?

Signature · 2 lines
Cheers,
Luca.