The Data Link layer is divided into two sublayers: the Logical Link Control (LLC) sublayer and the Media Access Control (MAC) sublayer.
When multiple computers are connected to the exact same shared communication medium (like an old Ethernet bus cable, or the airwaves in a Wi-Fi network), we have a severe problem. If Computer A and Computer B both transmit electrical signals at the exact same millisecond, those signals will crash into each other on the wire, altering the voltages and destroying the data. This is called a Collision.
The MAC sublayer provides Multiple Access Protocols to determine which device gets control of the shared medium at any given time to minimize or avoid collisions.
Before transmitting, early networks just sent data blindly (ALOHA protocol), resulting in massive collisions.
To improve this, CSMA introduced a simple rule: "Listen before you talk."
The Problem: Because electrical signals take a fraction of a millisecond to travel down a long cable (propagation delay), Computer A might start transmitting, but the signal hasn't reached Computer B yet. Computer B listens, falsely assumes the wire is idle, and starts transmitting. A collision still occurs!
CSMA/CD is the standard protocol used in traditional wired Ethernet networks. It improves upon CSMA by adding a mechanism to detect and recover from collisions.
The Rule: "Listen while you talk."
CSMA/CA is the standard protocol used in wireless Wi-Fi networks (802.11).
Why not use CSMA/CD for Wi-Fi? In a wireless network, a radio transmitter is so loud that it drowns out any incoming signals. A Wi-Fi antenna cannot physically "listen" for a collision while it is actively transmitting. Therefore, collisions cannot be detected; they must be avoided entirely.
Furthermore, wireless networks suffer from the Hidden Node Problem. Computer A and Computer C might both be able to reach the central Router B, but a concrete wall prevents A and C from hearing each other. They will both assume the air is clear and transmit simultaneously, colliding at Router B.
The Solution: