How does CSMA/CD work, and is it still relevant?
Show the answer
Say this first
Carrier Sense Multiple Access with Collision Detection was how half-duplex Ethernet shared a medium. Listen first, transmit when idle, keep listening; on a collision send a 32-bit jam signal, wait a random backoff and retry, up to 16 attempts. The slot time is 512 bit times, which is why the minimum frame is 64 bytes. It is off on full-duplex links, so it is relevant today only for duplex mismatches, old 10 and 100 Mbps gear, and as background for Wi-Fi's CSMA/CA.
Go deeper
Backoff
After the nth collision the sender waits a random number of slot times from 0 to 2^k - 1, where k is the smaller of n and 10. After 16 failed attempts it drops the frame and counts an excessive collision. At 10 Mbps a slot time is 51.2 microseconds; at 100 Mbps it is 5.12 microseconds.
Normal versus late collisions
A normal collision happens within the first 64 bytes, while the frame could still be colliding with a sender at the far end of a legal network. A late collision happens after that point. On a correctly built half-duplex network it never happens, so it signals a duplex mismatch or a segment that is too long.
Wireless is different
A radio cannot hear a collision while it transmits, so 802.11 uses collision avoidance: listen, random backoff before sending, and an ACK for every unicast frame.
They will ask next
Why did gigabit half duplex need carrier extension?
At 1 Gbps a 64-byte frame finishes so quickly that collision detection would only work over about 20 meters. 802.3z extended the slot time to 512 bytes with carrier extension. Almost nothing used gigabit half duplex in practice.
Traps
- Saying switches still use CSMA/CD on full-duplex ports. Full duplex turns it off.