You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
221 lines
7.0 KiB
HTML
221 lines
7.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<!-- CSMA.html (C) K. J. Turner 18/12/14 -->
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>CSMA/CD ("Ethernet")</title>
|
|
|
|
<link rev="made" href="http://www.cs.stir.ac.uk/~kjt/"/>
|
|
|
|
<script type="text/javascript" language="JavaScript">
|
|
|
|
<!--
|
|
var simulator;
|
|
var serviceCount;
|
|
var serviceMode;
|
|
|
|
function validInteger(name, value, min, max) {
|
|
if (!value.match("\\d+") || value < min || value > max) {
|
|
alert("Value for " + name + " must be in range " + min + " to " + max);
|
|
return false;
|
|
}
|
|
else
|
|
return true;
|
|
}
|
|
|
|
function set() {
|
|
retryLimit = document.settings.retryLimit.value;
|
|
if (validInteger("Retry Limit", retryLimit, 0, 5)) {
|
|
simulator.setParameter("retryLimit", retryLimit);
|
|
simulator.restart();
|
|
}
|
|
}
|
|
//-->
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body background="simulator.jpeg"
|
|
onload="simulator=document.ProtocolSimulator; set();">
|
|
|
|
<div style="text-align: center">
|
|
|
|
<h1>CSMA/CD (Ethernet)</h1>
|
|
|
|
<img src="simulator.gif" alt="Simulator Logo"/>
|
|
|
|
</div>
|
|
|
|
<h2>Protocol Description</h2>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
Transmission proceeds in one of the following ways:
|
|
</p>
|
|
|
|
<dl>
|
|
|
|
<dt><b>Normal:</b></dt>
|
|
<dd>
|
|
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.
|
|
</p>
|
|
</dd>
|
|
|
|
<dt><b>Deferral:</b></dt>
|
|
<dd>
|
|
<p>
|
|
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.
|
|
</p>
|
|
</dd>
|
|
|
|
<dt><b>Collision:</b></dt>
|
|
<dd>
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<h2>Protocol Parameters</h2>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<form name="settings">
|
|
|
|
<center>
|
|
|
|
<table cellspacing="5">
|
|
|
|
<tr>
|
|
<td align="right">Retry Limit (0 = no collisions, 5 maximum):</td>
|
|
<td><input name="retryLimit" size="4" value="0"></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="center" colspan="2">
|
|
<input type="button" name="btnSet" value="Change Settings"
|
|
onclick="set()"/>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</center>
|
|
|
|
</form>
|
|
|
|
<h2>Protocol Simulation</h2>
|
|
|
|
<p>
|
|
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 <var>DATA(Dn)</var>. Data
|
|
messages are numbered <var>D0</var>, <var>D1</var>, etc.; no explicit data
|
|
content is given. If the retry limit is reached, this is reported to a
|
|
station with the message <var>FAIL(Retry Limit)</var>. Protocol messages
|
|
have the form <var>START(Dn)</var> to start a transmission,
|
|
<var>FINISH(Dn)</var> to finish the transmission, and <var>JAM</var> to jam
|
|
transmission.
|
|
</p>
|
|
|
|
<center>
|
|
|
|
<applet code="simulator.ProtocolSimulator.class"
|
|
archive="ProtocolSimulator.jar" width="750" height="700"
|
|
name="ProtocolSimulator">
|
|
<param name="protocol" value="CSMA"/>
|
|
</applet>
|
|
|
|
</center>
|
|
|
|
<hr/>
|
|
|
|
<p>
|
|
<a href="index.html"><img src="uparrow.gif" alt="Up Arrow"/></a>
|
|
Up one level to <a href="index.html">Protocol Simulators</a>
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|