CSMA an acronym used for Carrier Sense Multiple Access. It is a type of random-access protocol, where multiple stations transmit their data over a shared channel. However, before transmission, each station senses the channel first and transmits only when finds the channel idle.
In CSMA, each station is equally prioritized and thus the transmission occurs according to the channel availability. This is a network protocol and functions on the MAC layer.
Need for CSMA
CSMA was introduced to deal with the downsides of the ALOHA protocol. Both CSMA and ALOHA are the classifications of random-access protocols. Before elaborating, why do we need CSMA, first see-
What is Random Access Protocol?
Random access protocol helps in providing a common channel to multiple users in order to send or receive data. It is a classification of multiple access protocol where the various user holds equal priority thus enabling them to transmit whenever they wish to do so.
Random access protocol is of the following types:
We have already discussed in our previous content on ALOHA Protocol that it is not so coordinated type of random-access technique through which various hosts can transmit over a shared channel. However, as each station operates independently without considering others. Thus, the chance of collision between data packets was very high in ALOHA or we can say the collision was guaranteed.
ALOHA is of two types:
- Pure ALOHA: In this scheme, none of the users from the large number of users accessing the channel is concerned about the use of the channel by any other user. This simply means that each individual user can transmit whenever they wish to do so.
Thus, due to the simultaneous transmission of data by multiple users, the chances of collision of data packets are quite high. As partial as well as complete collisions both can occur here. The collision of data packets will result in the loss of data.
- Slotted ALOHA: This scheme is an advancement of pure aloha, with the improvisation of the slotted channels. Here from the slotted channel, we mean that the whole channel is fragmented into various time slots. Each individual user is given a specific time slot, and the user transmits, in that particular slot only.
The implementation of slotted aloha has vanished the chances of partial collision however, there are still chances of complete collision. This is so because a complete collision can take place when multiple users are allotted the same time slot.
But even after adopting, any of the two above-discussed schemes, collision may still occur. The reason is that none of the stations are sensing whether the channel is free to take the data or not. And with an increase in traffic, collision becomes quite severe. This was the major drawback associated with aloha and to deal with this, carrier sense multiple access was introduced.
Principle of CSMA
The principle of operation of CSMA is based on:
Sense before Transmit
In simplest terms, it is somewhat like, listen before speak.
The name of this scheme, itself indicates that here the carrier is sensed first and then transmission takes place. From the word carrier here, we mean channel or medium through which the transmission is taking place. So, in CSMA, first, the channel over which the data is to be transmitted is checked by the user/station to see if it is free to transmit or not. This checking before actually sending the data enables us to reduce the chances of collision.
Basically, whenever a carrier is sensed then two possibilities mainly exist:
- Busy Carrier: This corresponds to the condition when there is an ongoing transmission that is already taking place over the channel. This means that the moment a user sensed the channel, any other user within the network is utilizing the channel.
- Idle Carrier: Idle carrier state shows that the channel is free and no other node of the network is transmitting at that instant. When this idle carrier state is noticed by a user who is willing to transmit then only it begins the transmission otherwise wait for some random time.
So, before transmitting if the medium is checked then this minimizes the chances of collision and enhances the performance. Theoretically, on this basis, it is said that CSMA offers no blocking or collision thereby providing the throughput of 100%. But it is possible practically?
The answer is no and the reason is propagation delay. So,
What is propagation delay and how it causes collision?
Propagation delay corresponds to the time which a data packet transmitted from a node, takes to reach other nodes in the network. Basically, when a station is transmitting but the sent data has not reached a point over the channel where the other node is present then if that station senses the channel, then it seems to be idle because the transmitted signal has not reached that particular node yet.
To understand propagation delay, consider the figure shown below where multiple nodes are connected with a common bus:
Here suppose node A is transmitting and node E is receiving while R, S, and T are the intermediary nodes. Initially, A sends the data frame which is propagating over the common channel. At the same time, node S also checks for the availability of free channel. As the data frame has not reached node S yet due to the propagation time it takes to reach S, node S will consider the channel as idle and think to begin transmission.
This is so because each node before starting the transmission will not sense the whole channel region, despite will check its specific node region. Hence, if the transmitted data packet has not reached the node which is willing to transmit due to propagation delay, then it may lead to collision between data packets.
Thus, for CSMA, it is preferred that the propagation delay between the stations must be less than the packet transmission time. As when propagation delay is small then the nodes will get to know about any ongoing transmission immediately. This will help in easily checking the carrier availability thereby reducing collision in case of the busy channel. Because if propagation delay is longer then, the effect becomes more prominent and efficiency will get reduced.
Propagation delay plays a crucial role in determining the efficiency of CSMA:
a = Propagation delay/packet transmission time
Modes of CSMA
As this technique is built upon the way of sensing the carrier so this can be done in three ways. This section is all about how the carrier is sensed which is regarded as modes of CSMA.
1. 1-persistent CSMA: The word persistent corresponds to something continuous or constant in nature. In this mode of CSMA, the node which is willing to transmit the data packet checks for the availability of a free carrier.
However, if it finds the channel busy, then it continuously checks for the availability of a free channel. As soon as the medium gets free, the new station immediately begins transmission. But still, this mode is not collision-free because there exists a worst case.
In this case, the collision of data packets may happen, when two nodes continuously sense the channel and the instant when the channel gets free, both the nodes begin transmission immediately. Ethernet uses 1-persistent technique.
2. Non-Persistent: It is sometimes known as 0-Persistent. In this mode of CSMA, the channel is sensed by the station and if it is free then the host begins to transmit. However, if a busy channel is sensed then the station that is willing to transmit will wait for a random period of time and once this random duration will get over then it checks for availability again.
This means here, continuous sensing will not take place for immediately seizing the channel once the previous transmission gets completed. But once the random tenure gets over, then again it will sense the channel and if finds free then begin the transmission. Here the channel is utilized in a better way than the previous mode and also the worst-case collision occurring there was not taking place here. So, the chances of collision will be less.
But in this case, the worst-case is that if the channel gets free before the completion of the random time, then it will remain unutilized in that time. This is so because the node will check again only once the random period gets over.
3. P-Persistent: This technique is a combination of the 1-persistent and non-persistent mode of CSMA. Here, similar to the 1-persistent scheme, the station willing to transmit senses the channel constantly to check it is free or not. If it finds the channel free, then the station sends the data frame with probability P.
However, if the data fails to get transmitted i.e. if collision has occurred and the sender has not received the acknowledgment i.e., failing of P probability. Then it retransmits the data packet after a random period of time in the next time slot by considering probability Q = 1-P. However, even after the random time slot, if the channel is sensed busy then the algorithm is repeated in the same way.
By this technique, the worst case of non-persistent i.e., keeping the channel unused in the idle state is eliminated by regularly keeping a check on the availability of the channel. And once gets free the data is transmitted with probability P.
Also, the worst case of 1-persistent is dealt with efficiency where multiple stations transmitting after continuously sensing the state of the channel will wait for the desired time slot to retransmit the data packet. It is used in Wi-fi networks.
CSMA/CA and CSMA/CA are the two versions of CSMA and were improvisation of CSMA network protocol.