Table of Contents

1. Starting wsnet1
2. Running applications with the network
3. Debuging distributed applications
4. Wireless performance estimation and code source annotation

WSim can be attached to the WSNet simulator through radio interfaces such as the Chipcon CC1100 or CC2420. This allows to build a complete simulation framework that is able to debug and analyse a complete wireless sensor network. Thus WSim and WSNet allow to design and test full distributed applications from the top level specifications to the application binary within the same framework and application description.

Distributed Simulation Setup

Figure VI.1. Distributed Simulation Setup

1. Starting wsnet1

WSim currently uses the previous version of WSNet which is available in the /utils directory of WSim sources. A much more recent version of WSNet is available here: WSNet2 website. The WSim update to WSNet2 is now available and brings more communication channels and capabilities between WSim and WSNet (multi antenna devices, physical world information...). Please see WSNet tutorial for more informations.

Use the following command to run WSNet1 :


[Note]WSNet1 configuration

WSNet1 version included in WSim sources has a configuration set to a perfect radio physical layer containing up to 128 static nodes. Transmissions are performed without fading and only collisions are taken into account.

2. Running applications with the network

For simple simulations we only need to add a new parameter that adds a node id to a WSim simulation. This node id represents the node configuration within the WSNet simulation. This configuration will be used to instanciate the nodes parameters such as location, mobility, etc.

[Note]WSim network configuration

To ask to WSim to use WSNet2 interface, you just have to add --wsnet2 parameter. --wsnet1 option also exists but is facultative.

The next demo application is taken from the MANTIS OS source tree compiled for BSN2 nodes in /comb/trunk/systems/MANTIS_OS/trunk/build/bsn2/src/apps/sense_and_forward/.

[Note]Multicast network configuration

You computer must have multicast enable interface cards. If WSNet stops right after the nodes are connected to it and stay stalled then it means that the multicast UDP trafic is filtered on your computer.

#! /bin/sh

LOG="--logfile=wsim.log --verbose=9"

MODE="--mode=time --modearg=10s"

${WSIM} ${MODE} --ui ${LOG} ${TRC} ${SERIAL} ${WS_MODE}$1

${WTRC} --in=wsim.trc --out=wsim.vcd --format=vcd
MantisOS: sense and forward demo application

Figure VI.2. MantisOS: sense and forward demo application

3. Debuging distributed applications

One of the node can be set to debug mode. That way the whole set of nodes is synchronized on communications through WSNet1 and step by step debuging on 1 node stops and drives all the other nodes. Network protocols and MAC layers can be debuged this way.

[Note]Serial communications with a distributed application

WSNet and WSim are distributed parallel applications. An optimistic synchronization model is used among all the processes. Event coherency is checked within the simulation and backtracks can occur to ensure correct events ordering. An external application connected to a WSim serial port may see duplicate messages if the node is sent back in time while transmitting over its serial port. In order to ensure correct communication with the outside world we need to design external applications to take care of backtracks either by connecting to WSNet or by implementing robust communication protocols.

MantisOS: sense and forward demo application, debug mode

Figure VI.3. MantisOS: sense and forward demo application, debug mode

4. Wireless performance estimation and code source annotation

Performance reporting tools and traces are still available in distributed simulation modes. Traces will have to be collected according to the nodes that have to be monitored. Loging and traces need to be manipulated with care as the WSim nodes are using local time. Each node has a time that starts at 0 and they must be shifted according to the information available in WSNet1 to have correct offsets.

[Note]Traces with a distributed application

Traces from WSim do not contain backtracked events, the correct order of events is outputed in trace files with duplicated events removed.