# Algorithm for CSMA and Rules for CSMA/CD

**Rules for CSMA/CD:**

- If medium is idle, transmit, otherwise go to 2
- If the medium is busy, continue to listen until the channel is idle, then transmit immediately
- 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
- After transmitting the jamminnig signal wait for a random amount of time reffered as back off then attemps transmit Again

**Algorithm For CSMA:**

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

**(a) Non-Persistant CSMA:**

If channel is not free then wait for random amount of time then sense the channel, if free then sends the data

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

**(b) 1-Persistant CSMA:**

Continuously sense the channel and when it sense that the channel is free, it transmit the data.

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

**(c) 2-Persistant CSMA:**

Sense the channel before sending the data.

- With probability “P”, the station sends its frame
- 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 occur ed and uses the backoff algorithm

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

## Recommended Posts:

- Back-off Algorithm for CSMA/CD
- Implementation of a Back-off Algorithm for CSMA/CD
- Difference between CSMA/CA and CSMA/CD
- Efficiency of CSMA/CD
- CSMA/CD Full Form
- Acquiring Channel in CSMA/CD
- Collision Detection in CSMA/CD
- Carrier Sense Multiple Access (CSMA)
- Virtual Time Carrier Sensed Multiple Access (VT-CSMA)
- Mathematics | Rules of Inference
- RC5 Encryption Algorithm
- RC4 Encryption Algorithm
- Cristian's Algorithm
- Berkeley's Algorithm
- RSA Algorithm in Cryptography
- Difference between RSA algorithm and DSA
- Relabel-to-front Algorithm
- ElGamal Encryption Algorithm
- How to solve RSA Algorithm Problems?
- C-LOOK Disk Scheduling Algorithm

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.