在 C# 中检测网络连接速度和带宽使用情况 [英] Detecting network connection speed and bandwidth usage in C#

查看:91
本文介绍了在 C# 中检测网络连接速度和带宽使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 C# 中检测网络速度和带宽使用情况?甚至欢迎指向开源组件的指针.

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

推荐答案

尝试使用 System.Net.NetworkInformation 类.特别是,System.Net.NetworkInformation.IPv4InterfaceStatistics 应该有一些与您要查找的内容相符的信息.

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.

具体来说,您可以检查 bytesReceived 属性,等待给定的时间间隔,然后再次检查 bytesReceived 属性以了解您的连接每秒多少字节正在处理.但是,要获得一个好的数字,您应该尝试从给定的来源下载大量信息,然后进行检查;这样,您应该在进行测试时最大化"连接,这应该会提供更多有用的数字.

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# 中检测网络连接速度和带宽使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