CSMA in Computer Network

The efficiency of pure ALOHA and Slotted ALOHA is very less but they are effectively used in large distance communication where a shared medium is used for exchanging data. The efficiencies are less as there is no mechanism applied to detect whether the medium is already carrying any data or not. But, In the case of LAN, it is possible to check the signal level of the medium to sense a carrier. Protocol in which a station listens for a carrier and it acts accordingly is known as Carrier Sense Multiple Access (CSMA). There are three types of CSMA protocol are exists :
1. 1-Persistent CSMA

2. Non-Persistent CSMA

3. p-Persistent CSMA

1-Persistent CSMA

A station ready with data to send does the following steps:

(i) It senses the carrier to see whether it is idle or not.
(ii) If the channel is idle then it transmits the frame.
(iii) If the channel is busy then it waits and continually senses the channel. As soon as the channel becomes free it transmits the frame.
(iv) If the collision occurs then it waits for a random amount of time and starts all over again.

Non-Persistent CSMA

Problem arising out of continuously sensing a busy channel by a number of stations are removed in this case by waiting for a random amount of time after a channel is sensed as busy.
A station ready with data to send does the following steps:

(i) It senses the carrier to see whether it is idle or not.
(ii) If the channel is idle then it transmits the frame.
(iii) If the channel is busy then instead of continually sensing the channel, it waits for a random amount of time and starts all over again.

p-Persistent CSMA

This protocol is applied for slotted channels.
A station ready with data to send does the following steps:

(i) It senses the carrier to see whether it is idle or not.
(ii) If the channel is idle then it transmits the frame with probability p with probability q=1-p // It defers transmission for the next slot.
(iii) In the next slot also it senses the carrier to see whether the channel is idle then it transmits the frame with probability p and defers with probability q. This process continues until the frame is transmitted.
(iv) If the channel is initially sensed as busy then it waits for the next slot and starts the algorithm.
(v) If the collision is sensed then it waits for a random amount of time and starts all over again.