Emulating Multiple Nodes on a Single Computer

[English | Japanese]
last-updated: February 13, 2011

In this tutorial, you use Distributed Environment Emulator, invoke multiple instances of DHT shell on it.

The following instructions assume that you have the toolkit installed (extracted and built), and set PATH environment variable to execute toolkit commands in bin directory. You can execute the commands without setting the PATH by preceding the commands with the path of the bin directory.

Prepare a scenario file

Emulator reads a scenario from a file or world-wide web. You have to prepare a scenario in advance.

Prepare a file named SimpleScenario which contains the following text.

timeoffset 2000

# invokes the first node
class ow.tool.dhtshell.Main
arg -p 10000
schedule 0 invoke

# invokes 3 nodes, which contacts the first node (emu0) to join an overlay
arg emu0
schedule 1000,1000,3 invoke

# keeps the emulator running
schedule inf control all halt
This scenario first invokes a node and the node waits for connection at 10000/tcp to read DHT shell commands. Next, the scenario invokes 3 nodes. They contacts the first node (emu0) to join an overlay.

Start an Emulator

Type the following command to start an Emulator.

owemu SimpleScenario
You see messages from 4 instances of DHT shell.
...
DHT configuration:
  hostname:port:     emu3:3997
  transport type:    UDP
  routing algorithm: Chord
  routing style:     Iterative
  directory type:    VolatileMap
  working directory: .
  initial contact:   emu0:3997
A DHT started.

Control a DHT shell manually

As specified, the first instance of DHT shell is waiting on 10000 port. Try to connect the shell.

Open another character terminal and telnet to the shell.

telnet localhost 10000
You see the shell prompting you.
Ready.
Type status command and see routing table of the node.
status
ID and address: ac4d64e281e1ad8670db2c3123a842874c394f4d:emu0:3997
Routing table:
predecessor:
 5de550ebe439e30918a0d11c6173aa0a7df6afff:emu1:3997
successor list: [
...
Type quit command to exit from the shell.
quit

Stop the Emulator before the next step, for example, by typing Ctrl + C.

Control DHT shells along a scenario

Try an advanced scenario. Prepare a scenario file named AdvancedScenario. The file should contain the following text.

timeoffset 2000

# invokes the first node
class ow.tool.dhtshell.Main
arg -p 10000
schedule 0 invoke

# invokes 3 nodes
arg
schedule 1000,1000,3 invoke

timeoffset 7000

# 3 nodes join an overlay
schedule 0 control 1 init emu0
schedule 1000 control 2 init emu0
schedule 2000 control 3 init emu0

# put and get
schedule 4000 control 1 put a_key a_value
schedule 5000 control 1 get a_key
This scenario controls 4 DHT shells after invoking them. The scenario contains a new scenario command "schedule". It schedules issues of commands sent to each DHT shell. For example, "schedule 5000 control 1 get a_key" means that the emulator sends a command "get a_key" to a DHT shell on a virtual node numbered 1 (emu1) at 5000 millisecond after the specified offset (7000 msec).

Start an Emulator with the scenario file.

owemu AdvancedScenario
You see the result of get command issued to the second DHT shell.
...
control 1 (Sun Feb 13 21:52:18 JST 2011): get a_key
key:   5d8b23c071cb95840397933b5969c69413fc87cf
value: a_value 10798

Next

Demonstration of the toolkit on this web site uses a more complicated scenario. It involves Overlay Visualizer in addition to DHT shell. Emulator has been proved to be able to host 350,000 nodes on a moderate PC, for example, with 8 gigabytes of memory and a 3.0 GHz Phenom II X4 940. The following archive include a scenario, which invokes 10,000 nodes. Emulator has more features such as hosting usual Java applications, reading a scenario from world-wide web and constructing a distributed emulator with multiple computers. See the manual of Emulator. DHT shell accepts other commands than status and quit. See its tutorial and manual.
Return to Documents page
Return to Overlay Viewer main page