mobile agent programming concepts

39
Mobile Agent Programming Concepts FK

Upload: tex

Post on 23-Feb-2016

48 views

Category:

Documents


1 download

DESCRIPTION

Mobile Agent Programming Concepts. FK. Dimensions of mobility. Moving between different execution servers (processes, hosts) Moving in time Moving with the user (execution server) Moving between contexts. Properties of agent execution environments. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mobile Agent Programming Concepts

Mobile Agent ProgrammingConcepts

FK

Page 2: Mobile Agent Programming Concepts

Dimensions of mobility

• Moving between different execution servers (processes, hosts)

• Moving in time• Moving with the user (execution server)• Moving between contexts

Page 3: Mobile Agent Programming Concepts

Properties of agent execution environments

• Static network (fixed host network address)• Roaming network (dyn. host netw. address)• Reliable real-time (stationary server computer)• Intermittent real-time (laptop, iPhone)• True persistence (Hard-disc, NV-RAM)• Volatile persistence (battery RAM)

Page 4: Mobile Agent Programming Concepts

Properties of agent execution environments

Static network addressReliable realtimeTrue persistence Dynamic network address

Intermittent realtimeTrue persistence

Dynamic network addressIntermittent realtimeVolatile persistence

Page 5: Mobile Agent Programming Concepts

Properties of agent execution environments

Network address

Static

Dynamic

Real-time

Persistence

Intermittent

Volatile

Cell phonesEarly wearables

Laptops

Servers

Page 6: Mobile Agent Programming Concepts

Dynamic network address

• Difficult to find a particular host• Needs registration at a well-known name• LAN: local discovery techniques (eg Jini)• WAN: remote interaction (eg SIP)• Network Address Translation (NAT)

imposes similar problem• IPv4 → IPv6 : needed but costly

Page 7: Mobile Agent Programming Concepts

Intermittent real-time

• If the agent is suspended externally, eg by power management, it may not “see” the suspension.

• Can the agent control power mgmt when it needs to?

• Small devices (mobile phones) may be suspended without warning.

Page 8: Mobile Agent Programming Concepts

Volatile persistence

• How much of the present state must be saved?• To where can it be saved?• How to (re)establish state after

reanimation?• How can the saved state be found?• Time (how long was the agent asleep?)

Page 9: Mobile Agent Programming Concepts

Planned discontinuity (1)

Z z1. Save state

2. Set timer

3. Sleep 4. Wake up

5. Restore state

Page 10: Mobile Agent Programming Concepts

Planned discontinuity (2)

1. Save state

2. Terminate

3. External event

5. Restore state

4. Restart

Page 11: Mobile Agent Programming Concepts

Planned discontinuity (3)

2. Save state3. Terminate

1. Negotiate hosting

6. Restore state5. Restart

4. Transfer identity and state

Page 12: Mobile Agent Programming Concepts

Mobile code (1)

4. Terminate

2. Negotiate hosting

5. Continue

3. Transfer identityand state

Initial execution environment

Next execution environment

1. Locate exec. env.

Page 13: Mobile Agent Programming Concepts

Mobile code (2)

7. Terminate

2. Negotiate hosting

5. Continue

3. Transfer identityand state

Initial execution environment

Next execution environment

1. Locate exec. env.

6. Acknowledge

Page 14: Mobile Agent Programming Concepts

What do we mean by “state”?

• Memory and cpu configuration of process• Values of active variables (including call

stack) and the execution point• A classifiable subset of the true state:

