Sub topic 15
CSMA/CA and the Hidden Terminal Problem
This chapter assumes you know carrier sensing and CSMA persistence, the CSMA/CD collision-detection idea, and binary exponential backoff. It also assumes you know that a MAC protocol decides who may transmit on a shared channel. Here you will see why those ideas fail on a wireless LAN and what 802.11 does instead.
Why CSMA/CD does not work on wireless
CSMA/CD relies on two assumptions. A transmitting station can listen to the medium while it sends, and every station on the segment hears roughly the same signal. Wireless breaks both.
- A radio cannot listen while it sends. Its own transmission is millions of times stronger than a distant signal, so it drowns out any collision. Detecting a collision mid-frame is not practical.
- Stations do not all hear each other. Signal strength falls quickly with distance, and walls and obstacles block it. Carrier sensing at the sender tells it about the channel at the sender. What matters is the channel at the receiver.
So wireless LANs use collision avoidance (CA). The protocol tries to prevent collisions, because it cannot detect them. It infers success only from an explicit acknowledgment.
The hidden terminal problem
Suppose station A and station C are both in range of access point B, but A and C are out of range of each other.
- A senses the channel, hears nothing from C, and transmits to B.
- C also senses an idle channel, because it cannot hear A, and transmits to B.
- Both frames arrive at B at the same time and collide there. Neither sender notices.
A and C are hidden terminals with respect to each other. Carrier sensing fails because the collision happens at the receiver, not at either sender.
The exposed terminal problem
The reverse failure wastes capacity. Suppose B is transmitting to A, and C wants to send to a station D that is out of B's range. C hears B and defers, even though C's transmission would not disturb A. C is exposed to B. A sender-side sensing rule is too cautious here.
| Problem | What the sender senses | What is wrong |
|---|---|---|
| Hidden terminal | Idle channel | A collision occurs at the receiver |
| Exposed terminal | Busy channel | Waiting is unnecessary, so capacity is lost |
Basic 802.11 does not solve the exposed terminal problem. RTS/CTS addresses the hidden terminal problem.
Basic CSMA/CA with acknowledgments
The 802.11 distributed coordination function (DCF) works like this:
- The station senses the channel. If it has been idle for a full DIFS (DCF interframe space), the station may transmit.
- If the channel is busy, the station waits until it becomes idle. It then waits a DIFS and draws a random backoff counter from 0 to CW, where CW is the contention window.
- The counter decrements once per idle slot. If the channel turns busy, the counter freezes. It resumes after the channel is idle for a DIFS again. The station transmits when the counter reaches 0.
- The receiver checks the frame, waits a SIFS (short interframe space), and sends an ACK.
- If no ACK arrives, the sender assumes a collision or error. It doubles the contention window and retries.
The inequality SIFS < DIFS matters. An ACK waits only a SIFS, so it always gets the channel before any station that waits a DIFS. Nobody can slip in between a data frame and its ACK. The protocol is effectively stop-and-wait at the MAC layer.
The window grows as CW → 2(CW + 1) − 1, so 15 becomes 31, then 63, 127, and so on, up to a maximum such as 1023. A successful transmission resets CW to its minimum.
Freezing the counter is the main difference from Ethernet's backoff. A station that loses a contention round keeps its remaining count. It does not draw a new one, so waiting stations gain a priority over newcomers.
import random
def contention_round(counters):
"""counters: dict of station -> remaining backoff slots.
Returns (winners, slots_elapsed, frozen_counters)."""
elapsed = min(counters.values())
winners = [s for s, c in counters.items() if c == elapsed]
frozen = {s: c - elapsed for s, c in counters.items() if c != elapsed}
return winners, elapsed, frozen
def draw_backoff(cw):
return random.randint(0, cw)
print(contention_round({"A": 7, "B": 12, "C": 9}))
# (['A'], 7, {'B': 5, 'C': 2})
print(contention_round({"A": 7, "B": 7, "C": 9}))
# (['A', 'B'], 7, {'C': 2}) two winners means a collisionIf two stations draw the same counter, both transmit, there is no ACK, and both double their windows. Collisions still happen, but they are discovered afterwards.
RTS/CTS: reserving the channel
For long frames, a collision at the receiver is costly. 802.11 offers an optional handshake:
- The sender transmits a short RTS (request to send) frame, which carries the duration of the planned exchange.
- The receiver replies with a short CTS (clear to send) frame after a SIFS. The CTS repeats the duration.
- Every station that hears either frame sets its NAV (network allocation vector), a virtual carrier-sense timer. It stays silent until the NAV expires, even if the physical channel looks idle.
- The data frame and the ACK follow, each separated by a SIFS.
The handshake works because C cannot hear A's RTS but can hear B's CTS. Hidden terminals are now silenced by the receiver. A collision can still occur, but only between short RTS frames. That costs far less than losing a long data frame. For short frames the handshake costs more than it saves, so it is usually enabled only above a size threshold.
CSMA/CD versus CSMA/CA
| Aspect | CSMA/CD (wired Ethernet) | CSMA/CA (802.11) |
|---|---|---|
| Collision handling | Detect during transmission and abort | Avoid beforehand and infer failure from a missing ACK |
| Acknowledgment | None at the MAC layer | Mandatory ACK after each frame |
| Backoff | After a collision | Before every transmission after a busy channel, and after a missing ACK |
| Hidden terminals | Not an issue on a shared cable | Addressed by optional RTS/CTS and NAV |
| Minimum frame size | Needed so that collisions are detected | Not needed |
Common mistakes
- Saying CSMA/CA detects collisions. It does not. A missing ACK is the only evidence.
- Saying RTS/CTS removes all collisions. RTS frames can still collide.
- Confusing hidden and exposed terminals. In the hidden case a sender transmits when it should not. In the exposed case it waits when it need not.
- Forgetting the interframe ordering. An ACK uses SIFS. A new transmission uses DIFS. This is why ACKs are never preempted.
Exercise
A station using 802.11 backoff starts with CW = 15. Its first three transmission attempts all fail with no ACK. What is the range of the backoff counter it draws before the fourth attempt, assuming the window doubles in the form 2(CW + 1) − 1 each time and the maximum is not reached?
Show answer
The window goes 15 → 31 → 63 → 127 after three failures. The station draws an integer uniformly from 0 to 127, which gives 128 possible values.
Exercise
Stations A and C are both in range of B but not of each other. A is sending a long frame to B. Explain why plain carrier sensing lets C cause a collision, and which frame in the RTS/CTS exchange prevents it.
Show answer
C senses an idle channel because A is out of its range, so it transmits to B and the two frames collide at B. In RTS/CTS, the CTS sent by B reaches C. C reads the duration in it, sets its NAV, and stays silent until A's exchange finishes.