开发者

How do i measure how much data has been sent over a C# socket

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 instanc开发者_如何学Ce, in windows server 2008 there is a dialog that shows bandwidth usage pr. connection; perhaps it's possible to access this information?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