Skip to main content

12.3 Network Topologies

With the frame header byte ordering sorted out, we need to take a step back and look at the bigger picture.

These frames don't fly around in a vacuum—they are produced and consumed within a specific "social structure." This is the network topology. 802.11 defines the "basic rules" for device interaction, and built on top of those rules, the most common is the first mode we'll discuss.


Infrastructure BSS

This is the mode most people interact with daily. Your home router, your company's Wi-Fi—they are fundamentally all running on this same setup.

In this mode, the world is not equal: there is a central node called an AP (Access Point), surrounded by a circle of Client Stations. The AP and its clients together form a BSS (Basic Service Set).

It's like a star topology: all roads lead to the AP.

But you can't just connect and start using it. For a client to send data through the AP, it must first complete two steps: Authentication and Association.

This might sound like bureaucratic red tape, but think of it this way: the wireless medium is shared, and the AP needs to know "who you are" and "what you want to do." In most cases, before a client even knocks on the AP's door, it will perform a Scanning to see which APs are nearby, how strong their signals are, and what data rates they support. It's like checking the menu and reviews before walking into a restaurant.

Association is exclusive. At any given time, a client can only be bound to a single AP. You can't have a foot in both camps.

Once association succeeds, the AP assigns the client an AID (Association ID). This is a number between 1 and 2007 that uniquely identifies the client within the current BSS.

What's Behind the AP?

From a kernel developer's perspective, what exactly is an AP?

Essentially, an AP is just a wireless network card with some peripheral hardware attached (like an Ethernet port, LEDs, and that infuriating Reset button). But what truly turns it into an AP is the software running on top of it.

Enter a famous player: hostapd.

hostapd is a user-space daemon. It handles the heavy management tasks within the MLME (MAC Layer Management Entity), such as processing authentication requests and association requests. How does it work? It registers itself through the nl80211 interface to specifically receive relevant management frames. If we compare these management frames to administrative paperwork, hostapd is the person sitting behind the window stamping them.

The entire hostapd project is open source, empowering countless ordinary wireless network cards with the ability to transform into APs.

How Does Data Flow?

In Infrastructure mode, communication almost always goes through the AP.

  • Client → AP: The client sends the data frame to the AP.
  • AP → Destination: After receiving it, the AP forwards it to the final destination (which could be another wireless client, or an external device bridged out through a wired network).

This "everyone must cross the bridge to get across the river" design might seem inefficient, but it greatly simplifies management. The AP holds a global view.

If you need to cover a large area (like a big office building), a single AP won't cut it. In this case, we deploy multiple APs and connect them with Ethernet cables. This deployment architecture is called an ESS (Extended Service Set). In an ESS, two or more BSSs exist simultaneously.

Here is a tricky detail: a broadcast frame sent in BSS A might drift into neighboring BSS B. Stations in BSS B will receive it, but they must discard it. Why? Because the BSSID in the 802.11 header doesn't match. It's like hearing the roll call in the next classroom—you hear it, but they aren't calling your name.

So, in an ESS deployment, to avoid interfering with each other, adjacent APs typically operate on different channels.


IBSS (Independent BSS), a.k.a. Ad Hoc Mode

If Infrastructure mode is "centralized authority," then IBSS mode is "anarchism."

IBSS (Independent BSS) is commonly known as an Ad Hoc network. It doesn't need an AP, doesn't need a router—devices just gather together and communicate. This type of network is usually set up temporarily, used on the fly, and requires no pre-planning.

Setting Up an IBSS

Setting up an IBSS is ridiculously simple. You don't need to write complex logic in the kernel; just type a couple of commands in the terminal.

Using the iw tool (the modern generation of tools):

iw wlan0 ibss join AdHocNetworkName 2412

Here, 2412 refers to the center frequency of channel 1 (in MHz).

Or using the old-school iwconfig:

iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid AdHocNetworkName

The moment you press Enter, the kernel calls the ieee80211_sta_create_ibss() method (defined in net/mac80211/ibss.c), and the IBSS network is born.

Of course, you'll need to figure out a way to tell the SSID (network name) to everyone who wants to join—type it in manually, or write it on a piece of paper and send a photo, whatever works for you.

What Makes IBSS Unique?

With no AP around, who's in charge?

Nobody.

In IBSS mode, the BSSID is a randomly generated 48-bit address (implemented by calling get_random_bytes()). Because there is no central node, many tasks that the AP would handle in Infrastructure mode must now be negotiated among peers, or simply abandoned altogether.

One of the mechanisms that is complex enough to cause headaches is Power Save.

In Infrastructure mode, when you sleep, the AP keeps watch for you. But in Ad Hoc mode, there is no AP to act as your nanny. IBSS uses a message called ATIM (Announcement Traffic Indication Map) to coordinate who should be awake and who should be asleep.

Frankly, the ATIM mechanism is quite complex and fragile, and mac80211 currently does not support ATIM. So if you're writing a driver or debugging and counting on this feature, you're going to be disappointed. We won't dive into that rabbit hole in this chapter.


Now that we have a clear understanding of the two most basic network formations. In the next section, we will dive into one of the most important mechanisms in the mac80211 stack: Power Save Mode. We'll see exactly how the AP "delivers mail" for clients in Infrastructure mode, and explore the pitfalls that have caused countless driver developers to pull their hair out.