Network programming language tutorial

Introduction

Programming sensor networks is often a tedious and complex task. One of the factors that contributes to this is the extreme degree in which code is distributed over various entities within (especially heterogeneous) sensor networks. One problem in writing such systems is that in order to write a program for an entire network, one often writes a lot of small programs in isolation which should when connected in a network behave according to some overal scenario. Our service composition language is aimed at decreasing the gap between scenario and actual running code on individual nodes by programming at the level of entire network (i.e. write one single program, compile it and automatically deploy it to various nodes in the network).

This language takes a service oriented approach to sensor nodes and programs them by specifying services with event-condition-action rules and compositions between these services.

In this programming model, a sensor conceptually consists services (which in turn consist of functions, handlers and event generators) and subscriptions. These elements form the main concepts within our language as well.

Using the compiler

In case your working with the binary version of the compiler, then it can be called directly from the commandline like this:

compiler.exe <yourProgram>.wsp

In case you're working with the source version, a python interpreter is required. The compiler has been tested with python version 2.5, no guarantees are given with regard to compatibility with earlier versions. Invoke the compiler from the commandline like this:

python <compiler>.py <yourProgram>.wsp

In order to compile your program, the compiler needs to have a configuration file which describes the current network configuration (in xml). This file should be stored in the same location as your program. The format of the configuration file is described in the toolchain, though you seldomly need to edit this file directly. In case no configuration file is present a default configuration will be used which reflects the initial status of the OSAS runtime image flashed onto the nodes.

Some small additions

Before starting the examples below, download the background grid image and the custom nodes. Put the grid file in the same folder as your GUIsimulator.exe and put the custom nodes in the location where you will store your scenario files.

Examples