switch (myState) {case 0: /* state 0 */ break;case 1: /* state 1 */ break; // etc...}

Page 15: Mobile Agent Programming Concepts

State (cont’d)

• For the programmer, state and code are often the same concept

• Mobile code (e.g. Java) may not be able to transfer the execution point

• This breaks the code-state relationship

Page 16: Mobile Agent Programming Concepts

State (cont’d)

y = y*2

Migrate?

z = y

START

Yes

Noy = y*2

Migrate?

z = y

START

No

y==1

y==2

z==2

z==4

Variables evolve whilecode point is reset

Page 17: Mobile Agent Programming Concepts

Goal-driven execution

• The task can be expressed as a sequence of discrete steps

• The accomplishment of each step can be tested

• What to do next is computable

Page 18: Mobile Agent Programming Concepts

Goal-driven execution (cont’d)Task: Deliver a message (to a user)

The message is executable and mustrun on the recipient’s current host.

Page 19: Mobile Agent Programming Concepts

Goal-driven execution

while (true) doif (the current host is the user host) then

execute the messageexit

elselocate the user hostmove to user host

endifdone

Page 20: Mobile Agent Programming Concepts

Goal-driven execution

• Gets complicated quite fast, e.g. remember failures, responses, a dialogue...

• State must be ”knitted” into the task resolution structure

• Goal stack approach

Page 21: Mobile Agent Programming Concepts

Goal stack interpreter

• Useful for intermittent real-time (wearable devices, power management)

• The goal stack is maintained as a data structure

• The goal on top of the stack is either replaced by a sequence of subgoals, or executed as an idempotent unit until it succeeds

Page 22: Mobile Agent Programming Concepts

Goal stack interpreter

Deliver message to Ralph

Establish host of Ralph

Move to Ralph’s host

Execute message code

Establish host of Ralph

Move to Ralph’s host

Execute message code

Goal expansionExecute

goal-code

Popstack

Y

N

Fail?

Emptystack?

N

StopY

Move commandedby external eventshas small impacton top-most goal.

Page 23: Mobile Agent Programming Concepts

Goal stack interpreter

Move to Ralph’s host

Execute message code

Executegoal-code

Popstack

Current goal

N

Fail?

Emptystack?

N

StopY

Establish host of Ralph

Move to Ralph’s host

Execute message code

Current goal

Y

Pop

Page 24: Mobile Agent Programming Concepts

Layers of abstraction

Task

Transport

Discovery

Communication

Page 25: Mobile Agent Programming Concepts

Layers of abstraction

Task

Transport

Discovery

Communication

Code for identifying and approaching the goal.

Page 26: Mobile Agent Programming Concepts

Layers of abstraction

Task

Transport

Discovery

Communication

Code for identifying and approaching the goal.

Code for moving the agent between places of execution.

Page 27: Mobile Agent Programming Concepts

Layers of abstraction

Task

Transport

Discovery

Communication

Code for identifying and approaching the goal.

Code for moving the agent between places of execution.

Methods for finding (the addresses) to resources.

Page 28: Mobile Agent Programming Concepts

Layers of abstraction

Task

Transport

Discovery

Communication

Code for identifying and approaching the goal.

Code for moving the agent between places of execution.

Methods for finding (the addresses) to resources.

Sending the bits of the agent to another place.

Page 29: Mobile Agent Programming Concepts

Agent enabling middleware

• Discovery mechanisms (execution hosts, other agents, negotiation partners ...)

• Addressing namespaces (IP, URLs, SIP, RMI)• Communication means (netw. stack)• Protocol (language and semantics)

Page 30: Mobile Agent Programming Concepts

Game of Tag for agents

• Discover execution environments• Query properties of the exec. env.• Locate other agents• Negotiate for status (being ‘it’ or not)• Transaction (reliably transferring ‘it’

between players)• Multiple roles and tasks dep. on being ‘it’.

Page 31: Mobile Agent Programming Concepts

TAG player outline

Acquire state of game

Decide what to do

Execute choice

Page 32: Mobile Agent Programming Concepts

TAG player outline

Locate all Bailiffs and players

Am I it?

Move toa Bailiff

with players

Isthe ’it’ player

here?

YES NO

YES

Move toanother Bailiff

NO

Move or waitaccording to

strategy

Isthere a player

here?

YESNO

Tag aplayer

Page 33: Mobile Agent Programming Concepts

TAG player outline

Locate all Bailiffs and players

Am I it?

Move toa Bailiff

with players

Isthe ’it’ player

here?

YES NO

YES

Move toanother Bailiff

NO

Move or waitaccording to

strategy

Isthere a player

here?

YESNO

Tag aplayer

State informationmust be updated

Page 34: Mobile Agent Programming Concepts

TAG player outline

Locate all Bailiffs and players

Am I it?

Move toa Bailiff

with players

Isthe ’it’ player

here?

YES NO

YES

Move toanother Bailiff

NO

Move or waitaccording to

strategy

Isthere a player

here?

YESNO

Tag aplayer

Seek to be lonelySeek companyAct randomly

Page 35: Mobile Agent Programming Concepts

TAG player outline

Seek to be lonelySeek companyAct randomly

Page 36: Mobile Agent Programming Concepts

TAG player outline

Seek to be lonelySeek companyAct randomly

Page 37: Mobile Agent Programming Concepts

TAG player outline

Seek to be lonelySeek companyAct randomly

Page 38: Mobile Agent Programming Concepts

TAG player outlineThe lonely strategy• increases the chance that the it player goes to another Bailiff• makes the player faster• needs as many Bailiffs as there are players, but no more• with fewer Bailiffs it approaches the company strategy

The company strategy• increases the chance that the it player tags another player• needs fewer Bailiffs• makes the player slower

Page 39: Mobile Agent Programming Concepts

End