= Tutorial 1: Hello World Example = [[TOC(heading=Tutorial TOC, Tutorial, Tutorial/Testbed, Tutorial/HowtoWriteScripts, Tutorial/HelloWorld, Tutorial/CollectMeasurements, Tutorial/AnalyzeResults, depth=2)]] The "Hello World" Experiment is simple. The script for this experiment is shown below. {{{ # # Define nodes used in experiment # defNodes('sender', [1,1]) {|node| node.image = nil # assume the right image to be on disk node.prototype("test:proto:sender", { 'destinationHost' => '192.168.1.2', 'packetSize' => 1024, 'rate' => 300, 'protocol' => 'udp' }) node.net.w0.mode = "managed" } defNodes('receiver', [1,2]) {|node| node.image = nil # assume the right image to be on disk node.prototype("test:proto:receiver" , { 'protocol' => 'udp' }) node.net.w0.mode = "master" } allNodes.net.w0 { |w| w.type = 'b' w.essid = "helloworld" w.ip = "%192.168.%x.%y" } # # Now, start the application # whenAllInstalled() {|node| wait 30 allNodes.startApplications wait 40 Experiment.done } }}} Figure 1. Script for "Hello World" Experiment = Understanding the Hello World = The first part of the script creates a group called ''sender'' and assigns node1-1 to it. Next, we instruct nodehandler to assign the prototype to node1-1 using ''test:proto:sender'' Note that the ''sender'' prototype is defined using a corresponding ''sender.rb'' file and launches an underlying application on the node. In this case, the application is ''otg'' [wiki:OTG ORBIT Traffic Generator] Next, we pass command line options that will be used by nodehandler when it launches the application on the node. for e.g, the following description will launch ''otg –-destinationHost 192.168.1.2 --packetsize 1024 --rate 300 -- protocol udp'' {{{ defNodes('sender', [1,1]) {|node| node.image = nil #Default image on the node to be used for the experiment node.prototype("test:proto:sender", { 'destinationHost' => '192.168.1.2', 'packetSize' => 1024, 'rate' => 300, 'protocol' => 'udp' }) node.net.w0.mode = "managed" } }}} Create a group called ''receiver'' and assign node1-2 to it. Next, we instruct nodehandler to assign the prototype to node1-2 using ''test:proto:receiver'' Note that the ''receiver'' prototype is defined using a corresponding ''receiver.rb'' file and launches an underlying application on the node.In this case, the application is ''otr''. Next, we pass command line options that will be used by nodehandler when it launches the application on the node. for e.g, the following description will launch for e.g, the following will description will cause nodeagent to launch ''otr –- protocol udp'' {{{ defNodes('receiver', [1,2]) {|node| node.image = nil node.prototype("test:proto:receiver" , { 'protocol' => 'udp' }) node.net.w0.mode = "Master" } }}} Configures the first wireless card on all nodes to 802.11b, essid ‘helloworld’ with ip addresses 192.168.x.y where x.y are the grid co-ordinates of the repsective nodes. {{{ allNodes.net.w0 { |w| w.type = 'b' w.essid = "helloworld" w.ip = "%192.168.%x.%y" } }}} Now, we start the application. This is like a barrier implementation where nodehandler waits to receive an OK message from each of the nodeagents, and only proceeds when initial configurations are OK. {{{ whenAllInstalled() {|node| }}} This command will request nodeagents to launch the application corresponding to the role that the node is playing, e.g sender will launch the application ''otg'' and the receiver will launch the application ''otr'' with the command line options as specified before {{{ allNodes.startApplications }}} Conduct experiment for 60 seconds {{{ wait 60 }}} End of experiment – Shut down all nodes {{{ Experiment.done }}}