| 163 | | This experiment is given in the attached script [attachment:a a]. |
| 164 | | |
| 165 | | This file contains extensive comments that should help you understand the different steps involved in running an application on the nodes of a testbed. |
| | 163 | In this step, we describe the experiment script that demonstrates the use of the above two prototypes. |
| | 164 | |
| | 165 | This experiment involves an ad-hoc network of two group of nodes, each containing a single node. The first group "firstWorker" contains node [1,1], which will use the "gentlePing" prototype/application to assert that it can reach node [1,2]. The second group "secondWorker" contains node [1,2], which will use the "agressivePing" prototype/application to get a coarse estimate of the packet drop rate on its link to node [1,1]. |
| | 166 | |
| | 167 | The following code should be saved into a file "tut_app_3.rb" in the same directory as the above application and prototype definitions: |
| | 168 | {{{ |
| | 169 | # Define the first group |
| | 170 | # The node(s) within this group will run the "gentlePing" prototype/application |
| | 171 | # |
| | 172 | defGroup('firstWorker', [1,1]) {|node| |
| | 173 | |
| | 174 | # Associate the prototype to use with this group |
| | 175 | # and configure any eventual parameters |
| | 176 | # |
| | 177 | node.prototype("gentlePing", { |
| | 178 | 'destination' => "192.168.0.2" |
| | 179 | }) |
| | 180 | |
| | 181 | # Configure the wireless interface on the node(s) in this set |
| | 182 | node.net.w0.mode = "ad-hoc" |
| | 183 | node.net.w0.type = "g" |
| | 184 | node.net.w0.essid = "tutorial" |
| | 185 | node.net.w0.ip = "192.168.0.1" |
| | 186 | } |
| | 187 | |
| | 188 | # Define the second group |
| | 189 | # The node(s) within this group will run the "aggressivePing" prototype/application |
| | 190 | # |
| | 191 | defGroup('secondWorker', [1,2]) {|node| |
| | 192 | |
| | 193 | # Here we decide that the default 1000 probes are not enough in our case |
| | 194 | # and we give a specific value of 4000 to the 'numPacket' parameter of |
| | 195 | # the "aggressivePing" prototype |
| | 196 | # |
| | 197 | node.prototype("aggressivePing", { |
| | 198 | 'destination' => "192.168.0.1", |
| | 199 | 'numPacket' => 4000 |
| | 200 | }) |
| | 201 | |
| | 202 | # Configure the wireless interface on the node(s) in this set |
| | 203 | node.net.w0.mode = "ad-hoc" |
| | 204 | node.net.w0.type = "g" |
| | 205 | node.net.w0.essid = "tutorial" |
| | 206 | node.net.w0.ip = "192.168.0.2" |
| | 207 | } |
| | 208 | |
| | 209 | # When all the applications on all the nodes in this experiment are ready |
| | 210 | # |
| | 211 | whenAllInstalled() {|node| |
| | 212 | |
| | 213 | # Wait 10 sec to make sure that the wireless interfaces are all |
| | 214 | # configured |
| | 215 | wait 10 |
| | 216 | |
| | 217 | # Start all the applications |
| | 218 | allGroups.startApplications |
| | 219 | |
| | 220 | # Wait 10 sec, this will be the experiment duration time |
| | 221 | wait 10 |
| | 222 | |
| | 223 | # Stop the experiment |
| | 224 | Experiment.done |
| | 225 | } |
| | 226 | |
| | 227 | }}} |
| | 228 | |
| | 229 | === Final Step! === |