JonBlog
Thoughts on website ideas, PHP and other tech topics, plus going car-free
Unix-like wifi-specific bandwidth counter
Categories: Ideas, Outline

I use wireless broadband via a wireless router, the use of which needs to be monitored carefully to avoid going over-quota. However I also use another wifi connection at home, and wifi connections at the office and many public ones. Thus, I wish to count data bytes on a specific interface for one specific router; unfortunately, all data accounting software will only filter on interface, as far as I can tell.

I have the beginnings of a solution in mind, however! I discover that this *nix command can be used to read a remote MAC address:

arp -i en1 192.168.1.1

From there, I can use something lightweight like vnstat to monitor a specific interface. Then, every few minutes on a cron, I can run the arp command to see if the MAC address matches my Wifi router. If it does, it turns vnstat monitoring on, and if it does not, it gets turned off. Specific times that delineate differing bandwidth allowances could also be added trivially.

So, I foresee something like a PHP script run by cron, which will work in all Linux/Unix/OSX environments. Will add it to the to-do list!

Leave a Reply