Networking · Wireless Networking
DCF Backoff and the Contention Window Growth Rule
How a station decides when to transmit after the medium goes idle, why the backoff is counted in slots rather than microseconds, and how the window doubles after loss.
A station with a frame ready does not transmit when the medium goes idle. It waits a fixed interval, then draws a random number of slot times and counts them down, transmitting only if the medium is still idle when the counter reaches zero. The counter pauses whenever another station starts transmitting. The randomness is what prevents every waiting station from starting at the same instant; the pausing is what makes the countdown a queue rather than a timer.
The interframe spacing ladder
802.11 defines several interframe spaces, and their relative lengths encode priority without any explicit field. The shortest is the short interframe space, used before acknowledgements, CTS frames, and the fragments of a burst. The distributed coordination function interframe space, DIFS, is longer and is the delay a ordinary data frame must observe. An extended interframe space exists for frames a station sends after it has failed to decode something and wants to give the current exchange more room to finish.
The numbers scale with the physical layer. For the OFDM PHYs the slot time is 9 microseconds, SIFS is 16 microseconds, and DIFS is SIFS plus two slot times, 34 microseconds. For the older direct-sequence PHY the slot is 20 microseconds, SIFS is 10, and DIFS is 50. The exact values matter less than the ordering guarantee they create: because SIFS is strictly shorter than DIFS, a station that is mid-exchange can always respond before any contending station’s timer can expire. The gap is the priority mechanism. A station that hears an ACK knows the exchange continues, and it restarts its countdown after the next DIFS.
This is also why the ACK timeout is a small multiple of SIFS rather than a round number of milliseconds. The sender must decide the frame was lost before a contending station could have legitimately taken the medium, otherwise the retry logic and the contention logic disagree about who owns the channel.
Counting down in slots
The backoff procedure has three parts: a random integer, a slot counter, and the rule that the counter only decrements while the medium is idle.
When a station has a frame to send and the medium has been idle for DIFS, it draws a backoff value uniformly from the range zero to CW, where CW is the current contention window. It then waits that many slot times. If the medium becomes busy at any point, the counter freezes at its current value and resumes after the next DIFS. A station that has never transmitted in this contention round and draws zero transmits immediately, which is why a lightly loaded network sees almost no delay.
The freeze-and-resume rule has a consequence that is easy to miss: an interrupted countdown is resumed, never redrawn. A station that has counted down to 7 and then hears another station transmit keeps the 7 and continues from there when the medium clears, rather than drawing a new value. A fresh draw happens only when the previous backoff has been completed or abandoned — at the start of a new frame, or after a failed attempt — which is why the count is per-station state stored with a flag saying whether a draw is outstanding, rather than something recomputed for each frame.
Backoff is counted in slot times rather than microseconds because slot times are a unit the PHY defines, and because the count must be suspended and resumed without drift. Counting in slots means that a station that freezes at 7 and resumes still has exactly 7 slots of deference, regardless of how long the interruption lasted.
/* The essential state machine, with the parts 802.11 leaves to the PHY removed. */
struct dcf {
unsigned cw_min; /* 31 for the DSSS PHY, 15 for the OFDM PHYs */
unsigned cw_max; /* 1023 for both */
unsigned cw; /* current contention window */
unsigned backoff; /* slots remaining */
int frozen;
};
void on_medium_busy(struct dcf *d)
{
if (d->backoff > 0)
d->frozen = 1; /* keep the remaining count, do not redraw */
}
void on_difs_expired(struct dcf *d)
{
if (d->frozen) {
d->frozen = 0;
return; /* resume counting from where it stopped */
}
d->cw = d->cw_min; /* new frame, new draw */
d->backoff = rand() % (d->cw + 1);
}
void on_slot(struct dcf *d)
{
if (d->backoff > 0 && --d->backoff == 0)
transmit();
}
void on_no_ack(struct dcf *d)
{
d->cw = (d->cw * 2 + 1 > d->cw_max) ? d->cw_max : d->cw * 2 + 1;
d->backoff = rand() % (d->cw + 1); /* redraw, do not resume */
}
The doubling in on_no_ack is the exponential backoff proper. After the first failure the window goes from 15 to 31, after the second to 63, and so on to a cap. The cap exists so that a station in a bad radio environment does not defer for unbounded time and starve; the doubling exists so that a congested cell spreads retries over a wider range and reduces the chance that the same two stations collide again.
Note the asymmetry in the code: a busy medium freezes and resumes, a failed transmission redraws. Freezing preserves a station’s position in the implicit queue; redrawing randomises it after a loss, which is the only way to break a persistent collision between two stations whose backoff draws keep coinciding.
Why the window is bounded and where the bound comes from
The maximum contention window is a PHY-dependent constant: 1023 slots for the 2.4 GHz OFDM PHY, 1023 for the 5 GHz PHY, and 1023 slots for the direct-sequence PHY with a minimum of 31. The minimum is also PHY-dependent and is set to the value at which the expected collision probability under a fully loaded cell is acceptable rather than zero. These are spec constants, not tuning parameters, and a station that used a smaller minimum would take more than its share.
The cost of a large window is latency. At 9 microseconds per slot, a window of 1023 slots spans about 9.2 milliseconds of possible deferral, and the expected wait is half of that. A voice frame that has already spent 20 milliseconds in a queue cannot afford another 5 milliseconds of contention, which is why 802.11e introduced access categories with different window parameters rather than one global set. A voice access category uses a minimum contention window of 3 slots and a maximum of 7, so its expected contention delay is a small fraction of a millisecond, while background traffic uses a window that grows to 1023 slots and absorbs the deferral instead.
The trade is explicit: narrower windows buy latency at the cost of collision probability, wider windows buy collision avoidance at the cost of delay. Because the categories are enforced by the same slot-counting machinery and the same interframe spaces, a high-priority station wins not by transmitting during another station’s turn but by drawing from a shorter range and waiting a shorter interval before counting.
Throughput behaviour under load
The classic analysis of this protocol treats each station as a two-state process: it either has a frame to send or it is in backoff, and it transmits with a probability that depends on the window and the collision probability it observes. The result is that throughput rises with offered load, peaks, and then falls as collisions consume an increasing share of airtime. The peak occurs at a number of active stations that depends on the frame size and the window parameters, and beyond it adding stations reduces total throughput rather than increasing it.
The reason is that a collision wastes the entire frame duration, and the wasted airtime is not recovered by anyone. Retransmissions add load, which raises collision probability, which raises the window, which lengthens the average deferral, which increases the queueing delay at every station. The system reaches an equilibrium in which a large fraction of airtime is spent on frames that no one receives.
The practical consequence for a network designer is that a cell with many active stations is not simply slower per station; it is slower in aggregate. Splitting the same stations across two channels, or reducing the number of stations that transmit simultaneously by scheduling, recovers throughput that contention destroys. This is the argument that eventually produced the scheduled, OFDMA-based access in later amendments, described in OFDMA scheduling and multi-user transmission.
Frame size interacts with all of this. A long frame occupies the medium for longer, so a collision costs more; but the per-frame overhead of preamble, header, interframe spaces, and ACK is amortised over more payload. Aggregation, discussed in A-MPDU aggregation and block acknowledgement, is the mechanism that lets a station hold the medium for a long, efficient burst after winning contention once, which shifts the trade in favour of fewer, larger transmissions.
The edges of the model
Several assumptions in the procedure break in real deployments.
The backoff counter is per-station, but real stations run multiple access categories with independent counters. A station with four active categories contends four times, and the aggregate load it presents to the cell is larger than a single-station model suggests. The virtual contention among a station’s own queues is resolved internally, so the airtime a station captures is the sum of its categories’ shares rather than one share.
The collision signal is the missing ACK, and a missing ACK does not distinguish collision from channel loss. A station at the edge of coverage loses frames to attenuation, doubles its window, and defers longer than a nearby station with a clean channel. The result is that distant stations get less airtime precisely when they need more of it, an effect that interacts with rate selection and is the subject of Airtime fairness and the slow-client problem.
Finally, the countdown assumes the medium state it observes is the medium state that matters. In an overlapping cell, a station may defer to a transmission that could not have collided with it, spending airtime on politeness. The mechanisms that try to distinguish harmful from harmless overlap are covered in Spatial reuse, OBSS, and BSS coloring.
References
- IEEE 802.11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications — IEEE
- Performance Analysis of the IEEE 802.11 Distributed Coordination Function — Bianchi, IEEE Journal on Selected Areas in Communications, 2000
- 802.11 Wireless Networks: The Definitive Guide — Matthew Gast, O'Reilly