SEN2008 · Week 4 · Data Link Layer Concepts (II) : Channel allocation problem, multiple Access, Ethernet

Channel allocation and multiple access: ALOHA, CSMA, CSMA/CD

When many nodes share a single broadcast channel, who talks when? The flaw of static allocation, pure and slotted ALOHA efficiency, CSMA/CD, minimum frame size, and binary exponential backoff.

channel allocation problembroadcast channelmultiple access protocolFDMA / TDMAcollisionpure ALOHAslotted ALOHAvulnerable periodCSMACSMA/CDbinary exponential backoffminimum frame sizetaking-turns protocolspollingtoken passing

The original Ethernet, Wi-Fi and satellite links share a common problem: many nodes share a single broadcast channel. If two nodes send at the same time, the signals overlap and both are corrupted. This is called a collision. A multiple access protocol is a set of rules that decides who sends when, without a central authority.

On the exam this topic hits in two places: ALOHA efficiency calculation and the minimum frame size in CSMA/CD. Golden rules:

  1. Slotted ALOHA is 1/e1/e, pure ALOHA is 1/(2e)1/(2e). In pure ALOHA the vulnerable period is two frame times.
  2. N nodes, probability pp: success =Np(1−p)N−1= Np(1-p)^{N-1}.
  3. Lmin=2dpropRL_{min} = 2 d_{prop} R. You must hear the collision before the transmission ends.
  4. The backoff range doubles with every collision.

The channel allocation problem

An ideal shared channel (rate RR) should provide:

  1. If only one node is sending, it can use the whole RR.
  2. If MM nodes are sending, each gets R/MR/M on average.
  3. There is no central coordinator (no single point of failure).
  4. It is simple and cheap.

Why is static allocation bad?

The simplest solution is to divide the channel into fixed parts: FDMA (frequency) or TDMA (time). Each node uses its own slice. The problem: when a node is silent its slice is wasted, and a node that is talking gets only R/NR/N. A simple model from queueing theory gives the mean delay:

T=1μC−λT = \frac{1}{\mu C - \lambda}

Here CC is the channel capacity (bps), 1/μ1/\mu is the mean frame length (bits), and λ\lambda is the arrival rate (frames/s).

C = 100 Mbps, frame 10,000 bit, lambda = 5000 frames/s
mu C = 10^8 / 10^4 = 10,000 frames/s
Single channel  : T = 1 / (10,000 - 5,000) = 0.2 ms
10 subchannels  : each has C/10 and lambda/10
                  T = 1 / (1,000 - 500)    = 2 ms  (10 times)

With static division the delay is multiplied by NN. Because computer traffic is bursty, dynamic sharing is needed.

Protocol families

FamilyIdeaExample
Channel partitioningFixed slicesTDMA, FDMA, CDMA
Random accessEveryone sends at full rate, waits a random time after a collisionALOHA, CSMA, CSMA/CD
Taking turnsNodes talk in turnPolling, token passing

ALOHA

It was developed at the University of Hawaii for a radio network between the islands. It is the ancestor of random access.

Pure ALOHA

When a node has a frame it sends it immediately. If it collides, the node waits a random time and tries again. Let the duration of a frame be TT and let our frame start at t0t_0.

     t0 - T           t0            t0 + T
       |--------------|---------------|
       a frame starting  a frame starting
       in this interval  in this interval
       collides          collides
       vulnerable period = 2T

Let GG be the average number of attempts (new + retransmissions) per frame time. If the attempts are assumed to follow a Poisson distribution, the probability that there is no other attempt in the 2T2T interval is e−2Ge^{-2G}:

Spure=G e−2G,Smax=12e≈0.184 (at G = 0.5)S_{pure} = G\,e^{-2G}, \qquad S_{max} = \frac{1}{2e} \approx 0.184 \text{ (at G = 0.5)}

Slotted ALOHA

