Fetch unique identifier for a WiFi router
Is there any way I can get any unique identifier for a particular wifi router?
I'm trying to write an Android app that needs to know which router it is connected to. I know that android provides a way to get the BSSID of the currently connected network, but to my surprise, this is not unique.
I found out that on dual band routers, two different devices could be getting two different BSSID, even if they are on the same SSID.
Is there any other parameter I can fetch that can uniquely identify the wifi I am connected to? I would love to try some third party library, if that would allow me, since I am quite certain Android does not come packaged with a better method than giving me the BSSID.
Edit: I'm trying to find out who all have set their home wifi (via the app) as the same Wi-Fi as me. Each user sets their 'home Wi-Fi' which gets saved on the server ( the mac address is what I'm saving). Then each user can query who all are on their Wi-Fi, and if they are currently connected on that Wi-Fi or not. The query of 'who is on my wifi' is done by searching for the same MAC address as the one I'm connected to. This fails if my home has a dual band, since they could be connected to the second frequency (and thus second MAC).
You are correct in assuming that getBSSID()
will return two different addresses for the two different bands, as they are essentially two different access points, one 2.4GHz and one 5 GHz, simply wrapped up in the same package. I wrote a quick app that gets and displays all of the available fields that may be obtained using the WifiInfo
class. When I connected to the 2.4 GHz band of my access point the details were as follows:
Note that you can tell you are connected to the 2.4 GHz band ("Frequency: 2452"). Repeating the process with the 5 GHz band shows the following:
As you can see, the MAC addresses for the two different bands differ by only one number; I do not know if this is the case for all routers. If this is indeed the case, then you can conclusively determine which access point you are connected to by analyzing a combination of the MAC address (BSSID) and the frequency.
Sadly, there is no guaranteed method of uniquely identifying a specific access point. You can come close by using the SSID, MAC, etc. but it wouldn't necessarily work every time and it would still be possible for someone to spoof this if they desired.
If you wish to consider different WiFi interfaces(1) (as opposed to the physical device supporting it) then the MAC address is, by definition, what you need (barring broken devices that wrongly re-use a MAC).
(1) I use the word "interfaces" because it's possible to support multiple networks (ie SSIDs) on the same interface. An interface will effectively be a single channel at a single frequency.
Just use MAC address of the AP. (MAC Address is unique)
Here is how: Can I find the MAC address of my Access point in Android?
链接地址: http://www.djcxy.com/p/70128.html上一篇: 通过我的手机将设备神奇地桥接到我的网络?
下一篇: 获取WiFi路由器的唯一标识符