MAC protocol simulator

A bunch of stations want to talk on one shared radio channel. Only one transmission can be heard cleanly at a time — if two start at once, both get garbled. Pick a rule for when a station may talk, then watch what happens.

How to use

  1. Pick a protocol (one of the four buttons).
  2. Press Play. Watch the timeline scroll. Green blocks are successful transmissions, red blocks are collisions.
  3. Drag the offered load slider up. Notice how every protocol breaks down differently as the channel gets busy.
  4. Look at Throughput vs offered load at the bottom — the dot is your current run, the dashed curves are the textbook predictions.

Protocol

Knobs

0.50frames per frame-time
5sharing the channel
0.50p-CSMA only
5xslots per render

Channel timeline

transmission — success transmission — collision has packet, waiting backing off after collision idle

Live counters

Slots elapsed
0
Attempts
0
Successes
0
Collisions
0
Throughput S
0.000frames/frame-time
Carried load G
0.000incl. retries

Throughput vs offered load

your current run (live) theory: pure ALOHA   S = G·e−2G theory: slotted ALOHA   S = G·e−G

Things to try

  1. Start with Pure ALOHA. Set load to 0.5 — this is the theoretical sweet spot. Note the throughput ≈ 1/(2e) ≈ 0.18.
  2. Push the load to 2.0. Watch the channel saturate with collisions; throughput collapses. This is the famous ALOHA instability.
  3. Switch to Slotted ALOHA at the same load. Throughput roughly doubles — lining transmissions up to slot boundaries removes half the vulnerable window.
  4. Switch to CSMA + random backoff. Stations now listen before talking. Most collisions vanish; throughput stays high even at heavy load.
  5. Switch to p-persistent CSMA at heavy load (load = 2.0, 16 stations). With p = 1.0, all the queued stations stampede the moment the channel goes quiet and collide. Drop p to 0.1: stations spread their attempts out, collisions plummet, and throughput jumps above 0.5. The cost is each individual station has to wait a bit longer for its turn — latency vs. throughput trade-off.
What the simulator is actually doing

Time is discretised into mini-slots. One frame takes 4 mini-slots to transmit. Each station independently generates packets as a Poisson process; the slider sets the aggregate arrival rate G in in frames per frame-time, which is then split equally across stations.

A "collision" means two transmissions overlap on the channel for any portion of their frames — both are marked failed and both stations retry after a random backoff. Successes and attempts are counted in frames; S and G are those counts converted to frame-time units, so a value of 1.0 means the channel is fully utilised.

Pure ALOHA: transmit on arrival. Slotted ALOHA: defer arrivals to the next frame-aligned slot boundary. CSMA: at every mini-slot, if the channel is idle, transmit (1-persistent). p-CSMA: at every idle mini-slot, flip a biased coin with probability p first. Carrier sensing here is idealised — zero propagation delay — so CSMA collisions only happen when two stations decide to start in the same idle mini-slot.