CSMA/CD explained

Half-duplex Ethernet networks use an algorithm called Carrier Sense Multiple Access with Collision Detection (CSMA/CD). This algorithm helps devices on the same network segment to decide when to send packets and what to do in case of collisions. CSMA/CD is commonly used in networks with repeaters and hubs because these devices run in the half-duplex mode and all of their ports are in the same collision domain.

Packet collisions occur when packets are transmitted from different host at the same time. To prevent this, CSMA/CD forces a transmitting station to check for the presence of a digital signal on the wire. If no other hosts are transmitting packets, the sender begins sending the frame. The sender also monitors the wire to make sure no other hosts begin transmitting. However, if another host begins transmitting at the same time and a collision occur, the transmitting host sends a jam signal that causes all hosts on the network segment to stop sending data. After a random period of time, hosts retransmit their packets.

Consider the following example:

how csma/cd works

In the picture above we have a network of four hosts connected to a hub. Since hubs work in the half-duplex mode and each port on a hub is in the same collision domain, packet collisions can occur and CSMA/CD is used to prevent and detect them. Host A detects that there are no other signals on the network and decides to send a packet. However, Host B also assumes that no other station is transmitting and sends a packet as well. A collision occurs and it is detected by Host A and Host B. The sending stations send a jamming signal telling all hosts on the segment that a collision occured. After a random period of time, Host A and Host B resend their packets.

 

Since switches have replaced hubs in most of today’s LANs, CSMA/CD is not often used anymore. Switches work in full-duplex mode and each port on a switch is in a seperate collision domain, so no collisions can occur.
Geek University 2022