All emulator configuration files contain an event control script. At a minimum, this event script should add nodes to the emulation, and specify an emulation end time. In addition, this script can be used to control simple experiments. For example, the script file can be used to control the movement of nodes in the physical world, and execute application commands on emulator nodes.
The script interface is an easy-to-use interface for conducting basic experiments without having to write real code. The scripting interface that we provide is deliberately simple. No looping, branching, or variables are supported. Rather scripts are defined as lists of events using an XML-based syntax. This restricted interface provides a very shallow learning curve, and makes writing basic emulator experiments an easy task. This design maintains the key benefit of scripting - the ability to run simple experiments - while supporting full programmatic control in a clean manner.
The event script is loaded when run "emuRun", thus can not be modified and reloaded during an experiment.
As an example, the following simplified script adds nodes to the emulation, specifies node movement, and specifies an emulation end time.
<EventDef> <EventGroup time="0.1" concurrent="true"> <Add> <node>nodew1</node> <pos>-100 -100 0</pos> </Add> <Add> <node>nodew1</node> <pos>-50 -100 0</pos> </Add> </EventGroup> <EventGroup time="5.0" concurrent="false"> <StartRoute> <node>nodew1</node> <route>loop1</route> </StartRoute> <StartRoute> <node>nodew2</node> <route>loop2</route> </StartRoute> </EventGroup> <EventGroup time="600.0" concurrent="false"> <EventThreadExit/> </EventGroup> </EventDef>
Scripts consist of a series of Mobility Definitions and EventGroups. All routes (loop1 and loop in the above example) or pathloss trace playback are predefined in the MobilityDef. Routes are defined as a loop consisting of several waypoints, and a moving speed.
Each EventGroup definition specifies the time of at which the EventGroup commences, and whether or not the EventGroup is a concurrent group. Events within concurrent groups all commence at the same time. Non-concurrent events occur sequentially starting with the first event specified, and proceeding in the order in which they are defined.
Here is an example of route definition using MobilityDef:
<MobilityDef> <route> <name>loop1</name> <loop>true</loop> <waypoint> <pos>-150 150 0</pos> <arrivalTime>0</arrivalTime> </waypoint> <waypoint> <pos>150 150 0</pos> <speed>10</speed> </waypoint> <waypoint> <pos>150 -150 0</pos> <speed>10</speed> </waypoint> <waypoint> <pos>-150 -150 0</pos> <speed>10</speed> </waypoint> <waypoint> <pos>-150 150 0</pos> <speed>10</speed> </waypoint> </route> </MobilityDef>The "simpleRoute" in the examples illustrates how to define routes and add them to the eventGroups. For pathloss trace playback, a seperate xml file is required to contain pastloss traces. The "replay" in the examples illustrates how to define traces and run a pathloss playback.
Adds a node to the emulation.
<Add> <node>nodew1</node> <pos>-100 -100 0</pos> </Add>
Terminates emulation.
No attributes.
<EventThreadExit/>
Begins node navigation of a route.
<StartRoute> <node>nodew1</node> <route>loop1</route> <StartRoute/>
Sets the position of a node. Stops any in-progress navigation.
<SetPos> <node>nodew1</node> <pos>-100 -100 0</pos> </SetPos>
Sets the orientation of a node. orientationX and orientationY must be at right angles to each other.
<SetOrientation> <node>nodew1</node> <orientationX>1.0 0.0 0.0</orientationX> <orientationY>1.0 0.0 0.0</orientationY> </SetOrientation>
Moves a node to a destination in a straight line over a specified time interval. Stops any in-progress navigation.
<SetDestAndDuration> <node>nodew1</node> <pos>-100 -100 0</pos> <duration>55.5</duration> </SetDestAndDuration>
Moves a node to a destination in a straight line with a specified arrivalTime. Stops any in-progress navigation.
<SetDestAndDuration> <node>nodew1</node> <pos>-100 -100 0</pos> <arrivalTime>62.3</arrivalTime> </SetDestAndDuration>
Start a random walk. Stops any in-progress navigation.
<RandomWalk> <node>nodew1</node> <seed>0</seed> <maxWait>60.0</maxWait> <maxSpeed>3.0</maxSpeed> <duration>3600.0</duration> </RandomWalk>
Sleep for a given duration. This can be used within non-current EventGroups to provide a space between events.
<Sleep> <duration>10.0</duration> </Sleep>
Execute a command on a node.
<Exec> <node>nodew1</node> <cmd>iwconfig ath0</cmd> <log> <location>central</location> <stdoutFile>test.stdout.txt</stdoutFile> <stderrFile>test.stderr.txt</stderrFile> </log> <asynchronous>true</asynchronous> <exitOnError>false</exitOnError> <Exec/>
Displays a text message.
<Message> <message>Hello world!</message> </Message>