Orbit > NodeHandler > Tutorial > Hello World Example

The "Hello World" Experiment is simple. It has one sender and one receiver as diagrammed in Figure 7 below. The script for this experiment is shown in Figure 8.

Figure 7. "Hello World" Experiment. = "tutorial-1a"
Experiment.project = "orbit:tutorial"

# Define nodes used in experiment
defNodes('sender', [1,2]) {|node|
  node.image = nil  # assume the right image to be on disk

  node.prototype("test:proto:sender", {
    'destinationHost' => '',
    'packetSize' => 1024,
    'rate' => 300,
    'protocol' => 'udp'    
  }) = "managed"

defNodes('receiver', [1,4]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:receiver" , {
    'hostname' => '',
    'protocol' => 'udp'
  }) = "master"
} { |w|
  w.type = 'b'
  w.essid = "helloworld"
  w.ip = "%192.168.%x.%y"

# Now, start the application
whenAllInstalled() {|node|
  wait 30 

  wait 40


Figure 8. Script for "Hello World" Experiment

The first line of the script in Figure 8 assigns a name to the experiment and the second line assigns the name of the associated project to the experiment. Next, the sender node is defined, then the receiver node. Each of these definitions uses the defNodes method which takes the name of the group of nodes (here a group of one) then a selector for addresses of the nodes in the group, then a block of Ruby code enclosed in braces. These blocks of code are performed for each selected node using the selector (only one each here) to specify to the image to be loaded (defaulted here), prototype, and mode (managed and master). The prototype statement contains a name and a hash list which associates values with the destinationHost, packetSize, rate and protocol properties, thus setting the parameters for a node. Setting the mode helps configure the node.

The script then uses the allNodes method that evaluates the block for all nodes in the array, here to load each of the nodes in the array, assign its type, specify its load id and assign its IP address.

The last part of the script uses whenAllInstalled() to wait to execute the block of code enclosed in braces until each specified image is installed OK. The block of code then waits 30 seconds, then starts each of the specified applications, waits 40 seconds, then concludes the experiment insuring all measurements are saved to the database.

Last modified 15 years ago Last modified on Sep 29, 2005, 5:21:15 PM
Note: See TracWiki for help on using the wiki.