MAPS: A Mobile Agent Platform for WSNs based on Java Sun Spots

nationmattedΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 8 χρόνια και 8 μήνες)

427 εμφανίσεις

ATSN'09, Budapest, 12 May 2009

1

MAPS: A Mobile Agent Platform for WSNs based on
Java Sun Spots


F. Aiello,
Giancarlo Fortino
, R. Gravina, A. Guerrieri


Department of Electronics, Informatics and Systems (DEIS)

University of Calabria, Rende (CS), ITALY


g.fortino@unical.it

ATSN'09, Budapest, 12 May 2009

2

Motivations and Objectives


Wireless Sensor Networks (WSNs) are emerging as powerful
platforms for distributed embedded computing supporting a variety
of high
-
impact applications



However programming WSNs is a complex task due to the limited
capabilities and energy resources of each sensor node as well as
the lack of reliability of the radio channel.



Moreover, WSN programming is usually application
-
specific (or
sometimes domain
-
specific) and requires tradeoffs in terms of task
complexity, resource usage, and communication patterns. Therefore
the developed software which usually integrates routing mechanisms,
time synchronization, node localization and data aggregation is
tightly dependent on the specific application and scarcely reusable.

2

ATSN'09, Budapest, 12 May 2009

3

Motivations and Objectives


Thus to support rapid development and deployment of flexible
WSN applications, WSN
-
aware programming paradigms are
needed which directly provide proactive and on
-
demand code
deployment at run
-
time as well as ease software programming at
application, middleware and network layer.



Among the programming paradigms proposed for the development
of WSN applications, the
mobile agent
-
based paradigm
, which has
already demonstrated its effectiveness in conventional distributed
systems as well as in highly dynamic distributed environments, can
effectively deal with the programming issues that WSNs have
posed.



We believe that mobile agents can provide more benefits in the
context of WSNs than in conventional distributed environments.

3

ATSN'09, Budapest, 12 May 2009

4

Motivations and Objectives


The objective of this paper is twofold:



we motivate the use of mobile agents as enabling paradigm
and technology for WSNs due to their distinctive features
able to effectively and efficiently deal with WSN network
dynamism and constrained resources.



we propose the design of a Java
-
based lightweight mobile
agent
-
based framework for WSNs which provide a flexible
and extensible distributed programming environment for
WSN applications and services.


4

ATSN'09, Budapest, 12 May 2009

5

Outline


Mobile Agents in WSNs: restyling the 7 good reasons


Related Work


A

Mobile

Agent
-
based

Framework

for

WSNs
:

architecture

and

programming

model


A

simple

programming

example


Performance

evaluation


Conclusions and on
-
going work

ATSN'09, Budapest, 12 May 2009

6

Mobile Agents in WSNs


Mobile agents are a distributed computing paradigm
particularly suitable for supporting the development of
distributed applications, services, and protocols in conventional
distributed systems as well as in highly dynamic distributed
environments.



A mobile agent is a software process able to migrate from one
computing node to another by retaining its execution state.



As advertised by Lange and Oshima in their seminal paper,
there are at least 7 good reasons (
Network load reduction
,
Network
latency overcoming
,
Protocol encapsulation
,

Asynchronous and autonomous
execution,
Dynamic adaptation, Orientation to heterogeneity,

Robustness and
fault
-
tolerance
) to use mobile agents

ATSN'09, Budapest, 12 May 2009

7

Mobile Agents in WSNs: 7 good
reasons


Network load reduction


Mobile agents can access remote resources (e.g. databases, data repositories,
sensors) or communicate with remote mobile/stationary agents or with other
software components, by moving to their locations and interacting with them
locally so saving network resources such as bandwidth during the interaction
phase.


An example: “
A sensor node periodically transmits the sensed data to a sink node
which, in turn, processes them to extract some aggregated information
”.


The transmission of the sensed data from the sensor node to the sink node consumes
bandwidth in the path from the sensor node to the sink node (this effect is much more
remarkable in multi
-
hop paths than in single
-
hop paths).


A mobile agent incorporating the data processing algorithm can migrate to the
sensor node and locally apply this algorithm so reducing bandwidth consumption.
Finally, the mobile agent should also transmit the aggregated data to the sink node
but, in this case, the consumed bandwidth is much lower than the bandwidth needed
for the transmission of raw sensed data.


ATSN'09, Budapest, 12 May 2009

8

Mobile Agents in WSNs: 7 good
reasons


Asynchronous and autonomous execution


Asynchrony and autonomy are distinctive properties of mobile agents. Once
injected into the network, mobile agents can autonomously carry out the
programmed tasks and support disconnected operations by operating
asynchronously with respect to the process or device that has generated them.
These properties are very important in dynamic environments where the network
topology rapidly changes and connections are not stable so that they can be
established only for short time periods.


