CSMA/CD (Ethernet)

Simulator Logo

Protocol Description

CSMA/CD (Carrier Sense, Multiple Access, Collision Detection) illustrates how multiple systems can share a common communications medium. CSMA/CD is best known in the form of Ethernet - a kind of LANs (Local Area Network). LANs have a MAC layer (Medium Access Control) that operates the data link protocol.

Many systems (known as stations) can be attached to an Ethernet - the Multiple Access aspect. A station will not transmit if it finds that another station is already using the Ethernet - the Carrier Sense aspect. However, it is still possible for two stations to transmit at almost the same time. While a station is transmitting, it may find that another station has already begun its own transmission - the Collision Detection aspect. In such a case, each station backs off and tries again - hopefully avoiding a collision on the second or later attempt.

An Ethernet is a broadcast medium: whatever one station sends is received by all others. Each message carries the address of its intended destination; only the station with this address will act on the message. A transmission takes a very short (but not zero) time to arrive at its destination. Since stations will be at different distances from each other, the transmission time between them varies. The maximum transmission time between any two stations is called the slot time.

Ethernet does not provide any guarantee of correct delivery, so its protocol can be simple. Instead, a higher-level protocol such as TCP (Transmission Control Protocol) is responsible for detecting and correcting errors.

Transmission proceeds in one of the following ways:

Normal:
The station transmits its message from start to finish. When the message has been fully received at the intended destination, that station processes the message.

Deferral:

In fact, a station listens for a transmission from another station before beginning its own transmission. If it hears such a transmission, it defers to the other station. Once that transmission has finished, the station begins its own transmission.

Collision:

However, this does not avoid interference. For example, a distant station may have started transmission but its signal has not yet arrived. The local station may therefore think the network is not in use and begin its own transmission. Both transmissions will then collide in the network. This can be detected by the transmitting stations, but this is not always fully reliable. The stations therefore ensure that the collision is properly detected by sending a jam signal.

Following this, each station backs off a random delay (a number of slot times) before retrying its transmission. Ideally, one station should choose a smaller delay and so start retransmitting before the other one.

For the first retransmission, the random delay is 0 or 1 slot times. Since two stations may choose the same delay, there is a 50% chance that they retry at the same point (and therefore collide again). On further collisions, the maximum delay is doubled (0 to 2, 0 to 4, etc.). A limit is set on the maximum number of retries.

For this simulation, only two stations are involved; addresses are therefore not required. For simplicity, the protocol simulation below assumes that the LAN works perfectly (no message corruption, loss or misordering). However, interference among transmissions is still a source of potential error that the protocol must cope with.

Protocol Parameters

By default, the simulation has a retry limit of 0. Since this means that retries are not allowed, the simulation internally ensures that collisions cannot occur. Retry limits from 1 to 5 can be used, but the possibility of collisions complicates the behaviour. Click Change Settings after altering the retry limit. This will restart the whole simulation.

Retry Limit (0 = no collisions, 5 maximum):

Protocol Simulation

The protocol simulation shows a time-sequence diagram with two stations, the MAC entities that support them, and a LAN that carries messages between them. Stations transmit messages in the format DATA(Dn). Data messages are numbered D0, D1, etc.; no explicit data content is given. If the retry limit is reached, this is reported to a station with the message FAIL(Retry Limit). Protocol messages have the form START(Dn) to start a transmission, FINISH(Dn) to finish the transmission, and JAM to jam transmission.


Up Arrow Up one level to Protocol Simulators