| 3 | | [[TOC(heading=Tutorial TOC, Tutorial, Tutorial/Testbed, Tutorial/HelloWorld, Tutorial/UnderstandingHelloWorld, Tutorial/HowtoWriteScripts, Tutorial/CollectMeasurements, Tutorial/AnalyzeResults, depth=2)]] |
| | 3 | [[TOC(heading=Tutorial TOC, Tutorial, Tutorial/Testbed, Tutorial/HowtoWriteScripts, Tutorial/HelloWorld, Tutorial/CollectMeasurements, Tutorial/AnalyzeResults, depth=2)]] |
| 54 | | To understand the details of the script, go to [wiki:Tutorial/UnderstandingHelloWorld Understanding the Hello World Script] |
| | 55 | The first part of the script creates a group called ''sender'' and assigns node1-1 to it. |
| | 56 | Next, we instruct nodehandler to assign the prototype to node1-1 using ''test:proto:sender'' |
| | 57 | Note that the ''sender'' prototype is defined using a corresponding ''sender.rb'' file |
| | 58 | and launches an underlying application on the node. In this case, the application is ''otg'' [wiki:OTG ORBIT Traffic Generator] |
| | 59 | |
| | 60 | Next, we pass command line options that will be used by nodehandler when it launches the application on the node. |
| | 61 | for e.g, the following description will launch |
| | 62 | ''otg –-destinationHost 192.168.1.2 --packetsize 1024 --rate 300 -- protocol udp'' |
| | 63 | |
| | 64 | {{{ |
| | 65 | defNodes('sender', [1,1]) {|node| |
| | 66 | node.image = nil #Default image on the node to be used for the experiment |
| | 67 | node.prototype("test:proto:sender", { |
| | 68 | 'destinationHost' => '192.168.1.2', |
| | 69 | 'packetSize' => 1024, |
| | 70 | 'rate' => 300, |
| | 71 | 'protocol' => 'udp' |
| | 72 | }) |
| | 73 | node.net.w0.mode = "managed" |
| | 74 | } |
| | 75 | }}} |
| | 76 | Create a group called ''receiver'' and assign node1-2 to it. |
| | 77 | Next, we instruct nodehandler to assign the prototype to node1-2 using ''test:proto:receiver'' |
| | 78 | Note that the ''receiver'' prototype is defined using a corresponding ''receiver.rb'' file |
| | 79 | and launches an underlying application on the node.In this case, the application is ''otr''. |
| | 80 | |
| | 81 | Next, we pass command line options that will be used by nodehandler when it launches the application on the node. |
| | 82 | for e.g, the following description will launch for e.g, the following will |
| | 83 | description will cause nodeagent to launch ''otr –- protocol udp'' |
| | 84 | |
| | 85 | {{{ |
| | 86 | defNodes('receiver', [1,2]) {|node| |
| | 87 | node.image = nil |
| | 88 | node.prototype("test:proto:receiver" , { |
| | 89 | 'protocol' => 'udp' |
| | 90 | }) |
| | 91 | node.net.w0.mode = "Master" |
| | 92 | } |
| | 93 | }}} |
| | 94 | Configures the first wireless card on all nodes to 802.11b, essid ‘helloworld’ with ip |
| | 95 | addresses 192.168.x.y where x.y are the grid co-ordinates of the repsective nodes. |
| | 96 | {{{ |
| | 97 | allNodes.net.w0 { |w| |
| | 98 | w.type = 'b' |
| | 99 | w.essid = "helloworld" |
| | 100 | w.ip = "%192.168.%x.%y" |
| | 101 | } |
| | 102 | }}} |
| | 103 | Now, we start the application. This is like a barrier implementation where nodehandler waits to receive an OK message from each of |
| | 104 | the nodeagents, and only proceeds when initial configurations are OK. |
| | 105 | {{{ |
| | 106 | whenAllInstalled() {|node| |
| | 107 | }}} |
| | 108 | This command will request nodeagents to launch the application corresponding |
| | 109 | to the role that the node is playing, e.g sender will launch the application ''otg'' and |
| | 110 | the receiver will launch the application ''otr'' with the command line options |
| | 111 | as specified before |
| | 112 | {{{ |
| | 113 | allNodes.startApplications |
| | 114 | }}} |
| | 115 | Conduct experiment for 60 seconds |
| | 116 | {{{ |
| | 117 | wait 60 |
| | 118 | }}} |
| | 119 | End of experiment – Shut down all nodes |
| | 120 | {{{ |
| | 121 | Experiment.done |
| | 122 | }}} |