802.11 — Wireless LAN MAC Layer

80211-MAC

How Wi-Fi devices share a half-duplex medium using CSMA/CA, frame types, and the association state machine.

802.11wificsma-calayer2wirelessmacrts-cts

Overview

The Layer 1 Wireless article covered frequencies, modulation, and signal propagation. This article covers Layer 2: how 802.11 devices take turns on a shared half-duplex RF medium, how a client joins a BSS, and what an 802.11 frame actually contains.

Unlike Ethernet, wireless is inherently half-duplex and broadcast. Every station on the same channel hears every transmission. Because a transmitting station cannot simultaneously detect collisions from other stations (the hidden terminal problem), 802.11 uses collision avoidance rather than collision detection — CSMA/CA instead of CSMA/CD.

CSMA/CA — Carrier Sense Multiple Access with Collision Avoidance

Before transmitting, a station listens to the medium. If it detects activity, it waits until the medium is idle, then waits an additional DIFS (Distributed Interframe Space) period, then starts a random backoff timer. The timer counts down only while the medium remains idle. When it reaches zero the station transmits.

Station A
Medium
Sense idle → wait DIFS (34 μs)
802.11g values
Backoff: random 0–CW slots
Initial contention window CW = 0–15 slots
DATA frame
Transmits when backoff reaches 0
DATA received — B defers
B's backoff pauses while medium is busy
ACK after SIFS (16 μs)
Shortest IFS — highest priority

Each successfully received unicast frame is acknowledged with an ACK sent after a SIFS (Short Interframe Space). If no ACK arrives the sender assumes a collision and retransmits after doubling the contention window (binary exponential backoff).

Interframe Spaces

IFSDuration (802.11g)Purpose
SIFS16 μsACKs, CTS — highest priority, no backoff
DIFS34 μsNormal data frames
AIFSVariableQoS differentiation (802.11e / WMM)
EIFSExtendedAfter a frame error — gives time to clear

RTS/CTS — Solving the Hidden Terminal Problem

Two stations may be in range of the AP but out of range of each other. Both sense the medium as idle, transmit simultaneously, and collide at the AP. RTS/CTS (Request to Send / Clear to Send) solves this:

Station A
Access Point
RTS (duration = DATA + ACK time)
Small frame — low collision cost
CTS (broadcast, same duration)
Heard by all stations including B
NAV timer set — defers
B saw CTS duration, knows medium is reserved
DATA
No collision from B
ACK

The NAV (Network Allocation Vector) is a virtual carrier sense timer stations set when they read a duration field in any frame. A station with a non-zero NAV defers without physically sensing the medium.

802.11 Frame Types

TypeSubtypesPurpose
ManagementBeacon, Probe Req/Resp, Auth, Assoc Req/Resp, Disassoc, DeauthBSS management — discovery, joining, leaving
ControlRTS, CTS, ACK, Block ACK, PS-PollMedium access and flow control
DataData, Null, QoS DataActual payload delivery

802.11 MAC Frame Format

802.11 MAC Frame

Frame Control (2B)
2B
Duration / ID (2B)
2B
Address 1 — Receiver (6B)
6B
Address 2 — Transmitter (6B)
6B
Address 3 — Dest / BSSID (6B)
6B
Sequence Control (2B)
2B
Address 4 — WDS only (6B)
6B
QoS Control — optional (2B)
2B
Frame Body (0–7951 B)
8B
FCS — CRC-32 (4B)
4B

802.11 uses up to four address fields — more than Ethernet’s two. Their meaning depends on the To DS and From DS bits in Frame Control:

To DSFrom DSAddr 1Addr 2Addr 3Addr 4
00DestinationSourceBSSID
01DestinationBSSIDSource
10BSSIDSourceDestination
11Receiver APTransmitter APDestinationSource

The 1/1 case applies only in WDS (AP-to-AP wireless backhaul) links.

Frame Control Field

Frame Control (2 bytes)

Protocol Version (2b)
1B
Type (2b)
1B
Subtype (4b)
1B
To DS (1b)
1B
From DS (1b)
1B
More Frag
1B
Retry
1B
Power Mgmt
1B
More Data
1B
Protected Frame
1B
Order
1B

Type 00 = Management, 01 = Control, 10 = Data. The Protected Frame bit indicates the frame body is encrypted (WPA2/WPA3).

BSS, SSID, and ESS

TermMeaning
BSSBasic Service Set — one AP and its associated clients
BSSIDMAC address of the AP radio — identifies the BSS
SSIDNetwork name — human-readable string
ESSExtended Service Set — multiple APs sharing one SSID
IBSSIndependent BSS — ad-hoc, no AP

Clients roam between APs in an ESS by reassociating to the AP with the strongest signal. The DS (Distribution System) interconnects APs — typically Ethernet or a wireless backhaul.

Association State Machine

A client must step through three states before passing data frames.

Client (STA)
Access Point (AP)
Probe Request (broadcast or directed)
Active scanning — client broadcasts to find SSIDs
Probe Response
AP capabilities, supported rates, SSID, security info
Authentication Request (Open System)
Always succeeds at L2 — real auth is WPA2/3
Authentication Response (status = 0)
Client moves to State 2: Authenticated, Unassociated
Association Request (capabilities, SSID, rates)
Association Response (AID assigned)
Client in State 3 — data frames now allowed
StateDescriptionPermitted frames
1Unauthenticated, UnassociatedManagement only
2Authenticated, UnassociatedManagement + Control
3Authenticated, AssociatedAll frames — data traffic flows

Passive scanning: instead of sending Probe Requests, a client listens for Beacon frames sent by APs every 102.4 ms (default). Slower to discover networks, but uses no airtime.

Beacons

APs broadcast Beacon frames at the DTIM interval to announce the BSS. Beacons contain:

Power Save Mode

Clients indicate doze state in their Association Request. The AP buffers frames for sleeping clients and announces which clients have buffered traffic in the TIM element of each Beacon. Clients wake at the DTIM interval to receive buffered multicast/broadcast, and send PS-Poll frames to retrieve buffered unicast.

Block ACK

High-throughput amendments (802.11n/ac/ax) use Block ACK to acknowledge multiple frames at once. The sender transmits a burst of frames (A-MPDU — aggregated MAC Protocol Data Units), then the receiver sends one Block ACK bitmap confirming which frames arrived. This dramatically reduces the overhead of individual per-frame ACKs at high data rates.

References