Incremental Network Programming for Wireless Sensors

21
Incremental Network Programming for Wireless Sensors IEEE SECON 2004 Jaein Jeong and David Culler UC Berkeley, EECS

description

Incremental Network Programming for Wireless Sensors. IEEE SECON 2004 Jaein Jeong and David Culler UC Berkeley, EECS. Sensor nodes. …. Sensor node. Serial or parallel port. Host Machine. Program Code. Radio Channel. Host Machine. In system programming. Program Code. - PowerPoint PPT Presentation

Transcript of Incremental Network Programming for Wireless Sensors

Page 1: Incremental Network Programming for Wireless Sensors

Incremental Network Programming for Wireless Sensors

IEEE SECON 2004Jaein Jeong and David Culler

UC Berkeley, EECS

Page 2: Incremental Network Programming for Wireless Sensors

Introduction –Loading Program to Wireless Sensors

• In System Programming– Most Common.– Programming time is in

proportion to # nodes.

• Network Programming– Sending whole code over

radio still takes time.

HostMachine

ProgramCode

Sensor nodeSerial orparallel

port

In system programming

Network programming

HostMachine

ProgramCode

RadioChannel

Sensor nodes

Page 3: Incremental Network Programming for Wireless Sensors

Introduction – Incremental Network Programming

• Program source code is changed in small amounts.

• Reduce programming time by sending the difference.

Incremental Network programming

HostMachine

Program CodeVersion 1

Radio Channel

Sensor nodes

Program CodeVersion 2+

Difference

Page 4: Incremental Network Programming for Wireless Sensors

Previous Work

• Single-hop Network Programming: XNP

• Multi-hop network programming: MOAP, Deluge– Extends the Range

• Incremental network programming: Reijers / Kapur – Reduces the Programming Time

• Virtual machine programming: Maté / Trickle– Small Application Level Code

• Our incremental network programming approach– Difference Generation using Rsync.– Platform independent solution.

Page 5: Incremental Network Programming for Wireless Sensors

Network Programming Steps –Incremental Network Programming

(1) Encoding: Generates the difference.(2) Dissemination: Transmits the difference.(3) Decoding: Rebuilds the new code.

User appbinary

DisseminationData

RadioPackets External

Flash

UserApplication

Section

Boot loaderSection

Host Machine Sensor Node(1) Encode (2) Dissemination (3) Decode

HostMachine

Sensor node

Page 6: Incremental Network Programming for Wireless Sensors

Design Considerations

• Reduce the amount of data transmission.

• Minimize the access to the external flash memory.

• Avoid expensive operations for sensor nodes.

Page 7: Incremental Network Programming for Wireless Sensors

Step 1: Difference Generation (Encoding) –Storage Organization

• Program Memory– Running Program

• External Flash Memory– Program images for

previous / current versionExternal Flash

L bytes Previous Image

ProgramMemory

Boot loader

New Image

For others

On-chip Memory

Sensor Node Memory

SRAM

Internal Flash

User Program(L bytes)

L bytes

Page 8: Incremental Network Programming for Wireless Sensors

Step 1: Difference Generation (Encoding) –First Approach: Fixed Block Comparison

• Comparing at fixed sized blocks:– Doesn’t work when code is shifted.

B bytes

B bytes

B bytes

Remaining

PreviousProgram

Image

NewProgramImage

B bytes

B bytes

B bytes

=?

n bytes

shift

insert

Page 9: Incremental Network Programming for Wireless Sensors

Step 1: Difference Generation (Encoding) –First Approach: Fixed Block Comparison

• Comparing at every byte:– Finds shared blocks with high cost.

• Need an efficient way of finding shared blocks.

B bytes

B bytes

B bytes

Remaining

PreviousProgram

Image

NewProgramImage

B bytewindow

=? For each byte

Page 10: Incremental Network Programming for Wireless Sensors

Step 1: Difference Generation –How to Find Shared Blocks Efficiently?

• Two level checksums (Idea of Rsync algorithm)– Finds a matching code block quickly with high accuracy. – Checksum (1st level): Fast but not accurate (32-bit).

– Hash (2nd level): Not fast but very accurate (128-bit).

Hash Table(Checksum, Hash)

NewProgramImage

B bytewindow

For each byte

B bytes

B bytes

B bytes

Remaining

PreviousProgram

Image

=? Checksum

Hash

Page 11: Incremental Network Programming for Wireless Sensors

Step 1: Difference Generation –Using Rsync Algorithm

(1) Build hash table for previous image.(2) For the window of new image, calculate checksum.(3) Lookup hash table.

– For a matching checksum, calculate hash.– Otherwise, move to the next byte and repeat (2).

Hash Table(Checksum, Hash)

NewProgramImage

B bytewindow

For each byte

B bytes

B bytes

B bytes

Remaining

PreviousProgram

Image

=? Checksum

Hash

(1)

(2)(3)

Page 12: Incremental Network Programming for Wireless Sensors

Step 2: Dissemination –Modified Rsync Protocol for Wireless Sensors

• Modified Rsync protocol for resource constrained sensor nodes.