An example: “
Periodically the WSN manager queries all the nodes (or a node
subset) of its WSN to have a snapshot of the energy consumption
”.


To this purpose, a mobile agent, spawn by the manager, can autonomously travel
across the network to gather the requested information “node by node” and,
finally, asynchronously report this information to its owner.

ATSN'09, Budapest, 12 May 2009

9

Mobile Agents in WSNs: 7 good
reasons


Robustness and fault
-
tolerance


As mobile agents possess the ability to react dynamically to unfavorable
situations and unexpected events, they can support the construction of robust and
fault tolerant distributed systems.


An example: “
A sensor node is going to be shut down due to uncharged batteries so
the sensing activity should be activated on a neighbor sensor node at run
-
time
”.


All the mobile agents executing on the uncharged sensor node can (autonomously
or passively) migrate to another equivalent node (already present or newly
introduced) so continuing their activity after migration.

ATSN'09, Budapest, 12 May 2009

10

Mobile Agents in WSNs: available
MAS


MAS for conventional platforms:


Java
-
based: Aglets, Ajanta, Voyager, Jade, etc…


Non
-
Java
-
based: D’Agents, ARA, etc…



MAS for WSNs:


Agilla (very lightweight, tuple
-
space, TinyOS)


SensorWare (TCL, iPAQ)


Variants/Extensions of Agilla (message comms)


actorNet (functional language, TinyOS)


Agent Factory Micro Edition (AFME, J2ME for smartphones/PDAs)

ATSN'09, Budapest, 12 May 2009

11

MAPS: Requirements


Lightweight agent architecture
, so that agents can be efficiently
executed and migrated.


Minimal core services

to provide agent migration, sensing capability
access, agent naming, agent communication, and timing.


Plug
-
in
-
based architecture extensions
, which allows to define any other
service in terms of one or more dynamically installable components (or
plug
-
ins) implemented as single mobile agent or cooperating mobile
agents.


Layer
-
oriented mobile agents
, which are natively characterized on the
basis of the layer to which they belong: application, middleware and
network layer. They must be also able to locally interact to enable
cross
-
layering.


Programming language of the sensor node platform
.

ATSN'09, Budapest, 12 May 2009

12

MAPS: MAS architecture

MA
APP
MAEE
MA
MW
MA
NET
MAMM
RM
TM
MACC
VM
/OS
MAN
MA - Mobile Agent (
APP
- Application Layer,
MW
-
Middleware
Layer, NET - Network Layer)
MAEE
- Mobile Agent Execution Engine
MAMM
- Mobile Agent Migration Manager
MACC
- Mobile Agent Communication Channel
MAN - Mobile Agent Naming
RM
- Resource Manager
TM
- Timer Manager
ATSN'09, Budapest, 12 May 2009

13

MAPS: agent architecture

<<
GV
>>
<<
GF
>>
S1
S2
S3
E
D
ECAA
core primitives
t
1
t
2
t
3
t
4
<<
LV
>>
<<
LF
>>
ED
MPSM
Plane
i

MPSM=Multi
-
plane State Machine


ECAA=Event/Condition/Action Automaton


GV=Global Variables


GF=Global Functions


LV=Local Variables


LF=Local Functions


ED=Event Dispatcher

ATSN'09, Budapest, 12 May 2009

14

MAPS: agent primitives

send(SourceMA,
TargetMA
, EventName,
Params
, Local
)

SourceMA = id of the invoking MA

TargetMA = id of the MA target |

id of the Group target |

ALL for event broadcast
to neighbors

EventName = name of the event
to be
sent

Params
= set of event parameters encoded

as pairs <attribute, value>

Local = local (true) or remote (false) scoped event


create(SourceMA, MA
Id, MAType, Params, NodeLoc
)

MAId = id of the MA to be created

MAType = type of the MA to be created

Params = agent creation parameters

NodeLoc = node location of the created agent


cl
one(SourceMA, MAId, NodeLoc
)

MAId = id of the cloned MA

NodeLoc = node location of the cloned agent


migrate(SourceMA, NodeLoc
)

NodeLoc = target location of the MA
| ALL
neighbors

sense(SourceMA, IdSensor,
Params, BackEvent
)

IdSensor =
id of the sensor

Params
=
parameters for sensor readings

BackEvent
=

notifying

event containing the readings


actuate(SourceMA, IdActuator,
Params
)

IdActuator
=
id of the actuator

Params =
par
ameters for actuator writings


input
(SourceMA, BackEvent)

BackEvent = event notifying the
input
captured from the
switch


flash(SourceMA, Params, BackEvent)

