The regiment macroprogramming system
- ISBN: 978159593638X
- DOI: 10.1145/1236360.1236422
Abstract
The development of high-level programming environments is essential if wireless sensor networks are to be accessible to non-experts. In this paper, we present the Regiment system, which consists of a high-level language for spatiotemporal macroprogramming, along with a compiler that translates global programs into node-level code. In Regiment, the programmer views the network as a set of spatially-distributed data streams. The programmer can manipulate sets of these streams that may be defined by topological or geographic relationships between nodes. Regiment provides a rich set of primitives for processing data on individual streams, manipulating regions, performing aggregation over a region, and triggering new computation within the network. In this paper, we describe the design and implementation of the Regiment language and compiler. We describe the deglobalization process that compiles a network-wide representation of the program into a node-level, event-driven program. Deglobalization maps region operations onto associated spanning trees that establish region membership and permit efficient in-network aggregation. We evaluate Regiment in the context of a complex distributed application involving rapid detection of spatially-distributed events, such as wildfires or chemical plumes. Our results show that Regiment makes it possible to develop complex sensor network applications at a global level.
Author-supplied keywords
The regiment macroprogramming system
Ryan Newton
MIT
newton@mit.edu
Greg Morrisett
Harvard University
greg@eecs.harvard.edu
Matt Welsh
Harvard University
mdw@eecs.harvard.edu
Abstract
The development of high-level programming environments is es-
sential if wireless sensor networks are to be accessible to non-
experts. In this paper, we present the Regiment system, which con-
sists of a high-level language for spatiotemporal macroprogram-
ming, along with a compiler that translates global programs into
node-level code. In Regiment, the programmer views the network
as a set of spatially-distributed data streams. The programmer can
manipulate sets of these streams that may be defined by topologi-
cal or geographic relationships between nodes. Regiment provides
a rich set of primitives for processing data on individual streams,
manipulating regions, performing aggregation over a region, and
triggering new computation within the network.
In this paper, we describe the design and implementation of the
Regiment language and compiler. We describe the deglobaliza-
tion process that compiles a network-wide representation of the
program into a node-level, event-driven program. Deglobalization
maps region operations onto associated spanning trees that estab-
lish region membership and permit efficient in-network aggrega-
tion. We evaluate Regiment in the context of a complex distributed
application involving rapid detection of spatially-distributed events,
such as wildfires or chemical plumes. Our results show that Reg-
iment makes it possible to develop complex sensor network appli-
cations at a global level.
Categories and Subject Descriptors:
D.3.2 Concurrent, distributed, and parallel languages;
Applicative (functional) languages; Data-flow languages
C.2.4 Distributed Systems
General Terms: Design, Languages
Keywords: functional macroprogramming, sensor networks
1. Introduction
Programming complex coordinated behaviors in sensor networks
is a difficult task. When programming at the sensor node level,
developers must concern themselves with low-level details of ra-
dio communication, sensing, buffer management, and concurrency,
typically under severe constraints on resource usage. One approach
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee.
IPSN’07, April 25-27, 2007, Cambridge, Massachusetts, USA.
Copyright 2007 ACM 978-1-59593-638-7/07/0004 ...$5.00.
that has been proposed to address these problems ismacroprogram-
ming, which involves programming the sensor network at the global
level, rather than individual sensor nodes. In a macroprogramming
system, the global network program is automatically translated into
a node-local program.
This paper presents Regiment, a macroprogramming language
and runtime environment based on the concept of functional reac-
tive programming (FRP) [5]. In Regiment, the programmer views
the network as a set of spatially-distributed, time-varying signals,
each representing either the state of an individual sensor node (e.g.,
sensor readings or the results of local computation) or an aggregate
taken across regions of sensor nodes. Regions may be defined in
terms of geographic area, network topology, or functional capabil-
ity (e.g., all of the climate sensors within a given area). Regiment
provides a rich set of primitives for processing data on individual
signals, manipulating regions, performing aggregation over signals
in a region, and triggering new computation within the network.
A Regiment macroprogram compiles down to a node-level inter-
mediate language called token machines (TMs). A token machine
program provides basic facilities for local computation, sampling,
and radio communication, as well as the ability to construct gradi-
ents within the network for region formation and aggregation. In
contrast to declarative query languages such as TinyDB [10], Reg-
iment offers a more complete, flexible programming environment
that supports complex in-network processing, triggered execution,
and coordination within local regions of the network.
In previous work, we presented an early design of the Regiment
language [14] and the TM interface [13]. In this paper, we signif-
icantly extend this previous work by describing the complete Reg-
iment macroprogramming environment, a compiler that translates
Regiment code to TM programs, and a runtime system that sup-
ports the global coordination primitives in the Regiment language.
In addition, we present a performance evaluation of Regiment in
the context of a complex distributed application involving rapid de-
tection of spatially-distributed events such as wildfires or chemical
plumes. Our results show that sophisticated macroprograms writ-
ten in Regiment can be compiled to efficient node-level code.
The rest of this paper is organized as follows. Section 2 presents
the background and motivation for this work, with an emphasis on
existing approaches to sensor network macroprogramming. Sec-
tion 3 gives a brief overview of the Regiment language and Sec-
tion 4 presents an example application. Section 5 describes the
Regiment compiler and deglobalization techniques in detail. Sec-
tion 6 presents a detailed performance evaluation of several variants
of the event-detection program in simulation, focusing on detection
latency and communication overheads. Finally, Section 7 describes
future work and concludes.
489
The goal of macroprogramming systems is to provide a high-
level programming model for sensor networks that abstracts away
the details of individual sensor nodes. Rather, an application de-
veloper writes code that describes the operation of the network as
a whole, which is then compiled down to a node-level program.
Macroprogramming can greatly simplify application design, mak-
ing it possible for non-sensor-networking experts to directly de-
velop complex distributed programs.
2.1 Spatiotemporal Macroprogramming
A range of macroprogramming models have been proposed in
the literature [16, 17, 6, 18, 10], which are each designed to sup-
port a particular style of network-wide programming. For example,
TinyDB [10] is focused on data collection with a limited form of
in-network aggregation, while EnviroSuite [9] has special support
for tracking applications.
Regiment is designed to support an important class of sensor
node applications that we call spatiotemporal macroprograms (ST-
MPs). STMPs are distinguished by exhibiting significant spatial
and temporal structure. That is, STMPs are typically concerned
with nodes’ locations and their topological relationships, with geo-
graphical localities in real space, as well as with time-varying sen-
sor data and computational state. Common idioms in STMPs in-
clude local communication amongst neighborhoods in the network;
the use of sensor data and location to estimate properties of a field;
and exploiting redundancies between sensor nodes to mitigate the
effects of failure. Good examples of STMPs include estimation
of a gradient or contour in the sensor field [7], or the use of local
neighborhood communication to estimate the location of a target
vehicle [17].
STMPs describe a wide range of sensor network applications,
but it is important to point out that this model is by no means uni-
versal. In contrast, non-spatiotemporal applications include those
without regard for specific sensor locations or which consider the
capabilities of nodes, rather than their positions, as primary. Exam-
ples of non-STMPs also include agent-based models in which code
migrates between nodes.
2.2 Macroprogramming languages
Among the first macroprogramming environments were database-
inspired declarative query languages in which the user describes
sensor data of interest using an SQL or XML query. TinyDB [10],
Cougar [19], and IrisNet [11] are examples of this approach. Query
languages offer an extremely high-level interface to the sensor net-
work, and provide exactly the right solution for applications that
need to retrieve data from the whole network, or compute an ag-
gregate over the whole network. They are, however, limited in
that they do not offer much flexibility for introducing application-
specific logic. In TinyDB, for example, a developer could imple-
ment new query operators, but doing so requires extensive modifi-
cations to the parser and query engine.
Kairos [6] provides an SPMD-style programmingmodel in which
parallel computation over a set of sensor nodes is represented as a
loop that iterates over members of the set. EnviroSuite [9] is a lan-
guage and runtime environment with special support for tracking
applications. Abstract Task Graphs [1] offers a dataflow program-
ming model with a graphical composition language, while Seman-
tic Streams [18] use a logic program to compose services hosted on
different sensor nodes into a dataflow.
One of the key challenges in defining a macroprogramming en-
vironment is resolving the tension between ease-of-use, efficiency,
and providing adequate flexibility for expressing powerful distributed
computations. Indeed, the wide range of proposals for macropro-
gramming systems suggests that there is no universal model for
macroprogramming, and different application domains will involve
very different tradeoffs along these axes. Regiment aims to signif-
icantly extend the functionality of declarative query interfaces by
supporting a rich set of primitives for computation and communi-
cation at the node, region, and global levels.
Of course, this degree of abstraction will always come with some
overhead as compared to highly-tuned, hand-coded systems. But
we believe that these overheads can be minimized to the point that
macroprogramming is viable for the majority of applications. Fur-
ther, we will demonstrate that rapidly prototyping applications—
embodying drastically different communication strategies—can be
accomplished within the macroprogramming environment.
3. Overview of Regiment
In this section, we provide an overview of the Regiment lan-
guage and programming model. In a previous workshop paper [14],
we presented an earlier form of the Regiment language, which has
since evolved substantially. Thus, we offer the following summary.
Regiment is based on the concept of functional reactive pro-
gramming (FRP) [5]. Sensor network state is represented as time-
varying signals. Signals might represent sensor readings on an in-
dividual node, the state of a node’s local computation, or aggregate
values computed from multiple source signals. Regiment also sup-
ports the notion of regions, which are spatially distributed signals.
An example of a region is the set of sensor readings from nodes
in a given geographic area. Regiment abstracts away the details of
sensor data acquisition, storage, and communication from the pro-
grammer, instead permitting the compiler to map global operations
on signals and regions onto local structures within the network.
3.1 Regiment Language Basics
Signals: In Regiment, the principal objects that the program-
mer manipulates are signals. For example, a temperature sensor
on a given node, which returns a floating-point value, has type
Signal(float). Conceptually, a signal is a function that maps a
time t to a value v, but in practice the time t will always be “now”
and the signal must be sampled to produce a discrete stream. A
signal can carry primitive values (such as integers, floats, etc.) or
tuples, such as records containing both the light and temperature
sensor readings on a given node.
Regiment provides a number of operations for manipulating and
building new signals out of existing signals. For example, smap ap-
plies a function to each element of a signal, returning a new signal.
Thus, the code fragment:
smap(fun(t) {t * 10.0}, tempvals)
converts a sensor’s floating-point signal tempvals to a new signal
with each temperature value multiplied by ten.
Regions: Central to Regiment is the concept of a region, which
represents a collection of signals. Part of the job of the Regiment
compiler is to enable the user to treat the region as containing a
“snapshot” of the values of its constituent signals, while imple-
menting operations on the region in a distributed fashion.
It is important to note that membership in a region may vary
with time; for example, the region defined as “temperature readings
from nodes where temperature is above a threshold” will consist of
values from a varying set of nodes over time. The collection of
signals that participate in a region can also vary due to node or
communication failures or the addition of nodes in the network.
One of the advantages of programming at the region level is that
the application is insulated from the low-level details of network
topology and membership.
490
Sign up today - FREE
Mendeley saves you time finding and organizing research. Learn more
- All your research in one place
- Add and import papers easily
- Access it anywhere, anytime



