What is CSMA Protocol?


The CSMA’s full form is carrier sense multiple access. It is a MAC layer protocol in a computer network (as per OSI Model) for accessing an underlying shared communication channel. e.g., LAN. In another tutorial, we have described another common channel access protocol named  Aloha. CAMA differs from ALOHA in the way it works. There is sensing the channel before transmitting, while Aloha does not.

Sensing a channel reduces the chances of a collision. So more improved functionality over Aloha. Let’s first understand what the CSMA or carrier sense multiple access means. Having two things, first carrier sense and another multiple access.

What is carrier sense?

The carrier sense means a device on a computer network will first listen or sense the channel before transmitting a frame or message. This differs from Aloha, where there was no listening to the channel before sending a frame.

What is multiple access? 

In CSMA, multiple access means multiple devices can transmit on a commonly shared channel. It is the same as Aloha.

Versions of CSMA protocol:

There were different versions were developed. In each version of CSMA, a station or device listen to the channel before sending a frame. The difference is in sending patterns. The following describes the versions of CSMA.

Persistent or 1-persistent CSMA:

This is the primary and simplest version. When the device wants to transmit a frame over a shared channel, the device starts sensing the medium. If the channel is free, devices transmit the frame or else keep sensing the channel. The probability of sending the frame is one when the channel is free. That’s why it names as 1-Persistent CSMA.

It looks like the 1-persistent is perfect with no collision. But this is not the case. Still, there are chances of a collision. Here are a few scenarios of collision.

  • When more than one station/device listens for the common or shared channel, once the channel will get free, both devices detect the channel is free at the same time and start sending frames simultaneously. Simultaneous send leads to the collision.
  • Another scenario may lead to a collision because of the propagation delay. A network always has a  propagation delay, which may be significantly less but still not zero. Propagation delay is the time a signal travels from one station to another over the network. For example, if a station starts sending a frame, but the busy signal is still on the way toward other stations. If, at this point, a station listens to the channel, it will find it accessible and send the frame. Now two frames are on the channel, and a collision will occur.

Non-persistent CSMA:

  • The device starts sensing/listening to the channel.
  • If the channel is free, the device transmits the frame.
  • If the channel is not free, the device waits randomly and starts the procedure again.

The Non-Persistent version has fewer chances of collision than the 1-Persistent CSMA. But have a drawback of more delay in transmissions.

P-Persistent CSMA:

The P here means the probability. A probability(P) is assigned to the channel in P-persistent CSMA. The probability is always between 0 and 1. This version of the CSMA algorithm takes advantage of both the above versions. P-Persistent applies to the slotted channel. The following describes the procedure.

  • All stations listen to the channel and have an idle time slot.
  • Each listening station generates a random number(its probability) between 0 and 1 when a channel is free.
  • If the generated station probability is lesser than the channel probability(P), the frame is transmitted else; there is a wait for the next time slot.
  • If the next time slot is idle, the station again transmits or waits for the next time slot.
  • The above process is repeated until the frame is successfully transmitted or the channel is busy.
  • If the channel is busy, the sending station waits for the next idle time slot and starts the procedure again.

Conclusion :

Till now, we have learned an overview of the CSMA protocol and various versions of the protocol. As a reader, if you still feel something is unclear, add a comment.