views:

4436

answers:

4

Is there a way to detect the network speed and bandwidth usage in C#? Even pointers to open-source components are welcome. Thanks in advance.

+9  A: 

Try using the System.Net.NetworkInformation classes. In particular, System.Net.NetworkInformation.IPv4InterfaceStatistics ought to have some information along the lines of what you're looking for.

Specifically, you can check the bytesReceived property, wait a given interval, and then check the bytesReceived property again to get an idea of how many bytes/second your connection is processing. To get a good number, though, you should try to download a large block of information from a given source, and check then; that way you should be 'maxing' the connection when you do the test, which should give more helpful numbers.

GWLlosa
+1  A: 

You should be able to calculate everything you need from the IPGlobalStatistics class.

Randolpho
+1  A: 

Please see the link below

http://asimsajjad.blogspot.com/2009/08/calculating-network-bandwidth-speed-in.html

hope that will help.

Asim Sajjad
just what GWLIosa already said and was accepted by the OP.
Oliver
I have just see this question and paste the link, didn't see above answers
Asim Sajjad
A: 

Why the hell isnt their a component to buy for this

asdf
At some point, you've got to be willing to sit down with the tools provided and write some code yourself. There can't be components for everything, after all...
GWLlosa