On Sunday, April 01, 2012 05:02:02 dan wrote:
An easy way might be to just pull the info from ifconfig on a timer:
eth0 RX bytes:2841699391 (2.6 GiB) TX bytes:2681928474 (2.4 GiB)
- 5 seconds RX bytes:2842069649 (2.6 GiB) TX bytes:2682282969 (2.4 GiB)
=RX of 361.5Kb, TX of 346.2Kb
just update a value for the MAX of both as they change
Compare the stored value to the last 5 second interval so see what amount of the connection is available. In my case, I have a 20Mb/10Mb connection so I have 19.3Mb/9.3Mb available. If I know the connection speed (reliably) then I should be able to statically assign this. Otherwise it should just be based on historical observations. Wireless links are unpredictable so we have to rely on observation while wired or higher end backhaul links are more predictable so it may be best just use a set value.
It would be better if we could get total throughput on the wireless link if possible.
This approach bears some drawbacks: We can only assess the maximum throughput by saturating the link. Saturating the link isn't what we really want to do because it means nobody else can use the link to transfer data. Furthermore, what if nobody transmits anything whithin your interval ? The counters won't increase and the link will be considered "bad" ?
Regards, Marek