Params = flash memory access parameters

BackEvent = event notifying the completion of the fla
sh
memory operation (if it is a read operation, it contains
the read data)


setTimer(SourceMA, Params, BackEvent)

Param
s =
timer parameters

BackEvent
=
event notifying the timer firing


resetTimer(SourceMA, IdTimer)

IdTimer
=
id of the timer to res
et

ATSN'09, Budapest, 12 May 2009

15

MAPS framework: Java Sun Spots


The Sun SPOT sensor nodes are based on the Squawk VM which is fully
Java compliant and CLDC 1.1
-
compatible.


In particular, the offered features are the following:


Java programming language


NetBeans IDE for software development


Single
-
hop/multi
-
hop and reliable/unreliable communications


Easy access to the sensor node devices


Code migration support



Java is used as language for programming events, conditions and actions of
the behavior of agents.

ATSN'09, Budapest, 12 May 2009

16

MAPS framework: class diagram

AppMIDLet
IMobileAgentServer
<<uses>>
MobileAgentServer
IMobileAgentExecutionEngine
<<uses>>
MobileAgentExecutionEngine
<<interface>>
<<interface>>
Agent
*
1
1
Plane
EventQueue
1..*
1
Isolate
IDispatcher
Dispatcher
<<interface>>
1
RequestSender
<<from
SunSpot
lib>>
InterIsolateServer
IMACCSender
MACCSender
<<interface>>
IMACCReceiver
MACCReceiver
<<interface>>
1
1
1
IMANaming
MANaming
<<interface>>
IMAMigrationMan
MAMigrationMan
<<interface>>
ITimerManager
TimerManager
<<interface>>
ISensorBoardMan
SensorManager
<<interface>>
IOManager
1
Event
*
*
1
Timer
*
1
1
1
ISensorBoardComponent
1..*
AcceleratorSensor
TemperatureSensor
LightSensor
FlashManager
SwitchInput
LedOut
1
AcceleratorListener
TemperatureListener
LightListener
*
*
*
ISensorBoardComponentListener
SwitchListener
*
1
1
1
1
ATSN'09, Budapest, 12 May 2009

17

A Simple MA
-
based Application: a
programming example


The mobile agent application is composed of three
agents:


DataCollector, which collects data sensed from the
temperature, light and accelerometer sensors of the
SunSPOT node;


DataMessenger, which is launched by the DataCollector
and carries collected sensed data from the sensing
node to the base station;


DataViewer, which displays the received collected
data.

ATSN'09, Budapest, 12 May 2009

18

The Data Collector

AGN
_Start/
A0
DATA
SENSING
START
TIMER
SEND
COLLECTED
DATA
MSG[go==true]/
A1
DATA
COLLECTED
TMR
_Expired/
A2
MSG[go==false]/
A4
SWT
_
PressedReleased
/
A3
AGN
_Id/
A9
TMP
_Current/
A5
ACC
_Tilt/
A6
LGH
_Current/
A7
SWT
_
PressedReleased
/
A3
[
dataColl
==
numData
]/
A8
ATSN'09, Budapest, 12 May 2009

19

The Data Collector

A0
:
byte [] fls = new byte[]{12,13,14,15,16};

Event l = new Event(agent.getId(), agent.getId(),

Event.FLS_ADD, Event.NOW);

agent.flash(l, fls);


A1:
Event timer =
new Event(
agent
.getId(),
agent
.getId(),



Event.TMR_EXPIRED, Event.NOW );



timerID =
agent
.setTimer(true, 3000, timer);



Event blink = new Event(
agent
.getId(),
agent
.getId(),



Event.LED_BLINK, Event.NOW);



blink.setParam(ParamsLabel.LED_INDEX, "0");




blink.setParam(ParamsLabel.LED_COLOR, "blue");


agent
.actuate(blink);


Event swt
Pressed = new Event(
agent.getId(),agent.getId(),

Event.SWT_PRESSED_RELEASED,
Event.PERMANENT);


