Reputation: 9363
I am developing a small application that requires a module that would check whether there is bandwidth or not.Basically the module should trigger an event when the bandwidth goes down. Can this be achieved using c++ program
Upvotes: 0
Views: 2039
Reputation: 845
Look for your network interface in /sys/class/net/ directory. My system only has two interfaces lo and eth0.
There are a lot of files describing the status of the interface to explore.
I would start with operstate, statistics/rx_bytes or statistics/rx_packets.
Upvotes: 2
Reputation: 96109
Yes, two approaches - if you have a router with some sort of logging you could query it's values with SNMP or (harder) scrape the web interface for the stats.
Or if you need the real bandwidth you would have to find a server and download a file - measuring the time taken.
Upvotes: 0