8/7/2019 Mobile Agent-1
1/68
Mobile Agent
8/7/2019 Mobile Agent-1
2/68
2
Main Content
Introduction of Mobile Agent
Aglets Tcl Agent
8/7/2019 Mobile Agent-1
3/68
3
Introduction
An information agentis charged with the
task of managing all or a portion of a users
information space.
The resources in this space are distributed
across a network and can contain
tremendous quantities of data.
8/7/2019 Mobile Agent-1
4/68
4
What is a Mobile Agent ?
A mobile agent is an executing program that can migrate from
machine to machine in a heterogeneous network under its own
control.
Here an agent has migrated to interact with a search engine ,an agent will
migrate again to bring the results back to its owner.
8/7/2019 Mobile Agent-1
5/68
5
A Mobile Agent Can Suspend execution at any point, transport its code and state
to another machine, and resume execution on the new
machine. An agent can access the resource locally and eliminate the
network transfer of all intermediate data.
Move the programmer away from the rigid client-server
model to the more flexible peer-peer model. Programs communicate as peers
Act as either clients or servers depending on their
current needs
8/7/2019 Mobile Agent-1
6/68
6
Introduction to
Mobile Agents What is Mobile Agents?
Mobility: Agents that can travel in network
Autonomy: migrate at times and to place oftheir own choosing
Compare to ..Stationary agent
Mobile code (Applets)
Mobile object
8/7/2019 Mobile Agent-1
7/68
7
Network Computing ParadigmsClient-Server Paradigm Code-onDemand Paradigm
Know-
how
ClientServer
ClientKnow-
how
Know
how Server
Download
(Applet)
Agent Agent
Know- how Know- how
Host Host
Network
Mobile Agent Paradigm
8/7/2019 Mobile Agent-1
8/68
8
Compare Client/Server & Mobile Agent
Model
Limitation ofClient/Server
Scaling -- Multiple servers
Quality of network connection
Reliability , latency , bandwidth
Protocol
Advantage of Mobile AgentsEvery node is a server
Request Network connection (decentralized)
No application-level protocol (flexible, not
standard)
8/7/2019 Mobile Agent-1
9/68
9
Seven good reasons forMobile Agents
Reduce network load (average in distributed db)
Overcome network latency (network management)
Encapsulate protocols (customized protocols) Execute asynchronously and autonomously
Adapt dynamically
Naturally heterogeneous Fault-tolerant
8/7/2019 Mobile Agent-1
10/68
10
Mobile Agent Systems
Java-based:
Odyssey. General Magic Inc.
Concordia. Mitsubishis
Aglets. IBM
Voyager. ObjectSpace
Others:Tacoma: Univ.of Tromso and Cornell Univ.
Agent TCL: Dartmouth College
8/7/2019 Mobile Agent-1
11/68
11
Mobile Agent Model
Key concepts:
Agent
-- the main entity in Mobile Agent System
Place
-- the environment where agents operate
8/7/2019 Mobile Agent-1
12/68
12
Agent
State: needed for resume computation after traveling
Implementation:
needed for location-independent agent execution
Interface needed for agent communication
Identifier needed for recognize and locate traveling agents
Principals needed to determine legal and moral responsibility
8/7/2019 Mobile Agent-1
13/68
13
Engine Virtual machines for one or more places
Resources
Databases,processors,and other services provided by the host
Location The network address of a given place
Principals
Those legally responsible for the opration of a place
Place
8/7/2019 Mobile Agent-1
14/68
14
The Agent Model Pyramid
Host
Engines
Places
Agents
8/7/2019 Mobile Agent-1
15/68
15
Place and Engine
Host
Engine
Agent
PlaceResources
8/7/2019 Mobile Agent-1
16/68
16
Agent Behavior(1)Creation and Disposal
Creation:
Instantiation and identifier assignment
InitializationAutonomous execution
Disposal
Preparing for disposalSuspension of execution
8/7/2019 Mobile Agent-1
17/68
17
Agent Behavior(2)
Transferdispatching/receiving Dispatch and Receive:
Sender
Suspend Execution
Serialize Agent
Encode Data
Transfer Data
Receiver
Resume Execution
Deserialize Agent
Decode Data
Receive Data
Network
8/7/2019 Mobile Agent-1
18/68
18
Agent Behavior(2)
Transferagent class transfer Agent Class Transfer
Server
Class code
Origin
Class code
Server
Class code
Agent Agent
Class at destinationClass at origin
Class at Server(code on demand)
8/7/2019 Mobile Agent-1
19/68
19
Security of Mobile Agent
What can go wrong?Agent protection
remote host , other agents, unauthorized third parties
Host protection incoming agents, third parties
Network protection
-- incoming agents
Security ServicesAuthentication
user, host, code, agent
Integrity
Confidentiality
AuthorizationNon-repudiation
Auditing
8/7/2019 Mobile Agent-1
20/68
20
Aglets Platform & Aglet
8/7/2019 Mobile Agent-1
21/68
21
Aglet Model
Basic Elements:
Aglet a mobile Java object
Proxy a representative of an aglet
Context an aglets workplace
Identifier
Aglet and Proxy:
Client Interaction Proxy Aglet
Context Context
Host
Server Process(Engine)
Network
Host,Server process(engine) and Context
8/7/2019 Mobile Agent-1
22/68
22
Aglet : Life Cycle Model
Fundamental
operations:Creation
Cloning
Dispatching
Retraction
Activation and
deactivation
Disposal
AgletC
lone
Class File
Aglet
Disk storage
Dispose
Dispatch
Retract
Create DeactivateActivate
Context A Context B
8/7/2019 Mobile Agent-1
23/68
23
Aglet : Event Model
Clone listener
Mobility listener
Persistence listener
Aglet
Clone event
Mobility event
Persistence event
CloneListener
MobilityListener
PersistenceListener
8/7/2019 Mobile Agent-1
24/68
24
Aglet : Communication Model
Message passing:
Allows aglets to create and exchange
messages in flexible ways.
Key Components: Aglet, Aglet Proxy, Message,Future reply, Reply set
Aglet/
Application
Message
Reply
Message
Reply
Proxy Aglet
8/7/2019 Mobile Agent-1
25/68
25
Aglet Package :a Quick Tour
Aglet Class
AgletProxy Interface AgletContext Interface
Message Class
FutureReply Class AgletID Class
8/7/2019 Mobile Agent-1
26/68
26
Aglet API: Aglet Class
Create a customized aglet:
import com.ibm.aglet.*;
Public class MyFirstAglet extends Aglet{
//put aglets methods here}
Overriden methods:
public void onCreation(Object init){
//do some initialization here
}
public void run() { //do something here; }//main entry point
//e.g. call dispatch(new URL(atp://some.host.com//context));
8/7/2019 Mobile Agent-1
27/68
27
Aglet API:Aglet Class
What happens when dispatch?
State
Byte Code
Host Host
Sending Receiving
State
Byte Code
HostHost
Object Serialization
Transfer
Deserialization and
re-create state
8/7/2019 Mobile Agent-1
28/68
28
Aglet API: AgletProxy
Why AgletProxy?
Acts as a shield object that protects an aglet from malicious aglets
Provide the aglet with location transparency
How to get a proxy?Get proxy from a newly created aglet:
AgletContext.createAglet(),
AgletProxy.clone()
Get proxy from existing aglets
Aglet.getProxy() get its own proxy
AgletContext.getAgletProxies() retrieve an enum. of proxies in a context
AgletContext.getAgletProxy() get an aglet proxy for a given aglet ID
Message passing passed as an argument
AgletContext.setProperty put proxy into context property and share it.
8/7/2019 Mobile Agent-1
29/68
29
Aglet API: AgletContext
An aglet context is the equivalent of a place.
An aglet uses AgletContext interface to:
Get information about its environment
Send message to the environment, including other
aglets currently active in that environment
How it works:context=getAgletContext();
context.createAglet();
context.retractAglet(remoteContextURL,agletID);
8/7/2019 Mobile Agent-1
30/68
30
Aglet API: Message Class
Aglets communicate by exchanging objects of the
Message class.
kind field: distinguishes messagesMessage myName=new Message(my name, Jacob);
Message yourname=new Message(your name?);
Methods to send message(defined in AgletProxy class):
Object sendMessage(Message msg)
FutureReply sendFutureMessage(Message msg)
Void sendOnewayMessage(Message msg)
8/7/2019 Mobile Agent-1
31/68
31
Aglet API: Message Class
handleMessage method:Public boolean handleMessage(Message msg){
if(msg.samekind(my name)){
String name=(String)msg.getArg();return true; //Yes, I handled this message
} else if(msg.samekind(your name?)) {
msg.sendReply(Yina); //Return its name
return true; //Yes, I handled this message} else
return false; //No, I did not handle this message
}
8/7/2019 Mobile Agent-1
32/68
32
Aglet API: AgletID Class
Identity:Globally unique
Throughout lifetime
AgletID objectHides the implementation-specific representation
Immutable Use :
AgletID aid=proxy.getAgletID();
proxy=context.getAgletProxy(aid);
8/7/2019 Mobile Agent-1
33/68
33
Anatomy of an Aglet
Creation & Disposal
C
lone Mobility
Dispatch and Retract
Persistence Activate and Deactive
8/7/2019 Mobile Agent-1
34/68
34
Creation
public final AgletContext Aglet.getAgletContext()
//Example:
getAgletContext().createAglet(getCodeBase(),SomeAglet,null);
Methods that can be overridden
protected Aglet.Aglet()Public void Aglet.onCreation(Object init)
Public void Aglet.run()
createAglet()Aglet()
onCreation
run()
8/7/2019 Mobile Agent-1
35/68
35
Disposal
public final void Aglet.dispose();
public void Aglet.onDisposing();
Dispose()
onDisposing()
run()
8/7/2019 Mobile Agent-1
36/68
36
Event
Event Types:
C
loneEventMobilityEvent
PersistencyEvent
Delegation-Based Event Mode
CloneListener CloneAdapter
MobilityListener MobilityAdapter
PersistencyListener PersistencyAdapter
8/7/2019 Mobile Agent-1
37/68
37
Cloning
Public final Object Aglet.clone()
Public final void Aglet.addCloneListener(CloneListener
listener)
Public final void Aglet.removeCloneListener(CloneListenerlistener)
public CloneAdapter.CloneAdapter()
public void CloneAdapter.onCloning(CloneEvent event)public void CloneAdapter.onClone(CloneEvent event)
public void CloneAdapter.onCloned(CloneEvent event)
8/7/2019 Mobile Agent-1
38/68
38
Cloning (continued)public class CloningExample extends Aglet{
boolean _theClone=false;public void onCreation(Object o) {
addCloneListener(new CloneAdapter(){
public void onCloning(CloneEvent e){
// print to the console }
public void onClone(CloneEvent e){
// print to the console }
public void onCloned(CloneEvent e){
// print to the console }
} );
}
public void run() {if (! _theClone) {
//the original runs heretry{
clone();} catch (Exception e)
{ System.out.println(e.getMessage());
}
else {//the clone runs here}
}
run()
onCloning()onCloned()
onClone()
run()
original
clone
8/7/2019 Mobile Agent-1
39/68
39
Mobility
-- Dispatching
-- Retracting
run( )
dispatch( )
onDispatching( )
onArrival( )run( )
Origin
Destination
retractAglet( )
onArrival( )
run( )
run( )onReverting( )
Local
Remote
8/7/2019 Mobile Agent-1
40/68
40
Persistence
Persistence
run( )
deactivate( )
onDeactivating( )onActivation( )
run( )
Before
After
Aglet Context
Deactivate
Activate
8/7/2019 Mobile Agent-1
41/68
41
Inside Aglets
Architecture Overview
Services and User-defined aglets
Aglet APIAglet Runtime Layer
Core FrameworkManagementComponents
CacheManagerSecurityManager
PersistanceManager
Communication API
Communication Layer
8/7/2019 Mobile Agent-1
42/68
42
Communication Layer
Communication API
Agent Transfer Protocol(ATP)
An ATP request consists of : a request line,header fields, content.
Four standard request method:
Dispatch
Retract
Fetch
Message
Host HostATP ATP
HTTP
HTTP Tunneling of ATP
8/7/2019 Mobile Agent-1
43/68
43
Aglet Security
PrincipalAglet
Context & Server
Network Domain
Permissions
Protection
Policy & Authority
Aglet owner
Context owner
Network Domain owner
8/7/2019 Mobile Agent-1
44/68
44
8/7/2019 Mobile Agent-1
45/68
45
8/7/2019 Mobile Agent-1
46/68
46
8/7/2019 Mobile Agent-1
47/68
47
8/7/2019 Mobile Agent-1
48/68
48
8/7/2019 Mobile Agent-1
49/68
49
8/7/2019 Mobile Agent-1
50/68
50
8/7/2019 Mobile Agent-1
51/68
Tcl Agent
A flexible and secure mobile-agent system
8/7/2019 Mobile Agent-1
52/68
52
Overview
Introduction
Agent Tcl Architecture
Tcl and Agent Tcl
Security in Agent Tcl
8/7/2019 Mobile Agent-1
53/68
53
Introducing Agent Tcl
Mobile agent system developed at Dartmouth
College.
Uses a flexible scripting language Tclas its mainlanguage but provides a framework for
incorporating addiotional languages.
Provides migration and communication primitives
that dont require the programmer to explicitly
capture state information and hides actual
transport mechanisms
8/7/2019 Mobile Agent-1
54/68
54
Agent Tcl continued
Uses Safe Tcl security modelto protect a machine from a
malicious agent and agents from each other.
Allows agents To migrate from machine to machine orremain stationary and
access resources from across the network.
To create child agents to perform subtasks.
To communicate with other agents on the local and remote
machines.
Intended as a general environment for
distributed applications.
8/7/2019 Mobile Agent-1
55/68
55
The Architecture
4 main goals
Reduce migration to a single instruction.Provide transparent communication among
agents.
Support multiple languages and transport
mechanisms.Provide effective security in the uncertain
world of the Internet.
8/7/2019 Mobile Agent-1
56/68
56
Architecture continued
Agents
Tcl .. Java
Server or engine
TCP/IP .. Electronic
Interpreter
State
Capture
Server
API
Security
8/7/2019 Mobile Agent-1
57/68
57
Levels in Architecture
4 Levels to architecture
API
Server
Interpreter
Agents
8/7/2019 Mobile Agent-1
58/68
58
Server Level
Server performs following tasks:
Status - keeps track of the agents on machines
Migration - accepts each incoming agent, authenticatesidentity of its owner, passes to appropriate interpreter
Communication- provides a hierarchical namespace for
agents and allows agents to send messages to each other
within this name spaceNonvolatile Store - provides access to a nonvolatile
store so agents can back up their internal state as
desired.
8/7/2019 Mobile Agent-1
59/68
59
Interpreter Level
One interpreter for each available language
Four components to interpreter
interpreter
security module
state module
captureState
restoreState
API
8/7/2019 Mobile Agent-1
60/68
60
Tcl and Agent Tcl
Current implementation does not provide
event messages or the nonvolatile store
Has a single language (Tcl)
Single transport mechanism (TCP/IP)
Incoming agents are authenticated using
PGP
8/7/2019 Mobile Agent-1
61/68
61
Tcl
High level scripting language
Advantages as a mobile agent language
Easy to learn Interpreted thus highly portable and easy to make secure
Can be embedded in other applications
Can be extended with user-defined commands
Disadvantages of Tcl
Interpreted - thus much slower than machine language No facilities for capturing the complete internal state of an executing
script
This was modified by adding to the Tcl core
8/7/2019 Mobile Agent-1
62/68
62
Agent Tcl
Two components
Server
Runs at network site
Implemented as two cooperating processes
One watching the network
Other maintaining a table of running agents
Modified version of Tcl 7.5 and a Tcl extension
Provides explicit stack and state-capture routines
Extension provides commands for an agent to
migrate, communicate, and create child agents.
8/7/2019 Mobile Agent-1
63/68
63
How does it work ?
Agent simply a Tcl script running on top of
a modified version of Tcl 7.5
agent_begin - register with server and obtain a
name in flat namespace
agent_submit - used to create a child agent on
a particular machineagent_jump - migrates an agent to a particular
machine
agent_send, agent_receive - to send and
receive messages
8/7/2019 Mobile Agent-1
64/68
64
How does it work, continued
agent_meet - used by source agent to send
a connection request to the destination agent
agent_accept - used by destination agent to
receive the connection request and send
with an acceptance or rejection.
Acceptance includes sending a TCP/IP port numberto which the source agent connects
8/7/2019 Mobile Agent-1
65/68
65
Agent Tcl and Security
Main Problems are to
Protect the machine
Protect other agents
Protect the agent
Protect a group of machines
8/7/2019 Mobile Agent-1
66/68
66
Authentication
Based on PGP (Pretty good Privacy)
Encrypts a file using the IDEA private key
algorithm and random private key Encrypts the private key using RSA and public key
Sends encrypted key and file to recipient
Initiated by the agent_begin command
8/7/2019 Mobile Agent-1
67/68
67
Authorization and Enforcement
Resources divided into 2 types
Indirectresources
Only accessed through another agent
Built-in resources
Directly accessible through language primitives
Security maintained using Safe Tcl and A set ofresource manageragents
Safe Tcl creates trusted and untrusted
interpreter
8/7/2019 Mobile Agent-1
68/68
Conclusion
Future work includes incorporating Java
into the architecture
Agent Tcl
Secure mobile agent system which gains
flexibility and simplicity from use of hih-level
scripting language Tcl