Design Article
Faster code generation for wireless sensor networks
Stefano Olivieri, Mostafizur Mozumdar, Luciano Lavagno, & Laura Vanzago
4/16/2009 4:40 AM EDT
In the main scenario, users retrieve information from a WSN by injecting queries and gathering results from sensor nodes, called “motes.” A single mote might consist of sensing, computing, communication, actuation, and power components, which are integrated and packaged into a miniaturized mote. A WSN usually consists of tens to thousands of such nodes, communicating through wireless channels for information sharing and cooperative processing.
Because of the requirement of unattended operation in remote or even potentially hostile locations, sensor networks are extremely energy-limited.
The major challenges in the WSN domain include sensing and collecting data from sensors and then evaluating it to formulate meaningful information such as generating alarms or decision-making while minimizing energy consumption.
Currently, researchers are developing software applications at different stack levels for WSNs. However, several serious barriers to the success of WSN in commercial applications remain:
Two primary types of functional analysis packages are currently available. One is very platform- and operating system (OS)-specific (for example, TOSSIM), which provides a binary API to model the OS and the motes, with limited capabilities for reusing existing channel models, tracing, collecting statistics, and so on. The other set includes generic network simulators (such as OmNet, NS, etc.), sometimes enhanced with models tailored to the radios and channel used by WSNs.
Both show significant drawbacks in the application development phase. The first group makes it quite difficult to port an application to a different platform, for example from TinyOS to MANTIS, or to a ZigBee-compliant platform, without very extensive code rewriting and a significant amount of debugging. The second group still leaves a lot of detailed platform-dependent code to be developed. Integrated use of a network simulator followed by a platform simulator is the most commonly used path, but still requires one to port code between different environments. Moreover, if one finds a bug at the end of the development and integration phase, the only solution is led-based debugging, which is extremely time-consuming.
To solve these issues, system engineers need to be able to model applications using high-level abstractions, and to simulate them using configurable and realistic topologies for the network itself. Moreover, suitable tools to automatically generate code for several target operating systems would be desirable. As a result of a joint research project of STMicroelectronics, Politecnico di Torino, and The MathWorks, we prototyped a framework for modeling, simulating, and generating code for sensor network applications which has been defined based on MathWorks tools.
At the top level, a sensor network model with Simulink can be built and serves as a time-based simulator for dynamic systems. Such a model has two major components: the wireless channel model (called communication medium in the following) and the node block.
One can implement the communication Medium block in C, so that it can be modified to reuse any existing channel and connectivity models. We are now working, for example, on refining it using the ZigBee physical and medium access control standards.
The node block contains a number of motes; each of them is fully parameterized and contains a model of the hardware and software platform, including for example a timer and the LEDs, as well as a parameterized Stateflow block representing the application. Stateflow is a finite-state machine language used to model and simulate control logic and flow charts. Here, it implements the algorithm (application, middleware, or device drivers) running inside each mote. The timer, for example, is used for generating time events for the Stateflow algorithm. It is possible to model sensor networks running either identical or different applications in each node. To model a new sensor network application based on this framework, an application developer only needs to modify the template algorithm implementation (Stateflow library object) and set the connectivity parameters of the nodes in the communication medium block.
A simple simulation framework for wireless sensor networks.
To see a bigger version of this graphic click here.



