问题
The problem is as follows - there's a university campus wide wifi connection with a single SSID, say "campus-wifi". The user freely roams around campus, and the usual hand-off between access points occurs. My question is, is there any information at any layer of the network stack that allows the client to identify (any unique identifier is fine) the specific access point they're connected to, rather than simply the fact that they are connected to "campus-wifi"?
If it's relevant, I'd like to be able to do this from mobile devices (android/iOS primarily).
回答1:
You can get the BSSID of the access point you are connected to. Something like:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String BSSID = info.getBSSID();
Not 100% what you'll get back with the BSSID since I've never used it -- but it should uniquely ID the base station -- Wikipedia seems to indicate that you'll get the MAC of the AP (near the bottom):
http://en.wikipedia.org/wiki/Service_set_(802.11_network)#Basic_service_set_identifier_.28BSSID.29
-- Dan
EDIT:
According to the Android docs, it is the MAC address:
http://developer.android.com/reference/android/net/wifi/WifiInfo.html
来源:https://stackoverflow.com/questions/5629665/ways-for-a-client-to-identify-the-specific-access-point-it-is-connected-to-withi