Sub topic 9
Sharing the air: CSMA/CA and airtime
This chapter assumes you know what a channel and a channel width are, and that an access point (AP) and its clients form a basic service set (BSS). Here you will learn how devices on one channel take turns, why that turn-taking costs throughput, and why slow devices slow down everyone else.
One channel, one speaker at a time
A Wi-Fi channel is a shared medium. If two nearby devices transmit on the same channel at the same moment, their signals mix and neither frame can be decoded. Wired Ethernet solved this long ago with switches and full-duplex links. Wi-Fi cannot, because a radio cannot reliably listen while it transmits on the same frequency. The signal it sends is vastly stronger than the one it is trying to hear.
So Wi-Fi uses CSMA/CA, which stands for Carrier Sense Multiple Access with Collision Avoidance. Ethernet's old shared-cable scheme, CSMA/CD, detected collisions after they happened. Wi-Fi tries to avoid them, because it cannot detect them.
- Carrier sense: a device listens before it talks.
- Multiple access: many devices share the same channel.
- Collision avoidance: devices wait a random time before sending, which makes simultaneous starts unlikely.
The contention steps
The core mechanism is called the Distributed Coordination Function (DCF). The steps are:
- The device has a frame to send. It checks whether the channel is idle.
- If the channel stays idle for a fixed gap called DIFS (DCF Interframe Space), the device may start its countdown.
- It picks a random backoff number of slots from a range called the contention window (CW). A slot is a few microseconds long, for example 9 µs on 5 GHz.
- It counts down one slot at a time, but only while the channel is idle. If another device starts transmitting, the countdown freezes and resumes after that transmission ends.
- At zero, the device transmits.
- The receiver replies with an ACK (acknowledgement) after a short gap called SIFS (Short Interframe Space). SIFS is shorter than DIFS, so an ACK always wins the air over a new contender.
- If no ACK arrives, the sender assumes a collision or loss. It doubles its contention window, up to a maximum, and tries again.
Two devices can still pick the same backoff value and collide. That is why the contention window doubles after each failure: more possible values means fewer repeat collisions.
Hidden nodes and RTS/CTS
Carrier sense only works if you can hear the other transmitter. Imagine two clients on opposite sides of an AP. Each hears the AP, but they are too far apart to hear each other. Both sense an idle channel and transmit, and the frames collide at the AP. This is the hidden node problem.
The optional RTS/CTS handshake addresses it:
- The client sends a short Request to Send (RTS).
- The AP answers with a Clear to Send (CTS). Every device in range of the AP hears the CTS.
- Devices that hear it set a timer called the NAV (Network Allocation Vector) and stay quiet for the stated duration.
- The client sends its data.
RTS/CTS adds overhead to every exchange, so it is usually applied only to frames above a size threshold. On most home networks it is off.
Airtime: the real shared resource
Because only one device transmits at a time, the useful way to think about a channel is airtime: the fraction of time spent transmitting. Throughput is not shared fairly. The contention process gives each device roughly equal chances to send frames, not equal chances to use time.
That matters because a frame sent at a low data rate takes much longer on the air than the same frame at a high rate. The effect is called the performance anomaly.
A worked example. A 1500-byte frame is 12,000 bits. Ignoring overhead:
| Client | Data rate | Time for one frame |
|---|---|---|
| Close to AP | 120 Mbit/s | 100 µs |
| Far from AP | 6 Mbit/s | 2000 µs |
If both clients win contention equally often, the far client uses 20 times as much airtime per frame. The fast client's throughput falls to about the same low figure as the slow client's, even though it could go much faster.
You can compute this yourself:
def per_client_throughput(rates_mbps, frame_bits=12000):
"""Each client sends one frame per round; return the shared per-client throughput in Mbit/s."""
round_time_us = sum(frame_bits / r for r in rates_mbps) # bits / (Mbit/s) = microseconds
return frame_bits / round_time_us
print(per_client_throughput([120, 120])) # 60.0
print(per_client_throughput([120, 6])) # about 11.4Two fast clients get 60 Mbit/s each. Replace one with a 6 Mbit/s client and both drop to about 11.4 Mbit/s, so the fast client lost most of its speed.
Overhead you cannot avoid
Every frame carries costs that do not carry your data:
- A preamble and header sent at a low, robust rate so all devices can decode them.
- DIFS, the backoff slots, SIFS and the ACK.
- Beacons from the AP, usually about ten per second per SSID, sent at a basic rate.
Small frames suffer most, since the fixed overhead is a large share of their airtime. Later standards respond with frame aggregation (several frames sent in one transmission with one ACK) in 802.11n and later. This is one reason real throughput is far below the headline rate, a topic the later chapter on real throughput returns to.
Practical consequences
- Many SSIDs cost airtime. Each SSID on an AP sends its own beacons. Ten SSIDs can use a visible share of a busy channel. Keep the count low.
- Remove old low rates. Disabling the lowest basic rates (such as 1, 2 and 5.5 Mbit/s on 2.4 GHz) forces beacons and management frames to go faster and pushes distant clients to roam to a closer AP.
- Neighbors count too. Carrier sense works across networks. An AP on the same channel as your neighbor's shares airtime with it, even though the two networks are unrelated. Chapter material on co-channel interference covers this.
- Wi-Fi 6 changes the model. OFDMA lets one transmission carry data for several clients, which reduces the cost of contention for small frames.
Observing airtime on Linux
The iw tool reports the data rate of your link. A low rate here is the signal that a client is expensive in airtime.
iw dev wlan0 link
iw dev wlan0 station dump | grep -E 'signal:|tx bitrate:|rx bitrate:'Exercise
Three clients share one 5 GHz channel. Two send at 100 Mbit/s and one sends at 10 Mbit/s. Each wins contention equally often and sends 12,000-bit frames. Using the per-round model from this chapter, what throughput does each client get, in Mbit/s?
Show answer
One round takes 12000/100 + 12000/100 + 12000/10 = 120 + 120 + 1200 = 1440 µs. Each client sends 12,000 bits per round, so each gets 12000 / 1440 ≈ 8.3 Mbit/s. The slow client drags the two fast ones down from a possible 100 Mbit/s to the same figure as itself.
Exercise
Why does Wi-Fi use collision avoidance rather than collision detection, and what problem does RTS/CTS address that carrier sensing cannot?
Show answer
A Wi-Fi radio cannot reliably listen while transmitting, so it cannot detect a collision as it happens. It instead waits a random backoff before sending to make collisions unlikely. Carrier sensing fails when two clients cannot hear each other (the hidden node problem). RTS/CTS lets the AP's CTS reach both clients, and the NAV timer makes them defer.