根据代码中的名称将Wifi标记为移动热点 [英] Flag Wifi as mobile hotspot based on its name from code

查看:80
本文介绍了根据代码中的名称将Wifi标记为移动热点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我有一个Android平板电脑,可通过WiFi连接到汽车的车载单元(OBU).
  • OBU的SIM卡可以访问互联网.
  • 平板电脑上的应用通过OBU提供的互联网与服务器通信.
  • 因此,基本上,OBU是平板电脑的移动热点.
  • 平板电脑执行更新会消耗大量数据,因为它认为它在Wifi上
  • 这将导致SIM卡可用的数据量耗尽
  • 这会导致整个解决方案失败
  • ...或转移的数据每超出限制(超出限制)的额外费用
  • I can prevent automatic updates of normal apps on the tablet via settings in google play
  • I can't prevent system updates via the method mentioned in previous point
  • I can mark WiFi as mobile hotspot manually which also prevents the system updates
  • I read: http://www.lorier.net/docs/android-metered
  • I read: https://stackoverflow.com/questions/...
  • 根据其SSID从Android代码将Wifi网络标记为移动热点
  • To flag a Wifi network as mobile hotspot from android code based on its SSID

有什么想法吗?

推荐答案

WiFi无法可靠地将自己标识为移动热点.基本上,热点不会告诉您有关它如何连接到Internet的信息,因此没有一种明确的告诉方法.热点的上游连接可能不是以下任何内容:

WiFis don't reliably identify themselves as mobile hotspots. Basically, a hotspot tells you nothing about how it's connected to the Internet, so there isn't a clean way of telling. The hotspot's upstream connection could be anything out of the following:

  • 住宅(DSL,电缆,光纤)Internet连接
  • 移动数据连接
  • 强制性门户网站,需要先在专用网页上进行身份验证,然后才能访问Internet
  • 公司网络,要求您使用代理服务器进行Web访问并阻止大多数非HTTP [s]服务
  • 完全没有Internet连接的隔离网络.

( Radiobeacon (根据AGPLv3许可)具有一种检测移动热点的方法. (这里的想法有所不同,因为应用程序地理参考热点用于位置跟踪,因此需要过滤出位置可能会发生变化的热点,但是这些热点往往位于移动数据连接上,因此您应该获得良好的成功给他们打分.)

Radiobeacon (licensed under AGPLv3) has an approach to detect mobile hotspots. (The idea here is somewhat different, as the app georeferences hotspots to use for position tracking, and thus needs to filter out hotspots whose position is likely to change – but those tend to be on mobile data connections, so you should get a good hit rate from them.)

这是Radiobeacon使用的两种方法之一.检查SSID以获取移动热点中常用的模式(诸如 Android mobile iPhone 之类的字符串).当然,任何人都可以在其非移动热点中使用它(人们的SSID名称确实很有创意),因此要考虑的是错误接受和错误拒绝率.

This is one of the two methods employed by Radiobeacon. Examine the SSID for patterns that are commonly used in mobile hotspots (strings such as Android, mobile, iPhone and the like). Of course, anyone could use that in their non-mobile hotspot (people do get creative about their SSID names), so there's both a false acceptance and false rejection rate to consider.

Radiobeacon使用的另一种方法:查看BSSID(热点的硬件地址). BSSID是格式为00:60:0d:c0:ff:ee的十六进制字符串,其前半部分标识芯片的制造商.有些芯片主要用于移动设备,而另一些则用于固定设备,因此有些前缀表示移动热点.一些前缀已经可以帮助您过滤掉所有iPhone.尽管如此,在移动设备和固定设备中都可能有前缀,而且我们甚至没有在谈论将移动数据连接作为上游链接的家用路由器.

The other method employed by Radiobeacon: Look at the BSSID (the hardware address of the hotspot). The BSSID is a hexadecimal string of the form 00:60:0d:c0:ff:ee, of which the first half identifies the manufacturer of the chip. Some chips are used mainly in mobile equipment while others are used in fixed equipment, thus some prefixes indicate a mobile hotspot. A few prefixes will already help you filter out all iPhones. Still, there may be prefixes that are found in both mobile and fixed equipment, and we're not even talking about home routers which have a mobile data connection as their upstream link.

对于这两个示例,请访问Radiobeacon链接以获取包含黑名单的代码.它们是通过反复试验获得的,可能还远远不够,甚至可能包含错误-但它们可以作为起点.

For both these examples, visit the Radiobeacon link for the code containing the blacklists. They have been obtained by trial and error, may be far from complete or even contain errors – but they may serve as a starting point.

作为第三种方法,您也可以尝试通过诸如 Mozilla定位服务.那里还有其他一些较小的提供商,再加上Google和Apple提供的服务,但后两者可能不合法地用于此目的.

As a third method, you can also try looking up the geographic coordinates for the BSSID through a service such as Mozilla Location Service. There are a handful of other, smaller providers out there, plus the services offered by Google and Apple, but the last two are probably not legal to use for that purpose.

尽管我真的不知道这些服务如何处理移动WiFi的细节,但是他们将需要采取一些预防措施,以防止使用这些服务来确定用户的位置.如果热点移动得太频繁,或者给它们一个低的置信区间,或者只是将它们保留在数据库中,然后由消费者决定使用哪个BSSID位置元组来建立位置,则可能会从数据库中消除热点.

Though I don't really know the details of how these service handle mobile WiFis, they will need to do take some precaution to prevent using these to establish the user's location. The may eliminate hotspots from the database if they move around too frequently, or give them a low confidence interval, or just keep them in the database and leave it up to the consumer to decide which BSSID-location tuples to use for establishing their location.

如果他们采用前两种方法中的一种,那么获得高置信度的位置(最大可达200​​0m,这是WiFi的典型范围)表明您使用的是固定WiFi.如果他们采用最后一种方法,则您还需要通过GPS或小区查找来确定您的位置.如果距离WiFi位置较远(4000米以外的地方),则表明移动热点.

If they go for one of the first two approaches, then getting a position with a high confidence (up to 2000m, which is the typical range of a WiFi) is a sign that you're on a fixed WiFi. If they go for the last approach, you will additionally need to establish your position by means of GPS or cell lookup. If that is far away from the WiFi's location (something beyond 4000 meters), that indicates a mobile hotspot.

您可能要研究的第四种方法是确定外部IP地址(不是分配给设备的IP地址,而是通信对等方将其视为原始Internet地址的地址),然后将其与Internet提供商列表进行匹配.您需要进行一些研究:

A fourth approach you could look into is to determine your external IP address (not the one assigned to your device but the one that your communication peers would see as the originating Internet address), and matching that against a list of Internet providers. You'll need to research that a bit:

  • 如何确定您的外部IP地址–最简单的方法是仅设置自己的Web服务,将IP地址回显给请求者
  • 如何从IP地址中查找它是否属于移动运营商-反向DNS查找可能对此有所启发.

同样,运营商可能会为移动和固定数据客户使用相同的IP地址池.

Again, there is a chance of carriers using the same IP address pool for both mobile and fixed data customers.

这里提到的所有方法都可能给出假阴性或假阳性.您可能希望将这四种方法的结果合并为您处于移动数据连接中的可能性,如果可能性超过特定阈值,则避免移动大量数据.

All approaches mentioned here may give false negatives or false positives. You will probably want to combine he result of all four methods into a likelihood that you're on a mobile data connection, and avoid moving large amounts of data if the likelihood exceeds a certain threshold.

这篇关于根据代码中的名称将Wifi标记为移动热点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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