Sub topic 12
Binary exponential backoff
This chapter assumes you know how CSMA/CD detects a collision and what slot time means (51.2 µs on 10 Mbps Ethernet). It covers how a station decides when to retry after a collision, why the retry rule doubles its range, and the numbers GATE questions ask for.
The problem backoff solves
When two stations collide, both detect it, stop, and have to retransmit. If both retried immediately, or after a fixed delay, they would collide again, forever. Each station must wait a random time, and the range of that randomness must match the number of stations competing. The stations do not know how many are competing. Binary exponential backoff estimates it from the station's own collision history: each collision is evidence that the channel is busier than assumed, so the range doubles.
The algorithm
After a station detects a collision, it sends a short jam signal so every other station notices the collision. It then increments its collision count n for this frame and does the following:
- If n reaches 16, give up on the frame and report a failure to the upper layer.
- Let k = min(n, 10).
- Pick an integer K uniformly at random from 0 to 2^k − 1.
- Wait K × slot time, then sense the channel and try again.
The count n belongs to one frame. It resets to 0 after the frame is sent successfully or abandoned.
The numbers
The mean of a uniform choice over 0 to 2^k − 1 is (2^k − 1)/2 slots. The table uses a 51.2 µs slot.
| Collision n | Range of K | Max wait | Mean wait |
|---|---|---|---|
| 1 | 0 to 1 | 51.2 µs | 25.6 µs |
| 2 | 0 to 3 | 153.6 µs | 76.8 µs |
| 3 | 0 to 7 | 358.4 µs | 179.2 µs |
| 4 | 0 to 15 | 768 µs | 384 µs |
| 10 to 15 | 0 to 1023 | 52 377.6 µs | 26 188.8 µs |
The range stops growing at n = 10, so a station never waits more than 1023 slots, about 52.4 ms. Doubling forever would make waits absurdly long. The abort at 16 attempts keeps a station from retrying indefinitely on a channel that is broken or hopelessly overloaded.
Worked example: two stations
Suppose A and B collide on their first attempt. Each picks K from {0, 1}.
- If they pick different values (probability 1/2), the one with the smaller K transmits first. The other waits at most one slot, senses the carrier, and defers until the winner finishes. This works because the slot time covers a full round trip, so the winner's signal has already reached the other station.
- If they pick the same value (probability 1/2), they collide again. The range becomes {0, 1, 2, 3}, and the chance of picking the same value drops to 1/4.
After collision i the chance of colliding again is 2^−i, as long as i ≤ 10. The probability that the frame succeeds after exactly n collisions is therefore:
P(n) = (2^−1 × 2^−2 × … × 2^−(n−1)) × (1 − 2^−n)
For n = 1, 2, 3 this gives 1/2, 3/8, and 7/64. These sum to 63/64, so the chance of three or more collisions in a row is 1/64. The next program computes P(n) and checks it against a simulation.
import random
from collections import Counter
def backoff_slots(collision_count):
if collision_count >= 16:
return None # give up: the frame is dropped after 16 attempts
k = min(collision_count, 10)
return random.randrange(2 ** k) # wait this many slot times
def exact(n):
p = 1.0
for i in range(1, n):
p *= 2.0 ** -min(i, 10)
return p * (1 - 2.0 ** -min(n, 10))
def simulate(trials=200_000):
results = Counter()
for _ in range(trials):
n = 1 # both stations just had their first collision
while True:
a, b = backoff_slots(n), backoff_slots(n)
if a is None:
results["dropped"] += 1
break
if a != b:
results[n] += 1
break
n += 1
return results, trials
results, trials = simulate()
for n in (1, 2, 3):
print(n, round(exact(n), 4), round(results[n] / trials, 4))
# The two columns agree: about 0.5, 0.375, 0.1094Properties and gotchas
- The range is based on the station's own history. A station that has just arrived starts with n = 0 and tries immediately. It is more aggressive than a station that has already collided several times.
- Capture effect. After a successful send, the winner resets its range to {0, 1}. The loser still carries a large range. Under heavy load, the same station tends to win repeatedly while others stay in long backoffs. Backoff is not fair over short periods.
- Slots are counted from the collision. Backoff time is a multiple of the slot time (512 bit times). It is not a multiple of the frame time.
- Larger groups need more rounds. With a small, fixed range, many stations would collide repeatedly. Doubling lets the range grow until it roughly matches the number of contenders. With k stations and a window of W slots, the best case is W ≈ k, which gives a per-slot success probability near 1/e.
Why this connects to frame size
Backoff only works if every collision is detected before the sender finishes transmitting. If the sender stopped before the collision signal returned, it would believe the frame was delivered, and no retry would happen. The minimum frame size, 512 bits on 10 Mbps Ethernet, guarantees detection. The slot time used in the backoff is the same 51.2 µs round-trip bound, so frame size and backoff are tied to one number.
Exercise
Two stations collide on their first attempt. Assuming they keep competing only with each other, what is the probability that the frame goes through on the third attempt, meaning after exactly two collisions?
Show answer
After the 1st collision both pick from {0, 1}, and they collide again with probability 1/2. After the 2nd collision both pick from {0, 1, 2, 3}, and they pick different values with probability 1 − 1/4 = 3/4. The answer is 1/2 × 3/4 = 3/8.
Exercise
A 10 Mbps Ethernet station has just suffered its 12th collision on one frame. What is the longest time it can wait before the next attempt, ignoring the jam signal?
Show answer
The exponent is capped at 10, so K is at most 2^10 − 1 = 1023 slots. The wait is 1023 × 51.2 µs = 52 377.6 µs, about 52.4 ms.
Exercise
Why does the station not simply choose from 0 to 1023 slots from the very first collision?
Show answer
Most collisions involve only two stations, and a window of 1023 slots would make them idle for hundreds of slot times on average even though a window of {0, 1} resolves the collision half the time. Starting small gives low delay under light load, and doubling gives stability under heavy load.