How can my wifi board detect wireless networks that are in range? What protocol is used to communicate with the devices in the area to announce a wifi AP? Does every router transmit on its own frequency and my wifi board scans "every" frequency to detect one?
How can my wifi board detect wireless networks that are in range?
Your client has a radio which listens to the wifi 802.11 frequencies for the country configured in the radio.
What protocol is used to communicate with the devices in the area to announce a wifi AP?
Wifi APs are configured with an SSID; those SSIDs are known via beacon frames; by default beacon frames are sent every 102.4 milliseconds.
The radio in your AP is configured for a specific channel. Those beacon frames are transmitted on the AP's channel.
Does every router transmit on its own frequency and my wifi board scans "every" frequency to detect one?
Every wireless AP can select from a pre-defined list of wireless channels, and it chooses one channel to announce the SSID. Your wifi client constantly walks (or scans through) all those channels to figure out which SSIDs are available.
The IEEE 802.11 standards define two methods for a client device to discover wireless networks in the area. Both methods are based on using 802.11 management frames as defined in these standards.
The first method is a passive method. All 802.11 infrastructure devices will send out a beacon frame approximately every 100ms (this is the default for many devices, but often can be configured either higher or lower) for each wireless network it is provide service for at the time. These beacon frames will contain information about the wireless network such as the SSID (aka network name), encryption details (if any), supported data rates, etc.
Wireless clients that are in the area will be able to "hear" the beacon and know the network is in the area, adding it to any
The second method is an active method, and is the one most often used by operating systems. The client device can send a probe request frame either generally ("Is anyone out there?") or to a specific network ("Hey, Bill, are you out there?"). An access point (any in the first case, matching ones in the second) will respond to this probe request with a probe response that will contain information similar to a beacon frame.
This probe request/probe response process is also part of the association process by which a station joins a wireless network.
The reason that the active method is generally preferred by most operating systems is obvious when one sits down to think about it. To discover a network passively, the device will have to listen on a channel long enough to stand a good chance of hearing a beacon frame. Since a beacon is only sent every period of time, a device may have to listen (and only listen) for 200ms or more to make sure they hear all the networks. If you only consider 2.4GHz, that is at least 11 channels...do the math.
The active method allows a station to switch to a channel, send a probe request, pause briefly (less than 100ms) and then move to the next channel. This makes this a faster process while still being fairly confident it has found the networks on that channel.