# Algorithm for CSMA and Rules for CSMA/CD

• Difficulty Level : Hard
• Last Updated : 10 Nov, 2021

Rules for CSMA/CD:

1. If medium is idle, transmit, otherwise go to 2
2. If the medium is busy, continue to listen until the channel is idle, then transmit immediately
3. If collision is detected during transmission then transmit a brief jamming signal to assure that all station knows that there has been a collision so that stations can cease the transmission
4. After transmitting the jamming signal wait for a random amount of time referred as back off then attempts transmit Again

Algorithm For CSMA:
Algorithm for CSMA are: Non-Persistent, 1-Persistent, and 2-Persistent. These are explained as following below.

(a) Non-Persistent CSMA:
If channel is not free then wait for random amount of time then sense the channel, if free then sends the data

1. Transmit if medium is idle otherwise go to 2
2. Wait for random amount of time and repeat (1) if medium is busy

(b) 1-Persistent CSMA:
Continuously sense the channel and when it sense that the channel is free, it transmit the data.

1. If medium is idle transmit, otherwise go to 2
2. Wait for random amount of time and repeat (1) if medium is busy

(c) 2-Persistent CSMA:
Sense the channel before sending the data.

1. With probability “P”, the station sends its frame
2. With probability 1-P, station waits for the beginning of the next time slot and check the line again:
• (i) If line is idle go to 1
• (ii) If line is busy, it act as a collision has occurred and uses the backoff algorithm

My Personal Notes arrow_drop_up