Detecting network connection speed and bandwidth usage in C#

匿名 (未验证) 提交于 2019-12-03 02:00:02

问题:

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

回答1:

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.



回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!