C# 检测网络连接速度和带宽使用情况
有没有办法在C#中检测网络速度和带宽使用情况?甚至欢迎指向开源组件的指针。
Is there a way to detect the network speed and bandwidth usage in C#? Even pointers to open-source components are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用 System.Net.NetworkInformation 类。特别是
System.Net.NetworkInformation.IPv4InterfaceStatistics
应该有一些与您要查找的内容相关的信息。具体来说,您可以检查
bytesReceived
属性,等待给定的时间间隔,然后再次检查bytesReceived
属性,以了解您的连接每秒处理的字节数。不过,为了获得一个好的数字,您应该尝试从给定的来源下载大量信息,然后进行检查;这样,您在进行测试时应该“最大化”连接,这应该会给出更有用的数字。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 thebytesReceived
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.您应该能够从 IPGlobalStatistics< 计算所需的一切/a> 类。
You should be able to calculate everything you need from the IPGlobalStatistics class.
如果您只关心协商的速度,可以查看 NetworkInterface.Speed 属性
MSDN NetworkInterface.Speed
If you only care about the negotiated speed, you can look at the NetworkInterface.Speed property
MSDN NetworkInterface.Speed