This simulation demonstrates the CSMA/CD (Carrier Sense Multiple Access with Collision Detection) protocol used in Ethernet networks. Four devices share a single communication channel and must coordinate to avoid data collisions.
Packet Generation: Each cycle, every device has a 20% chance of generating a packet destined for a randomly selected other device. Packets require 1-3 cycles to transmit, randomly determined when created.
Carrier Sense: Before transmitting, devices check if the network is idle. If another device is already sending, they wait until the channel becomes available. This prevents most collisions but cannot eliminate them entirely.
Collision Detection: When multiple devices attempt to send simultaneously (detected in the same cycle), a collision occurs. Both devices detect this failure and immediately stop transmission.
Exponential Backoff: After a collision, devices enter a backoff period before retrying. The initial backoff is randomly chosen between 500-2000ms. With each subsequent collision for the same packet, the backoff time doubles (up to a maximum of 8000ms), reducing the likelihood of repeated collisions.
Delivery: Successful transmissions complete after their designated duration, and packets are marked as delivered. The simulation tracks average delivery times to monitor network efficiency.