Changes between Version 6 and Version 7 of Tutorials/a0Basic/Tutorial2
- Timestamp:
- Apr 13, 2006, 11:17:34 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Tutorials/a0Basic/Tutorial2
v6 v7 3 3 [[TOC(heading=Tutorial TOC, Tutorial, Tutorial/Testbed, Tutorial/HowtoWriteScripts, Tutorial/HelloWorld, Tutorial/CollectMeasurements, Tutorial/AnalyzeResults, depth=2)]] 4 4 5 The "Hello World" Experiment is simple. The script for this experiment is shown below.5 In the "Hello World" experiment, a ''sender'' node sends a data stream to a ''receiver'' node. The script for this experiment is shown below. 6 6 7 7 {{{ … … 11 11 # 12 12 defNodes('sender', [1,1]) {|node| 13 node.image = nil # assume the right image to be on disk14 15 13 node.prototype("test:proto:sender", { 16 14 'destinationHost' => '192.168.1.2', … … 23 21 24 22 defNodes('receiver', [1,2]) {|node| 25 node.image = nil # assume the right image to be on disk26 23 node.prototype("test:proto:receiver" , { 27 24 'protocol' => 'udp' … … 54 51 55 52 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'' 53 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. 63 54 64 55 {{{ 65 56 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', 57 node.prototype("test:proto:sender", { 58 'destinationHost' => '192.168.1.2', 69 59 'packetSize' => 1024, 70 60 'rate' => 300, 71 61 'protocol' => 'udp' 72 62 }) 73 node.net.w0.mode = "managed"63 node.net.w0.mode = "managed" 74 64 } 75 65 }}} 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''. 66 The last line 'node.net.w0.mode' configures the first wireless interface ''w0'' to be used in ''managed'' mode. 80 67 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'' 68 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. 84 69 85 70 {{{ 86 71 defNodes('receiver', [1,2]) {|node| 87 node.image = nil88 72 node.prototype("test:proto:receiver" , { 89 73 'protocol' => 'udp' 90 74 }) 91 node.net.w0.mode = " Master"75 node.net.w0.mode = "master" 92 76 } 93 77 }}} 78 79 94 80 Configures the first wireless card on all nodes to 802.11b, essid ‘helloworld’ with ip 95 81 addresses 192.168.x.y where x.y are the grid co-ordinates of the repsective nodes.