Maté: A Tiny Virtual Machine for Sensor Networks
Philip Levis and David Culler
A Summary and Presentation By: Michele Romano

Summary

The development and improvement of sensor networks is a popular area of research because of their unique potential for gathering data that can be used to learn about and monitor a variety of environments.

The main challenges that sensor networks face include:

  • Reprogramming - Often when a sensor network is implemented, the requirements of the tasks for each mote are not clearly defined. This leads to a desire to reprogram the network after it has already been deployed.
  • Limited Resources - Each mote is limited to approximately 128KB of program memory with only 8KB of RAM
  • Limited Energy - Once the network is deployed, it is very difficult, if not impossible to recharge the motes.
  • Unreliable Communication - lossy wireless networks are used with limited bandwidth.
  • Difficult Programming - TinyOS is an operating system used in sensor networks with split-phase non-blocking execution. It is said to be difficult for non-expert programmers to work with as problematic code can easily lead to race conditions and/or deadlock.

These challenges motivated the design of a virtual machine architecture for tiny devices and led to the implementation of Maté. Maté is a bytecode interpretor that runs on TinyOS. Since it is a virtual machine, the code can be written in any language, compiled and installed on the mote. This minimizes the amount of memory used for program code and allows for easier programming (as the programmer can choose the language to use). It also provides bounds checks on every instruction to ensure a safe execution environment. All programs fit into one capsule that is the same size as a TinyOS packet, thereby eliminating the need to buffer partial programs when a program is received over the network for installation.

The process of reprogramming a sensor network is simple using Maté. When a new program is created to be implemented, it is given a newer version number and broadcast to the network. Once a capsule with a newer version is received, the mote will install it and forward it on to it's neighbours. Over time the new program will disseminate through the network like a virus.

To test the expressiveness, behaviour and performance of Maté, an ad-hoc routing algorithm was implemented, measuring its rate of instruction issue, quantified its CPU overhead, and measured network infection rates with different capsule forwarding probabilities. It was found that simple operations had a very high overhead compared to performing them in native code. The long-split operations (such as send capsule) were almost equal in performance. Given the energy cost of execution compared to the energy cost of reprogramming, Maté was found to be preferable for applications with few executions and more frequent reprogramming. Native code (without Maté) was found to be preferable for applications with larger number of executions.


Discussion

Why bother using Maté if it only lasts 5 days?

A case study was done on the sensor network at Great Duck Island (GDI), which monitors the behaviour of storm petrels. Given the CPU overhead of Maté the duty cycle of the GDI application and the energy cost of installing a native image, a Maté version running for five days or less will save energy over a binary version. It is true that this doesn't seem useful but Maté was developed as a study on the advantages of implementing a virtual machine in a sensor network. This study showed that it would not be preferable as an application like GDI.

A suggestion was made that Maté may be useful for development of the application in a deployed network. So once the network is deployed, it can be reprogrammed using Maté architecture until the final requirements of the system are set. At that time, a native image can be placed on the mote (replacing Maté).

There are other ways of dealing with reprogramming, why bother using a virtual machine?

A virtual machine is beneficial over other methods of reprogramming because it provides a safe execution environment. Often it is the biologists or civil engineers that will be programming these networks and they aren't usually trained in split-phase non-blocking programming environments. If buggy code is implemented using native code, it could irrevocably crash a mote. A virtual machine can prevent this from occurring.

Multi platform Environment

One of the benefits to using a virtual machine in a dedicated environment is that it allows for easy programming in a multi platform environment. It was discussed that this was probably not a motivation behind implementing a virtual machine for a sensor network because usually all of the motes within the network are deployed at the same time and are the same platform.

What happens if a capsule gets lost?

Each subroutine fits into one capsule. Since each capsule is installed and broadcast by each mote, if one capsule gets dropped, there is a good chance one of the neighboring capsules will be rebroadcasting it anyhow. Also, since a capsule contains an entire subroutine (or perhaps even an entire program), no buffering needs to be done as in the case where only partial subroutines are received. A program may consist of more than one subroutine but there is only room in the virtual machine space for 4 subroutines so it is not possible for a program to be larger than 4 capsules which reduces the chance that an entire program will not be received.


Presentation

Download the Microsoft PowerPoint Presentation or view as HTML


Other Resources

  1. Maté: Building Application-Specific Sensor Network Language Runtimes
  2. A presentation by Philip Levis - Intel Research: Berkeley
  3. A presentation of Mate by Damon Jo - University of Virginia