235 lines
6.6 KiB
HTML
Executable File
235 lines
6.6 KiB
HTML
Executable File
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<!-- SWP3.html (C) K. J. Turner 18/12/14 -->
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>Sliding Window Protocol (3-Column)</title>
|
|
|
|
<link rev="made" href="http://www.cs.stir.ac.uk/~kjt/"/>
|
|
|
|
<script type="text/javascript" language="JavaScript">
|
|
|
|
<!--
|
|
var simulator;
|
|
var mediumType;
|
|
var mediumTypeOld;
|
|
var maxSeq;
|
|
var maxSeqOld = 7;
|
|
var winSize
|
|
var winSizeOld = 3;
|
|
|
|
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() {
|
|
mediumType =
|
|
document.settings.medium[0].checked
|
|
? 2
|
|
: document.settings.medium[1].checked
|
|
? 1
|
|
: 0;
|
|
if (mediumType != mediumTypeOld) {
|
|
mediumTypeOld = mediumType;
|
|
simulator.setParameter("mediumType", mediumType);
|
|
simulator.restart();
|
|
}
|
|
maxSeq = document.settings.maxSeq.value;
|
|
winSize = document.settings.winSize.value;
|
|
if (validInteger("Maximum Sequence Number", maxSeq, 1, 31) &&
|
|
validInteger("Window Size", winSize, 1, 31)) {
|
|
maxSeq = parseInt(maxSeq);
|
|
winSize = parseInt(winSize);
|
|
if (winSize <= maxSeq) {
|
|
if (maxSeq != maxSeqOld || winSize != winSizeOld) {
|
|
maxSeqOld = maxSeq;
|
|
winSizeOld = winSize;
|
|
simulator.setParameter("maxSeq", maxSeq);
|
|
simulator.setParameter("winSize", winSize);
|
|
simulator.restart();
|
|
}
|
|
}
|
|
else
|
|
alert("Window Size must be 1 to the Maximum Sequence Number");
|
|
}
|
|
}
|
|
//-->
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body background="simulator.jpeg"
|
|
onload="simulator=document.ProtocolSimulator; set();">
|
|
|
|
<div style="text-align: center">
|
|
|
|
<h1>
|
|
Sliding Window Protocol Simulator
|
|
<br/>
|
|
(3-Column)
|
|
</h1>
|
|
|
|
<img src="simulator.gif" alt="Simulator Logo"/>
|
|
|
|
</div>
|
|
|
|
<h2>Protocol Description</h2>
|
|
|
|
<p>
|
|
SWP (Sliding Window Protocol) a connection-less protocol. It allows data
|
|
to be sent in one direction between a pair of protocol entities, subject to
|
|
a maximum number of unacknowledged messages. If SWP is operated with a
|
|
window size of 1, it is equivalent to the <a href="ABP.html">Alternating Bit
|
|
Protocol</a>. The simulation below does not include the users; see the <a
|
|
href="SWP5.html">five-column</a> version for this.
|
|
</p>
|
|
|
|
<p>
|
|
The protocol has a maximum number of messages that can be sent without
|
|
acknowledgement. If this window becomes full, the protocol is blocked
|
|
until an acknowledgement is received for the earliest outstanding
|
|
message. At this point the transmitter is clear to send more messages.
|
|
</p>
|
|
|
|
<h2>Protocol Parameters</h2>
|
|
|
|
<p>
|
|
The following settings are adequate for a simple simulation. For a more
|
|
advanced exploration, choose different options and click <em>Change
|
|
Settings</em>. This may cause the simulation to restart.
|
|
</p>
|
|
|
|
<p>
|
|
Optionally set the level of control that the simulator user needs over
|
|
the medium:
|
|
</p>
|
|
|
|
<dl>
|
|
|
|
<dt><b>Automatic</b>:</dt>
|
|
<dd>
|
|
Messages are delivered immediately without loss. This is suitable for
|
|
initial experimentation, but limits what can be explored. For example,
|
|
message are never lost and never have to be timed out and resent.
|
|
</dd>
|
|
|
|
<dt><b>Delivery</b>:</dt>
|
|
<dd>
|
|
Alternatively, message delivery may be controlled - though messages
|
|
will still never be lost. Choose this option to allow messages to be
|
|
delivered in different orders and to be resent.
|
|
</dd>
|
|
|
|
<dt><b>Delivery/Loss</b>:</dt>
|
|
<dd>
|
|
Finally, delivery and loss of messages may be completely controlled.
|
|
This is the most comprehensive option, but also the most complex one to
|
|
manage.
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
<p>
|
|
Optionally set the maximum sequence number used by the protocol: this is
|
|
one less than the modulus. Sequence numbers wrap round to zero when they
|
|
pass the maximum. Optionally set the maximum window size permitted: this
|
|
must not exceed the maximum sequence number. Changing either of these
|
|
parameters will restart the simulation.
|
|
</p>
|
|
|
|
<form name="settings">
|
|
|
|
<center>
|
|
|
|
<table cellpadding="5">
|
|
|
|
<tr>
|
|
<td align="right">Medium Control:</td>
|
|
<td>
|
|
<input type="radio" name="medium" value="2"
|
|
checked="checked"/>Automatic
|
|
</td>
|
|
<td>
|
|
<input type="radio" name="medium" value="1"/>Delivery
|
|
</td>
|
|
<td>
|
|
<input type="radio" name="medium" value="0"/>Delivery/Loss
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="right">Maximum Sequence Number (1 to 31):</td>
|
|
<td colspan="3">
|
|
<input type="text" name="maxSeq" value="7" size="2"/>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="right">Window Size (1 to Maximum Sequence Number):</td>
|
|
<td colspan="3">
|
|
<input type="text" name="winSize" value="3" size="2"/>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="center" colspan="4">
|
|
<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 transmitting
|
|
and receiving protocol entities, and a communications medium that carries
|
|
messages. The transmitter simply sends messages numbered <em>DT(0)</em>,
|
|
<em>DT(1)</em>, etc. Once sequence numbers reach a maximum number (like
|
|
7), they wrap back round to 0. The content of messages is not explicitly
|
|
identified. An acknowledgement <em>AK(n)</em> means that the <em>DT</em>
|
|
message numbered <em>n</em> is the next one expected (i.e. all messages
|
|
up to but not including this number have been received). Since sequence
|
|
numbers wrap round, an acknowledgement with sequence number 1 refers to
|
|
messages 0, 1, 7, 6, etc. Note that if a <em>DT</em> message is received
|
|
again due to re-transmission, it is acknowledged but discarded.
|
|
</p>
|
|
|
|
<center>
|
|
|
|
<applet code="simulator.ProtocolSimulator.class"
|
|
archive="ProtocolSimulator.jar" width="600" height="700"
|
|
name="ProtocolSimulator">
|
|
<param name="protocol" value="SWP3"/>
|
|
</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>
|
|
|
|
|