Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch unique identifier for a WiFi router

Tags:

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).

like image 341
Urban Avatar asked Apr 17 '15 07:04

Urban


1 Answers

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:

enter image description here

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:

enter image description here

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.

like image 138
Willis Avatar answered Oct 14 '22 03:10

Willis