ChebbiOS

The Wifi Stack (802.11)

Understanding the chaotic world of RF, Frames, and State Machines.

As a low-level engineer, you might deal with drivers (Linux `mac80211`), firmware, or embedded IoT. Wifi isn't just "Ethernet without wires"; it is a complex state machine built to manage a shared, noisy medium.


1. The Layers

The 802.11 standard maps primarily to the Physical (PHY) and Data Link (MAC) layers of the OSI model.

LLC
Logical Link Control (802.2)
Multiplexing protocols (IP, ARP)
MAC
Media Access Control (802.11)
CSMA/CA, Retries, Encryption, Fragmentation
PHY
Physical Layer (RF)
Modulation (OFDM, DSSS), Frequencies (2.4/5GHz)

2. Anatomy of a Frame

Unlike Ethernet frames which are simple destination/source structures, Wifi frames are heavily packed with management info.

Frame Types

  • Management (Type 00): Beacons, Probes, Auth, Assoc. These manage the connection.
  • Control (Type 01): RTS, CTS, ACK. These manage the medium (prevent collisions).
  • Data (Type 10): The actual IP packets wrapped in 802.11 headers.
FC
2 Bytes
Dur
2 Bytes
Addr 1
Receiver
Addr 2
Transmitter
Addr 3
Destination
Seq
Control
Frame Body (Layout Varies)
FCS
CRC32

3. The Connection Dance

Connecting to Wifi is a rigorous 4-step process. If any step fails, you get "Unable to connect."

  1. Scanning: The client sends Probe Request frames. APs respond with Probe Response containing capabilities (Rates, SSID).
  2. Authentication (802.11): A legacy artifact. Usually just "Open System" authentication saying "Hello, I exist."
  3. Association: The client asks to join the BSS (Basic Service Set). The AP assigns an Association ID (AID).
  4. 4-Way Handshake (Security): The real authentication (WPA2/WPA3).
    • PTK (Pairwise Transient Key) is derived.
    • GTK (Group Temporal Key) for broadcasts is exchanged.
    • If this fails, it's usually a "Wrong Password" error.

Connect & Discuss

Have questions about systems engineering, or found a bug in the code? Reach out!

Feedback

This blog is a static site, but I'd love to hear your thoughts. You can discuss this post by sending me an email or reaching out on social media.

Send Feedback