CSMA/CD
The Carrier Sense Multiple Access with Collision Detection media access method.
The Problem: A Polite Conversation on a Shared Line
Imagine a group of people in a room trying to have a conversation. If everyone talks at once, the result is chaos and no one can be understood. To communicate effectively, they need a set of rules, or a protocol. For example: "Listen before you speak. If someone else is talking, wait your turn. If you accidentally start talking at the same time as someone else, stop, apologize, and wait for a moment before trying again."
Early Ethernet networks faced a very similar problem. They used a (typically a single coaxial cable like in a bus topology, or a simple hub) that all devices were connected to. This shared medium acts like that single room: if two or more devices tried to send data at the exact same time, their electrical signals would mix on the wire, becoming corrupted and unintelligible. This event is called a collision.
To manage this "conversation" and handle collisions gracefully, early Ethernet developed a foundational media access control protocol: CSMA/CD.
Decoding the Name: CSMA/CD
The name itself is a perfect description of how the protocol works. Let's break it down piece by piece:
CS - Carrier Sense
This means "listen before you talk." Before a device attempts to transmit data, it first "listens" to the communication channel (the cable) to check for a signal, or "carrier." If it detects that another device is already transmitting, it will wait. It only attempts to send data when it senses that the channel is idle (quiet).
MA - Multiple Access
This simply acknowledges the nature of the network: there are multiple devices (multiple access points) sharing the same medium. The protocol is designed to manage this shared access, allowing any device to try and use the channel when it's free.
CD - Collision Detection
This is the "listen while you talk" part. A collision can still occur even with Carrier Sense. For instance, two devices might listen, find the channel idle at the same time, and begin transmitting simultaneously. To handle this, a transmitting device continues to monitor the channel while it is sending data. It compares the signal it is sending with the signal it senses on the wire. If the sensed signal is different from what it's sending (e.g., has a higher voltage level), it knows that its data has collided with another signal. This ability to detect a collision in progress is the key to managing the shared medium.
The CSMA/CD Algorithm: A Step-by-Step Guide
The entire CSMA/CD process can be described as a simple but effective algorithm that every device on a shared Ethernet segment follows:
Initialization phase: getting ready to transmit
- 1: Host wants to transmit – the station prepares data for sending.
- 2: Check if carrier is detected (is someone else transmitting).
- YES: go to step 5 to keep monitoring for collisions.
- NO: go to step 3 and assemble the frame.
- 3: Assemble frame – the host builds the Ethernet frame with header fields.
- 4: Start transmission – bits are placed on the shared medium.
Monitoring phase: transmitting and detecting collisions
- 5: Check if collision occurred – the host compares what it sends with what it senses on the wire.
- YES: go to step 9 and notify the network about the collision.
- NO: go to step 6 and continue transmitting.
- 6: Continue transmission – the frame keeps flowing unless a collision is detected.
- 7: Check if transmission is complete.
- NO: return to step 6 and keep transmitting.
- YES: go to step 8.
- 8: Transmission complete – the frame was delivered successfully.
Collision handling phase
- 9: Broadcast jam signal – a 32-bit Jam pattern alerts all stations to the collision.
- 10: Increment attempt counter – update the collision count for the current frame.
- 11: Check if too many collisions occurred.
- NO: go to step 13 to compute the wait time and retry.
- YES: go to step 12 – transmission of the frame is aborted.
- 12: Too many collisions, abort transmission – the frame is dropped after exceeding the retry limit.
Backoff and retry phase
- 13: Calculate wait time – the station draws a delay using the binary exponential backoff algorithm.
- 14: Wait for specified time – after the delay expires, the host returns to carrier sensing (step 2) to retry the transmission.
Why Minimum Frame Size is Crucial for Collision Detection
A critical and often misunderstood part of CSMA/CD is the reason for a minimum Ethernet frame size of 64 bytes. This rule is directly linked to ensuring that Collision Detection can work reliably across the entire network segment.
Imagine the worst-case scenario: two devices, A and B, are at opposite ends of the longest possible cable segment.
The problem is a "race" against time. For CSMA/CD to work, a station must still be transmitting when the signal of a collision (the "echo" of the collision event) travels back to it. If a station finishes sending a very small frame before the collision signal gets back, it will mistakenly think the transmission was successful and will not retransmit, resulting in lost data.
The Math Behind the Rule
- Propagation Delay : This is the time it takes for a signal to travel from one end of the cable to the other.
- Slot Time: The worst-case time to detect a collision is the round-trip time: the time for a signal to travel to the far end of the cable and for the resulting collision signal to travel back. This window is defined as the and is slightly longer than to account for electronics. For 10 Mbps Ethernet, the slot time is standardized at 51.2 µs.
- The Calculation: To ensure a station is still transmitting when the collision signal arrives, the time it takes to transmit the smallest possible frame must be greater than or equal to the slot time.
Example: 10 Mbps Ethernet
Since 8 bits make up 1 byte, . This is why the smallest Ethernet frame must be 64 bytes long. This rule guarantees that even in the worst-case scenario, a collision will always be detected. As network speeds increased (e.g., to 1 Gbps), this rule would require either much larger minimum frame sizes or much smaller network diameters. In practice, the advent of switching and full-duplex communication made this issue largely moot for modern networks.
The Decline of CSMA/CD in Modern Networks
CSMA/CD was a brilliant and robust solution for the technological constraints of its time. It formed the foundation of early Ethernet and allowed for the creation of simple, cost-effective networks. However, its relevance in modern networks is vastly diminished.
The key factor in its decline was the invention and widespread adoption of the network switch. Unlike a hub, which creates a single collision domain, a switch intelligently forwards frames only to the port connected to the destination device. This creates a separate, two-device micro-segment for each connection.
This, combined with full-duplex communication (where devices can send and receive simultaneously on separate wire pairs), effectively eliminates the possibility of collisions on links between a switch and a host device. With no chance of collision, there is no need for Collision Detection, and the entire CSMA/CD mechanism can be disabled, allowing devices to transmit whenever they have data, achieving much higher efficiency.
Today, CSMA/CD remains an important historical concept and may still be active in half-duplex links (e.g., on legacy hubs or certain wireless links), but it is no longer the primary method of media access in the vast majority of wired Ethernet networks.