| 1 | [wiki:WikiStart Orbit] > [wiki:Tutorial Tutorial] > [wiki:Tutorial/HowtoWriteScripts Writing Experiment Scripts] > ORBIT-Specific Methods |
| 2 | |
| 3 | ===== ORBIT-specific Methods ===== |
| 4 | Four ORBIT-specific methods are available for debugging help: ''error( |
| 5 | )'', ''warn( |
| 6 | )'', ''info( |
| 7 | )'', and ''debug( |
| 8 | )''. 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. |
| 9 | |
| 10 | Among the implicit methods two are used to define resources: |
| 11 | {{{ |
| 12 | defProperty(name, value, description) |
| 13 | defNodes(setName, nodeList) {} |
| 14 | }}} |
| 15 | Some 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: |
| 16 | {{{ |
| 17 | nodes(setName) {} |
| 18 | allNodes {} |
| 19 | nodes("_ALL_") {} |
| 20 | }}} |
| 21 | Other ORBIT-specific methods use events which delay execution of the associated block of code and sequential execution until that event is true: |
| 22 | {{{ |
| 23 | whenAll(setTest, nodeTest, interval = 5) {} |
| 24 | whenAllInstalled() |
| 25 | whenAll("_ALL_", "apps/app/status[text()='INSTALLED.OK']") {} |
| 26 | wait time_in_sec |
| 27 | }}} |
| 28 | |
| 29 | The Experiment methods and properties are ORBIT-specific methods and properties associated with the Experiment object. They have the form Experiment.method. These methods include: |
| 30 | {{{ |
| 31 | name = "tutorial-1a" |
| 32 | project = "orbit:tutorial" |
| 33 | props.propName = "" |
| 34 | Done |
| 35 | }}} |
| 36 | It is anticipated that the 'Experiment' prefix will be removed in future versions. |
| 37 | |
| 38 | Other ORBIT-specific methods are NodeSet methods that set properties for the specified set of nodes. They have the form |
| 39 | {{{ |
| 40 | NodeSet ( nodes(setName).method ) |
| 41 | image = |
| 42 | pxeImage = |
| 43 | prototype(name) {|node| |
| 44 | } |
| 45 | onNodesUp {|node| |
| 46 | } |
| 47 | startApplication(appName), startApplications |
| 48 | stopApplication(appName), stopApplications |
| 49 | resource |
| 50 | net.if_name |
| 51 | }}} |
| 52 | |
| 53 | The defNodes method declares the nodes used in the experiment: |
| 54 | {{{ |
| 55 | defNodes(setName:string, nodeList) {} |
| 56 | }}} |
| 57 | There are various ways to declare node list: |
| 58 | {{{ |
| 59 | A single node: [x,y] |
| 60 | multiple nodes: [[x1,y1], [x2, y2], [x3, y3]] |
| 61 | ranges of nodes: [x1..x2, y1..y2] |
| 62 | the entire grid: [1..20, 1..20] |
| 63 | with other node sets: [nodeSet1, nodeSet2] |
| 64 | }}} |
| 65 | These 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. |
| 66 | |
| 67 | {{{ |
| 68 | net |
| 69 | e0, e1 |
| 70 | arp = true|false En/disable ARP |
| 71 | forward = true|false Enable forwarding |
| 72 | ip = address/netmask IP address of interface |
| 73 | up = true|false En/disable interface |
| 74 | route |
| 75 | w0, w1 |
| 76 | All the above |
| 77 | channelI = 1..11; 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161 |
| 78 | essid = string |
| 79 | frequencyI = 2.412 2.462 (5 Mhz steps); 5.18Ghz (20Mhz steps) |
| 80 | mode = master|managed|ad-hocI|monitorI |
| 81 | rtsA = packetSizeThreshold [bytes] |
| 82 | rateI = 1, 5, 11; 6, 9, 12, 18, 24, 36, 48, 54 |
| 83 | tx_power = -12 .. 15 dBm (intel), 0 .. 20 dBm (atheros) |
| 84 | type = a/b/g |
| 85 | }}} |