MAC, Ethernet & CSMA/CD

RoadmapsCore CS

Scenario

Imagine a dark room full of people where anyone can speak, but only one person can speak at a time. Before talking, you listen. If it's quiet, you speak. If someone else starts talking at the exact same moment, you both stop, wait a random amount of time, and try again. This is exactly how early Ethernet handled traffic.

Mental model

MAC addresses are physical name tags. Ethernet is the room they are in. CSMA/CD is the polite rulebook for taking turns speaking in that room so voices don't overlap.

Carrier Sense Multiple Access with Collision Detection (CSMA/CD) is the protocol early Ethernet used for shared mediums (like a single copper wire). Nodes 'sense' the line, transmit if clear, and if a collision occurs (two signals crashing), they back off for a random exponential time before retrying.

Explanation

To move data across a local physical network, computers need unique physical identities. This is the MAC (Media Access Control) address. Unlike an IP address which can change based on your location, a MAC address is permanently burned into a computer's Network Interface Card (NIC) at the factory. It is a 48-bit address, typically represented as six pairs of hexadecimal digits.

Ethernet is the dominant technology used for these local wired networks. In its early days, Ethernet used a 'shared medium' architecture. Imagine multiple computers connected to a single, long coaxial cable. Because they shared the same physical wire, if two computers sent electrical signals at the exact same moment, the signals would crash into each other, distorting the voltage and destroying the data. This is called a collision.

To manage this chaos, Ethernet adopted a protocol called CSMA/CD (Carrier Sense Multiple Access with Collision Detection). 'Carrier Sense' means a computer listens to the wire before transmitting. If it hears existing traffic (a carrier signal), it waits. 'Multiple Access' simply means many devices share the wire.

If the wire is quiet, a computer begins sending its frame. However, because electrical signals take a tiny fraction of a second to travel down the wire, another computer at the far end might also think the wire is quiet and start transmitting simultaneously. 'Collision Detection' means that while transmitting, the sender actively listens to its own signal on the wire. If the voltage spikes unexpectedly, it knows a collision occurred.

When a collision is detected, the transmitting computers immediately stop sending data and instead transmit a 'jam signal' to ensure all other devices on the network know a collision happened. Then, they initiate an Exponential Backoff algorithm. Each computer waits a random amount of time before trying again. If they collide again, the range of random wait times doubles (exponentially). This randomness ensures they don't get stuck in an endless loop of simultaneous retries.

Today, modern Ethernet uses 'switches' instead of shared hubs. A switch creates dedicated, isolated physical circuits between devices. Because devices are on dedicated wires (Full-Duplex), collisions are physically impossible. Consequently, CSMA/CD is largely obsolete in modern wired networks, though its wireless cousin (CSMA/CA) is heavily used in Wi-Fi.

Key points

Common mistakes

Glossary

MAC (Media Access Control) address
A permanent, unique physical serial number burned into your computer's network chip at the factory so it can be identified on a local network.
Network Interface Card (NIC)
The actual physical hardware component inside a computer that allows it to connect to a network using Wi-Fi or a cable.
hexadecimal digits
A counting system based on 16 (using numbers 0-9 and letters A-F) often used in computing to write long binary addresses more compactly.

Recall questions

Questions & answers

A network has 10 computers connected via an old shared hub. How many collision domains exist in this network?

One collision domain.

Approach: Understand that a hub operates at Layer 1 and simply repeats electrical signals to all ports, making the entire network one large shared collision domain.

If two computers using CSMA/CD collide repeatedly, what happens to their wait times?

The maximum possible wait time increases exponentially after each consecutive collision.

Approach: Recall the 'Exponential' in Exponential Backoff. The window of random wait times doubles to reduce the probability of further collisions under heavy load.

Continue learning

Previous: Framing & Error Detection

Next: Address Resolution Protocol (ARP)

Return to Core CS Roadmap