Академический Документы
Профессиональный Документы
Культура Документы
FACULTY OF INFORMATICS
MASTER THESIS
Moslem Amiri
Brno, 2010
Declaration
Hereby I declare that this paper is my original authorial work, which I have worked out by my own.
All sources, references and literature used or excerpted during elaboration of this work are properly
cited and listed in complete reference to the due source.
ii
Acknowledgment
I would like to thank RNDr. Andriy Stetsko, the advisor of my master thesis, for his valuable
comments, suggestions and time he spent helping me with this work.
iii
Abstract
In order to provide WSNs with security, additional energy is required. Since sensor motes usually
have limited source of energy, it is important to balance the level of security and energy consumption.
To find this trade-off, we need to know the amount of energy consumed by different components on
sensor motes while running security algorithms. In this work we perform some measurements to
estimate the energy consumption and execution time of different operations on a Tmote Sky sensor
mote. This device is equipped with CC2420 radio transceiver, MSP430 microcontroller, and ST
M25P80 flash memory. To make the measurements, first we explore different methods to that end,
and then set up the best possible configuration in order to perform precise measurements.
For the transceiver, since CC2420 is an IEEE 802.15.4 compliant radio, we investigate different
frame structures and CSMA/CA medium access mechanism of this standard to discover the overhead
of channel acquisition, header and footer of data frame, and transfer reliability during packet
transmission. Next, the implementation of this standard in TinyOS, a popular operating system widely
used in WSNs, is taken into consideration. Then we measure time and energy needed to send and
receive a 1-byte data payload, an 11-byte acknowledgment frame, and an 18-byte header and footer of
the data frame in TinyOS. We also compute the energy consumed during channel acquisition and
listening operations. This data makes the fixed and incremental components of a linear equation to
estimate the power consumed during every packet transmission. Finally, we input this per-packet
power consumption in a mathematical model which estimates the lower and upper bounds of routings
in the network.
We categorize different simulators currently available in order to propose the function and
structure of a new potential simulator. Due to the fact that radio operations are the most expensive
ones in sensor motes, this proposed simulator focuses on radio rather than internal operations.
The microcontroller of Tmote Sky, MSP430, has several power states with varying power draws.
We measure energy consumptions in different power states of this microcontroller.
We also compute the energy consumption and time needed to write/read one byte of data from/to
ST M25P80, the external flash memory of Tmote Sky.
iv
Keywords
CC2420 radio, execution time, IEEE 802.15.4, lifetime bounds, measurements, MSP430
microcontroller, power consumption, simulator, ST M25P80 flash memory, Tmote Sky sensor mote,
wireless sensor network
Contents
Chapter 1: Categorizing simulators for wireless sensor networks..........................................................2
1.1 General-purpose simulators.........................................................................................................2
1.1.1 Taxonomy based on the level of accuracy...........................................................................2
1.1.2 Taxonomy based on the internal structure............................................................................4
1.2 Simulators for power consumption evaluation............................................................................7
1.2.1 Overall power usage approximation.....................................................................................7
1.2.2 Instruction level simulation..................................................................................................7
1.2.3 Logging power state transitions............................................................................................7
Chapter 2: Experimental measurements of the power consumption for WSNs....................................11
2.1 Using a shunt resistor................................................................................................................11
2.2 Using a clamp-on current probe................................................................................................12
2.3 Improved clamp-on current probe method................................................................................12
2.4 Using GoldCap capacitor for lifetime bounds...........................................................................13
Chapter 3: Measurement Setup.............................................................................................................15
Chapter 4: Experiments using Tmote Sky sensor motes.......................................................................18
4.1 TinyOS......................................................................................................................................18
4.2 Power States of MSP430 microcontroller.................................................................................19
4.3 CC2420 Radio...........................................................................................................................22
4.3.1 IEEE 802.15.4....................................................................................................................23
4.3.2 RSSI/Energy Detection......................................................................................................24
4.3.3 Clear Channel Assessment.................................................................................................24
4.3.4 The CSMA/CA algorithm..................................................................................................24
4.3.5 CCA and Sending...............................................................................................................25
4.3.6 Low power listening...........................................................................................................28
4.3.7 Listening and Receiving.....................................................................................................28
4.4 External Flash............................................................................................................................29
4.4.1 Writing to external flash.....................................................................................................30
4.4.2 Reading from external flash...............................................................................................30
vi
vii
Introduction
A Wireless Sensor Network can be composed of tens to thousands of sensor motes spread in a wide
area and communicating with each other either directly or through the other nodes. One or more of the
nodes are the base station with more or unlimited power supply than the other nodes. The user either
has direct access to the base station or through a wired network. The motes have limited power
supply, very often without the possibility to be recharged. WSNs are vulnerable to attacks; therefore it
is important to provide security services like integrity, confidentiality and authenticity for them.
Applying security to the sensor nodes requires additional energy. Thus we need to make trade-off
between the level of security and energy consumption of WSNs. To find such trade-off, the energy
consumed while running different security algorithms must be known. This requires us to provide a
precise simulator which is able to simulate energy consumption as well. To this aim, it is necessary to
find the power consumption model of sensor motes. To provide this power model, we go through a
series of measurements in this work and estimate the power consumed while running different
operations on sensor motes.
This text is organized as follows. In chapter 1, we discuss different structures for simulators in
order to propose a new simulator for power consumption of wireless sensor networks later in this text.
In chapter 2, we discuss different experimental methods currently available in order to measure the
power consumption of sensor motes. In chapter 3, we explain our measurement setup based on the
methods explained in chapter 2. Then in chapter 4, we provide precise measurements of energy
consumed during different operations on Tmote Sky sensor motes. In chapter 5, we represent a
mathematical model of lifetime bounds of a network in brief. Also, a model for per-packet energy
consumption of routings, using the results from chapter 4, is represented in this chapter, and finally
combining these two existing models, evaluation of lifetime bounds of a network is suggested. Later
in this chapter, we propose the structure of a new simulator. Chapter 6 presents the conclusion.
execute the compatible instructions on the host machine and simulate non-compatible ones via
procedure calls [6]. Since there are CPU features unavailable to user level processes (like trap
architecture or the execution of privileged instructions), simulator needs to handle them explicitly by
methods like CPU process notification by host OS or signaling by host OS. Simulation time increases
by handling such challenges. Likewise, the other target machine features are created in user-level
environment via different methods; physical memory via a single file representing the physical
memory of the target machine, and I/O device interrupts via sending signals of the host operating
system to the target CPU processes by simulated devices, and so on.
The direct execution mode often executes an operating system and target applications only two
times slower than they would run on the host hardware. Thus it is considered a fast simulation
method. Although it is quick, it does not model any aspect of the simulated systems timing.
Furthermore, it requires compatibility between the host platform and the architecture under
investigation.
1.1.1.2 Simulation via direct execution with code augmentation
Although direct execution provides the correct functionality of local instructions, it ignores the time
required to execute them. Code augmentation can be used to count the cycles required by the
instructions. For each basic block of instructions, code is added to increment a cycle counter by the
number of cycles required to execute that block.
This counter can be used in nonintrusive monitoring and debugging. Adding the monitoring code
may cause the behavior which we are monitoring to be affected, so we add non-cycle-counted code to
ensure no change in the behavior. To do so, we need to first turn off cycle counting, then add the extra
code (code for monitoring and debugging) and then turn on the counting.
1.1.1.3 Simulation via binary translation
This approach provides accuracy and does not have the defects mentioned for the previous methods.
This mode uses on-the-fly object code translation to dynamically convert target application and
operating system code into new code that simulates the original code running on a particular hardware
configuration.
To reduce the time spent on runtime code generation, simulator stores the code block translations
in a large translation cache. After receiving every basic block, the simulator searches the cache to see
if a translation of this code already exists. Basic block translations present in the cache are re-executed
without imposing translation costs.
The strongpoint of this method is that depending on the level of detail we need, it is possible to
adopt a different translation policy. We can have a fast binary translation mode by just counting the
number of instructions executed, and obviously for obtaining more details, more complete translation
is needed. Another strongpoint is that by simulating each target machine by a separate process, we can
benefit from concurrency and gain more speed.
Figure 1.1: Binary translation mechanics. Binary translation converts an instruction sequence from a block of
code in the target machines instruction set into a code sequence that runs on the host. Above, simRegs is an
array that holds the state of the target CPUs registers. The translated code uses simRegs to perform operations
on the target machines registers and memory. MMU is the Memory Management Unit of CPU responsible to
relocate virtual addresses to a location in physical memory. The MMU address translation and cycle-counting
annotations support the operating system. Adding a cache simulation entails adding two instructions to the
MMU translation. All instruction counts are for the hit case. Misses necessitate calling support functions. [4]
By replacing a few low-level components (those shaded in figure 1.2), TOSSIM translates
hardware interrupts into discrete simulator events; the simulator event queue delivers the interrupts
that drive the execution of a TinyOS application. When the core loop executes a simulator event, it
sets global state to indicate which mote is currently running. A simulator event calls an interrupt
handler in hardware abstraction components. The interrupt handler signals TinyOS events and calls
TinyOS commands, just as it would on a mote. The remainder of TinyOS code runs unchanged.
TOSSIM keeps time at 4 MHz. All simulator events are timestamped and processed in global time
order.
The program in the figure 1.3 has a 1 Hz timer that samples the light sensor and displays the three
high order bits of the reading on the mote LEDs. Since simulator time is kept in 4 MHz clock, the
timer events are four million ticks apart, and the 50 s ADC capture takes 200 ticks between request
and interrupt.
Mode
CPU
Active
Idle
ADC Noise Reduce
Power-down
Power-save
Standby
Extended Standby
Internal Oscillator
LEDs
Sensor board
EEPROM access
Read
Read Time
Write
Write Time
Current Mode
8.0 mA
3.2 mA
1.0 mA
103 A
110 A
216 A
223 A
0.93 mA
2.2 mA
0.7 mA
Radio
Rx
Tx (-20 dBm)
Tx (-19 dBm)
Tx (-15 dBm)
Tx (-8 dBm)
Tx (-5 dBm)
Tx (0 dBm)
Tx (+4 dBm)
Tx (+6 dBm)
Tx (+8 dBm)
Tx (+10 dBm)
Current
7.0 mA
3.7 mA
5.2 mA
5.4 mA
6.5 mA
7.1 mA
8.5 mA
11.6 mA
13.8 mA
17.4 mA
21.5 mA
6.2 mA
565 s
18.4 mA
12.9 ms
PowerTOSSIM tracks the power state of each hardware component of the simulated motes by
generating specific power state transition messages that are logged during the simulation run. This
is done by instrumenting the TOSSIM simulated hardware components with calls to a new
component, PowerState, which tracks hardware power states for each mote and logs them to a file
during the run. This file, which contains power state transition calls, can be combined with the power
model (figure 1.4) to generate detailed power consumption data or visualization. The process of
generating power usage can be performed using offline tools (actually the generation and processing
of power state transition data are decoupled).
The challenge is estimating the CPU power usage; since PowerTOSSIM runs the mote software as
a native binary of the host machine (in fact TOSSIM and PowerTOSSIM retarget compilation
process to host machines binary code instead of the motes binary), it has no information on the
length of time that a given mote spends using the CPU (active state or idle state or the other states).
The amount of time that a node spends in idle mode depends on external factors, such as the timing of
clock interrupts, which are already modeled by TOSSIM. However, the amount of time spent
executing CPU instructions is not captured by TOSSIM.
To capture CPU execution time, PowerTOSSIM behaves as follows:
1) Instrument the PowerTOSSIM binary to obtain an execution count for each basic block (run
of instructions with no branches) executed by the simulated CPU.
2) Map each basic block to its corresponding assembly instructions in the AVR binary (AVR is a
single chip microcontroller developed by Atmel and used in Mica2 sensor node).
3) Determine the number of CPU cycles for each basic block using simple instruction analysis.
4) Combine the simulation basic block execution counts with their corresponding cycle counts to
obtain the total CPU cycle count for each simulated mote.
At the end of the simulation run, PowerTOSSIM logs basic block execution counters that are
processed offline in the manner described above to obtain CPU cycle count totals. The power
consumptions for active and idle states are computed in the power model (figure 1.4), and the cycle
8
time for each instruction is well-documented, so using this information we can compute the power
consumption for the CPU.
To implement the four steps described above in capturing CPU execution time, the used method is
as follows: the NesC compiler inputs the entire TinyOS component graph and outputs a single C
source code, and then a back-end compiler compiles this C code to the target platform. In
implementing PowerTOSSIM, this intermediate C source file is instrumented with basic block
execution counters with the help of C Intermediate Language (CIL). Using CIL, a set of source
transformation rules are written to the C source code that insert an execution counter into each basic
block of the program. Moreover, this transformation code records the line number of the original
NesC source code corresponding to each basic block. This way we can map basic blocks back to their
original source code line number. The next step is mapping each basic block to the appropriate
number of CPU instructions as executed by the sensor mote. To do so, the TinyOS application is
compiled to a mote binary and then with the help of a disassembler, the set of AVR instructions for
each source code line is obtained. This is then correlated with the basic block line number information
9
to obtain the set of assembly instructions corresponding to each basic block. Then using the datasheet
of the sensor mote, the CPU cycle counts for each instruction is obtained and summed up. After the
simulation, the basic block execution counts are recorded and using the method above, the CPU cycle
counts for each mote is achieved.
10
+
Figure 2.1: Power measurements with shunt resistor; SUT System Under Test.
(2.1)
The drawback of this approach is that the shunt resistor interferes with the operation of the system
under test which is not suitable when there are large variations of current, while the advantage of this
method is that it is less susceptible to noise.
11
Figure 2.2: Power measurements with current probe; SUT System Under Test.
. ,
(2.2)
Contrary to the previous approach, the advantage of this method is that it is unobtrusive while its
drawback is that it is more susceptible to noise.
Figure 2.3: Block diagram of the environment for run-time power monitoring for wireless sensor platforms.
Description: DMM Digital Multimeter, DAQ Data Acquisition Card, SUT System Under Test.
12
In this approach, the current probe approach is advanced to provide more precise measurement.
As mentioned before, the current probe, which is clamped directly around the power supply line,
produces an output voltage that is proportional to the current in the line. Now in this approach, the
linear dependency of current on the voltage of current probe is calibrated using a simple circuit with
and the power supply
are measured for a
the power supply and a resistor. Both the current
range of resistors with resistances from 70 to 3 K using the digital multimeter.
The results show that a second order polynomial can better approximate the current from the
voltage of the current probe (instead of linear dependency on the voltage of the current probe).
Current in milliamps is calculated from voltage in volts as the following formula:
20.
99.1 .
0.1576
(2.3)
13
(2.4)
14
49.4
(3.1)
To reveal all power transitions, the gain of 98 was enough for our measurements. Hence a 510
pins of the in-amp.
resistor was placed between
While working with instrumentation amplifiers, there can be voltage offset error which should be
),
calculated in order to have precision measurements. There are two offset errors; Input Offset (
and Output Offset (
). For AD620AN, the datasheet indicates that
is 30 (typical) and
is 400 (typical). So referred to input, the total voltage offset will be:
30
400
(3.2)
400
(3.3)
Practically, to adjust the offset of the in-amp, we should ground both inputs and measure the output
voltage, the result should be accounted for all the measurements. Grounding both inputs, we detected
no voltage offset error in our measurements.
Other challenges with instrumentation amplifiers are Input Bias and Offset Currents. Input bias
currents are those currents, flowing into, or out of, the input terminals of the in-amp [10]. Input bias
currents can be considered as a source of voltage offset error (i.e. input current flowing through a
source resistance causes a voltage offset). Input offset current is the difference between the two input
bias currents and this leads to offset errors in in-amps when source resistances in the two input
terminals are unequal. The solution for these problems is to provide a return path for bias currents to
flow to ground. A high value resistor of 1 M to 10 M connected between each input and ground
will normally be all that is needed to correct this condition. We connected a 1 M resistor between
each input and the ground to solve this problem.
16
In the rest of this document, some screenshots of the scope while measuring different operations
are depicted. The x-coordinate is time. The y-coordinate of the shots is the voltage (with 98 gain)
across the 1.7 resistor placed between power supply (3 ) and the mote. The precise data is gained
digitally from oscilloscope. To calculate the consumed power, we do the following calculations:
(3.4)
98
1.7
3
17
(3.5)
4.1 TinyOS
TinyOS is a tiny microthreading operating system designed to meet these requirements for networked
sensors: small physical size and low power consumption, concurrency-intensive operation, limited
physical parallelism and controller hierarchy, diversity in design and usage, and robust operation [16].
TinyOS is a component-oriented, event-driven operating system for sensor networks which consists of
a simple FIFO task scheduler and some software components for doing different operations in sensor
motes.
A three-tier Hardware Abstraction Architecture (HAA) for TinyOS 2.0 is proposed that
combines the strengths of component model with an effective organization in form of three different
levels of abstraction. The top level of abstraction raises portability by providing a platformindependent hardware interface (HIL: Hardware Interface Layer), the middle layer promotes
efficiency through rich hardware-specific interfaces (HAL: Hardware Adaptation Layer), and the
lowest layer structures access to hardware registers and interrupts (HPL: Hardware Presentation
Layer) [17].
The first challenge while working with Tmote Sky sensor motes is that it is never defined in
TinyOS; in the directory tinyos-2.1.0/tos/platforms, Tmote Sky platform is not included.
In TinyOS 2.0, a platform is a collection of chips and some glue code that connects them
18
together [18]. Due to the lack of such implementation, every compilation (make) of code targeting the
Tmote Sky is retargeted to Telosb.
tinyos-2.1.0/support/make/tmote.target:
ifeq ($(TMOTE_REV) ,SKY)
TMOTE_TARGET = telosb.target
Endif
But comparing the two sensor motes, Moteiv Tmote Sky and Crossbow TelosB, we see that they
have rather the same features. The differences are: Tmote Sky has better RF performance, lower
power consumption, and faster startup times. Since none of these differences will lead into a different
binary code translation for Tmote Sky platform, there is no problem compiling the Tmote Sky code by
TelosB platform. Even if a different hardware component is used in Tmote Sky than TelosB, TinyOS
2.0 has provided a solution to it: horizontal decomposition [17]. A horizontal decomposition can
promote reuse of the hardware resource abstractions that are common on different platforms. To this
aim, TinyOS 2.0 introduces the concept of chips, the self-contained abstraction of a given hardware
chip: microcontroller, radio-chip, flash-chip, etc. Each chip decomposition follows the HAA model,
providing HIL implementations as the topmost components. Platforms are then built as
compositions of different chip components with the help of glue components that perform the
mapping.
19
disabling low power modes. However the approach used in MSP430 based platforms is costly,
introducing 40-60 cycles of overhead to every interrupt that wakes the system up, which can be a
bottleneck on the rate at which the system can handle interrupts.
This approach assumes that TinyOS can determine the correct low power state by examining
control and status registers. MSP430 defaults to low power mode 3 (LPM3) unless it detects that
Timer A, the USARTs, or the ADC is active, in which case it uses low power mode 1 (LPM1).
TinyOS 2.x uses three basic mechanisms to manage and control microcontroller power states: a
dirty bit, a chip-specific low power state calculation function, and a power state override function.
The dirty bit tells TinyOS when it needs to calculate a new low power state, the function performs the
calculation, and the override allows higher level components to introduce additional requirements, if
needed.
TinyOS exports one interface for the handling of the microcontroller, namely McuSleep, which
exposes a single asynchronous command, sleep(), that is called inside the TinyOS scheduler when
the FIFO task queue is empty. The job of the sleep() command is to calculate the correct power
state in which to put the microcontroller. The task requires analysis of the state of different registers
[19].
<tos/chips/msp430/McuSleepC.nc>
[]
const uint16_t msp430PowerBits[MSP430_POWER_LPM4 +
0,
//
SR_CPUOFF,
//
SR_SCG0+SR_CPUOFF,
//
SR_SCG1+SR_CPUOFF,
//
SR_SCG1+SR_SCG0+SR_CPUOFF,
//
SR_SCG1+SR_SCG0+SR_OSCOFF+SR_CPUOFF,
//
};
[]
1] = {
ACTIVE
LPM0
LPM1
LPM2
LPM3
LPM4
Depending on the power mode in which TinyOS puts the microcontroller, different clocks and
other resources of the microcontroller are adjusted. The MSP430 clock system is designed specifically
for battery-powered applications [20]. Multiple oscillators are utilized to support event-driven burst
activity. A low-frequency Auxiliary Clock (ACLK) is driven directly from a common 32-kHz watch
crystal or the internal very low-power oscillator (VLO) with no additional external components. The
ACLK can be used for a background real-time clock self wake-up function. An integrated high-speed
digitally controlled oscillator (DCO) can source the master clock (MCLK) used by the CPU and submain clock (SMCLK) used by the high-speed peripherals.
There are five low-power modes of operation, but two (LPM1 and LPM2) are rarely employed in
current devices [21]:
Active mode: CPU, all clocks, and enabled modules are active. The MSP430 starts up in this mode,
which must be used when the CPU is required. An interrupt automatically switches the device to
active mode.
20
LPM0: CPU and MCLK are disabled, SMCLK and ACLK remain active. This is used when the CPU
is not required but some modules require a fast clock from SMCLK and the DCO.
LPM3: CPU, MCLK, SMCLK, and DCO are disabled; only ACLK remains active. This is the
standard low-power mode when the device must wake itself at regular intervals and therefore needs a
(slow) clock. It is also required if the MSP430 must maintain a real-time clock.
LPM4: CPU and all clocks are disabled. The device can be wakened only by an external signal. This
is also called RAM retention mode.
MSP430 is put into low-power modes through the four bits: SCG0, SCG1, CPUOFF, and
OSCOFF in the status register. All these are clear in the active mode and particular combinations are
set for each low-power mode. For example setting only CPUOFF disables the CPU and MCLK,
putting the MSP430 into LPM0.
Since some external peripherals may require the microcontroller to not go below a given power
state (for example if it will require the CPU soon and the tradeoff between the time spent in a lowpower state and wake-up latency is not favorable), TinyOS allows them to specify the lowest
acceptable power state through the McuPowerOverride.lowestState() command [19].
As mentioned before, there are three mechanisms to control microcontroller in TinyOS. We used
power state override function method to force the microcontroller to stay in different power states in
our measurements. The trick we used was to let the microcontroller do no operation so that it would
go to the lowest state LPM4. Then using the command McuPowerOverride.lowestState(),
we could set the lowest state the microcontroller was allowed to go (source codes of the tasks done in
this document are available on the CD attached to it).
Here are the results we obtained:
272
, so
1.633
and
4.898
.
Active mode:
Almost the same results were obtained for both LPM0 and LPM1.
28
, so
0.168
and
0.504
LPM0 and LPM1:
21
LPM2, LPM3, and LPM4 consume approximately the same amount of power based on our
experiments:
8
, so
0.048
and
0.144
.
LPM2, LPM3, LPM4:
22
microcontroller through the SPI port and a series of digital I/O lines and interrupts. The radio may be
shut off by the microcontroller for low power duty cycled operation [15].
Bytes:
MAC
Layer
Frame
Data Sequence
Control Field
Number
20
Addressing
Fields
MAC Header
Bytes: 4
1
PHY
Start of Frame
Preamble Sequence
Layer
Delimiter
Synchronization Header
1
Frame
Length
PHY
Header
102
Data Payload
Frame Check
Sequence
MAC Payload
MAC Footer
20
0/2/8 bytes
0/2 bytes
0/2/8 bytes
Destination
address
Source PAN
identifier
Source
address
Practically 16-bit (2-byte) addresses i.e. short addresses are assigned to the sensor motes, source
PAN identifier is left empty, and 2-byte destination PAN identifier is assigned (see figure 4.5). In
802.15.4, a PAN identifier is chosen for every network which operates independently from the other
23
networks. Altogether 6 bytes is needed for addressing purposes, hence the length of the data packet
gets 17 n bytes.
Figure 4.6 [23] shows the structure of the acknowledgment frame.
4 bytes
1 byte
Preamble Start of Frame
Sequence
Delimiter
Synchronization Header
1 byte
Frame Length
PHY Header
2 bytes
1 byte
Frame Control Data Sequence
Field
Number
MAC Header
2 bytes
Frame Check
Sequence
MAC Footer
The length of the acknowledgment packet is 11 bytes. Although use of acknowledgment frames is
optional, we will consider them in our computations for transfer reliability.
Altogether to transmit an n-byte packet, we need to send 17 n bytes (data frame) and receive 11
bytes (acknowledgment frame). To receive an n-byte packet, we need to receive 17 n bytes (data
frame) and send 11 bytes (acknowledgment frame).
24
networks is called carrier-sense multiple access (CSMA). CSMA algorithms attempt to break
symmetries of failing transmissions being restarted at almost the same time by using randomized
binary exponential backoff procedures. While wired devices can listen during their own transmissions
and employ CSMA with collision detection (CSMA/CD), stations in wireless networks usually cannot
listen to their own transmissions, and consequently colliding transmissions can only be detected after
they have been completed. Thus wireless devices use CSMA with collision avoidance (CSMA/CA).
If beacons (beacons are transmitted by the coordinator to provide synchronization services) are
being used in the PAN, the MAC sub-layer shall employ the slotted version of the CSMA/CA
algorithm for the transmission. Conversely, if beacons are not being used in the PAN or if a beacon
could not be located in a beacon-enabled PAN, the MAC sub-layer shall transmit using the unslotted
version of the CSMA/CA algorithm. Here we only focus on unslotted CSMA/CA algorithm. It works
as follows [23]:
1. Initialization: if a device wishes to transmit a frame using CSMA/CA, it first initializes the local
variables BE:=macMinBE (0-3, default 3) for the backoff exponent and NB:=0 for the number
of successive backoffs before the current transmission.
2. Backoff: before a station attempts to send a frame, it waits for a random integer number between 0
and 2BE 1 complete backoff periods of length aUnitBackoffPeriod (20 symbol periods).
In unslotted CSMA/CA the backoff starts immediately.
3. Clear Channel Assessment: after completing its backoff, the station performs a clear channel
assessment (CCA). If, after eight symbol periods, the channel is assessed to be busy, both BE and
NB are incremented by one, up to a maximum of aMaxBE (=5) for BE and
macMaxCSMABackoffs+1 (macMaxCSMABackoffs=0-5, default 4) for NB. If NB exceeds
macMaxCSMABackoffs, the protocol terminates with a channel access failure; if not, the
protocol returns to the backoff step. If the channel is assessed to be free, the data frame can be
transmitted.
4. Starting the transmission
5. Acknowledgement: if the originator has not requested an acknowledgement, the transmission is
assumed to have been successful. If an acknowledgement has been requested, the sender needs
aTurnaroundTime (12 symbol periods) to switch from sending to receiving mode and vice
versa. The recipient starts the transmission of the acknowledgement aTurnaroundTime after
the reception of the last symbol of the data. If the originator receives an acknowledgement from the
recipient within a time of macAckWaitDuration (120 or 54 symbol periods), the data transfer
has been successful. If no acknowledge is received within that time, the frame will be retransmitted
up to a maximum of aMaxFrameRetries (=3) times, after which the protocol terminates and a
communications failure is issued.
PA_LEVEL
31
27
23
19
15
11
7
3
TXCTRL register
0xA0FF
0xA0FB
0xA0F7
0xA0F3
0xA0EF
0xA0EB
0xA0E7
0xA0E3
In TinyOS 2.x, we can set the global radio power of CC2420 by defining the
CC2420_DEF_RFPOWER to a different value or we can change it dynamically on a per-packet basis
using the setPower command from the CC2420Packet interface. There are 32 (0 to 31) valid
transmission power states for a given packet.
After compiling the applications for radio power measurements, we need to program Tmote Sky
with the following command:
make tmote reinstall.x
26
Voltage for CCA operation is 3.2 V and time is 1.4 ms, hence P 0.08 mJ.
As noted before, we ignore extra preamble bits and only consider the 4-byte preamble sequence at
IEEE 802.15.4 standard data frame. These 4 bytes are among the extra ones in the area marked
Preamble bits in figure 4.8. It takes 96 ms with the voltage 2.92 V to send 42 bytes (46 4). Thus,
power consumption to send 1 byte, 11 bytes and 18 bytes are 0.12 mJ, 1.32 mJ and 2.16 mJ,
respectively.
We repeated this experiment with output power set to different values and surprisingly no change
was made in the power consumption of sending operation. The only change was in the power
consumption used in sending the preamble bits; the less output power was set, the more deviation
from the main course of power consumption was seen. For example setting the output power to 3 (-25
dBm) led to the following trace:
27
We did this experiment setting different output power through both the methods mentioned before, i.e.
setting globally and dynamically. Still the power consumption was the same for all the output power
settings. Our conjecture is that TinyOS does not control the output power of CC2420 correctly.
There is listening for the duration of 10 ms before the data is received. This is one of those short
periodic receive checks shown in figure 4.10. As it is seen, less power is used in receiving mode than
listening mode. Voltage for listening operation is 3.2 V, hence P 0.58 mJ.
The time for receiving operation is roughly the same as sending operation for transmission of a
packet, but the voltage decreases to 2.88 V. Therefore, the power consumption to receive 1 byte, 11
bytes and 18 bytes are 0.12 mJ, 1.3 mJ and 2.13 mJ, respectively.
29
On average 174 mV for the duration of 2.61 ms was consumed to read one byte from the flash.
Hence P 0.0082 mJ.
30
0.2 nJ
Comparing these two results, we see that one bit transmitted by radio consumes about as much power
as executing 75,000 instructions. Thus, power consumption of routings is large enough to overshadow
the power consumed by the other operations. We focus on the power consumption of routings to
decide the lifetime of a WSN.
31
hops. Figure 5.1 shows an example of such network. This model assumes that all nodes transmit at the
same constant power.
The term balls of radius i denoted B is introduced in this model such that B
S
S . Some
|S |, b
|B |, N |V|. Using these definitions, a lower bound on the
other definitions are: s
energy consumption for a node in is:
(5.1)
where r is the energy consumed for receiving one packet and t is the energy consumed for
transmitting one packet. In the equation above, N b is the total number of nodes outside B and thus
the total number of packets that the set of nodes in sphere S receive in each iteration. The nodes in S
must transmit all the packets they receive plus their own packets. The minimum energy consumption
is when the total number of packets received and transmitted is equally divided among the nodes in S .
If we find minimum energy consumption for nodes in different spheres, the lower bound on the
energy consumption of a node in the whole network will be:
(5.2)
,,
The total number of packets received at each iteration at a node cannot exceed N s
1.
Likewise, the total number of packets transmitted cannot exceed N s . Thus, the upper bound on the
energy consumption of a node in the whole network will be:
.
(5.3)
Suppose each node has the exact same amount of energy EE. So the maximum number of
iterations, T , a sensor network can perform within its lifetime is as follows:
32
(5.4)
.
,,
preambles or consecutive packet repetition in the senders side or long listening period in the
receivers side.
In order to measure the lower and upper bounds of the energy consumption of routings based on
the framework of IEEE 802.15.4 for a network in which every node transmits a packet with size n at
each iteration, we proceed as follows:
(5.8)
1
17
(5.9)
11
(5.10)
1
17
(5.11)
11
(An important note is that there is no listening before receiving the acknowledgment frame by the
transmitter of the data frame, and no CCA before sending the acknowledgment frame by the receiver
of the data frame.)
(5.12)
(5.13)
(5.14)
,,
(5.15)
(Definition of variables in equations 5.14 and 5.15 can be found in section 5.1.)
3.54
4.03
(5.16)
(5.17)
Tmote Sky sensor motes use 2 AA batteries with the total amount of 30780 Joules.
Example: Consider a network consisted of 29 nodes as depicted in figure 5.1. The nodes are
Tmote Sky sensor motes (with CC2420 radios), and in the intervals of 10 seconds send packets with
2-byte data payload. In each iteration, every node transfers its own data plus the data coming from the
outer spheres (but leaves that only transfer their own data) to the inner spheres, and finally all the
packets are collected at the base station. To calculate the lifetime bounds, we work as follows:
E send
0.12 2 3.54 3.78 mJ
E receive
0.12 2 4.03 4.27 mJ
s
4, b
5, m
52.08
mJ
6, b
11, m
27.93
mJ
s
s
10, b
21, m
10.22
mJ
s
8, b
29, m
3.78
mJ
max m , , m
52.08
mJ
30780
30780
T
139194
52.08 10
221.13 10
591014
Considering the 10-second intervals, the lower lifetime bound will be about 387 hours and the upper
lifetime bound 1642 hours.
In this example, the bottle neck is S , the sphere which in fact determines the upper bound. By
better positioning the nodes, it is possible to spread the load of packet transmissions approximately
equally on all the nodes and improve the upper bound.
In case the base station does not need hard real-time evaluation of the data sent by the nodes, it is
possible for the nodes to aggregate their data and send it in longer intervals. This way we can improve
the bounds significantly. Imagine in the previous example the nodes instead of sending packets
consisting 2-byte data payload every 10 s, aggregate data and send packets with 6-byte data payload
every 30 s. The lower bound will be 1036 hours and the upper bound 4398 hours. Comparing with the
previous result, the bounds are now about 3 times more. The reason is obvious; the fixed component
of the linear equation, which determines the power consumed to acquire the channel, and to send and
receive acknowledgment frame and header and footer of the packet, is much higher than the
incremental component for CC2420.
35
In this potential simulator, there is no need to do direct execution or binary translation. In fact, we
don't need to handle the code of the tasks and go through all the commands of a large number of
sensor motes and run them. Instead, the pre-specified radio operations of the motes along with some
extra information like the positioning of the motes and their radio sphere of influence are input into
the simulator. The simulator then provides the information like the order of the nodes dying, or
suggests the best possible positioning of the nodes. We can check the results of different possible
implementations of the same task in this simulator and choose the most efficient one regarding power
consumption. This method can work well with synchronous applications. Since most of the
applications in WSNs are synchronous, this can be of great benefit to the developers. However, it can
be extended to address the asynchronous applications too.
This potential method is rather close to the method explained in section 1.2.1, overall power usage
approximation. But our proposed method goes a step further and instead of challenging with the
duration of the time the radio is operating, it works with the size of the packets transmitted between
the nodes and the intervals between transmissions.
36
Chapter 6: Conclusion
In this work, we investigated different experimental methods to measure the power consumption of
sensor motes. At the end, we decided the best measurement setup for this purpose is to insert a small
resistance between the power supply and the mote to decrease the effect of measurement interference.
Using an instrumentation amplifier, we magnified the traces and could precisely track the changes in
the amount of energy supplied to the mote during different operations.
Using this measurement setup, we went through a series of experiments to obtain the power
consumption of different components of Tmote Sky sensor mote while doing specific operations. We
estimated the power consumed at different power states of the microcontroller MSP430. Also the
power consumed to write/read 1 byte of data into/from external flash memory of Tmote Sky was
measured. Then, after exploring IEEE 802.15.4 standard, we did some measurements on CC2420
radio, which is compliant with this standard. Power consumption to send and receive 1 byte of data
payload, header and footer of the data frame, acknowledgment frame, and clear channel assessment
and listening operations was computed. Summary of our measurements is shown in figure 6.1.
Mode
Power
Radio
CCA
Sending 1 byte
Sending acknowledgment frame
Sending header and footer of data frame
Listening (periodic receive check)
Receiving 1 byte
Receiving acknowledgment frame
Receiving header and footer of data frame
0.08 mJ
0.12 mJ
1.32 mJ
2.16 mJ
0.58 mJ
0.12 mJ
1.3 mJ
2.13 mJ
Mode
CPU
Active mode
LPM0 and LPM1
LPM2 and LPM3 and LPM4
External Flash
Reading 1 byte
Writing 1 byte
Power
4.898 mW
0.504 mW
0.144 mW
0.0082 mJ
0.0349 mJ
Later, we presented how to compute the lower and upper lifetime bounds of WSNs using the
results from our radio operation measurements. Also categorizing different simulators, we proposed a
new simulator based on the method devised to compute the bounds. For future work, we plan to
implement this simulator.
Computing the lifetime bounds, although we concentrated on IEEE 802.15.4 frames, this method
can be extended to any type of frame used in the other standards for wireless data transmission. We
did not discuss the effect of different Network topologies supported in 802.15.4 (star or peer-to-peer)
in our measurements. Also we did not take into consideration the presence of coordinators and
beacons and superframe structures. Adding them will lower the lifetime bounds. However to provide
more precise bounds, it is desirable to work on these concepts in future work.
37
References
1. D. Raskovic, Energy-efficient Hierarchical Processing in the Network of Wireless Intelligent
Sensors (WISE), Ph.D. Thesis, ECE Dept., University of Alabama in Huntsville, 2004.
2. A. Milenkovic, M. Milenkovic, E. Jovanov, D. Hite, D. Raskovic, An Environment for Runtime
Power Monitoring of Wireless Sensor Network Platforms, 2005.
3. H. Ritter, J. Schiller, T. Voigt, A. Dunkels, J. Alonso, Experimental Evaluation of Lifetime
Bounds for Wireless Sensor Networks.
4. M. Rosenblum, S. Herrod, E. Witchel, and A. Gupta, Complete Computer System Simulation:
The SimOS Approach, IEEE Parallel and Distributed Technology, 3(4), Winter 1995.
5. The network simulator:
http://www.isi.edu/nsnam/ns/
6. E.A. Brewer, C.N. Dellarocas, A. Colbrook, and W. E. Weihl, PROTEUS: A High-Performance
Parallel-Architecture Simulator, MIT Technical Report MIT/LCS/TR-516, Sept. 1991.
7. P. Levis, N. Lee, M. Welsh, and D. Culler, TOSSIM: Accurate and scalable simulation of entire
TinyOS applications, In Proceedings of the first ACM Conference on Embedded Networked
Sensor Systems (SenSys) 2003, Nov. 2003.
8. M. Karir. atemu Sensor Network Emulator / Simulator / Debugger.
http://www.isr.umd.edu/CSHCN/research/atemu/
9. V. Shnayder, M. Hempstead, B. Chen, G. W. Allen, and M. Welsh, Simulating the Power
Consumption of Large-Scale Sensor Network Applications.
10. Book: A designers guide to instrumentation amplifiers, by C. Kitchin and L. Counts.
11. Analog Devices AD620 Instrumentation Amplifier:
http://www.analog.com
12. AD620: Low Cost Low Power Instrumentation Amplifier:
http://www.analog.com/static/imported-files/data_sheets/AD620.pdf
13. Tektronix TDS2012B Oscilloscope:
http://www.tek.com
14. Analog devices: Evaluation Boards for the AD620 Series and the AD8220 Series Instrumentation
Amplifiers.
15. Tmote Sky Datasheet:
http://sentilla.com/files/pdf/eol/tmote-sky-datasheet.pdf
16. J. Hill, R. Szewczyk, A. Woo, S. Hollar, D. Culler, K. Pister, System Architecture Directions for
Networked Sensors.
17. TEP 2 Hardware Abstraction Architecture:
http://www.tinyos.net/tinyos-2.x/doc/txt/tep2.txt
18. TinyOS 2.0 Overview:
http://www.tinyos.net/tinyos-2.x/doc/txt/overview.txt
19. TEP 112 Microcontroller Power Management:
http://www.tinyos.net/tinyos-2.x/doc/txt/tep112.txt
20. MSP430 16-bit Ultra-Low Power MCUs:
38
http://www.ti.com/msp430
21. Book: MSP430 Microcontroller Basics, by J. Davies - Page: 198.
22. CC2420 datasheet:
http://focus.ti.com/lit/ds/symlink/cc2420.pdf
23. IEEE Std. 802.15.4 2003: Wireless Medium Access Control (MAC) and Physical Layer (PHY)
specifications for Low Rate Wireless Personal Area Networks (LR-WPANs):
http://standards.ieee.org/getieee802/download/802.15.4-2003.pdf
24. TEP 105 Low Power Listening:
http://www.tinyos.net/tinyos-2.x/doc/txt/tep105.txt
25. Storage TinyOS Documentation Wiki:
http://docs.tinyos.net/index.php/Storage
26. J. Alonso, A. Dunkels, T. Voigt, Bounds on the Energy Consumption of Routings in Wireless
Sensor Networks, In Modeling and Optimization in Mobile, Ad Hoc and Wireless Networks,
Cambridge, UK, March 2004.
27. S. Tilak, N. Abu-Ghazaleh, W. Heinzelman, A Taxonomy of Wireless Micro-sensor Networks,
ACM Mobile Computing and Communications Review, 6(2), 2002.
28. L.M. Feeney, M. Nilsson, Investigating the Energy Consumption of a Wireless Network
Interface in an Ad Hoc Networking Environment.
39