可以重置 Windows Native Wifi 信号强度更新间隔吗?
我正在编写一个 .Net 类库,当信号强度高于某个阈值时,它会连接到预先已知名称的特定 Wifi 网络。
一切都很完美,除了性能有点参差不齐。我有一个反复调用 WlanGetAvailableNetworks() 的轮询线程。该循环执行良好 - WLanGetAvailableNetworks() 通常只需要 10-20 毫秒。然而,WLAN_AVAILALBLE_NETWORK结构中的信号强度属性似乎需要很长时间才能更新。我发现当移动到信号强度已知的区域时,最多需要 100 秒才能注册更新值。
我发现了一个对更新间隔的神秘引用,包括这个,来自一个实现了 NETSH 生成器的人: http://www.codeproject.com/KB/gadgets/WifiScanner。 aspx?msg=3031431
但我还没有找到任何人解决过这个具体问题: 是否可以调整 Native Wifi API 中信号强度和其他网络参数的更新间隔?
或者,我错过了另一个有用的概念吗? (关于Wifi,我是个十足的菜鸟)。
可能相关的环境信息: --.Net 3.5 -- 针对 WlanApi 的 XP 和 KB 修复 -- C# / VS 2008(4.0 和 VS2010 可用)
thanks --
Carl
I'm writing a .Net class library that's to connect to a specific Wifi network whose name is known in advance, when the signal strength is above a certain threshold.
It all works beautifully, EXCEPT that peformance is a bit spotty. I have a polling thread that repeatedly calls WlanGetAvailableNetworks(). This loop performs well - WLanGetAvailableNetworks() typically takes only 10-20ms. HOWEVER, the signal strength attribute in the WLAN_AVAILALBLE_NETWORK structure seems to take a long time to update. I've seen it take up to 100 seconds to register an updated value when moving to an area with a known signal strength.
I've found cryptic references to the update interval, including this one, from a guy who's implemented a NETSH spawner:
http://www.codeproject.com/KB/gadgets/WifiScanner.aspx?msg=3031431
But I haven't found anyone who's addressed this specific question:
Is it possible to tweak the update interval for signal strength and other network parameters in the Native Wifi API?
Or, am I missing another helpful concept? (I'm a complete noob, regarding Wifi).
Possibly relevant environmental info:
-- .Net 3.5
-- XP plus KB fix for WlanApi
-- C# / VS 2008 (4.0 and VS2010 available)
thanks --
Carl
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎呀。我在 WLANAPI 文档中错过了这个:WlanScan()!在 WlanGetAvailableNetworks() 之前调用它,以确保 WlanGetAvailableNetworks() 返回或多或少的当前信息。根据文档(http://msdn.microsoft. com/en-us/library/ms706783(VS.85).aspx),
WlanScan() 立即完成并开始异步扫描。
根据经验,似乎发生的情况是下一个 WlanGetAvailableNetworks() 似乎会停止,直到扫描完成(在我的测试中为 3.085 秒,+/- 0.031 秒)。因此,正如文档所示,您不想在任何会削弱性能的地方执行此操作。此外,三秒可能是 WiFi 信号检查的最佳时间分辨率,至少在 XP 上是如此(Vista 和 7 版本的 WLANAPI 支持单网络 WlanScan(),这可能会更快完成)。
问题解决了,或多或少。
Oops. I missed this in the WLANAPI documentation: WlanScan()! Call that before WlanGetAvailableNetworks() to ensure that WlanGetAvailableNetworks() returns more or less current information. According to the doc (http://msdn.microsoft.com/en-us/library/ms706783(VS.85).aspx),
WlanScan() completes immediately and starts an asynchronous scan.
Empirically, what seems to happen is that the next WlanGetAvailableNetworks() appears to stall until the scan completes (3.085 seconds, +/- 0.031 seconds, in my testing). So, as the doc indicates, you don't want to do this anywhere that will cripple performance. Also, three seconds is probably about the best possible temporal resolution for wifi signal checks, at least on XP (Vista and 7 versions of WLANAPI support single-network WlanScan(), which may complete more quickly).
Problem solved, more or less.