Overview
The distributed algorithms can be run in four ways:
- Browser
- Appletviewer
- Networked computers
- Loopback on a single computer using address 127.0.0.1
The Java applets are identical in all modes and only the HTML
files vary between modes. Sample HTML files are included in the
distribution.
These applets are not animations; rather, they are interactive
state machines that display the execution of distributed algorithms.
The content of each applet is identical:
- Two lines of data for node represented by this applet.
The first line displays the state of the node and the second
line lists prompts for outstanding actions that must be performed.
- Two similar lines of data for each of the other nodes.
- A sequence of buttons for choosing a step of the algorithm.
- The nodes are color-coded: the color of the first pair of
lines of an applet containing the data of the node that it represents
is also used to color the pairs of lines in other nodes containing
data of the node.
Interactive execution of an applet
Warning: If the applets do not start executing or crash
while running, it is almost certainly the result of a bug or
incompatibility in the compiler, appletviewer or browser. Try
using an alternate mode (appletviewer instead of browser, or
conversely), or a different version of the JDK or browser.
The sample HTML files start applets for each of four nodes.
The file for the browser creates a 2x2 table and runs an applet
in each cells. The file for the appletviewer creates a separate
window for each of the four applets, and it is convenient to
tile the screen 2x2.
The reset button in the top right corner will return all the
applets to their initial state. (This has been implemented only
for the non-distributed mode of execution.) When running with
the appletviewer you can terminate the applets by interrupting
the appletviewer (ctrl-C from the command window), or by choosing
Quit on one of the applet menus.
To perform a step of the algorithm, click on buttons in one
of the applets. This is how you specify the interleaved
sequence of instruction execution. Note:
- As the state of the algorithm at a node changes, an appropriate
set of buttons is displayed.
- An instruction may require multiple clicks to perform.
- Some buttons may not be active. It is a test of your understanding
of the algorithm that you not click on a non-active node, though
if you do so, nothing happens and you can analyze why the button
is not relevant.
- There are prompts to remind you what messages to send.
- Even some of the accepted transitions may not be "correct".
We illustrate each of these items with reference to the Byzantine
Generals algorithm:
- A node must initially choose attack or retreat before participating
in the exchange of messages. Only then do the buttons for message
passing appear.
- When sending a message from one node to another, you must
specify: (i) the address of the destination node, (ii) the name
of the general "about whom" the node is expressing
an opinion, and (iii) the opinion attack or retreat. Thus each
step of the algorithm requires three clicks.
- You can only send an opinion about another node if you have
already received that node's plan. If not, the address button
will be inactive.
- The prompts list which messages must be sent or relayed to
other nodes.
- The BG algorithm works correctly only if there is at most
one traitor. However, you can have two nodes give traitorous
messages and specify an execution sequence that causes an incorrect
state to be reached when the algorithm terminates.
HTML parameters
An HTML file must contain an applet invocation for each node
in the algorithm. The required Name parameter assigns a sequence
number to each applet, and it is recommended that you specify
the standard parameters WIDTH and HEIGHT so that the applets
will fit comfortably on your screen.
<HTML>
<TITLE>Byzantine Generals</TITLE>
<BODY>
<APPLET CODE="BG.class" NAME="0" WIDTH=350 HEIGHT=200></APPLET>
<APPLET CODE="BG.class" NAME="1" WIDTH=350 HEIGHT=200></APPLET>
<APPLET CODE="BG.class" NAME="2" WIDTH=350 HEIGHT=200></APPLET>
<APPLET CODE="BG.class" NAME="3" WIDTH=350 HEIGHT=200></APPLET>
</BODY>
</HTML>
The following parameters are optional:
Parameter name |
Meaning |
Default |
NUMBER |
Total number of applets |
4 |
DISTRIBUTED |
Networked communications |
false |
FONTSIZE |
Size of font |
12 |
NODEi |
Name of node i |
John, Zoe, Leo, Basil |
COLORi |
Color of node i |
cyan, green, yellow, lightgray |
IPi |
IP address of node i |
127.0.0.1 |
Usually it is easier to change the source code and recompile
than to change the HTML parameters of all the nodes!
For example, to use white background for all nodes just change
one line (supplied as a comment) in the source code of method
getParms in class DistAlg .
|