views:

77

answers:

2

I'm building an application that needs to charge users based on the exact bandwidth used by their connections.

I could of course keep track of how many bytes i pass to/from send/receive but that doesn't include IP packet overhead which i'd very much like to include since we're talking lots of small packets of varying size.

I could estimate it, but i'm curious if there is a relatively simple cheep way of knowing.

For instance, in windows server 2008 there is a dialog that shows bandwidth usage pr. connection; perhaps it's possible to access this information?

A: 

This question's answer uses PerformanceCounter to monitor bandwidth and could be helpful for what you're looking to do.

statenjason
A: 

From memory you might find the PerformanceCounter class in the System.Diagnostics namespace able to provide you with the information you want.

Failing that WMI has a large array of information about the computer

And my last thought but by no means an atractive one, get a sniffer and have a service analyse its results every hour or so. remember to delete the sniffers output when you have what you need they can get quite big.

Robert