C# 检测网络连接速度和带宽使用情况

发布于 2024-10-18 08:14:01 字数 44 浏览 6 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不奢求什么 2024-10-25 08:14:01

尝试使用 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 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.

断爱 2024-10-25 08:14:01

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

若水般的淡然安静女子 2024-10-25 08:14:01

如果您只关心协商的速度,可以查看 NetworkInterface.Speed 属性

MSDN NetworkInterface.Speed

If you only care about the negotiated speed, you can look at the NetworkInterface.Speed property

MSDN NetworkInterface.Speed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文