Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

This page is under construction.

Contact Thomas Watteyne to speed things up.

If you are completely new to OpenWSN, and you are using Linux, read this page first. It will walk you through all the steps to install OpenWSN and explore a number of key features.

In particular you will:

  • compile and run OpenWSN in simulation mode, ping a simulated mote, and interact with it over CoAP.
  • program a TelosB mote, connect it to your computer, ping it, and interact with it over CoAP.

what to bring

You will need:

  • a computer running Linux with root acess.a This page is written with Ubuntu 12.04.4 LTS.
  • optionally, two TelosB motes to do the hard tests

At the time of writing, we are using the latest and greatest of all software. Undoubtedly, this will become outdated very fast. If you see something out of the date, take action! Send an e-mail to Thomas Watteyne to get this page update. Thanks!

Download OpenWSN

The OpenWSN is a collection of repositories hosted on GitHub. We will download and use the following:

We will download these repositories side-by-side in an openwsn/ directory in your desktop using Git. 

~$ cd Desktop/
~/Desktop$ mkdir openwsn
~/Desktop$ cd openwsn/
~/Desktop/openwsn$ git clone https://github.com/openwsn-berkeley/openwsn-fw.git
[...]
~/Desktop/openwsn$ git clone https://github.com/openwsn-berkeley/openwsn-sw.git
[...]
~/Desktop/openwsn$ git clone https://github.com/openwsn-berkeley/coap.git
[...]

Running a Simulation

Frankly, it's a bit strange to start using OpenWSN with a simulation, since the firmware is really meant (and written) to run on real motes. But, not everyone has hardware, not always the same hardware, etc. So to make things nice and easy, we'll start by simulation. Oh, and the simulated code behaves exactly the same as the real code, so what you see now is what you'll get with real hardware.

Prepare

Before we can start running a simulation, we need to compile the firmware as a Python extension. This is all explained in the OpenSim page if you want to konw what's going on.

Oops!

Before you can go on, you need to install SCons:

~/Desktop/openwsn$ pip install scons

Oops!

Before you can go on, you need to install the Python header files:

~/Desktop/openwsn/openwsn-fw$ sudo apt-get install python-dev
~/Desktop/openwsn$ cd openwsn-fw/
~/Desktop/openwsn/openwsn-fw$ scons board=python toolchain=gcc oos_openwsn
[...]
Archiving build/python_gcc/bsp/boards/python/libbsp.a
Indexing  build/python_gcc/bsp/boards/python/libbsp.a
Linking (shared)   firmware/openos/projects/common/oos_openwsn.so
scons: done building targets.

This step compile the complete OpenWSN firmware as a Python extension module (a form of shared library) which the simulation environment can import at run-time.

The extension module is at ~/Desktop/openwsn/openwsn-fw/firmware/openos/projects/common/oos_openwsn.so, no need to move it.

Simulate

You can now start a simulation. Running a simulation just means taking the usual software which runs on your computer (and call "openvisualizer"), but running it in simulation mode. That is, instead of the openvisualizer connecting to read motes, it connects to emulated mote code actually running on you machine.

Oops!

Before you can go on, you need to install some Python packages:

~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ sudo pip install bottle
~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ sudo pip install PyDispatcher

Start a simulation:

~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ sudo scons runweb --sim
scons: Reading SConscript files ...
 ___                 _ _ _  ___  _ _ 
