7.2 Sensor Network Programming Challenges 245
transmission bears the maximum power consumption. However,
each radio packet (e.g., 30 bytes) only takes 4 ms to send, while lis-
tening to incoming packets turns the radio receiver on all the time.
The energy that can send one packet only supports the radio receiver
for about 27 ms. Another observation is that there are huge differ-
ences among the power consumption levels in the active mode, the
idle mode, and the suspend mode of the MCU. It is thus worthwhile
from an energy-saving point of view to suspend the MCU and the RF
receiver as long as possible.
7.2 Sensor Network Programming Challenges
Traditional programming technologies rely on operating systems to
provide abstraction for processing, I/O, networking, and user inter-
action hardware, as illustrated in Figure 7.4. When applying such a
React to all events/messages
(typically using an FSM)
• Message passing
• Handshaking
• Locks and monitors
• Interrupt services
• Polling sensors
Sensors Power Sensors Power Sensors Power
Application Application Application
Figure 7.4 Traditional embedded system programming interface.
246 Chapter 7 Sensor Network Platforms and Tools
model to programming networked embedded systems, such as sensor
networks, the application programmers need to explicitly deal with
message passing, event synchronization, interrupt handing, and sen-
sor reading. As a result, an application is typically implemented as
a finite state machine (FSM) that covers all extreme cases: unreliable
communication channels, long delays, irregular arrival of messages,
simultaneous events, and so on. In a target tracking application
implemented on a Linux operating system and with directed diffu-
sion routing, roughly 40 percent of the code implements the FSM and
the glue logic of interfacing computation and communication [142].
For resource-constrained embedded systems with real-time require-
ments, several mechanisms are used in embedded operating systems
to reduce code size, improve response time, and reduce energy con-
sumption. Microkernel technologies [211] modularize the operating
system so that only the necessary parts are deployed with the appli-
cation. Real-time scheduling [27] allocates resources to more urgent
tasks so that they can be finished early. Event-driven execution allows
the system to fall into low-power sleep mode when no interesting
events need to be processed. At the extreme, embedded operating
systems tend to expose more hardware controls to the programmers,
who now have to directly face device drivers and scheduling algo-
rithms, and optimize code at the assembly level. Although these
techniques may work well for small, stand-alone embedded systems,
they do not scale up for the programming of sensor networks for two
Sensor networks are large-scale distributed systems, where global
properties are derivable from program execution in a massive
number of distributed nodes. Distributed algorithms themselves
are hard to implement, especially when infrastructure support is
limited due to the ad hoc formation of the system and constrained
power, memory, and bandwidth resources.
As sensor nodes deeply embed into the physical world, a sensor
network should be able to respond to multiple concurrent stimuli
at the speed of changes of the physical phenomena of interest.

Get Wireless Sensor Networks now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.