Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

OpenSim allows you to simulate an OpenWSN network without physical devices.

Table of Contents

How it works

A simulated network dehaves behaves exactly like a network with real hardware. You can interact with the OpenVisualizer, communicate with your nodes from the Internet. The difference is that the firmware of each node mote is emulated running on your computer, rather than being real hardwareon a target device.

OpenSim does so by compiling the mote code firmware 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 motes interact with the eventBus the exact say way a moteProbe instance (connected to a hardware mote) does. In fact, the

The OpenVisualizer is not aware it is talking with emulated motes, and from a networking point of view, interacting with the emulated motes is exactly the same as interacting with real motes.

Gliffy
namehardware_vs_simulation

Preparing for a simulation

...

Directory organization

The OpenSim environment combines

...

elements from the following repositories:

The OpenSim environment

...

assumes that you have

...

cloned them at the same level. That is, you need to have the openwsn-sw/ and openwsn-fw/ directories side-by-side on your computer.

Installation requirements

  • You need to be able to run the OpenVisualizer, so make sure installed the elements necessary for the OpenVisualizer to run.
  • Your computer needs to have gcc installed to be able to compile the firmware as a Python extension module. On Linux, that should be the case by default. On Windows, we recommend http://www.mingw.org/.
  • To be able to compile the firmware, the compiler will need to have access to the Python.h header file. If the compiler cannot find it, you will get the following error:

    Code Block
    File "/home/user/Desktop/openWSN-sim/openwsn-fw/SConscript", line 449, in sconscript_scanner
    scons: done reading SConscript files.
    scons: Building targets ...
    Compiling (shared) firmware/openos/projects/common/03oos_openwsn/03oos_openwsn_obj.os
    In file included from build/python_gcc/bsp/boards/board_obj.h:46:0,
                     from firmware/openos/projects/common/03oos_openwsn/03oos_openwsn_obj.c:15:
    build/python_gcc/bsp/boards/python/openwsnmodule_obj.h:11:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    scons: *** [firmware/openos/projects/common/03oos_openwsn/03oos_openwsn_obj.os] Error 1
    scons: building terminated because of errors.

    The Python header files should be present by default on Windows. On Linux, you need to install the python-dev package:

    Code Block
    apt-get install python-dev
  • In some Linux installations, you might need to install the python-tk package:

    Code Block
    apt-get install python-tk

Compiling firmware

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:

...

You can see an example output of this command on the OpenWSN build serversbuilders:

...

Code Block
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

Note

This section is under construction as we are slightly redesigning the way to run simulations.

In your openwsn-fw/ folder, enter the following command to build the OpenWSN mote's firmware as a Python extension library:

No Format
scons board=python toolchain=gcc oos_openwsn

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:

No Format
python openVisualizerGui.py --sim True -n <NumEmulatedMotes>

...

Running a simulation

Running a simulation is exactly like running the OpenVisualizer, but specifying that this is a simulation.

As with the OpenVisualizer, there are several interfaces available.

graphical user interface (GUI)

You have two options to start it:

  • from the command line, navigate to openwsn-sw/software/openvisualizer/bin/openVisualizerApp/ and enter the following command:

    Code Block
    python openVisualizerGui.py --sim [--simCount=<number of simulated nodes>]
  • enter the following command from openwsn-sw/software/openvisualizer/:

    Code Block
    scons rungui --sim [--simCount=<number of simulated nodes>]
Note

Brackets are not required when issuing a command. For example, to run a 5 motes simulating network, use following command without brackets. It's the same for following two cases: CLI and Web interface

Code Block
scons rungui --sim --simCount=5

command line interface (CLI)

You have two options to start it:

  • from the command line, navigate to openwsn-sw/software/openvisualizer/bin/openVisualizerApp/ and enter the following command:

    Code Block
    python openVisualizerCli.py --sim [--simCount=<number of simulated nodes>]
  • enter the following command from openwsn-sw/software/openvisualizer/:

    Code Block
    scons runcli --sim [--simCount=<number of simulated nodes>]

web interface

You have two options to start it:

  • from the command line, navigate to openwsn-sw/software/openvisualizer/bin/openVisualizerApp/ and enter the following command:

    Code Block
    python openVisualizerWeb.py --sim [--simCount=<number of simulated nodes>]
  • enter the following command from openwsn-sw/software/openvisualizer/:

    Code Block
    scons runweb --sim [--simCount=<number of simulated nodes>]