Time is divided into slots the length of one frame time. Nodes can send only at the start of a slot. A collision happens only among nodes that choose the same slot, and the vulnerable period drops to TT:

Sslotted=G e−G,Smax=1e≈0.368 (at G = 1)S_{slotted} = G\,e^{-G}, \qquad S_{max} = \frac{1}{e} \approx 0.368 \text{ (at G = 1)}

The other model in textbooks has NN nodes, each sending in every slot with probability pp:

P(successful slot)=Np(1−p)N−1P(\text{successful slot}) = N p (1-p)^{N-1}

The best pp is 1/N1/N. As N→∞N \to \infty this converges to 1/e1/e.

Worked example

N=5N = 5, p=0.2p = 0.2:

success   : 5 x 0.2 x 0.8^4         = 0.4096
idle slot : 0.8^5                   = 0.32768
collision : 1 - 0.32768 - 0.4096    = 0.26272
pure ALOHA same N, p : N p (1-p)^(2(N-1)) = 0.8^8 = 0.1678

On a 1 Mbps slotted ALOHA channel, the useful throughput in the best case is 106/e≈36810^6/e \approx 368 kbps.

PITFALL · GG versus SS. GG is the attempted load (including collided frames), SS is the fraction of successful frames. GG can exceed 1, SS never can. If GG is very large, almost every slot collides and S→0S \to 0.

CSMA: listen before you send

ALOHA is crude: it sends even when the channel is busy. CSMA (carrier sense multiple access) listens to the channel first.

  • 1-persistent: if the channel is idle, send immediately; if busy, wait for it to become idle and send immediately. Two nodes that were waiting will certainly collide when it frees up.
  • Non-persistent: if the channel is busy, wait a random time, then listen again.
  • p-persistent: (slotted) if the channel is idle, send with probability pp, and with probability 1−p1-p defer by one slot.

Listening does not eliminate collisions. Because of propagation delay, B may think the channel is idle and send, since A’s signal has not reached it yet. The longer the propagation (the longer the cable), the more likely a collision.

CSMA/CD: listen while sending too

This is the protocol of classic Ethernet. CD (collision detection): the node keeps listening to the channel while it sends. If it hears something different from its own signal:

  1. It stops sending immediately (there is no point in sending the corrupted frame to the end).
  2. It sends a 48-bit jam signal so that everyone notices.
  3. It waits a random time with binary exponential backoff, then starts over.

Minimum frame size

Worst case: A and B are at the two ends of the cable. A starts to send. Just before its signal reaches B, B starts too. News of the collision returns to A after 2dprop2 d_{prop}. A must still be sending at that moment, otherwise it cannot attribute the collision to its own frame:

LR≥2dprop⟹Lmin=2 dprop R\frac{L}{R} \ge 2 d_{prop} \quad\Longrightarrow\quad L_{min} = 2\,d_{prop}\,R

R = 10 Mbps, cable 2500 m, s = 2 x 10^8 m/s
dprop = 2500 / 2e8 = 12.5 us
Lmin  = 2 x 12.5e-6 x 1e7 = 250 bit

Real Ethernet also accounted for repeater delays and chose 512 bits (64 bytes). When the speed is multiplied by 10, the allowed distance for the same 512 bits shrinks 10 times: 5120 m at 10 Mbps, 512 m at 100 Mbps (with the propagation calculation alone).

Binary exponential backoff

After the nn-th consecutive collision, the node chooses KK at random:

K∈{0,1,…,2min⁡(n,10)−1},wait=K×512 bit timesK \in \{0, 1, \ldots, 2^{\min(n,10)} - 1\}, \qquad \text{wait} = K \times 512 \text{ bit times}

CollisionKK rangeLongest wait at 10 MbpsProbability the two nodes collide again
10, 151.2 µs1/2
20..3153.6 µs1/4
30..7358.4 µs1/8
10 and later0..102352.4 ms1/1024