Sender Receiver(1) Asks version

of blocks

(2) Sends checksum list

(3a) Sends difference(4) Rebuilds

the latest version

(3) Compares checksums &

generatedifference

Original Rsync algorithm

Sender Receiver

(3) Sends thedifference.

(4) Rebuilds the latest version

(1) Calculatesthe checksums.

(2) Generates the difference

Modified Rsync algorithm

Page 13: Incremental Network Programming for Wireless Sensors

Step 3: Decoding –Program Rebuild during Code Delivery

• Host sends difference as a sequence of messages.• Sensor rebuilds new image using the diff.• Optimizing Flash Memory Access

– Copy blocks are aligned to flash memory record boundary.

Previous ProgramImage

New ProgramImage

Copy

DownloadDownload Copy

DifferenceMessage

Matching block

Non-maching block

Host Machine Sensor Node

Page 14: Incremental Network Programming for Wireless Sensors

Experiment Setup

• Test Platforms: MICA2 / MICA2DOT• Test Applications

– Simple network programmable app: XnpBlink and XnpCount.

• Test Steps– Test app code and modified code are given to host program.– Compare the xmit time with that of XNP (non-incremental).

+ DisseminationData

HostProgram

TestApplication

Modified TestApplication

Sensornodes

Page 15: Incremental Network Programming for Wireless Sensors

Experiment Setup – Test Cases

• Case 1: Changing a constant (XnpBlink)

• Case 2: Modifying implementation file (XnpCount)

command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT, 1000);}

event result_t Xnp.NPX_DOWNLOAD_DONE (uint16_t wProgramID, uint8_t bRet, uint16_t wEENofP){ if (bRet == TRUE) call CntControl.start(); else call CntControl.stop(); return SUCCESS;}

• Case 3: Major change (XnpBlink XnpCount)

Page 16: Incremental Network Programming for Wireless Sensors

Experiment Setup – Test Cases

• Case 4: Modifying configuration file (XnpCount)– Commented out IntToLeds component.

• Case 5: Modifying configuration file (XnpCount)– Commented out IntToRfm component.

configuration XnpCount { }implementation { components Main, Counter, /*IntToLeds,*/ /*IntToRfm,*/ TimerC, XnpCountM, XnpC; // Main.StdControl -> IntToLeds.StdControl; // IntToLeds <- Counter.IntOutput; // Main.StdControl -> IntToRfm.StdControl; // Counter.IntOuput -> IntToRfm;}

Page 17: Incremental Network Programming for Wireless Sensors

Results

• Fixed Block Comparison: Almost no speedup except for case 1.• Using Rsync algorithm:

– Speed up of 2 to 2.5 for a small change (case 2 and 4).– Still limited speed up for big changes (case 3 and 5).

0.00

1.00

2.00

3.00

4.00

5.00

6.00

7.00

Case 1 Case 2 Case 3 Case 4 Case5

Sp

ee

d u

p

Estimated Speed Up (Fixed)Measured Speed Up (Fixed)Estimated Speed Up (Rsync)Measured Speed Up (Rsync)

ModifyingConstant

CommentLines

XnpBlink toXnpCount

CommentIntToLeds

CommentIntToRfm

Page 18: Incremental Network Programming for Wireless Sensors

Problems of Rebuild during Delivery –Difference Delivery Still Not Optimal

Difference is decoded without being stored.(1) Size of copy msg is limited to bound running time.

(2) Inefficient handling of missing copy msg.

DisseminationData

External Flash

Host Machine Sensor Node

RadioPackets

PreviousImage

NewImage

Forothers

Page 19: Incremental Network Programming for Wireless Sensors

Optimizing Difference Delivery

Solution: Separate difference delivery and decoding.

(1) Stores the difference script in the first step

(2) Rebuilds the program after receiving decode command.

PreviousProgramImage

NewProgram

Image

CMD_DOWNLOADINGCopy

DownloadDownload

Copy

ScriptCommands

PreviousProgramImage

NewProgramImage

download

copy

CopyDownloadDownload

Copy

ScriptCommands

download

CMD_DECODE_SCRIPT

Page 20: Incremental Network Programming for Wireless Sensors

Results – Using Rsync with separate decode• The performance of using Rsync algorithm with separate

decode command is similar to just using Rsync.• But, the performance for changing a constant has improved

(speed up of 9.1).

0.00

1.00

2.00

3.00

4.00

5.00

6.00

7.00

8.00

9.00

10.00

Case 1 Case 2 Case 3 Case 4 Case5

Sp

eed

up

Fixed Block ComparisonRsyncRsync + decode

ModifyingConstant

CommentLines

XnpBlink toXnpCount

CommentIntToLeds

CommentIntToRfm

Page 21: Incremental Network Programming for Wireless Sensors

Conclusion

• Faster network reprogramming using incremental update. • Platform independent solution using Rsync algorithm.• Speed-up over non-incremental delivery

– 2 – 2.5 for changing a few lines.– 9.1 for changing a constant.

• Future Work– Extension for multi-hop delivery.