swt
Pressed.setParam(ParamsLabel.SWT_PRESSED, "false
");


swt
Pressed.setParam(ParamsLabel.SWT_RELEASED, "true");


swt
Pressed.setParam(ParamsLabel.SWT_INDEX, "2");


agent
.
input
(
swt
Pressed);


A2:
Event temp
= new Event(
agent
.getId(),
agent
.getId(),


Event.TMP_CURRENT, Event.
NOW);


temp
.setParam(ParamsLabel.TMP_CELSIUS, "true");

agent.sense(temp
);



Event accel = new Event(
agent
.getId(),
agent
.getId(),


Event.ACC_TILT, Event.NOW);


agent
.sense(accel);



Event light = new Event(
agent
.ge
tId(),
agent
.getId(),


Event.LGH_CURRENT, Event.NOW);


agent
.sense(light);


A3:

agent
.create("test.Messenger", null,


agent
.getMyIEEEAddress().asDottedHex());


A4:

this.terminateAgent();


A5:
data
+=
event.getParam(Par
amsLabel.TMP_TEMPERATURE_VALUE)+
"
-
";


dataColl++


A6:

data+=
event.getParam(ParamsLabel.ACC_T
ILT_X_VALUE) + "
-
";

dataColl ++


A7:

data+=
event.getParam(ParamsLabel.LGH_LIGHT_VALUE);

dataColl++


A8:

data+=
"|";

Event blink = new Event(
agent
.getId(),
agent
.getId(),


Event.LED_BLINK, Event.NOW);

blink.setPara
m(ParamsLabel.LED_INDEX, "0");

blink.setParam(ParamsLabel.LED_COLOR, "blue");


agent
.actuate(blink);


dataColl
= 0;


A9:
Event msg = new Event(
agent
.getId(), messengerAgentID,

Event.MSG, Event.NOW);

msg.setParam("co
llectedData",
data
);


agent
.send(
agent
.getId(), messengerAgentID, msg, true);


data
= "";


ATSN'09, Budapest, 12 May 2009

20

Performance Evaluation


The used testbed for testing and evaluation consists
of a SunSPOT kit (two sensor nodes and one base
station) with the SDK 3.0 version (purple).


The MAPS framework has a memory occupation
(without any running agent) of about 70 Kbyte in
central memory, keeping free a space of 378
Kbyte. (ping
-
pong agent memory = 22KB)


Such space can be exploited for agent execution.


The space occupied by the jar of MAPS on the flash
memory is 92 Kbyte out of the 4 MB available.

ATSN'09, Budapest, 12 May 2009

21

Performance Evaluation


To evaluate the performance of MAPS three micro
-
kernel benchmarks have been defined for the
following mechanisms:


Agent communication


Agent creation


Agent migration

ATSN'09, Budapest, 12 May 2009

22

Performance Evaluation

0
500
1000
1500
2000
2500
3000
3500
100
200
300
400
500
600
700
800
900
1000
byte
ms
Data B&F
Data B
2100
2150
2200
2250
2300
2350
2400
1
11
21
31
41
51
plane
ms
Agent communication: request/reply time.


Agent creation time.

0
5000
10000
15000
20000
25000
30000
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
byte
ms
wi th MAPS
wi thout MAPS
Agent migration: ping
-
pong time.

The

obtained

migration

times

are

high

due

to

the

slowness

of

the

SquawkVM

operations

supporting

the

migration

process
.

In

particular,

serialization

is

a

very

costly

operation
:

serialization

of

the

ping
-
pong

agent

averagely

takes

4
.
5
s
.

Moreover,

radiostream

connections

are

very

slow

to

guarantee

reliability
.

ATSN'09, Budapest, 12 May 2009

23

Conclusions


This paper has proposed mobile agents as an enabling technology for programming WSNs.
We believe that, due to their specific characteristics, mobile agents can provide more benefits
in the context of WSNs than in conventional distributed environments.


To actually experiment with mobile agents in WSNs a mobile agent framework, named MAPS,
has been defined which provides an event
-
driven component
-
based architecture for
supporting agent execution, communication and migration.


Mobile agents are programmed according to a hybrid yet effective programming language which
integrates three major WSN programming paradigms (event
-
driven, state
-
based and mobile agent
-
based programming) along with the emerging role
-
based programming.


A programming example of mobile agents at middleware layer (data collection) has been also
presented and discussed to exemplify the proposed framework.


The framework is currently developed by using the innovative Sun SPOT technology which
allows for an easy programming of the sensor nodes in Java. In particular, both the agent
server and the mobile agents are implemented as
Isolates

(applications represented as
isolated threaded objects) which can be easily paused, migrated to a different sensor node
and restarted.


However, performance penalties do exist due to Java Sun Spot basic mechanisms (hibernation,
serialization, and reliable communications)

ATSN'09, Budapest, 12 May 2009

24

On
-
going Work


More detailed performance evaluation by using the last
version (Blue) of the SunSPOT SDK


Test Applications


Object tracking


Rumor routing


Data collection


Agent
-
based version of SPINE


Signal Processing In
-
Node
Environment (spine.tilab.com)


Activity monitoring of assisted livings by using MAPS
-
based SPINE


Porting on Sentilla sensor platform

ATSN'09, Budapest, 12 May 2009

25

MAPS


Mobile Agent Platform for
Java SunSPOTS



http://maps.deis.unical.it



Any questions ???