After 16 attempts the frame is dropped and an error is reported to the upper layer. The idea: collisions mean heavy load; by enlarging the range you spread everyone out more as the load grows.

Ethernet efficiency

When many nodes always have a frame to send, approximately:

efficiency=11+5 dprop/dtrans\text{efficiency} = \frac{1}{1 + 5\,d_{prop}/d_{trans}}

dprop = 12.5 us
1500-byte frame @10 Mbps : dtrans = 1200 us -> 1/(1 + 0.052) = 0.950
64-byte frame   @10 Mbps : dtrans = 51.2 us -> 1/(1 + 1.22)  = 0.450

When the frame is long and the cable short, the efficiency approaches 1.

Taking-turns protocols

  • Polling: a master node asks each node in turn “do you have anything to send?”. There are no collisions, but there is polling delay, and if the master crashes the network stops. Bluetooth works this way.
  • Token passing: a special token frame circulates from node to node; only the node holding the token sends. There are no collisions, but there is trouble if the token is lost or a node does not release it.

Wireless: why no CD?

In Wi-Fi, a sending node’s own strong signal drowns out the weak signal coming from afar; it cannot hear the collision. There is also the hidden terminal problem: A and C cannot hear each other but both send to B. So 802.11 tries to avoid collisions rather than detect them (CSMA/CA): a random countdown, an ACK for every frame, and optional RTS/CTS reservation.

TIP · the security connection. On a shared medium every node sees every frame; the card passes only what is addressed to it to the upper layer. Someone who puts the card in “promiscuous mode” can read all the traffic. On shared and wireless networks, what provides confidentiality is not the medium but encryption.

Common mistakes

Wrong ideaCorrect
Slotted ALOHA max 0.184Slotted is 1/e=0.3681/e = 0.368, pure is 1/(2e)=0.1841/(2e) = 0.184.
The pure ALOHA vulnerable period is TTIt is 2T2T: before and after.
Success probability is p(1−p)N−1p(1-p)^{N-1}That is for a specific node. For any node, multiply by NN.
Lmin=dpropRL_{min} = d_{prop} R2dpropR2 d_{prop} R: the news must come back.
CSMA completely prevents collisionsCollisions still happen because of propagation.
In backoff K∈{0,…,2n}K \in \{0, \ldots, 2^n\}The upper bound is 2n−12^n - 1, and nn is at most 10.
When speed rises the network diameter stays the sameFor the same LminL_{min} the diameter shrinks in inverse proportion to the speed.
Wi-Fi uses CSMA/CDCSMA/CA; collision detection is not practical on wireless.

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

What is the maximum efficiency of slotted ALOHA as the number of nodes grows large?

  1. 1/(2e)≈0.1841/(2e) \approx 0.184
  2. 1/e≈0.3681/e \approx 0.368
  3. 0.50.5
  4. 11
Show answer
B) 1/e≈0.3681/e \approx 0.368

Slotted ALOHA: S=Ge−GS = G e^{-G}, with the maximum 1/e≈0.3681/e \approx 0.368 at G=1G = 1.
In pure ALOHA the vulnerable period is twice as long, so it is 1/(2e)≈0.1841/(2e) \approx 0.184.

Question 2medium

In slotted ALOHA, 5 active nodes each transmit in a slot with probability p=0.2p = 0.2. What is the probability that a given slot is a success (exactly one transmission)?

Show answer
0.4096

S=Np(1−p)N−1=5×0.2×0.84=1×0.4096=0.4096S = N p (1-p)^{N-1} = 5 \times 0.2 \times 0.8^4 = 1 \times 0.4096 = 0.4096.
Because p=1/Np = 1/N was chosen, this is the best value for N = 5. As N grows it falls toward 1/e1/e.

Question 3medium

Same setting (5 nodes, p=0.2p = 0.2). What fraction of slots are idle, and what fraction contain a collision?

Show answer
idle 0.32768, collision 0.26272

