Original Post
🔒 Locked
Statistics
Advertisement
There is no standard API for doing this; each OS does it in its own way.
On Windows, you can use WMI (Windows Management Instrumentation) to read "performance counters" that contain the data you want. I once did this to write a plug-in that shows the network I/O on my keyboard LCD; the API to read the counters is easy, but the counters themselves are not well documented, so you have to use the API to list the available counters, and then figure out what does what. (Using "perfmon" from the command line helps, too).
On Linux, you can dig the data out of /proc fairly easily.
On Windows, you can use WMI (Windows Management Instrumentation) to read "performance counters" that contain the data you want. I once did this to write a plug-in that shows the network I/O on my keyboard LCD; the API to read the counters is easy, but the counters themselves are not well documented, so you have to use the API to list the available counters, and then figure out what does what. (Using "perfmon" from the command line helps, too).
On Linux, you can dig the data out of /proc fairly easily.
If you want to do this programatically then you will need to interface with something like libpcap (http://www.tcpdump.org/) (windows version: http://www.winpcap.org/) and monitor the connection as needed (this is what the packet sniffer Ethereal does). This won't be a simple task though.
A simpler method might just be for you to collect the number of bytes sent and read manually, as you say.
However, if you want to just monitor a connection and collect statistics to diagnose your own program (that is, do this manually and not programatically), you can just go ahead and download Ethereal and play around in that to monitor what your program is doing - it displays a lot of useful network data neatly.
Be aware though, you need some knowledge of networks to understand a lot of the stuff Ethereal will show you.
Hope that helps.
A simpler method might just be for you to collect the number of bytes sent and read manually, as you say.
However, if you want to just monitor a connection and collect statistics to diagnose your own program (that is, do this manually and not programatically), you can just go ahead and download Ethereal and play around in that to monitor what your program is doing - it displays a lot of useful network data neatly.
Be aware though, you need some knowledge of networks to understand a lot of the stuff Ethereal will show you.
Hope that helps.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement