Is using C # the most reliable way to calculate network bandwidth?

Is using C # the most reliable way to calculate network bandwidth?

I found several examples using NetworkInterface , performance counters, native Win32 code, etc., but they all give different results, and none of them matches what other, already existing tools show.

Any tips on the most reliable method for calculating network bandwidth speed in C #?

Edit: To clarify, I'm looking to find out how much bandwidth a particular interface consumes.

+4
source share
3 answers

The same question :

Try using the System.Net.NetworkInformation classes. In particular, System.Net.NetworkInformation.IPv4InterfaceStatistics should have some information according to what you are looking for.

In particular, you can check the bytesReceived property, wait for the interval, and then check the bytesReceived property again to get an idea of ​​how many bytes per second the connection is processing. To get a Good Number, however, you should try to download a large block of information from a given source and then check; thus, you should "maximize" when you run a test that should produce more useful numbers

+2
source

Is using C # the most reliable way to calculate network bandwidth?

The most realistic way is to periodically send / download a small test file to / from a obviously very fast server and notify you of the time it takes.

+1
source

Another way to do this - although it might seem like a hoax as such - is to create a hidden process using "netstat -e X", where X is the interval, for example, "netstat -e 5" with redirected output and keep track of the numbers under the heading " Received and Sent ... what do you think?

Hope this helps, Regards, Tom.

+1
source

Source: https://habr.com/ru/post/1303265/


All Articles