Skip to main content
gamedev.net
🔒 Locked

Statistics

Started by Gagyi Jan 1, 2007 at 8:44 AM 2 replies 950+ views
Original Post
Gagyi
Gagyi
This question may sound like really noobish (I tried to google it, but found nothing): How can I get statistics about sent/received bytes? Is there an API call (using winsock), or I have to do it manually?
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
hplus0603
hplus0603
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.
enum Bool { True, False, FileNotFound };
cybernetic
cybernetic
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.
Gagyi
Gagyi
"but the counters themselves are not well documented"
Okay, thank you, maybe I try that approach, but collecting data manually sounds easier I think.

And Ethereal rocks!
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.