Carrier Sense Multiple Access (CSMA)

Learn via video courses
Topics Covered

Overview

In Carrier Sense Multiple Access (CSMA) protocol, the station will sense the channel before the transmission of data. CSMA reduces the chances of collision in the network but it does not eliminate the collision from the channel. 1-Persistent, Non-Persistent, P-Persistent, and O-Persistent are the three access methods of CSMA.

What is Carrier Sense Multiple Access (CSMA)?

CSMA stands for Carrier Sense Multiple Access (CSMA). CSMA is one of the network protocols which works on the principle of ‘carrier sense’. CSMA is a protocol developed to increase the performance of the network and reduce the chance of collision in the network.

  • If any device wants to send data then the device first senses or listens to the network medium to check whether the shared network is free or not. If the channel is found idle then the device will transmit its data.
  • This sense reduces the chance of collision in the network but this method is not able to eliminate the collision.
  • Carrier Sense Multiple Access (CSMA) is a protocol that senses or listens to the medium before any transmission of data in the medium.
  • CSMA is used in Ethernet networks where two or more network devices are connected.

Working Principle of CSMA

  • CSMA works on the principle of "Listen before Talking" or "Sense before Transmit". When the device on the shared medium wants to transmit a data frame, then the device first detects the channel to check the presence of any carrier signal from other connected devices on the network.
  • In this situation, if the device senses any carrier signal on the shared medium, then this means that there is another transmission on the channel. The device will wait until the channel becomes idle and the transmission that is in progress is currently completed.
  • When the channel becomes idle the station starts its transmission. All other stations connected in the network receive the transmission of the station.
  • In CSMA, the station senses or detects the channel before the transmission of data so it reduces the chance of collision in the transmission.
  • But there may be a situation where two stations detected the channel idle at the same time and they both start data transmission simultaneously so in this, there is a chance of collision.
  • So CSMA reduces the chance of collision in data transmission but it does not eliminate the collision.

Example: In the network given below in the diagram if node 1 wants to transmit the data in the network then, first of all, it will sense the network if data from any other device is available on the network then it will not send the data. When node 1 finds the channel idle then it will transmit data on the channel.

Refer to the below image for an example of CSMA

example-of-csma

Vulnerable Time in CSMA

In the CSMA vulnerable time is considered as the propagation time and Tp is used to denote it. Generally, it is the time taken by the data frame to reach from one end of the channel to another end. When two stations send the data simultaneously then it will result in a collision in the network. In a situation, if the first bit of the frame sent by the station reaches the end of the shared medium then every station connected in a network hears that bit and every device in the network refrains from sending it.

Refer to the below image for the vulnerable time of CSMA

vulnerable-time-of-csma

Types of CSMA Access Modes

1-Persistent

This method is considered the straightforward and simplest method of CSMA. In this method, if the station finds the medium idle then the station will immediately send the data frame with 1- probability.

  • In this, if the station wants to transmit the data. Then the station first senses the medium.
  • If the medium is busy then the station waits until the channel becomes idle. And the station continuously senses the channel until the medium becomes idle.
  • If the station detects the channel as idle then the station will immediately send the data frame with 1 probability that’s why the name of this method is 1-persistent.

Refer to the below image to show the flow diagram of the 1-persistent method of CSMA

one-persistent-method-of-csma

In this method, there is a high possibility of collision as two or more station senses the channel idle at the same time and transmits data simultaneously which may lead to a collision.
This is one of the most straightforward methods. In this method, once the station finds that the medium is idle then it immediately sends the frame. By using this method there are higher chances for collision because it is possible that two or more stations find the shared medium idle at the same time and then they send their frames immediately.

Refer to the below image to show the behavior of the 1-persistent method of CSMA

behaviour-one-persistent-method-of-csma

Non-Persistent

In this method of CSMA, if the station finds the channel busy then it will wait for a random amount of time before sensing the channel again.

  • If the station wants to transmit the data then first of all it will sense the medium.
  • If the medium is idle then the station will immediately send the data.
  • Otherwise, if the medium is busy then the station waits for a random amount of time and then again senses the channel after waiting for a random amount of time.
  • In P-persistent there is less chance of collision in comparison to the 1-persistent method as this station will not continuously sense the channel but since the channel after waiting for a random amount of time.

Refer to the below image to show the flow diagram of the Non-persistent method of CSMA