| . | ___  ___ ._ _ | | | |/ __>| \ |
| | || . \/ ._>| ' || | | |\__ \|   |
`___'|  _/\___.|_|_||__/_/ <___/|_\_|
     |_|                  openwsn.org
scons: done reading SConscript files.
scons: Building targets ...
Copy("bin/openVisualizerApp/sim_files", "../../../openwsn-fw/firmware/openos/bsp/boards/python/openwsnmodule_obj.h")
Mkdir("bin/openVisualizerApp/sim_files/linux")
Copy("bin/openVisualizerApp/sim_files/linux/oos_openwsn-x86.so", "../../../openwsn-fw/firmware/openos/projects/common/oos_openwsn.so")
Copy("bin/openVisualizerApp/sim_files", "../../../openwsn-fw/firmware/openos/projects/common/oos_openwsn.so")
Delete("build/runui/web_files")
Mkdir("/home/thomas/Desktop/openwsn/openwsn-sw/software/openvisualizer/build/runui")
Copy("build/runui/web_files", "bin/openVisualizerApp/web_files")
Delete("build/runui/sim_files")
Mkdir("/home/thomas/Desktop/openwsn/openwsn-sw/software/openvisualizer/build/runui")
Copy("build/runui/sim_files", "bin/openVisualizerApp/sim_files")
uiRunner(["bin/openVisualizerApp/openVisualizerWeb"], ["bin/openVisualizerApp/openVisualizerWeb.py"])
Child PID is 5144
scons: done building targets.
thomas@Thomas-X61s:~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ ioctl(TUNSETIFF): Device or resource busy
created following virtual interface:
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/none 
    inet6 bbbb::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::1/64 scope link 
       valid_lft forever preferred_lft forever

You need to run the openvisulizer with "sudo" since the Python program will create a tun interface.

That's it, an OpenWSN simulation is now running your computer!

Open http://127.0.0.1:8080/ to see the web interface of OpenWSN

>>>> TODO openvisualzer1.png

Open the "Topology" tab:

  • left click on a mote to move it around
  • right-click on two motes to connect them with a wireless link
  • left-click on a link to change its PDR (packet delivery ratio)

Set up the topology to have a chain 1-2-3, and set each PDR to 1.

>>>> TODO openvisualzer1.png

Back in the "Motes" tab, select mote 0001 and click on the "Toggle" button. You just declare mote 1 to be the root of your network (the DAGroot in RPL parlance, the sink in WSN parlance, the gateway, etc). You can select other motes and see that they quickly become "Synchronized!".

Congratulations, you have built your first OpenWSN simulated network.

Ping a mote

By convention (i.e. this is hardcoded in the software), the IPv6 prefix of the simulated network is bbbb:/64. This means that the IPv6 address of each mote will start with "bbbb::". The remainder of a mote's IPv6 address is it's MAC address (or EUI-64). You can read this in the web interface.

Open a new terminal to ping mote 2:

~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ ping6 bbbb::1415:92cc:0:2
PING bbbb::1415:92cc:0:2(bbbb::1415:92cc:0:2) 56 data bytes
64 bytes from bbbb::1415:92cc:0:2: icmp_seq=1 ttl=64 time=51.1 ms
64 bytes from bbbb::1415:92cc:0:2: icmp_seq=2 ttl=64 time=134 ms
64 bytes from bbbb::1415:92cc:0:2: icmp_seq=3 ttl=64 time=137 ms
64 bytes from bbbb::1415:92cc:0:2: icmp_seq=4 ttl=64 time=101 ms
^C
--- bbbb::1415:92cc:0:2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 51.172/106.146/137.486/34.713 ms

You can also ping mote 3 which is 3 hops away:

~/Desktop/openwsn/openwsn-sw/software/openvisualizer$ ping6 -s 10 bbbb::1415:92cc:0:3
PING bbbb::1415:92cc:0:3(bbbb::1415:92cc:0:3) 10 data bytes
18 bytes from bbbb::1415:92cc:0:3: icmp_seq=1 ttl=63 time=80.1 ms
18 bytes from bbbb::1415:92cc:0:3: icmp_seq=2 ttl=63 time=105 ms
18 bytes from bbbb::1415:92cc:0:3: icmp_seq=3 ttl=63 time=94.0 ms
18 bytes from bbbb::1415:92cc:0:3: icmp_seq=4 ttl=63 time=147 ms
^C
--- bbbb::1415:92cc:0:3 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
rtt min/avg/max/mdev = 80.115/106.887/147.964/25.359 ms

We had to reduce size of the ping request for that one (-s 10). The reason is that the packet contains also a source routing header, leaving less bytes for payload.

Interact over CoAP

CoAP is a protocol implement on each OpenWSN device, which makes it appear like a web server on the Internet.

By default, an OpenWSN mote implements a CoAP "info" resource which indicate what version of the code is running. You can test that by running the Python test script provided in the firmware:

~/Desktop/openwsn/openwsn-fw/firmware/openos/openwsn/07-App/rinfo$ python rinfo.py 
/home/thomas/Desktop/openwsn/openwsn-fw/firmware/openos/openwsn/07-App/rinfo
OpenWSN 1.4.1
Python
Python
Python

Debugging with Wireshark

In simulation mode, the openvisualizer takes care of simulating the wireless medium. You can use Wireshark to take a peek at what goes over this simulated radio space.

Oops!

Before you can go on, you need to install Wireshark:

sudo apt-get install wireshark

Start Wireshark on the tun interface at address bbbb::1, and configure the filtering for zep (the ZigBee encapsulation protocol).

You need to start Wireshark with "su":

sudo wireshark

For now, you don't see any packets, that's normal:

>>>> TODO wiresharkl1.png

In the OpenVisualizer's "Event bus" tab, check the "Wireshark debug" box. You now see all the packets exchanged over the simulated radio environment, exciting!

>>>> TODO openvisualizer4.png

Closing the OpenVisualizer

Now the embarrassing part. We haven't taken the time to implement a graceful way of stopping the openvisualizer, so you'll have to kill the process. Sorry.

~/Desktop$ ps -ef | grep openvisualizer
root      5354     1 99 00:28 pts/0    00:36:58 python bin/openVisualizerApp/openVisualizerWeb.py -a /home/thomas/Desktop/openwsn/openwsn-sw/software/openvisualizer/build/runui -s -H 0.0.0.0 -p 8080
thomas    7321  5487  0 01:04 pts/2    00:00:00 grep --color=auto openvisualizer
~/Desktop$ sudo kill -9 5354

 

Now with real hardware

TODO

What's next?

TODO

 

  • No labels