How CSMA/CD works
When Ethernet operates in shared media, it uses a network access method protocol called as CSMA/CD (Carrier Sense Multiple Access / Collision Detection). How CSMA/CD works is explained in a simple way below.
When Ethernet LAN technology evolved long back, it operated on shared media. In a shared media local area network (LAN), total available bandwidth in network is shared with all devices. The early Ethernet standards were 10Base2 and 10Base5. In 10Base2 and 10Base5 based Ethernet networks, devices were connected together using coaxial cables, in bus topology.
Another example of shared media is when the devices inside an Ethernet network are connected using hubs. When connected using hubs, all the devices in that Ethernet network logically share the same media. In a shared media, normally communication happen between devices using broadcasts.
These days we cannot find any Ethernet network, operating using shared media.
In CSMA/CD (Carrier Sense Multiple Access/Collision Detection) Access Method protocol, every host has equal access to the wire and can place data on the wire when the wire is free from traffic. In other words, devices are in listen-before-transmit carrier sense mode.
When a device wants to place data on the wire for transmission, it will "sense" the wire to find whether there is a signal already on the wire. If there is traffic already in the medium, the device will wait a random period of time and "sense" again.
If there is no traffic (no signal in wire), the device will place the data in the medium. At the same time, the device is listening from the media, because the device wants to ensure no other devices are transmitting at the same time.
But, if two devices place data on the medium at the same instance, the signals will collide with each other, destroying the data. If the data signal is destroyed during transmission because of collision and the lost data signal need to be retransmitted.
When a collision occurs and detected, the devices involved in collision will transmit "JAM signal" for a short time, so that all devices in the network detect that the collision had happened. The "JAM signal" indicates to all other devices on the shared Ethernet media that a collision had happened, and no one should place data on the wire.
When all devices detected that the collision had happened in the network, the devices stop transmitting for a random period of time. The random period of time to wait is determined by the backoff algorithm.
When the random period of time is expired, each device can access the shared media again.