CSMA/CD: Explanation of the process
In a local Ethernet network (IEEE 802.3), all network participants usually meet on a common transmission medium – a cable. This meeting must be regulated to avoid chaos during data transmission, which could lead to data loss or damage. CSMA/CD offers a method that organizes data transmission properly.
This technique isn’t suitable for WLAN. Therefore, the process has been adapted in the form of CSMA/CA. CSMA/CD is no longer important for most wired networks, since new cable technology offers other possibilities. However, it doesn’t hurt to be knowledgeable of this older procedure as well.
What is CSMA/CD?
CSMA/CD stands for Carrier Sense Multiple Access/Collision Detection, with collision detection being an extension of the CSMA protocol. This creates a procedure that regulates how communication must take place in a network with a shared transmission medium. The extension also regulates how to proceed if collisions occur i.e. when two or more nodes try to send data packets via the transmission medium (bus) simultaneously and they interfere with one other.
To understand how CSMA/CD works, it makes sense to break down the individual components of the term:
- Carrier sense (CS): The carrier state detection makes sure that all network participants check whether the medium is currently free – only then does the protocol initiate data transmission
- Multiple access (MA): Several participants (computers connected to the network) share a transmission medium
- Collision detection (CD): The collision detection is an extension of the original protocol and regulates how to proceed in case data packets happen to collide
How the CSMA/CD process works
CSMA/CD is divided into several steps. The procedure is based on a normal group conversation: for good communication, it is important that the participants don’t all speak at once, which can be confusing. Instead, they should speak one after the other, so that each participant can fully understand what the others are contributing to the discussion. Without realizing, we actually behave like this ourselves in conversations: When someone else is talking, we stand back and listen.
After the other participant has finished their contribution for the time being, we wait a short time and only start talking when the same participant or another participant in the conversation doesn’t start to say anything else. If we happen to start talking to someone else at the same time, we stop our attempt, wait a bit, and then try again.
The CSMA/CD process is very similar. First, the station monitors the transmission medium. As long as this is occupied, the monitoring will continue. Only when the medium is free and for a certain time (in interframe spacing), will the station send a data packet. Meanwhile, the transmitter continues to monitor the transmission medium to see if it detects any data collisions. If no other participant tries to send its data via the medium by the end of transmission, and no collision occurs, the transmission has been a success.
Collisions result in a voltage displacement on the cable. This makes it possible for the stations to detect the collisions.
If, however, a collision is detected, the participant immediately interrupts the transmission and instead sends an interference signal (JAM signal) so that all other stations can also detect the collision. Now the participant waits for a random amount of time (backoff) before trying the transmission again. The backoff must be random so that the next collision doesn’t occur straight away. Since both stations select a random value, the probability that both of them will start a transport attempt at the same time is quite low.
The transmission attempts are counted. If the following attempts also fail and the maximum number of attempts (16) is reached, the station reports the error to the next higher network layer and then terminates the transmission permanently. Since it is highly unlikely that a network participant will reach the maximum number of attempts during a normal process, it can be assumed that a system error has occurred.
The Ethernet collision resolution mechanism binary exponential backoff is used to mitigate permanent collisions. The participant must wait a while before starting a new attempt after a collision. This duration is always a random multiple of the so-called slot time. The slot time depends on the transmission rate and is a few microseconds long. The range of possible multiples doubles with each failed attempt so that the probability of simultaneous transmission becomes exponentially lower.
To detect whether a collision has occurred, the station simultaneously checks whether the transmitted signal is identical to that on the transmission medium. If this is not the case, another station carries out a transmission simultaneously and falsifies the signal on the bus. Collisions like these occur regularly and are part of the normal operation of a local area network (LAN). However, the size of the network also increases the probability of collisions. In this case, size refers not only to the number of participants, but also to the length of the transmission paths.
Due to it taking a while, it could be that a participant has already sent a signal, but it hasn’t yet been detected by another participant. This also leads to more collisions and slows down the network overall.
What is a collision domain?
A collision domain is the area of a network in which participants share a transmission medium. Participants receive access via the CSMA/CD procedure. However, the collision domain must not exceed a certain size: Networks cannot be enlarged indefinitely if the collision procedure is to remain effective. The reason for this is the speed of the transmission and the distance it must travel.
Network protocols can be divided into seven abstract layers according to the OSI reference model. The top layer (the application layer) provides features for applications, allowing users to enter and output data. These include layers for transport (where you can find TCP, for example) and switching (where the internet protocol is located). In the lowest layer (the physical layer), the task is to translate the binary digits of the computer into a physical signal that matches the transmission medium. The collision domain is also located at this level.
For CSMA/CD to work, error messages must reach all participants in the collision domain within a certain time: a data package runs from one end of the domain to the other, where a collision may occur. The corresponding signal must reach the first station before it’s ready for the complete transmission of the data packet. Otherwise the station will not realize that the transmitted data is already damaged and will consider the transmission to be success, while the data packet will be lost. Incidents like these are called “late collisions” and lead to the loss of data.
With this knowledge and the information about the network technology being used, the maximum size of a collision domain can be calculated. If you assume you’re dealing with a classic half-duplex Ethernet network, this has a data transmission rate of 10 Mbps. The smallest data package, which accordingly takes the shortest time for complete transmission, and is the most extreme case, has a size of 512 bits (64 bytes). This results in a slot time of 51.2 μs (microseconds). The slot time describes the length of time a signal may take to the end of the collision domain and back again.
Data in networks, however, is not sent through empty space at the speed of light. You’re bound to the physical conditions of the transmission medium. The nominal velocity of propagation (NVP) is the percentage of the speed of light that’s reached in the medium. For example, the twisted-pair cables that are typical for local networks have an NVP value of 0.6 and the slightly older coaxial cables a value of 0.77. Data can therefore reach 180,000 km/s (112.000 m/s) (60%) or approx. 230.000 km/s (143.000 m/s) (77%) of the speed of light.
All data is used to the purpose of maximizing the availability of a collection of data, to guarantee the accuracy of the CSMA/CD.
Data management x duration of transmission = twice the maximum length
230.000 km/s x 0.0000512 s = 11.776 km
(143.000 m/s x 0.0000512 s= 7.32 m)
A collision domain in a network based on coaxial cables may therefore have a maximum spread of 5.89 km (3.66 m). When calculating, the signals going in both directions need to be taken into account. The maximum size of a collision domain cannot be extended by interconnecting signal amplifiers (repeaters) either, as these have no influence on the CSMA/CD procedure.
How can collisions be prevented?
In general, collisions cannot be completely avoided with half-duplex systems. They are scheduled errors and CSMA/CD ensures that collisions do not lead to problems during transmission. However, this only applies to data loss. The transmission speed decreases if there are too many collisions. How do too many collisions occur? If there are too many participants in a collision domain, it increases the number of collisions and with it the number of delays. In very bad cases, it could be that only 30% of the speed is reached.
So that is doesn’t go too far, it’s worthwhile forming smaller collision domains. To do this, the network must be split up. Switches or bridges are used for this – both work on the basis of MAC. Media access control works on the second (i.e. the next highest) OSI layer, the backup layer (data link). It makes sense to form the sub networks in such a way that stations, which have to communicate with each other often, are next to each other. This prevents bottlenecks on the bridges from canceling out the gain in speed.
Half-duplex vs. full-duplex
A distinction is made between half-duplex and full-duplex in network technology. Both models are related to the technology used. In the context of networks or other communication techniques, duplex basically describes the possibilities with regard to data transmission. Therefore, half-duplex only allows transmission in one direction at a time. With full-duplex, however, a station can send and receive at any time.
In addition, there’s also simplex and dual-simplex when it comes to network technology. The former only allows transmission in one direction at any time. Radio is a good example of this: It can send transmissions, but it can’t receive them. Dual-simplex, on the other hand, corresponds more to the principle of full-duplex, where both sending and receiving is possible. In contrast to full-duplex, however, this is done in two different ways.
The distinction between half-duplex and full-duplex has a clear effect on the CSMA/CD procedure: the fact that only one transmission is possible with half-duplex means that a measure needs to be implemented to avoid collisions. This becomes tangible if you imagine the transmission channel as a single-lane road. If traffic comes simultaneously from both directions, it leads to a collision. Full-duplex, on the other hand, is always two-track. Traffic can flow past each other from both directions. Therefore, Carrier Sense Multiple Access with Collision Detection is not required in networks that use full-duplex: collisions cannot occur.
The duplex type is linked to the technical conditions and very specifically to the types of cable used. Networks connected to coaxial cables can only run in half-duplex mode. Full-duplex was only possible after twisted-pair and fiber optic cables were introduced. At the same time, fast Ethernet (100 Mbps) and gigabit Ethernet (1 Gbit/s) were implemented as full-duplex networks, so that CSMA/CD only plays a minor role in practice.
CSMA/CD vs. CSMA/CA
Besides the extension of Carrier Sense Multiple Access with Collision Detection, media access can also be provided with collision avoidance CSMA/CA. The latter is particularly needed when it comes to wireless connections; CSMA/CD doesn’t work well in radio networks for various reasons. The central problem here is the hidden station problem. This occurs when two stations do not recognize each other, but communicate simultaneously with a third station in the middle – which inevitably leads to collisions.
CSMA/CA, however, aims to avoid collisions (as the name suggests) instead of just recognizing them. If a collision does occur, a corresponding protocol is established. In this respect, CSMA/CA is an adaptation of CSMA/CD to another transmission medium.