Changes between Initial Version and Version 1 of Old/Tutorials/HowtoWriteScripts


Ignore:
Timestamp:
Sep 29, 2005, 10:07:54 PM (19 years ago)
Author:
Surya Satyavolu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/Tutorials/HowtoWriteScripts

    v1 v1  
     1
     2
     3===== Developing the Script for an Experiment =====
     4A script is used to run an '''ORBIT Radio Grid Testbed''' experiment.  The script contains the configuration of the experiment, specifies its application and operating system software, describes its initialization and any parameters, and describes each phase of its operation.
     5
     6'''ORBIT Radio Grid Testbed''' scripts are written in Ruby, an easily understood, extensible, dynamic, object-oriented scripting language.  Ruby has been extended into the testbed user's domain with a number of methods.  Besides its extensibility and object-orientation, Ruby is concise and consistent.  It is a dynamic language supporting closure, that is, a Ruby block can use its original scope information even if the environment in which it was defined would otherwise have disappeared.
     7
     8An '''ORBIT Radio Grid Testbed''' script therefore is written in Ruby primarily using ORBIT-specific methods.  A brief description or Ruby follows, then information on the ORBIT-specific methods used to define and control an '''ORBIT Radio Grid Testbed''' experiment, then a note on script coding techniques.
     9
     10===== Ruby Resources =====
     11There are two primary resources for the Ruby programming language.  The first is [http://www.ruby-lang.org the Ruby Web site].  It contains current information on Ruby and a link to download it for free.  The second is an excellent tutorial and reference book, '''Programming Ruby The Pragmatic Programmer's Guide, Second Edition''', Dave Thomas with Chad Fowler and Andy Hunt, Pragmatic Bookshelf, October 2004, ISBN:0-9745140-5-5, 864 pages;  see [http://www.pragmaticprogrammer.com/titles/ruby].
     12
     13===== Ruby =====
     14Ruby's syntax is similar to other object-oriented languages like Java or C++.  In Ruby everything that is represented is an object, even numbers like 1.  Functions or procedures are termed methods and are called using the name of the object, a period, and the name of the method, e.g., node.prototype.  Methods in ruby are usually small.
     15
     16Variables associated with objects are termed properties and are referred to by the name of the object, a period, and the name of the property, e.g., w.essid.  The formatting of ones use of the language is at the discretion of the programmer, but consistency is helpful, especially in the use of indentation and the placement of the opening and closing braces for code blocks.
     17
     18===== ORBIT-specific Methods =====
     19Four ORBIT-specific methods are available for debugging help:  ''error(
     20)'', ''warn(
     21)'', ''info(
     22)'', and ''debug(
     23)''.  How do they work?  Like assertions?  What arguments do they take?  Besides these debugging methods, there are three classes of ORBIT-specific methods discussed below:  implicit, Experiment, and NodeSet.
     24
     25Among the implicit methods two are used to define resources:
     26{{{
     27      defProperty(name, value, description)
     28      defNodes(setName, nodeList) {}
     29}}}
     30Some ORBIT-specific methods work with node sets to specify a set of nodes for each member of which the associated block of code is executed:
     31{{{
     32      nodes(setName) {}
     33      allNodes {}
     34      nodes("_ALL_") {}
     35}}}
     36Other ORBIT-specific methods use events which delay execution of the associated block of code and sequential execution until that event is true:
     37{{{
     38        whenAll(setTest, nodeTest, interval = 5) {}
     39      whenAllInstalled()
     40      whenAll("_ALL_", "apps/app/status[text()='INSTALLED.OK']") {}
     41      wait time_in_sec
     42}}}
     43
     44The Experiment methods and properties are ORBIT-specific methods and properties associated with the Experiment object.  They have the form Experiment.method.  These methods include:
     45{{{
     46      name = "tutorial-1a"
     47      project = "orbit:tutorial"
     48      props.propName = ""
     49      Done
     50}}}
     51It is anticipated that the 'Experiment' prefix will be removed in future versions.
     52
     53Other ORBIT-specific methods are NodeSet methods that set properties for the specified set of nodes.  They have the form
     54{{{
     55NodeSet ( nodes(setName).method )
     56      image =
     57      pxeImage =
     58      prototype(name) {|node|
     59}
     60      onNodesUp {|node|
     61}
     62      startApplication(appName), startApplications
     63      stopApplication(appName), stopApplications
     64      resource
     65      net.if_name
     66}}}
     67
     68The defNodes method declares the nodes used in the experiment:
     69{{{
     70      defNodes(setName:string, nodeList) {}
     71}}}
     72There are various ways to declare node list:
     73{{{
     74      A single node: [x,y]
     75      multiple nodes: [[x1,y1], [x2, y2], [x3, y3]]
     76      ranges of nodes: [x1..x2, y1..y2]
     77      the entire grid: [1..20, 1..20]
     78      with other node sets: [‘nodeSet1’, ‘nodeSet2’]
     79}}}
     80These methods are useful for declaring common functionality over multiple sets.  The various network parameters that may be configured within a defNodes or allNodes block are shown in Figure 9 below, here the first and second Ethernet interfaces are e0 and e1, and the first and second wireless interfaces are w0 and w1.
     81
     82{{{
     83• net
     84        – e0, e1
     85                • arp = true|false En/disable ARP
     86                • forward = true|false Enable forwarding
     87                • ip = address/netmask IP address of interface
     88                • up = true|false En/disable interface
     89                • route
     90        – w0, w1
     91                • All the above
     92                • channelI = 1..11; 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161
     93                • essid = string
     94                • frequencyI = 2.412 – 2.462 (5 Mhz steps); 5.18Ghz (20Mhz steps)
     95                • mode = master|managed|ad-hocI|monitorI
     96                • rtsA = packetSizeThreshold [bytes]
     97                • rateI = 1, 5, 11; 6, 9, 12, 18, 24, 36, 48, 54
     98                • tx_power = -12 .. 15 dBm (intel), 0 .. 20 dBm (atheros)
     99                • type = a/b/g
     100}}}
     101
     102Figure 9.  Configurable Network Parameters
     103
     104===== ORBIT Script Coding Techniques =====
     105There are many known techniques for defining an experiment with parameters that do not change over the course of the experiment and for controlling experiments with parameters that change while the experiment runs.  These techniques are available in the standard scripts for the baseline ORBIT experiments [where?].  It is also possible to change parameters based on the experiment's own measured behavior, e.g., to run until the observed packet error rate exceeds a given value, see [http://www.orbit-lab.org/download/publications/Orbit_Software.pdf '''ORBIT Testbed Software Architecture:  Supporting Experiments as a Service'''].
     106
     107===== Developing Application Software =====
     108The experimenter may need to develop application software, for example, to emulate the operation of a new network protocol.  An '''ORBIT Radio Grid Testbed''' application operates in the environment shown in Figure 10 below.  An application needs to be integrated into this application harness.  Once an application is developed it needs to have an application description developed and to be loaded onto an application server and assigned an id.  The process for developing this application description and loading the application software is as follows [?].
     109
     110Figure 10.  Experiment Execution Architecture (see page 12 of [http://www.orbit-lab.org/doc/tutorial]).
     111
     112===== Development Tools for Application Software =====
     113Three major tools are provided to the ORBIT experimenter to develop an application in C on Linux:  '''ORBIT Traffic Generator/Receiver (OTG/OTR)''', '''Libmac''' and the '''ORBIT Measurement Framework (OML)'''.  The '''ORBIT traffic generator/receiver (OTG/OTR)''' illustrated in Figure 11 below is a modular traffic generator/receiver that is integrated with '''OML''' and '''Libmac'''.  '''OTG/OTR''' has pluggable traffic models and transport protocols, see [http://www.orbit-lab.org/download/publications/Orbit_OML.pdf '''ORBIT Measurements Framework and Library (OML): Motivations, Design, Implementation, and Features'''].
     114
     115Figure 11.  '''ORBIT Traffic Generator/Receiver (OTG/OTR)'''(on page 53 of [http://www.orbit-lab.org/doc/tutorial]).
     116
     117'''Libmac''' is a user-space C library that brings the wireless driver application program interface (API) into user space allowing one to get or set values of driver parameters.  This library supports operation for a variable number of parameters per call. The call mac_get_params(struct mac_params *h, struct mac_ifinfo_list *if_ptr, int argc,
     118) requests the wireless device driver to GET parameter information.  The call mac_set_params(struct mac_params *h, struct mac_ifinfo_list *if_ptr, int argc,
     119) requests device driver to SET parameter information.
     120
     121The '''ORBIT Measurement Framework (OML)''' was discussed in the first section of this tutorial as one of the ORBIT Services.  It is a distributed software framework enabling real-time collection of data, and, as such, has a client application programming interface (API).  A developer can use this client API through a web interface to define the measurement points and parameters for his or her application.  Measurement points and their frequency of collection are an important part of ones experimental plan.
     122
     123The definition of a measurement point is illustrated in Figure 12 below.  Measurement point definitions are saved as an XML-based configuration file, and source code for the measurement client is automatically generated that contains application-specific methods that handle type-safe data collection.  This source code can be compiled and linked with the application as illustrated by a Makefile in Figure 13 and sample application code in Figure 14 below.
     124
     125{{{
     126<measurement-points>
     127<measurement-point id="group-1">
     128<metric id="rssi" type="float"/>
     129<metric id="noise" type="float"/>
     130</measurement-point>
     131<measurement-point id="group-2">
     132<metric id="throughput" type="int"/>
     133</measurement-point>
     134</measurement-points>
     135}}}
     136
     137Figure 12.  Defining Measurement Points
     138
     139{{{
     140Makefile:
     141$(INC_DIR)/oml_%.h : $(ETC_DIR)/%.xml
     142mkdir -p $(INC_DIR)
     143wget -q http://www.orbit-lab.org/oml/client_wrapper\
     144--post-file $< -O - \
     145| tar -C $(BUILD_DIR) -xzf –
     146oml_foo.h:
     147int oml_group1(float rssi, float noise);
     148int oml_group2(int throughput);
     149}}}
     150
     151Figure 13.  Makefile and include file for Measurement Points
     152
     153{{{
     154oml_init(&argc, &argv, NULL);
     155
     156
     157if (r_data->send_option == 1) {
     158buffer->rssi = recv_packet_params.rssi ;
     159buffer->noise = recv_packet_params.noise;
     160oml_group1(buffer->rssi, buffer->noise);
     161} else {
     162log(LOG_ERR, "Unknown receive option! \n");
     163}
     164lost_packets = pck_id.seqnum - old - 1;
     165oml_group2(lost_packets);
     166}}}
     167
     168Figure 14.  Application Code Sample
     169
     170Because not all measurements are needed and not all measurement samples are needed, '''OML''' supports preprocessing or filtering at source to reduce the amount of reported and recorded data.  Filters are defined by experimenter, and experimenter-provided filters are supported.  Figure 15 below illustrates the client-side data flow.  Collection of and access to the recorded data requires the use of a database schema.  '''OML''' automatically generates the appropriate schema as diagrammed in Figure 16 below.
     171
     172Figure 15.  Client-side Data Flow (see page 66 of [http://www.orbit-lab.org/doc/tutorial]).
     173
     174Figure 16.  Server-side DB Schema Generation (see page 67 of [http://www.orbit-lab.org/doc/tutorial]).
     175
     176===== Developing Device Drivers =====
     177A possibly difficult aspect of having to develop a completely new application would be to have to develop a device driver for Linux or for another operation system to support a new communications device.  Even a simple modification to an existing device driver requires extensive testing.  Once a device driver has been developed it needs to be loaded onto an application server.  The process for loading a device driver is as follows [?].
     178