确定网络连接链路速度
如何以编程方式确定活动网络连接的网络连接链接速度 - 就像任务管理器在“网络”选项卡中显示的那样? 我并不是真正追求可用带宽,只是当前连接的数字,例如 54Mbps、100Mbps 等。
How do I programmatically determine the network connection link speed for an active network connection - like Task Manager shows you in the Networking tab? I'm not really after the bandwidth available, just a figure for the current connection, e.g. 54Mbps, 100Mbps etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Win32_NetworkAdapter
WMI 类可以帮助您(Speed
属性)。 对于连接到 WiFi-g 接入点的 WiFi 适配器,它返回值 54000000。Win32_NetworkAdapter
WMI class can help you (Speed
property). It returns the value 54000000 for my WiFi adapter connected to a WiFi-g access point.最后我找到了
Win32_PerfRawData_Tcpip_NetworkInterface
WMI 类,因为我需要支持旧平台,不幸的是,Win32_NetworkAdapter
不支持。Win32_PerfRawData_Tcpip_NetworkInterface
有一个CurrentBandwidth
属性,它为我提供了所有必需平台上所需的内容(我意识到我说过我不需要“带宽”,但它是可以接受的,并且似乎返回无论如何,适配器的“标称带宽”)。感谢所有发帖的人,为我指明了正确的方向。
In the end I found the
Win32_PerfRawData_Tcpip_NetworkInterface
WMI class, as I need to support legacy platforms which, unfortunately, theWin32_NetworkAdapter
doesn't do.Win32_PerfRawData_Tcpip_NetworkInterface
has aCurrentBandwidth
property which gives me what I need on all required platforms (I realise I said I didn't need "bandwidth" but its acceptable and appears to return the "nominal bandwidth" of the adapter anyway).Thanks to all those who posted, pointing me in the right direction.
.NET方式如何知道适配器速度
有些适配器是隧道,所以它们的速度将返回为0。
有关详细信息,请阅读 MSDN 上的 NetworkInterface 文档信息。
.NET way how to know adapter speed is
Some adapters are tunnels, so their speed will be returned as 0.
Read NetworkInterface documentation on the MSDN for more information.