JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

CSMA, Collisions, and the MAC Address

ALOHA was brave but wasteful. This guide adds one piece of common courtesy — listen before you talk — to build CSMA, watches what happens when two stations still collide, learns why Wi-Fi must avoid collisions instead of detecting them, and finally meets the flat hardware name that every frame carries: the MAC address.

From ALOHA to listening first

In the previous guide we met the multiple-access problem: many stations share one channel — one cable, one radio frequency — and if two transmit at the same instant their signals overlap and garble each other into a collision. We saw three families of answers, and the most interesting was random access, whose ancestor is ALOHA: just transmit whenever you have data, and if a frame is damaged, wait a random little while and try again. ALOHA is gloriously simple, but it is also rude — it talks without checking whether anyone else is already talking — so under load most of the channel is wasted on collisions.

The fix is one small piece of common courtesy you already practice in conversation: pause and listen before you start to speak. A station that first checks whether the channel is busy, and only transmits when it sounds idle, is running CSMA — Carrier Sense Multiple Access. "Carrier sense" just means "listen for someone else's signal on the wire." It is the same instinct as not barging into a room where two people are mid-sentence. This one rule dramatically cuts collisions compared to plain ALOHA, because most of the time you can hear the channel is occupied and politely hold off.

When collisions still happen: CSMA/CD

On old wired Ethernet, where everyone shared one electrical bus, engineers added a second courtesy to CSMA: keep listening while you talk. If you hear your own transmission get scrambled by someone else's, you know a collision is happening right now. That is CSMA/CD — Carrier Sense Multiple Access with Collision Detection. The payoff is that a sender does not have to transmit a whole doomed frame and only learn later that it was lost. It detects the wreck within microseconds, slams on the brakes, and recovers — turning a wasted full frame into a wasted fraction of one.

  1. Sense the channel. If it has been idle, go ahead and start transmitting your frame; if it is busy, wait until it goes idle (then optionally wait a tiny extra beat).
  2. While transmitting, keep listening. Compare what is on the wire to what you are sending — if they differ, someone else is talking too: a collision.
  3. On detecting a collision, stop sending the frame immediately and broadcast a short "jam" signal so every station is certain the collision happened.
  4. Back off for a random amount of time, then return to step 1 and try again — the randomness keeps the colliding stations from re-colliding in lockstep.

The clever part is how the backoff scales. Ethernet uses binary exponential backoff: after the first collision a station picks its wait from {0, 1} slot-times; after the second, from {0, 1, 2, 3}; after the n-th collision, from a range up to 2^n - 1. The more crowded it gets, the wider stations spread their retries, so the channel calms itself down instead of melting into a storm of repeats. It is the same gentle wisdom you will meet later in TCP — a careful driver speeds up gently after success and brakes hard after trouble.

Why Wi-Fi can't detect collisions — so it avoids them

Here is a genuine surprise that trips up almost everyone: Wi-Fi does not use CSMA/CD. It uses CSMA/CA, where CA stands for Collision Avoidance. The reason is physical and unavoidable: a radio cannot listen for a faint collision while its own transmitter is blasting at full power right next to its own antenna — its own signal drowns out everything else. A wire could compare incoming voltage to outgoing voltage, but a radio is effectively deaf the moment it speaks. So Wi-Fi cannot detect collisions mid-air; it has to work hard to avoid them in the first place.

Avoidance leans on extra caution. A Wi-Fi station senses the channel, and even when it goes idle it waits a fixed gap plus a random backoff before transmitting, so two waiting stations are unlikely to leap at the same instant. Crucially, because the sender cannot hear a collision, it asks the receiver to confirm success: every received frame is answered with an explicit acknowledgment. No acknowledgment back means "assume it collided or was lost — back off and retransmit." That is the link layer doing its own little reliable-delivery dance, the ARQ idea you met earlier in this rung, right down at layer 2.

The MAC address: a flat name on every frame

All this taking-turns and backing-off decides who gets to speak. But once you do speak, how does the right neighbor know the frame is for them, and everyone else know to ignore it? That is the job of the MAC address — a 48-bit identifier baked into each network interface at the factory, usually written as six pairs of hex digits like 00:1B:44:11:3A:B7. "MAC" here is Media Access Control, the same sublayer that runs CSMA. Every frame on a local network carries a destination MAC address and a source MAC address in its header; an interface scoops up frames addressed to its own MAC (or to the all-ones broadcast address) and lets the rest sail past.

Ethernet frame (the link-layer envelope)
+-----------------+-----------------+--------+---------------+-----+
| dest MAC (6 B)  | src MAC (6 B)   | type   | payload (IP)  | FCS |
+-----------------+-----------------+--------+---------------+-----+
  00:1B:44:11:3A:B7  AA:BB:CC:00:11:22  0x0800  ...your packet...  CRC

  FF:FF:FF:FF:FF:FF  = broadcast: every interface on the LAN reads it
Destination and source MAC sit at the very front of the frame; the trailing FCS is the CRC error check from guide 2 of this rung.

Two things make a MAC address feel different from an IP address you may have heard of. First, it is flat, not hierarchical: 00:1B:44:11:3A:B7 tells you nothing about where the device is, the way a street address tells you the city and street. The first half identifies the manufacturer and the second half is just a serial number, so a MAC names a piece of hardware, not a location — which is exactly why it works only for the single hop across one local link and cannot, by itself, route across the Internet. Second, it is meant to be globally unique, since manufacturers are handed distinct blocks, though modern phones now randomize it for privacy.

From shared bus to switch: collisions fade away

Here is the happy ending, and another honest twist. Everything above assumed many stations share one collision medium — a collision domain, the set of devices whose transmissions can collide with each other. That was true of old Ethernet on a shared cable or a dumb hub. But modern wired Ethernet runs through a switch, which gives each device its own dedicated, full-duplex link — a private two-lane road where you can send and receive at the same time. On such a link there is no one to collide with, so CSMA/CD has nothing to do. It still lives in the standard for backward compatibility, but on a switched network it essentially never fires.

How does the switch know which port leads to which MAC? It learns by watching — like a receptionist who learns where everyone sits. Each time a frame arrives, the switch notes the source MAC and the port it came in on, and files that in a table; thereafter, a frame for that MAC goes out only the matching port instead of being shouted to everyone. So a switch slices one big collision domain into many tiny ones, one per link. But beware the classic exam trap: a switch does not break up the broadcast reach — a frame sent to FF:FF:FF:FF:FF:FF still floods every port. Splitting that broadcast domain takes a router or a VLAN, not a plain layer-2 switch.

Step back and admire what the data link layer accomplished across this rung. It drew lines around the bits to make frames, caught corruption with a checksum or a CRC, recovered lost frames with ARQ and a sliding window, decided who gets to talk with multiple-access rules, and named neighbors with MAC addresses. With that, one hop across one link works reliably. The next rung lifts off the single wire entirely: how does a packet find its way across many hops, between networks it has never seen, using the hierarchical address the MAC address pointedly is not? That is the network layer, and it is where the Internet truly becomes the Internet.