With Windows XP Wireless networking, the build-in supplicant revolves around the Preferred network list. This is the list of wireless networks and their configurations organized in the order in which we would PREFER to connect. Simple enough! However, as is noted in many places on the web, this list sometimes does not appear to be the order in which we actually connect, especially when hidden networks are involved.
So why is this? If my Preferred Network list contains the networks I want to connect to and in the proper order, why should the supplicant behave any differently than what I have specified? Well, the reason for this is because the Preferred List is not the only list used by the XP Supplicant. There are actually three lists!
The first, of course, is the Preferred List which we have already talked about. The other two lists are internal lists used by the supplicant logic to determine what order to actually connect to the available wireless networks. The second list the Visible Network List. This list contains all Service Set Identifiers (SSIDs) that the wireless interface can see as a result of the periodic scans performed by the network card. Every 60 seconds, the network card will scan the airwaves for any Access Points (APs) that are broadcasting an SSID in their beacon frames. When the network card sees the SSIDs, it reports them back to the operating system and a Visible Network list built.
The third list is the Select list and this is the most important list as this is the true order in which we will attempt to connect. This list is a combination of the Preferred list and the Visible list. The Wireless Configuration Service (WZC) applies a specific logic when building this list. First it makes a distinction between Infrastructure environments (APs and such) and Ad Hoc networks, giving preference to Infrastructure networks. Also, it prefers visible networks over non-broadcast networks (see Tim's post on hidden networks!). I will get to why this approach is taken later, but for now, this is order.
So consider the following Preferred Network list:
SSID1: Adh0cNetw0rk (Visible Adhoc Network)
SSID2: H1dd3nN3w0Rk (Non-broadcast Network)
SSID3: Br0adcA5tN3tw0Rk (Visible Network)
Now we look at the Visible list as returned by the network card:
SSID2: Br0adcA5tN3tw0Rk (Visible Network)
SSID3: S0m30th3N3tw0rK (Random Visible Network)
WZC will then combine these two list and this will result in a Select list that looks like this:
SSID1: Br0adcA5tN3tw0Rk (Visible Network)
SSID3: Adh0cNetw0rk (Visible Adhoc Network)
The complete ordering logic of WZC service is as follows:
Visible Preferred Infrastructure (VPI), Non-visible Preferred Infrastructure (PI), Visible Preferred Ad hoc (VPA) and Non-visible Preferred Ad hoc (PA)