CSMA/CD (Carrier Sense Multiple Access with Collision detection) is a Media Access Control (MAC) protocol used in Local Area Networking:
It uses early Ethernet technology to overcome collision when it occurs.
This method organizes data transmission properly by regulating communication in a network with a shared transmission medium.
This tutorial will give you a complete understanding of Carrier Sense Multiple Access Protocol.
What You Will Learn:
Carrier Sense Multiple Access With Collision Detection
CSMA/CD, a MAC process protocol, first senses for any transmissions from the other stations in the channel and starts transmitting only when the channel is clear to transmit.
As soon as a station detects a collision, it stops transmission and sends a jam signal. It then waits for some time period before retransmitting.
Let’s understand the meaning of the individual component of CSMA/CD.
- CS – It stands for Carrier Sensing. It implies that before sending data, a station first senses the carrier. If the carrier is found free, then the station transmits data else it refrains.
- MA – Stands for Multiple Access i.e. if there’s a channel, then there are many stations that are trying to access it.
- CD – Stands for Collision Detection. It also guides to proceed in case of packet data collision.
What Is CSMA/CD
CSMA/CD procedure can be understood as a group discussion, where if the participants speak all at once then it will be very confusing and the communication will not happen.
Instead, for good communication, it is required that the participants speak one after another so that we can clearly understand the contribution of each participant in the discussion.
Once a participant has finished talking, we should wait for a certain time period to see if any other participant is speaking or not. One should start speaking only when no other participant has spoken. If another participant also speaks at the same time, then we should stop, wait, and try again after some time.
Similar is the process of CSMA/CD, where the data packet transmission is only done when the data transmission medium is free. When various network devices try to share a data channel simultaneously, then it will encounter a data collision.
The medium is continuously monitored to detect any data collision. When the medium is detected as free, the station should wait for a certain time period before sending the data packet to avoid any chances of data collision.
When no other station tries to send the data and there is no data collision detected, then the transmission of data is said to be successful.
The algorithm steps include:
- First, the station that wants to transmit the data senses the carrier as to whether it is busy or idle. If a carrier is found idle, then the transmission is carried out.
- The transmission station detects a collision, if any, using the condition: Tt >= 2 * Tp where Tt is the transmission delay and Tp is the propagation delay.
- The station releases the jam signal as soon as it detects a collision.
- After collision has occurred, the transmitting station stops transmitting and waits for some random amount of time called the ‘back-off time’. After this time, the station retransmits again.
CSMA/CD Flow Chart
How Does CSMA/CD Work
To understand the working of CSMA/CD, let’s consider the following scenario.
- Suppose there are two stations A and B. If station A wants to send some data to station B, then it has to sense the carrier first. The data is being sent only if the carrier is free.
- But by standing at one point, it cannot sense the entire carrier, it can only sense the point of contact. According to the protocol, any station can send data at any time, but the only condition is to first sense the carrier as if its idle or busy.
- In case A and B together start transmitting their data, then it’s fairly possible that the data of both the stations will collide. So, both the stations will receive inaccurate collided data.
So, the question that arises here is: how will the stations know that their data got collided?
The answer to this question is, if the colloidal signal comes back during the process of transmission, then it indicates that the collision has occurred.
For this, the stations need to keep on transmitting. Only then they can be sure that it’s their own data that got collided/corrupted.
If in case, the packet is large enough, which means by the time the collision signal comes back to the transmitting station, the station is still transmitting the left part of data. Then it can recognize that its own data got lost in the collision.
Understanding Collision Detection
In order to detect a collision, it is important that the station keeps on transmitting the data until the transmitting station gets back the collision signal if any.
Let’s take an example where the first bits transmitted by the station is involved in the collision. Consider we have four stations A, B, C and D. Let the propagation delay from station A to station D be 1 hour i.e. if the data packet bit starts to move at 10 a.m., then it will reach D at 11 a.m.
- At 10 a.m. both the stations, A and D sense the carrier as free and start their transmission.
- If the total propagation delay is 1 hour, then after half an hour both the station’s first bits will reach halfway and will soon experience a collision.
- So, exactly at 10:30 a.m., there will be a collision which will produce collision signals.
- At 11 a.m. the collision signals will reach stations A and D i.e. exactly after one hour the stations receive the collision signal.
Therefore, for the respective stations to detect that it’s their own data that got collided the transmission time for both the stations should be greater than their propagation time. i.e. Tt>Tp
Where Tt is the transmission time and Tp is the propagation time.
Let’s see the worst-case situation now.
- Station A started the transmission at 10 a.m. and is about to reach station D at 10:59:59 a.m.
- At this time, station D started its transmission after sensing the carrier as free.
- So here the first bit of data packet sent from station D will face collision with the data packet of station A.
- After collision occurred, the carrier starts sending a colloidal signal.
- Station A will receive the collision signal after 1 hour.
This is the condition for detecting collision in the worst case where if a station wants to detect collision then it should keep on transmitting the data till 2Tp, i.e. Tt>2*Tp.
Now the next question is if the station has to transmit the data for at least 2*Tp time then how much data should the station have so that it could transmit for this amount of time?
So in order to detect a collision, the minimum size of the packet should be 2*Tp*B.
The below diagram explains the Collision of first bits in CSMA/CD:
Station A,B,C, D are connected through Ethernet wire. Any station can send its data packet for transmission after sensing the signal as idle. Here the data packets are sent in bits which take time to travel. Due to this, there are chances of a collision.
In the above diagram, at time t1 station A starts transmitting the first bit of data after sensing the carrier as free. At time t2, station C also senses the carrier as free and starts transmitting the data. At t3, the collision occurs between bits sent by stations A and C.
Thus, the transmission time for station C becomes t3-t2. After the collision, the carrier will send back the colloidal signal to station A which will reach at time t4. This means, while sending the data, the collision can also be detected.
Having seen the time durations for the two transmissions, refer to the below figure for a complete understanding.
Efficiency Of CSMA/CD
The efficiency of CSMA/CD is better than Pure ALOHA however there are some points that need to be kept in mind while measuring the efficiency of CSMA/CD.
- If the distance increases, then the efficiency of CSMA/CD decreases.
- For Local Area Network (LAN), CSMA/CD works optimally but for long-distance networks like WAN, it’s not advisable to use CSMA/CD.
- If the length of the packet is bigger, then the efficiency increases but then again there is a limitation. The maximum limit for the length of the packets is 1500 bytes.
Advantages & Disadvantages Of CSMA/CD
- Overhead is less in CSMA/CD.
- Whenever possible, it utilizes all the bandwidth.
- It detects collision within a very short span of time.
- Its efficiency is better than simple CSMA.
- It mostly avoids any kind of wasteful transmission.
- Not suitable for large distance networks.
- Distance limitation is 2500 meters. Collision can’t be detected after this limit.
- Assignment of priorities cannot be done to certain nodes.
- As devices are added, the performance disrupts exponentially.
CSMA/CD was used in shared media Ethernet variants(10BASE2,10BASE5) and in the early versions of twisted pair Ethernet that used repeater hubs.
But nowadays, modern Ethernet networks are built with switches and full-duplex connections so that CSMA/CD is no longer used.
Frequently Asked Questions
Q #1) Why is CSMA/CD not used on a full-duplex?
Answer: In full-duplex mode, communication is possible in both directions. So there are least or in fact no chance of collision and thus no mechanism like CSMA/CD find its use on a full-duplex.
Q #2) Is CSMA/CD still used?
Answer: CSMA/CD is not often used anymore as switches have replaced hubs and as switches are being used, no collision occurs.
Q #3) Where is CSMA/CD used?
Answer: It is basically used on half-duplex Ethernet technology for local area networking.
Q #4) What is the difference between CSMA/CD and ALOHA?
Answer: The main difference between ALOHA and CSMA/CD is that ALOHA does not possess the feature of carrier sensing like CSMA/CD.
CSMA/CD detects whether the channel is free or busy before transmitting data so that it can avoid collision whereas ALOHA cannot detect before transmitting and thus multiple stations can transmit data at the same time thereby leading to a collision.
Q #5) How does CSMA/CD detect collision?
Answer: CSMA/CD detects collisions by sensing transmissions from other stations first and starts transmitting when the carrier is idle.
Q #6) What is the difference between CSMA/CA & CSMA/CD?
Answer: CSMA/CA is a protocol that is effective before collision whereas CSMA/CD protocol comes into effect after collision. Also, CSMA/CA is used in wireless networks but CSMA/CD works in wired networks.
Q #7) What is the purpose of CSMA/CD?
Answer: Its main purpose is to detect collisions and see whether the channel is free before a station starts transmission. It allows transmission only when the network is free. In case the channel is busy, then it waits for some random amount of time before transmitting.
Q #8) Do switches use CSMA/CD?
Answer: Switches no longer use CSMA/CD protocol as they work on full duplex where collision does not occur.
Q #9) Do wifi use CSMA/CD?
Answer: No, wifi does not use CSMA/CD.
So from the above explanation, we can conclude that the CSMA/CD protocol was implemented in order to minimize the chances of collision during data transmission and improve performance.
If a station can actually sense the medium before using it then the chances of collision can be reduced. In this method, the station first monitors the medium and later sends a frame to see if the transmission was successful.
If the medium is found busy then the station waits for some random amount of time and once the medium becomes idle, the station starts the transmission. However, if there’s a collision, then the frame is sent again. This is how CSMA/CD handles collision.