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.
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.
3. The Connection Dance
Connecting to Wifi is a rigorous 4-step process. If any step fails, you get "Unable to connect."
- Scanning: The client sends
Probe Requestframes. APs respond withProbe Responsecontaining capabilities (Rates, SSID). - Authentication (802.11): A legacy artifact. Usually just "Open System" authentication saying "Hello, I exist."
- Association: The client asks to join the BSS (Basic Service Set). The AP assigns an Association ID (AID).
- 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