Idle slot: nobody transmits, (1−p)5=0.85=0.32768(1-p)^5 = 0.8^5 = 0.32768.
Collision: the remainder, 1−0.32768−0.4096=0.262721 - 0.32768 - 0.4096 = 0.26272.
The three probabilities must add up to 1.

Question 4medium

In pure ALOHA, the offered load is G=0.5G = 0.5 frames per frame time. What is the throughput SS?

Show answer
≈ 0.184

Pure ALOHA: S=Ge−2G=0.5×e−1≈0.184S = G e^{-2G} = 0.5 \times e^{-1} \approx 0.184.
This is also the maximum of pure ALOHA, reached at G=0.5G = 0.5.
In slotted ALOHA the same load would give 0.5e−0.5≈0.3030.5 e^{-0.5} \approx 0.303.

Question 5easy

Why is the vulnerable period of pure ALOHA twice the frame time?

  1. Because frames are twice as long as in slotted ALOHA
  2. Because a frame collides with any other frame that starts within one frame time before or after it
  3. Because the sender transmits each frame twice
  4. Because acknowledgements take one frame time
Show answer
B) Because a frame collides with any other frame that starts within one frame time before or after it

Our frame starts at t0t_0 and lasts TT. The tail of a frame that starts in [t0−T,t0][t_0 - T, t_0] hits the beginning of ours, and a frame that starts in [t0,t0+T][t_0, t_0 + T] hits the tail of ours. The total is 2T2T.
Slotting aligns the starts, which cuts the vulnerable period to TT and doubles the efficiency.

Question 6medium

A CSMA/CD network runs at 10 Mbps over a 2500 m cable with propagation speed 2×1082 \times 10^8 m/s. What is the minimum frame size (in bits) so that a collision is always detected while still transmitting?

Show answer
250 bits

dprop=2500/(2×108)=12.5 μsd_{prop} = 2500 / (2 \times 10^8) = 12.5\ \mu s.
In the worst case, news of the collision arrives after 2dprop2 d_{prop}. The sender must still be transmitting during that time:Lmin=2dpropR=2×12.5×10−6×107=250L_{min} = 2 d_{prop} R = 2 \times 12.5 \times 10^{-6} \times 10^7 = 250 bits.

Question 7hard

A 100 Mbps CSMA/CD segment has propagation speed 2×1082 \times 10^8 m/s and minimum frame size 512 bits. What is the maximum distance between two stations?

Show answer
512 m

Lmin=2dpropR⇒dprop=512/(2×108)=2.56 μsL_{min} = 2 d_{prop} R \Rightarrow d_{prop} = 512 / (2 \times 10^8) = 2.56\ \mu s.
Distance =2.56×10−6×2×108=512= 2.56 \times 10^{-6} \times 2 \times 10^8 = 512 m.
When the speed goes up 10 times (it would be 5120 m at 10 Mbps), the network diameter shrinks 10 times for the same minimum frame.

Question 8medium

In Ethernet's binary exponential backoff at 10 Mbps, after the 3rd consecutive collision a node picks KK at random. What is the range of KK, and what is the longest possible wait?

Show answer
K ∈ {0,...,7}; 358.4 µs

After the nn-th collision, K∈{0,1,…,2min⁡(n,10)−1}K \in \{0, 1, \ldots, 2^{\min(n,10)} - 1\}. For n=3n = 3: {0,…,7}\{0, \ldots, 7\}.
The wait is K×512K \times 512 bit times. At 10 Mbps, 512 bits =51.2 μs= 51.2\ \mu s.
Longest: 7×51.2=358.4 μs7 \times 51.2 = 358.4\ \mu s.

Question 9hard

Two nodes have just collided for the 2nd time and both run binary exponential backoff. What is the probability that they collide again on their next attempt (they collide if they pick the same KK)?

Show answer
1/4

