Sub topic 11
Binary Exponential Backoff
Assume you know Ethernet frames, carrier sensing, propagation delay, and the basic CSMA/CD process. This chapter explains what a station does after detecting a collision.
Why backoff is necessary
In CSMA/CD, several stations can listen to an idle channel and begin transmitting at nearly the same time. Their signals then interfere, causing a collision. The stations must retry, but retrying immediately would probably create another collision.
Binary exponential backoff makes the retry delay grow after repeated collisions. Each station chooses a random delay, so the stations are less likely to transmit together again.
The delay is measured in slot times. A slot time is long enough for a collision from the farthest part of the network to reach a transmitting station.
The backoff rule
After the nth collision, Ethernet computes:
\[ k = \min(n, 10) \]
It then chooses an integer \(K\) uniformly from:
\[ 0 \le K \le 2^k - 1 \]
The station waits \(K\) slot times before retrying.
| Collision number | Possible K values | Maximum wait |
|---|---|---|
| 1 | 0, 1 | 1 slot |
| 2 | 0, 1, 2, 3 | 3 slots |
| 3 | 0 through 7 | 7 slots |
| 10 or later | 0 through 1023 | 1023 slots |
The exponent stops growing at 10. This prevents the random range from becoming excessively large. Ethernet also limits the number of attempts. Classic Ethernet gives up after 16 failed attempts, including the initial transmission attempt in common descriptions.
import random
def backoff_slots(collision_count):
"""Return the random wait after a collision, or None after 16 failures."""
if collision_count >= 16:
return None
k = min(collision_count, 10)
return random.randrange(2 ** k)
for collision in range(1, 4):
print(collision, backoff_slots(collision))For example, after the second collision, a station chooses from 0, 1, 2, or 3. If it chooses 2, it waits two slot times. If another station chooses 0, the second station transmits first. The first station may sense the channel as busy and defer.
Common errors
- Using \(2n\) instead of \(2^n\). The window doubles exponentially.
- Forgetting the upper bound \(k=10\).
- Treating \(K\) as a number of seconds rather than a number of slot times.
- Assuming every collision causes an immediate frame drop. The station normally retries until the attempt limit is reached.
Exercise
A station has detected its third collision. What values can K take, and what is the largest possible delay?
Show answer
Here k = min(3, 10) = 3. Therefore K can be 0 through 2^3 - 1 = 7, and the largest delay is 7 slot times.