OpenSim allows you to simulate an OpenWSN network without physical devices.
How it works
A simulated network dehaves exactly like a network with real hardware. You can interact with the OpenVisualizer, communicate with your nodes from the Internet. The difference is that each node is emulated on your computer, rather than being real hardware.
OpenSim does so by compiling the mote code as a Python extension module, and creating an instance of the resulting class for each emulated mote. When the simulation is running, these emulate motes communicate with the rest of the OpenVisualizer architecture (see Architecture) over the eventBus.
As illustrated in the diagram below, the emulated modes interact with the eventBus the exact say way a moteProbe
instance (connected to a hardware mote) does. In fact, the OpenVisualizer is not aware it is talking with emulated motes.
Preparing for a simulation
The OpenSim environment combines from elements from the following repositories:
The OpenSim environment assume that you have clone them at the same level. That is, you need to have the openwsn-sw/
and openwsn-fw/
directories side-by-side on your computer.
Before you can run a simulation, you need to compile the OpenWSN firmware as a Python extension module. For that, navigate to the openwsn-fw/
directory, and enter the following command:
scons board=python toolchain=gcc oos_openwsn
You can see an example output of this command on the OpenWSN build servers:
- on Travis-ci (Linux environment) at https://travis-ci.org/openwsn-berkeley/openwsn-fw
This command creates the following Python extension module.
openwsn-fw/firmware/openos/projects/common/oos_openwsn.pyd
The OpenSim infrastructure automatically adjusts its path to find this extension module, no need to move this file.
Running a simulation
This section is under construction as we are slightly redesigning the way to run simulations.
Running a simulation is exactly like running the OpenVisualizer, but specifying that this is a simulation.
As with the OpenVisualizer, there are several options, listed below
using the graphical user interface
In order to easily run a simulated network based on the code, you can use the OpenSim integration provided by OpenVisualizer; so, in your ./openwsn-sw/ folder:
python openVisualizerGui.py --sim True -n <NumEmulatedMotes>
runs a session of OpenVisualizer in Simulator mode with a network of <NumEmulatedMotes> simulated motes.