CSMA/CA: Carrier Sense Multiple Access with Collision Avoidance
Contention Window: Random Backoff and Collision Avoidance
Read aloud is unavailable in this browser.
The Heart of Collision Avoidance
The Contention Window (CW) is the defining mechanism of CSMA/CA. While interframe spaces provide timing structure and acknowledgments confirm success, the contention window is where collisions are actually avoided—through randomness.
The core insight is elegant: when multiple stations want to transmit, instead of letting them all transmit simultaneously (causing collision), make each station wait a random amount of time. With high probability, their random delays will differ, and they'll transmit sequentially rather than simultaneously.
But the implementation is more sophisticated than simple randomness. The contention window adapts to network conditions, growing after collisions to reduce contention during busy periods and shrinking during light load to minimize latency. This adaptive behavior is crucial for performance across varying network conditions.
By the end of this page, you will understand the complete contention window mechanism: how backoff values are selected, how the contention window adapts through binary exponential backoff, how counters freeze and resume, and the performance implications of these design choices.
Contention Window Fundamentals
The contention window defines the range from which a station randomly selects its backoff value. A larger window means more possible values, spreading stations' transmission attempts further apart in time.
Backoff Value Selection:
Backoff = Random(0, CW) × Slot_Time
Where:
- Random(0, CW) generates a uniformly distributed integer from 0 to CW inclusive
- CW is the current contention window size
- Slot_Time is the PHY-dependent slot duration (9-20 μs)
Example (802.11a with CW=15):
- Slot_Time = 9 μs
- Backoff values range from 0 to 15 slots
- Time range: 0 to 135 μs
- Each of 16 possible values has equal probability (1/16 = 6.25%)
| PHY/AC | CWmin | CWmax | Slot Time | Min Backoff | Max Initial Backoff |
|---|---|---|---|---|---|
| 802.11b (DCF) | 31 | 1023 | 20 μs | 0 μs | 620 μs |
| 802.11a (DCF) | 15 | 1023 | 9 μs | 0 μs | 135 μs |
| 802.11a AC_VO | 3 | 7 | 9 μs | 0 μs | 27 μs |
| 802.11a AC_VI | 7 | 15 | 9 μs | 0 μs | 63 μs |
| 802.11a AC_BE | 15 | 1023 | 9 μs | 0 μs | 135 μs |
| 802.11a AC_BK | 15 | 1023 | 9 μs | 0 μs | 135 μs |
Contention window sizes are always 2^n - 1 (e.g., 7, 15, 31, 1023). This allows simple binary representation and efficient random number generation. With CW=15, you need exactly 4 random bits. With CW=31, you need 5 bits. Hardware implementation is straightforward.
The Complete Backoff Procedure
The backoff procedure is invoked whenever a station needs to contend for the medium. Understanding the complete procedure is essential for predicting and analyzing 802.11 behavior.
- •Initialization: Station sets CW = CWmin for its access category. This occurs when the station first associates or when CW was reset after successful transmission.
- •Backoff Selection: Station generates random backoff value:
backoff_counter = Random(0, CW) - •IFS Wait: Station waits for the appropriate IFS (DIFS or AIFS) after detecting channel idle.
- •Backoff Countdown: If channel remains idle after IFS, decrement backoff_counter by 1 each slot time.
- •Freeze on Busy: If channel becomes busy during countdown, freeze backoff_counter at current value. Do not decrement.
- •Resume After Busy: When channel becomes idle again, wait for IFS, then resume countdown from frozen value.
- •Transmit at Zero: When backoff_counter reaches 0, transmit the frame immediately.
- •Wait for ACK: After transmission, wait SIFS + ACK_Timeout for acknowledgment.
- •Success: If ACK received, reset CW = CWmin. Proceed with next frame (if any).
- •Failure: If no ACK, double CW (up to CWmax), select new random backoff, and repeat procedure.
Backoff Countdown Visualization:
Time →
|----DIFS----|---Slot 1---|---Slot 2---|---Slot 3---|
Station A (backoff=3): [waiting] [2] [1] [0→TX]
Station B (backoff=1): [waiting] [0→TX!]
↓
At this point, A detects B's transmission
A freezes at backoff=2
...later, after B's frame + ACK...
|----DIFS----|---Slot 1---|---Slot 2---|
Station A (frozen at 2): [waiting] [1] [0→TX]
Key Behaviors:
-
Backoff before first transmission: Unlike CSMA/CD, stations must perform backoff even for the first transmission attempt if the medium is busy. This is proactive collision avoidance.
-
Post-transmission backoff: After successful transmission, stations in DCF mode execute a backoff before the next frame. This prevents a single station from capturing the channel.
-
Frozen backoff persists: A station's remaining backoff time is preserved across busy periods. This is fair—a station that has already waited shouldn't lose its progress.
The random selection includes 0 as a valid value. A station that selects backoff=0 will transmit immediately after DIFS/AIFS (assuming channel stays idle). This means even with CW=15, there's a 1/16 chance of immediate transmission.
Binary Exponential Backoff
When a transmission fails (no ACK received), the contention window doesn't just stay the same—it doubles. This Binary Exponential Backoff (BEB) mechanism is borrowed from wired Ethernet but serves a different purpose in CSMA/CA.
BEB Operation:
Initial: CW = CWmin = 15
After fail 1: CW = min(2 × (CW + 1) - 1, CWmax) = min(31, 1023) = 31
After fail 2: CW = min(2 × (CW + 1) - 1, CWmax) = min(63, 1023) = 63
After fail 3: CW = min(2 × (CW + 1) - 1, CWmax) = min(127, 1023) = 127
After fail 4: CW = min(2 × (CW + 1) - 1, CWmax) = min(255, 1023) = 255
After fail 5: CW = min(2 × (CW + 1) - 1, CWmax) = min(511, 1023) = 511
After fail 6: CW = min(2 × (CW + 1) - 1, CWmax) = min(1023, 1023) = 1023
After fail 7+: CW = 1023 (capped at CWmax)
After success: CW = CWmin = 15
| Retry | CW Size | Possible Backoffs | Max Wait (802.11a) |
|---|---|---|---|
| 0 | 15 | 16 values | 135 μs |
| 1 | 31 | 32 values | 279 μs |
| 2 | 63 | 64 values | 567 μs |
| 3 | 127 | 128 values | 1.14 ms |
| 4 | 255 | 256 values | 2.30 ms |
| 5 | 511 | 512 values | 4.60 ms |
| 6+ | 1023 | 1024 values | 9.21 ms |
- •Collision indicates contention — If transmissions are failing, multiple stations are likely trying to access the medium. A larger CW spreads their attempts further apart.
- •Progressive adaptation — Each failure doubles the spread, providing increasingly aggressive collision avoidance as congestion worsens.
- •Statistical recovery — Even in heavy contention, eventually stations will select sufficiently different backoffs to transmit successfully.
- •Automatic load balancing — Stations experiencing more failures wait longer, naturally giving way to stations with better conditions or fewer retries.
- •Fast recovery — After success, CW immediately resets to CWmin. This prevents unnecessary delays when contention has cleared.
BEB can cause short-term unfairness. A station that just succeeded (CW=15) competes against a station that just failed (CW=31). The successful station is twice as likely to win. Over time, this averages out, but burst behavior may appear uneven.
Collision Probability Analysis
Understanding the probability of collisions given the contention window size is essential for analyzing 802.11 network performance. Let's derive the key probabilities.
Two-Station Collision Probability:
For two stations with the same CW size, both selecting from (CW + 1) possible values:
P(collision) = P(both select same slot)
= Σ P(A selects i) × P(B selects i) for all i
= Σ (1/(CW+1)) × (1/(CW+1)) for (CW+1) slots
= (CW+1) × (1/(CW+1))²
= 1/(CW+1)
| CW Size | Collision Probability (2 stations) |
|---|---|
| 15 | 1/16 = 6.25% |
| 31 | 1/32 = 3.13% |
| 63 | 1/64 = 1.56% |
| 127 | 1/128 = 0.78% |
| 1023 | 1/1024 = 0.098% |
With CWmin=15, two contending stations collide only 6.25% of the time!
N-Station Collision Probability:
For N stations all contending simultaneously:
P(no collision) = P(all N stations select different slots)
= (CW+1)/(CW+1) × (CW)/(CW+1) × (CW-1)/(CW+1) × ...
= (CW+1)! / ((CW+1-N)! × (CW+1)^N)
P(collision) = 1 - P(no collision)
| N | CW=15 | CW=31 | CW=63 | CW=127 |
|---|---|---|---|---|
| 2 | 6.25% | 3.13% | 1.56% | 0.78% |
| 3 | 17.6% | 9.09% | 4.62% | 2.33% |
| 4 | 32.3% | 17.4% | 9.05% | 4.62% |
| 5 | 47.6% | 27.4% | 14.7% | 7.59% |
| 10 | 93.3% | 74.0% | 50.6% | 30.8% |
Key Insight: With CWmin=15 and 10 active stations, collision probability is 93.3% per contention round! The CW must grow rapidly to handle heavy load.
This is similar to the birthday paradox: with only 23 people, there's >50% chance two share a birthday (from 365 possibilities). With 10 stations selecting from 16 slots, near-certain collision is expected. BEB automatically expands the 'calendar' when congestion is detected.
Optimal Contention Window:
Theoretically, the optimal CW for N stations is approximately 2N-1. This balances:
- CW too small: High collision probability wastes airtime
- CW too large: Excessive idle slots waste airtime
Since 802.11 doesn't know N exactly, BEB approximates optimal CW through trial and error:
- Start small (CWmin) assuming light load
- Double on collision (traffic is higher than assumed)
- Reset on success (traffic is lower now or we got lucky)
This adaptive approach works well across a wide range of network sizes.
Backoff Counter Freezing and Resumption
The backoff counter freezing mechanism is critical for both fairness and collision avoidance. Understanding exactly when the counter freezes and resumes is essential for predicting 802.11 behavior.
- •Freeze Trigger: Counter freezes immediately when physical carrier sense detects channel busy OR when NAV becomes non-zero.
- •Freeze Point: Counter value at freeze point is preserved exactly—no rounding to slot boundaries.
- •During Freeze: Counter remains at frozen value for entire duration of channel busy period.
- •Resume Trigger: Counter resumes when channel has been idle for DIFS/AIFS period.
- •Resume Point: Countdown continues from exact frozen value—no penalty for having been frozen.
- •Multiple Freezes: Counter may freeze and resume multiple times before reaching zero if channel is busy repeatedly.
Detailed Freeze/Resume Example:
Station A initially selects backoff = 5 slots
Time 0 D 1 2 B(busy) ... idle D 3 4 5
|-------|----|----|----XXXXXXXX...XXX----|-------|----|----|----TX
DIFS ↑ ↑ DIFS
ends Freeze Resume
at 3 at 3
Detailed Timeline:
- T=0: Channel becomes idle
- T=DIFS: Begin backoff countdown (5 slots to go)
- T=DIFS+1slot: Backoff = 4
- T=DIFS+2slots: Backoff = 3
- T=DIFS+2.5slots: Channel becomes busy (another station transmits)
- Station A FREEZES at backoff = 3 (not 2, not 4, exactly 3)
- ...busy period... (could be milliseconds)
- T': Channel becomes idle
- T'+DIFS: Resume countdown from 3
- T'+DIFS+1slot: Backoff = 2
- T'+DIFS+2slots: Backoff = 1
- T'+DIFS+3slots: Backoff = 0, TRANSMIT
- •Preserves time already waited
- •Station doesn't lose progress
- •Earlier waiters eventually win
- •Natural queue-like behavior emerges
- •Long-waiting stations have priority
- •Prevents transmission during busy
- •Respects ongoing transmissions
- •Maintains slot synchronization
- •All stations resume at same instant
- •Relative ordering preserved
After DIFS, all stations' backoff counters resume at the same moment (aligned to the start of the next slot). This synchronization is essential—if stations resumed at different times, the 'first to reach zero' logic would be unpredictable.
QoS and Contention Window Differentiation
IEEE 802.11e introduced Quality of Service through the Enhanced Distributed Channel Access (EDCA) mechanism. Beyond AIFS differentiation, QoS also uses different contention window parameters for different Access Categories.
| Access Category | CWmin | CWmax | TXOP Limit | Typical Traffic |
|---|---|---|---|---|
| AC_BK (Background) | aCWmin (15) | aCWmax (1023) | 0 (no limit) | Bulk transfers, backups |
| AC_BE (Best Effort) | aCWmin (15) | aCWmax (1023) | 0 (no limit) | Web browsing, email |
| AC_VI (Video) | (aCWmin+1)/2 - 1 (7) | aCWmin (15) | 3.008 ms | Video streaming |
| AC_VO (Voice) | (aCWmin+1)/4 - 1 (3) | (aCWmin+1)/2 - 1 (7) | 1.504 ms | VoIP, video calls |
The QoS Priority Stack:
Voice traffic has three advantages over best-effort:
- Shorter AIFS (AIFSN=2 vs AIFSN=3): Voice starts backoff earlier
- Smaller CWmin (3 vs 15): Voice has fewer initial slots to choose from
- Smaller CWmax (7 vs 1023): Voice never backs off as far
Combined effect: Voice traffic almost always wins contention against best-effort.
Probability Analysis (Voice vs Best-Effort):
Assume both have a frame to send after channel becomes idle:
Voice: AIFS = SIFS + 2×slot = 34μs, backoff ∈ [0,3]
BE: AIFS = SIFS + 3×slot = 43μs, backoff ∈ [0,15]
Voice starts backoff at T=34μs
BE starts backoff at T=43μs (one slot later)
Voice transmission times: 34μs + 0,9,18,27 = 34,43,52,61 μs
BE transmission times: 43μs + 0,9,18,...,135 = 43,52,61,...,178 μs
Voice wins if voice_time < BE_time
Voice wins 93.75% of head-to-head contention against best-effort traffic!
Voice traffic has CWmax=7, meaning maximum backoff is only 63μs (7×9μs). Even after failures, voice latency remains bounded. Best-effort can grow to CWmax=1023, potentially waiting 9.2ms—unacceptable for voice but fine for bulk data.
Implementation and Practical Considerations
Implementing the contention window mechanism correctly requires attention to several subtle details. Let's examine the practical considerations that affect real-world 802.11 deployments.
- •Random Number Quality — Poor random number generators can cause predictable backoff patterns, increasing collision probability. Hardware should use true entropy sources, not just linear feedback shift registers.
- •Slot Boundary Detection — Stations must agree on when slots begin and end. Clock drift between stations can cause disagreement about whether a slot has passed, potentially causing collisions.
- •CCA Threshold Sensitivity — The Clear Channel Assessment threshold affects when stations detect channel busy. A station with higher CCA threshold might start counting down while another station is transmitting.
- •SIFS Timing Precision — If a station's SIFS timing is slightly off, its ACKs might arrive too early (interfering with frame end) or too late (appearing as channel idle to other stations).
- •NAV Processing Delay — Virtual carrier sensing requires decoding Duration fields from overheard frames. Processing delays in extracting and applying NAV can cause temporary carrier sensing gaps.
- •Internal Collisions — When a station has multiple frames queued to different ACs, internal collisions are possible. EDCA specifies that higher AC wins and lower AC doubles CW.
Retry Limits:
802.11 defines maximum retry counts to prevent infinite retransmission loops:
| Parameter | Default Value | Purpose |
|---|---|---|
| dot11ShortRetryLimit | 7 | Max retries for frames ≤ RTS threshold |
| dot11LongRetryLimit | 4 | Max retries for frames > RTS threshold |
After reaching the retry limit:
- Frame is discarded
- CW is reset to CWmin
- Upper layer is notified of delivery failure
- Station proceeds to next queued frame
Excessive Retry Indication:
Modern drivers provide retry statistics that can indicate network health:
- Low retry rate (<1%): Healthy network, good signal conditions
- Moderate retry rate (1-5%): Normal contention, acceptable performance
- High retry rate (>10%): Heavy congestion or interference, degraded performance
- Very high retry rate (>30%): Severe problems, investigation needed
Each retry consumes airtime for the full frame plus doubled backoff. A single frame experiencing 6 retries might consume 10x the airtime of a successful transmission. High retry environments suffer more than the raw percentage suggests.
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.