确定网络接口带宽/类型,而不传输数据 [英] Determine network interface bandwidth/type without transferring data

查看:203
本文介绍了确定网络接口带宽/类型,而不传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Win32中有没有办法以编程方式确定给定网络接口的带宽,而不实际传输任何数据?我只想区分不同类型的接口(例如拨号对DSL和LAN),所以大致的数量级是好的,我不需要实际测量带宽。

Is there any way in Win32 to programmatically determine the bandwidth of a given network interface without actually transferring any data? I only want to distinguish between different types of interface (e.g. dialup vs DSL vs LAN), so a rough order of magnitude is fine, I don't need to actually measure the bandwidth.

问题的背景是,我的应用程序非常耗费带宽,我想向用户显示警告,如果他们尝试并在低带宽接口,例如拨号调制解调器或GPRS调制解调器。

Background to the problem is that my application is very bandwidth-hungry, and I want to display a warning to the user if they try and run it over a low-bandwidth interface, e.g. dialup modem or GPRS modem.

我看过一些其他相关问题,但如果可能,我想避免测量吞吐量。 GPRS调制解调器尤其可能有使用上限,我不想吃饭用户的津贴 - 我宁愿检测到不好的连接一些其他方式,实际上不发送任何数据。

I've looked at some other related questions but if possible I'd like to avoid measuring throughput. GPRS modems in particular may have usage caps and I don't want to eat into a user's allowance - I'd rather detect the poor connection some other way and not actually send any data at all.

我最感兴趣的是Win32 / C ++的答案,但任何想法都将非常感谢。

I'm most interested in Win32/C++ answers, but any ideas would be gratefully received.

推荐答案

您可以使用 InternetGetConnectedState 来确定类型连接(LAN /调制解调器等)。这将告诉你,如果他们有一个有点体面(非调制解调器)连接没有带宽传输。

You can use InternetGetConnectedState to determine the type of connection (LAN/Modem/etc). This will tell you if they have a somewhat decent (non-modem) connection without bandwidth transfer.

不幸的是,你不能真正地超越,没有连接和转移数据。系统无法知道其LAN连接之外的带宽限制 - 即:您可以直接连接到LAN上的网关,并且可能与外部世界有一个肮脏的连接。至于你的电脑,虽然,它是一个全速lan连接...

Unfortunately, you can't really go much beyond that without connecting and transferring data. There is no way for the system to know the bandwidth limitations outside of it's LAN connection - ie: you could connect to your gateway on a LAN directly, and it may have a crappy connection to the outside world. As far as your computer would be concerned, though, it's on a full speed lan connection...

这篇关于确定网络接口带宽/类型,而不传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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