Usually Mac OS X is a joy to use as things use to just work ™. However, sometimes -well- they just do not :-/ Recently I had a very mysterious issue in Moscow, Russia. Often WiFi would just work ™, however, sometimes that specific access point station would simply not show up at all in the network list. I kept resettings that AP point a couple of times and even started to reboot Mac OS X in misbelieve - what else should one do when that WiFi would not show up nor auto-connect again? More mysteriously that AP I kept resettings worked just fine with with plenty of iPhone’s and iPad’s and the like around. I started to really wonder what was wrong with my Mac when I noticed holding the option key to the boot chooser, that the recovery netbook WiFi selector would show that AP’s SSID network! Hah! I thought it must be some caching issue / plist corruption whatever that irritates the full Mac OS X network stack, but even a few more reboots and wiping of the network settings still made no difference. It was then when I noticed something strange was going on with the Wifi Country Code and thus allowed frequency channels (yeah, I got some inside knowledge, working on drivers and such).
Mar 18 19:53:25 retina kernel[0]: en0: 802.11d country code set to ‘TW’.
Mar 18 22:56:20 retina kernel[0]: en0: 802.11d country code set to ‘X3′.
Mar 18 22:56:21 retina kernel[0]: en0: 802.11d country code set to ‘TW’.
Mar 18 22:56:38 retina kernel[0]: en0: 802.11d country code set to ‘X3′.
Mar 18 22:56:40 retina kernel[0]: en0: 802.11d country code set to ‘TW’.
Mar 18 22:57:26 retina kernel[0]: en0: 802.11d country code set to ‘TW’.
Mar 18 22:59:11 retina kernel[0]: en0: 802.11d country code set to ‘TW’.
Mar 18 23:00:58 retina kernel[0]: en0: 802.11d country code set to ‘X3′.
TW? Taiwan? And what is X3? Rest of world or what??? Either does not sound particularly Russian, so where does it come from? Turns out in Mac OS X Lions 10.7 / 10.8 there is a command line WiFi scanner hidden in the Apple80211.framework:
$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
Xyz 01:23:45:67:89:a0 -83 13 Y TW WPA(PSK/TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
…
It reveled the three or so access points around all were broadcasting with a TW Country Code, obscure bits, nobody cares about, set in the Linux-based firmware once in Taiwan, probably a hardcoded C struct, and forgotten they are. And then all those forgotten bits and pieces lead to this user annoying behavior in the field. Thank you very much! :-/ Mac OS X picks up the mostly TW Country Code bits in the air, … and then concludes channel 13 is not valid, and, … your precious network never makes it into the higher levels of the network stack, nor the UI to choose from.
Given that we can not (too easily and legally) hack into those offending access points and alter the Country Code, how can we fix that? Turns out the access point had a nice sticker with username and password on the bottom side, which allowed me to login and notice it’s channel was set to “Auto”. This explains why sometimes the network worked for me, when the AP choose another channel than 13, … which allowed my MacBook to connect in the “TW” region.
A simply change from “Auto” to a channels with in the range that was not used around by other routers, and I had a WiFi connection happily ever after, …
I hope this helps, and educates not to broadcast random, and wrong settings thru the air!