使用 C# 计算网络带宽速度的最可靠方法是什么?
我找到了一些使用 NetworkInterface
、性能计数器、 native Win32 代码等的示例,但它们都提供了不同的结果,而且似乎没有一个与其他已经存在的工具所显示的相匹配。
关于在 C# 中计算网络带宽速度的最可靠方法有什么建议吗?
编辑:为澄清起见,我希望知道特定接口(interface)当前消耗了多少带宽。
最佳答案
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
关于c# - 使用 C# 计算网络带宽速度的最可靠方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2388198/