Before starting to describe the mechanism of Collision Detection, we need to understand why collision occurs in a computer network.
In the computer networking, a collision occurs when two or more devices attempt to send data along a shared media at the same time. All computer networks require some sort of mechanism to either prevent collision or to recover from it quickly, when it occurs.
In the next paragraphs we’ll take a deeper look into a protocol which is responsible for detecting collisions. We’ll also learn how a network hardware recovers from collision.
What kind of networks are prone to collision?
If you’re using a LAN hubs in your network, you have to get ready to face collision in your network. When an electrical signal arrives in one of the ports of a hub, it duplicates and re-sends (repeats) that signal out of every other ports (except the incoming port).
The result is that the data will be delivered to the rest of the nodes connected to the hub. The hub has no idea what a MAC address is so regardless of which device is the original sender, the hub will just send out the packets through every port.
The downside of using LAN hubs is that if two or more devices transmit a signal at the same time, the electrical signal will collide and the data will be lost. The hub repeats all received electrical signals, even if it receives multiple signals at the same time.
Now all the Ethernet nodes inside the network will have to use half-duplex mode instead of full-duplex, in order to stay away from those collisions. The problem only arises when two or more devices send at the same time. Half-duplex logic tells the rest of the nodes that someone else is busy sending data. It orders the other station to wait until the busy station finishes it’s job.
Carrier Sense/Multiple Access With Collision detection (CSMA/CD)
Another method to detect and prevent collision is known as CSMA/CD. Despite its long name, this media access technology is probably the most common way to prevent collisions in a network.
While using CSMA/CD, when a station has data to transmit, it first senses if a signal is already on the wire (a carrier). If there is, it indicates that someone is currently busy transmitting some data. This part is technically called “Carrier Sense”.
If the sending client senses no transmission signals on the wire, it will begin to transmit data and then starts to tap the media. If someone else tries to send data simultaneously, a collision will occur. Many factors can cause a collision to happen. For example, an unfortunate timing.
Now, both senders “back off” and stop transmitting until some random period of time has passed for each station. Notice that this random delay is different for each station. The station who was on a shorter delay, will naturally retry to send data sooner and the other unit will come next. The whole procedure eliminates any chance of collision. This is known as “Collision Detection”.
The final part “Multiple Access” just means that more than one station can share the medium on the network. CSMA/CD is the access method used in Ethernet networks.
Summary of CSMA/CD protocol
Step 1: The sending unit will first listen to the media to see if there is any signal currently passing over.
Step 2: if there’s no signal, it will start transmitting.
Step 3: The sender then listen if any collision occurs on the media. If a collision occurs, all currently sending nodes do the following:
- They send a jamming signal that tells all nodes that a collision has just happened.
- Then they need to choose a random length of time highhandedly to wait before trying to transmit again.
- Whenever the stations want to send another piece of data, they will start over with step 1.