= Tutorial 1: Hello World Example = [[TOC(heading=Tutorial TOC, Tutorial, Tutorial/Testbed, Tutorial/HowtoWriteScripts, Tutorial/HelloWorld, Tutorial/CollectMeasurements, Tutorial/AnalyzeResults, depth=2)]] In the "Hello World" experiment, a ''sender'' node sends a data stream to a ''receiver'' node. The script for this experiment is shown below. {{{ # # Define nodes used in experiment # defNodes('sender', [1,1]) {|node| 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.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 ''test:proto:sender'' to node1-1. A prototype is similar to a function or macro in conventional programming languages and defines in this case a re-usable configuration. The prototypes are normally defined in separate files . In this case, the prototype contains instructions to install a traffic generator, but we will learn about this later. What is important here is that a prototype can define properties which allows us to customize it for the specific experiment. In this experiment, we can set the address of the sender, and various properties of the traffic generator itself, such as packet size, rate, and the protocol over which to send the traffic. {{{ defNodes('sender', [1,1]) {|node| node.prototype("test:proto:sender", { 'destinationHost' => '192.168.1.2', 'packetSize' => 1024, 'rate' => 300, 'protocol' => 'udp' }) node.net.w0.mode = "managed" } }}} The last line 'node.net.w0.mode' configures the first wireless interface ''w0'' to be used in ''managed'' mode. The next block of code defines the receiver in similar fashion. We are using the ''receiver'' prototype here which installs a traffic sink. In addition, we are setting the receiver's first wireless interface to ''master'' mode. {{{ defNodes('receiver', [1,2]) {|node| 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 }}}