non-persistent-method-flow-diagram

So the random amount of time is unlikely to be the same for two stations that’s why this method reduces the chance of collision.

Refer to the below image to show the behavior of the Non-persistent method of CSMA

non-persistent-method-behaviour

P-Persistent

The p-persistent method of CSMA is used when the channel is divided into multiple time slots and the duration of time slots is greater than or equal to the maximum propagation time. This method is designed as a combination of the advantages of 1-Persistent and Non-Persistent CSMA. The p-persistent method of CSMA reduces the chance of collision in the network and there is an increment in the efficiency of the network. When any station wants to transmit the data firstly it will sense the channel If the channel is busy then the station continuously senses the channel until the channel becomes idle. If the channel is idle then the station does the following steps.

  1. The station transmits its data frame in the network by p probability.
  2. The station waits for the start of the next time slot with probability q=1-p and after waiting again senses the channel.
  3. If the channel is again idle, then it again performs step 1. If the channel is busy, then it thinks that there is a collision in the network and now this station will follow the back-off procedure.

Refer to the below image to show the flow diagram of the P-persistent method of CSMA

p-persistent-method-flow-diagram

Refer to the below image to show the behavior of the P-persistent method of CSMA

O-Persistent

In this method of CSMA supervisory node assigns a transmission order to each node in the network. When the channel is idle instead of immediately sending the data channel will wait for its transmission order assigned to them. This mode of CSMA defines the superiority of the station before data transmission in the medium. In this mode, if the channel is inactive then all stations will wait to transmit the data for its turn. Every station in the channel transmits the data in its turn.

Variations of CSMA Protocol

Carrier Sense Multiple Access with Collision Detection (CSMA/CD)

Carrier sense multiple access/ collision detection is one of the network protocols for transmission. CSMA/CD protocol works with the medium access control layer of the network. That’s why the station senses the channel before transmission of data and if the station finds the channel idle then the station transmits its data frames to check whether data transmission is successful in the network or not. If the station successfully the data frame sent then it will again send the next frame. If the station detects a collision in the network, then in CSMA/CD the station will send the stop/jam signal to all the stations connected in the network to terminate their transmission of data. Then the station waits for a random amount of time for the transmission of data.

Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA)

Carrier sense multiple access/collision avoidance is one of the network protocols for data frame transmission. When the station sends the data frame on the channel it receives the acknowledgment in response to the sent data frame to test whether the channel is idle or not. When the station receives a single signal i.e. its signal this means that there is no collision and data has been successfully received by the receiver. But in case of collision, the station receives two signals: its signal and the second signal sent by the other station. In CSMA/CA collision is avoided by using the following three strategies. Following are the methods used in the CSMA/ CA to avoid the collision:

  • Interframe space
  • Contention window
  • Acknowledgement

Interframe Space or IFS: If the station wants to transmit the data then it waits until the channel becomes idle and when the channel becomes idle station does not immediately send the data but waits for some time. This period is known as the Interframe Space or IFS. IFS can also define the priority of the frame or station.

Contention window: The contention window is a time that is divided into time slots. When the station is ready for data transmission after waiting for IFS then it chooses the random amount of slots for waiting. After waiting for the random number of slots if the channel is still busy then the station does not initiate the whole process again, the station stops its timer and restarts again when the channel is sensed idle.

Acknowledgement: There may be a chance of collision or data may be corrupted during the transmission. Positive acknowledgment and time-out are used in addition to ensuring that the receiver has successfully received the data.

Refer to the below image to show the behavior of the CSMA/CA

behaviour-csma-ca

Conclusion

  • Carrier Sense Multiple Access(CSMA) is one of the network protocols in which stations sense the channel before the transmission of data.
  • The vulnerable time of the CSMA is referred to as the propagation time denoted by Tp.
  • 1-Persistent, Non-Persistent, P-Persistent, and O-Persistent are the three access methods of CSMA.
  • In the 1-Persistent method of the CSMA, if the station finds the medium idle then the station will immediately send the data frame with 1- probability.
  • In the Non-Persistent method of CSMA, if the station finds the channel busy then it will wait for a random amount of time and if the channel is idle it will immediately send the data frame.
  • In the P-Persistent method of CSMA, if the station finds the channel idle then it will send the data frame with p probability and for the starting of the next time slot with q=1-p probability.
  • CSMA/CA and CSMA/CD are two variations of CSMA.