Because many computers are sharing the same radio frequencies, it’s important to coordinate how they send data. When there’s a crowd of people in a room, they can’t all talk at the same time or everything will be garbled. The same thing happens when multiple WiFi radios transmit at the same time on the same frequency.
So we need some way to coordinate all the radios to make best use of the shared frequencies. We will look at the basics of technical approaches to avoiding lost data due to transmission “collisions”.
The first technique is called “Carrier Sense”. The technique is to first listen for a transmission, and if there is already a transmission in progress, wait until the transmission finishes. It might seem like you could wait for a long time, but since all messages are broken into packets, usually your computer only has to wait for the computer currently sending data to finish a packet, after which your computer gets its chance to send data.
If your computer’s WiFi radio listens for data and hears silence, it can begin transmitting. But what if another computer’s WiFi radio that wants to send a packet listened to and heard the same silence and decided to start transmitting at exactly the same time?
If two or more WiFi radios start transmitting at the same time, all of the data is corrupted and both packets are lost. So once your WiFi radio starts sending a packet it is important for it to listen to make sure it can receive its own data. If it is not receiving the same thing that it is sending, your WiFi radio assumes that a collision has happened (this is called Collision Detection) and stops transmitting, since it knows that no data will be received by the destination WiFi radio.
We humans do a similar thing in a room full of people. When two people start talking at the same time, they are good at noticing that another person is talking and quickly stop talking. But the problem is how to restart the conversation. After a long pause it is common that both people start talking at the exact same time again. This can happen over and over and each person says “No, you” repeatedly to attempt to figure out how to get the conversation restarted. It can be quite comical at times.
The WiFi radios in two computers that send colliding packets are able to solve this problem much better than people can solve the problem. When the WiFi radios detect a collision or garbled transmission, they compute a random amount of time to wait before retrying the transmission. The rules for computing the random wait are set up to make sure the two colliding stations pick different amounts of time to wait before attempting to retransmit the packet.
The formal name for the listen, transmit, listen, and wait and retry if necessary is called “Carrier Sense Multiple Access with Collision Detection” or CSMA/CD.
It might sound a little chaotic to just “give it a try” and then “give it another try” if your transmission collides with another station’s transmission. But in practice it works well. There is a whole category of link layers that use this basic pattern of listen, transmit, listen, and optionally retry. Wired Ethernet, cellular telephone data, and even Short Message Service (SMS/Texting) all use this “try then retry” approach.