After the 2nd collision, each picks KK independently from {0,1,2,3}\{0, 1, 2, 3\}.
The probability of picking the same value is ∑k(1/4)(1/4)=4×1/16=1/4\sum_{k} (1/4)(1/4) = 4 \times 1/16 = 1/4.
After the 1st collision this is 1/2, after the 3rd it is 1/8: each collision halves the risk.

Question 10medium

Using the approximation efficiency=1/(1+5 dprop/dtrans)\text{efficiency} = 1/(1 + 5\,d_{prop}/d_{trans}), what is Ethernet's efficiency when dprop=12.5 μsd_{prop} = 12.5\ \mu s and frames are 1500 bytes at 10 Mbps?

Show answer
≈ 0.950

dtrans=12000/107=1.2d_{trans} = 12000 / 10^7 = 1.2 ms =1200 μs= 1200\ \mu s.5dprop/dtrans=62.5/1200≈0.0525 d_{prop}/d_{trans} = 62.5 / 1200 \approx 0.052.1/(1.052)≈0.9501/(1.052) \approx 0.950. Long frames and a short cable push the efficiency toward 1.

Question 11hard

A link of capacity 100 Mbps carries frames with mean length 10,000 bits arriving at 5000 frames/s. Using the static-allocation queueing formula T=1/(μC−λ)T = 1/(\mu C - \lambda), what is the mean delay on the full channel, and what is it if the channel is split statically into 10 equal FDM subchannels each receiving 1/10 of the traffic?

Show answer
0.2 ms; 2 ms

μC=108/104=10,000\mu C = 10^8 / 10^4 = 10{,}000 frames/s. T=1/(10000−5000)=0.2T = 1/(10000 - 5000) = 0.2 ms.
Split into 10, each subchannel has C/10C/10 and traffic λ/10\lambda/10: TN=1/(1000−500)=2T_N = 1/(1000 - 500) = 2 ms, that is N⋅TN \cdot T.
Static division multiplies the delay by N. This is the reason for dynamic sharing with bursty traffic.

Question 12easy

Which multiple access protocol is used by classic shared Ethernet, and which by Wi-Fi?

  1. Ethernet: CSMA/CA; Wi-Fi: CSMA/CD
  2. Ethernet: CSMA/CD; Wi-Fi: CSMA/CA
  3. Both use token passing
  4. Ethernet: slotted ALOHA; Wi-Fi: polling
Show answer
B) Ethernet: CSMA/CD; Wi-Fi: CSMA/CA

On a wired medium it is possible to listen while sending and notice a collision: CSMA/CD.
On wireless, your own strong signal drowns out the weak incoming signal, and there is the hidden terminal problem, so collisions cannot be detected. That is why Wi-Fi tries to avoid collisions (CSMA/CA, ACK, optional RTS/CTS).

Verification: ALOHA efficiencies, success probabilities for N nodes, static allocation delay, CSMA/CD minimum frame size, the Ethernet efficiency formula and backoff times were computed with node (verify/SEN2008/04.mjs).

Review card

Static allocation (FDM/TDM): T = 1/(muC - lambda), split into N parts gives N x T -> bad for bursty traffic Slotted ALOHA: S = G e^-G, max 1/e = 0.368 (G=1) N nodes: N p (1-p)^(N-1) Pure ALOHA: S = G e^-2G, max 1/(2e) = 0.184 (G=0.5) vulnerable period 2T idle slot (1-p)^N ; collision = 1 - idle - success CSMA: listen before sending; still collides because of propagation CSMA/CD: listen while sending, stop + jam signal on collision Lmin = 2 dprop R (to hear the collision before the transmission ends) n-th collision: K in {0..2^min(n,10) - 1}, wait K x 512 bit times (10M: 51.2 us) probability of same K: 1/2, 1/4, 1/8 ... Ethernet efficiency = 1 / (1 + 5 dprop/dtrans) Taking turns: polling (master asks), token passing (token circulates) Wired: CSMA/CD Wireless (Wi-Fi): CSMA/CA (hidden terminal)