Download presentation
Presentation is loading. Please wait.
1
Developing Mobile Agent Systems
with Java Prof. Dr. Jürgen Dunkel Computer Science Department Hannover University of Applied Science and Arts ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
2
Overview Overview 1. Mobile Agents Concept of Agent Mobility Benefits and Problems of Mobile Agents 2. Architecture of Mobile Agent Systems 3. The Jade-Framework 3.1. Overview 3.2. Creating JADE Agents 3.3. Agent Behaviours 3.4. Agent Communication 3.5. Yellow Pages Service 3.6. JADE Review 4. Conclusion ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
3
how can agents use services in distributed systems ?
1. Mobile Agents Mobile Agents agents must live in distributed systems because services and information are provided in computer networks how can agents use services in distributed systems ? A. Agents can use Interprocess Communication Mechanisms Remote Procedure Calls (RPC), RMI, Corba, Web Services,MOM,… B. Agents can be mobile move autonomously across a network transport program + state continue execution at remote site ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
4
Migration steps of a Mobile Agent:
1. Mobile Agents Migration steps of a Mobile Agent: interrupt processing of the agent save state agent and provides authentication information transfer agent code and state to server 2 Agent Environment Server 1 Server 2 agent 1 recover agent state resume execution of agent on server 2 agent cooperates with agents on server 2 and completes work agent returns home to server 1 agent communicates the results of his work ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
5
Benefits of Mobile Agents over RPC (1)
Mobile Agents replace expensive RPC with local calls reducing number of remote interactions and transmitted data Server 1 Client Service Server 2 Remote Procedure Calls: Agent Environment agent 1 Server 1 Server 2 Service Mobile Agents: ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
6
Benefits of Mobile Agents over RPC (2)
Mobile Agents: can work in spontaneous networks clients must be connected to the network only long enough to sending the agent on its way receiving the agent clients must not be connected when the agent carries out its task asynchronous communication Mobile Agents: are well suited for small devices lack of computational power: agent moves to another host Mobile Agents: can extend server functionality Agent contains its own functionality not completely dependent on the installed services ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
7
Problems of Mobile Agents
Host Protection host must trust in agents from another host Agent platform realizes Java Sandbox Model agents have only restricted access on system resources authenticated agents can have more access rights Agent Protection private data, agent knowledge base secure transport protocols (SSL) encryption of private agent information Interoperability of heterogenous agents different server platforms agents might be implemented with different agent frameworks ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
8
2. Architecture of Mobile Agents Systems
Standard Architectures of Mobile Agent Systems FIPA (Foundation For Intelligent Physical Agents) focus on interoperation of heterogenous agents defines ACL (agent communication language) ontologies for agents no emphasis on mobility JADE /LEAP, ZEUS, Grasshopper ( OMG /MASIF (Mobile Agent System Interoperability Facility) focus on interoperability between agent systems defines standard interfaces for Agent Management: creation, suspension, resumption, termination Mobility Infrastructure: communicate with and migrate to other agent systems Naming Services: to find and locate agents (CORBA based) Grashopper, Aglets ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
9
2. Architecture of Mobile Agents Systems
Architectural Components of a Multi Agent System User-Agent-Interface Agent Life Cycle Management Execution Layer Mobility Communication Persistence Services Agent Security Name Service Host Security Network ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
10
2. Architecture of Mobile Agents Systems
User-Agent-Interface user interface to interact with the agent user manages local and remote agents creating, destroying agents bidirectional communicating sending data to the agent presentation of agent results Agent Life Cycle Managment management of agent lifecycle creation, suspension, resumption, termination different kind of agents system agents: manager agents, monitor agents, repository agents, interface agents.. participant agents: support cooperative processes (negotiation, mediation,..) user agents: act on behalf of the user ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
11
2. Architecture of Mobile Agents Systems
Execution Layer execution environment for agents environment where agents live (and meet other agents) contains the virtual machine for the agent execution granting access to services Mobility Layer provides agent mobility physical transport of agent code classes are transported as part of the agent transfer protocol classes are loaded on demand from a designated code base weak mobility: agent restarts on the new host with its current data strong mobility: agent continues execution according to its program counter ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
12
2. Architecture of Mobile Agents Systems
Communication Layer responsible for agent collaboration defines Agent Communication Language (ACL) message content based on common vocabulary (ontology) necessary Standards: FIPA/ACL, Knowledge Interchange Format (KIF), KQML Message Delivery: 1. locate agent with naming service 2. transfer message to agent asynchronous communication Persistence Services Layer provides agent persistence Serialization/Deserialization of an agent state: used for agent mobility Checkpoint-Restore-Mechanism avoids loss of agents in case of host or network errors ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
13
2. Architecture of Mobile Agents Systems
Agent Security protect agent against malicious hosts Cryptographic techniques Trust-base computing: defining a trusted network Name Service provides name service requires globally unique agent name seeking Mobile Agents Brute Force Method: searching in every agent system in the region Logging: follows an agent is by its trail, (migrating agent leaves its next destination at each server) Agent Registration: every agent registers its current location in a database ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
14
2. Architecture of Mobile Agents Systems
Host Security protect host against malicious agents limits resource consumption verification (check agent code), access control policies use of authentication and authorisation mechanisms Network Layer responsible for agent transport Agent Transport Protocol: platform-independent based on standard protocols (HTTP, RMI/IIOP,.. includes security mechanism (SSL) ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
15
3. The JADE Framework 3. The Jade Framework 3.1. Overview
3.2. Creating JADE Agents 3.3. Agent Behaviours 3.4. Agent Communication 3.5. Yellow Pages Service 3.6. JADE Review ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
16
JADE JADE Components 3.1. JADE-Overview
Java Agent DEvelopment Framework developed by TILAB (formerly CSELT) FIPA compliant includes LEAP framework for PDA, mobile phones,.. Middleware that facilitates development of multi-agent systems fully implemented in Java Open source: distributed under LPGL JADE Components runtime environment where JADE agents can live class libraries for agent development graphical tools for administrating and monitoring agents ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
17
JADE Agent Platform 3.1. JADE-Overview
JADE Agent Platform: is a set of active containers Container: Instance of the JADE Runtime Environment Main Container: one in every JADE platform all other containers must register in main container containers might be distributed over different servers ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
18
Main Container JADE Agents 3.1. JADE-Overview
each main container constitutes a different platform contains two special agents AMS (Agent Management System) provides Naming Service Life Cycle Management (e.g. can start or kill agents) DF (Directory Facility) Yellow Pages: seeking agents with a special service JADE Agents identified by a unique name agents can communicate transparently regardless of their actual location ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
19
Book Trading Example 3.1. JADE-Overview two different types of agents
BookSellerAgent wants to sell books books with different prices in his stock (can be inserted by a simple GUI) BookBuyerAgent wants to buy a book: LookUp: BookBuyerAgent looks for all BookSellerAgents, who sell books Call For Proposal: asks all BookSellers for the price of a book title BookSellers send their offers BookBuyerAgent sends an order to the BookSellerAgent with the lowest price ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
20
HelloWorldAgent 3.2. Creating JADE Agents
import jade.core.Agent; public class HelloAgent extends Agent { protected void setup() { System.out.println("Hallo! "+getAID().getName()+" is ready."); } setup() is intended for agent initialization is a hook-method, i.e. automatically invoked by the agent platform each agent is identified by a unique identifier instance of class jade.core.AID is of the form e.g. String nickname = “pepe”; AID id = new AID(nickname, AID.ISLOCALNAME); ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
21
BookBuyerAgent - Initialization
3.2. Creating JADE Agents BookBuyerAgent - Initialization public class BookBuyerAgent extends Agent { private String targetBookTitle; private AID[] sellerAgents = {new AID(“seller1”, AID.ISLOCALNAME), new AID(“seller2”, AID.ISLOCALNAME)}; protected void setup() { System.out.println("Hallo! Buyer-agent "+getAID().getName()+" is ready."); Object[] args = getArguments(); if (args != null && args.length > 0) { targetBookTitle = (String) args[0]; System.out.println("Trying to buy "+targetBookTitle); } else System.out.println("No book title specified"); } protected void takeDown() { System.out.println("Buyer-agent "+getAID().getName()+" terminating."); getArguments() reads arguments from the command line takeDown(): invoked before an agent terminates and used for clean-up ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
22
Agent Behaviour 3.3. Agent Behaviours 4 3 1 2 QUEUE
real job of an agent is carried out within behaviours there are different Behaviour-classes in JADE each Behaviour-class must implement action()-method each Behaviour-class must implement done()-method: if it yields true, the behaviour is removed from the agent’s behaviour pool same agent can have different Behaviours: an Behaviour is added to an agent by addBehaviour() –method behaviours are scheduled co-operatively agent sleeps if there is no behaviour available 4 3 1 2 QUEUE ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
23
Behaviour Types 3.3. Agent Behaviours Generic Behaviour
One-shot Behaviour action()-method is executed only once WakerBehavior-class: executes a method after a given timeout addBehaviour(new WakerBehaviour(this, 10000) { protected void handleElapsedTimeout() { // perform operation X } } Cyclic Behaviour its action()-method is executed periodically in an endless loop TickerBehavior-class: executes a method repetitively waiting a period addBehaviour(new TickerBehaviour(this, 10000) { protected void onTickt() { // perform operation Y } Generic Behaviour embeds a state executes different operations depending on the state ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
24
Behaviour for the Book Trading Example
3.3. Agent Behaviours Behaviour for the Book Trading Example Behaviours of BookBuyerAgent TicketBehavior: only for scheduling periodically requests seller agents protected void setup() { … addBehaviour(new TickerBehaviour(this, 60000) { protected void onTick() { myAgent.addBehaviour(new RequestPerformer()); } } ); … RequestPerformer implements the real and complex behaviour sends Call for Proposal to the Sellers receives the proposals sends the purchase order to the seller with best offer receives the purchase order reply ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
25
Behaviours of BookSellerAgent
3.3. Agent Behaviours Behaviours of BookSellerAgent two cyclic behaviours OfferRequestsServer: serves a request for a offer PurchaseOrdersServer: serves a purchase order protected void setup() { … // Create and show the GUI myGui = new BookSellerGui(this); myGui.show(); addBehaviour(new OfferRequestsServer() ); addBehaviour(new PurchaseOrdersServer() ); .... OneShotBehaviour: updating the catalogue /** is invoked by the GUI when the user adds a new book for sale*/ public void updateCatalogue(final String title, final int price) { addBehaviour(new OneShotBehaviour() { public void action() { catalogue.put(title, new Integer(price)); } } ); } ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
26
JADE Communication Mechanism
3.4. Agent Communication JADE Communication Mechanism asynchronous message passing each agent has a private queue of ACL messages other agents can post messages into the queue agent is notified whenever a message arrives ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
27
ACL Messages 3.4. Agent Communication FIPA message format:
sender of the messages list of receivers performative: communicative intention, e.g. REQUEST: sender wants the receiver perform an action INFORM: sender wants to inform the receiver CFP: sender calls the receiver for a proposal content of the message content language: syntax of the message ontology: vocabulary of the message additional control fields (timeout, ACLMessage msg = new ACLMessage(ACLMessage.INFORM); msg.addReceiver(new AID(“Pepe”, AID.ISLOCALNAME)); msg.setLanguage(“English”); msg.setOntology(“Weather-forecast-ontology”); msg.setContent(“Today it’s raining”); send(msg); ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
28
ACL Messages for the Book Trading Example
3.4. Agent Communication ACL Messages for the Book Trading Example BuyerAgent SellerAgents request of a book offer: CFP-message containing book title ACLMessage cfp = new ACLMessage(ACLMessage.CFP); for (int i = 0; i < sellerAgents.lenght; ++i) { cfp.addReceiver(sellerAgents[i]); } cfp.setContent(targetBookTitle); myAgent.send(cfp); SellerAgents BuyerAgent send offer to buyer: PROPOSE-message containing price REFUSE-messsage, if requested book not in stock BuyerAgent SellerAgents send accept of the offer to the cheapest seller: ACCEPT_PROPOSAL-message ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
29
3.4. Agent Communication ACL Message Processing – in Behaviours
OfferRequestsServer – BookSellerAgent sends offer to Buyer private class OfferRequestsServer extends CyclicBehaviour { public void action() { ACLMessage msg = myAgent.receive(); if (msg != null) { String title = msg.getContent(); ACLMessage reply = msg.createReply(); Integer price = (Integer) catalogue.get(title); if (price != null) { reply.setPerformative(ACLMessage.PROPOSE); reply.setContent(String.valueOf(price.intValue())); } else { reply.setPerformative(ACLMessage.REFUSE); reply.setContent(“not-available”); myAgent.send(reply); } block(); // agent thread is going asleep ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
30
3.4. Agent Communication Message Filtering
a behaviour is only interested certain message MessageTemplates filter messages in the queue public void action() { MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP); ACLMessage msg = myAgent.receive(mt); if (msg != null) { // CFP Message received. Process it ... } else { block(); ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
31
Yellow Pages Service 3.5. Yellow Page Services
an agent wants to find other agents offering a certain service E.g. BuyerAgent wants to discover dynamically all SellerAgents Yellow Page Service provided by DF (Directory Facilitator) agent, according to FIPA ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
32
3.5. Yellow Page Services Publishing a Service
providing a description of the service AID, languages and ontologies an agent needs to know service name, service type protected void setup() { ... // Register the book-selling service in the yellow pages DFAgentDescription dfd = new DFAgentDescription(); dfd.setName(getAID()); ServiceDescription sd = new ServiceDescription(); sd.setType(“book-selling”); sd.setName(“JADE-book-trading”); dfd.addServices(sd); try { DFService.register(this, dfd); } ... in the example no ontology, language,.. is specified in takeDown()-method services should be deregistered ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
33
3.5. Agent Name Service Searching for Services
agent seeks all other agents offering a certain service necessary information: AID, required languages and ontologies public class BookBuyerAgent extends Agent { private AID[] sellerAgents; protected void setup() {… // Update the list of seller agents DFAgentDescription template = new DFAgentDescription(); ServiceDescription sd = new ServiceDescription(); sd.setType(“book-selling”); template.addServices(sd); try { DFAgentDescription[] result = DFService.search(myAgent, template); sellerAgents = new AID[result.length]; for (int i = 0; i < result.length; ++i) { sellerAgents[i] = result.getName(); } }…. AID[ ] contains the names of all agent, offering the “book-selling”-service also publish-subscribe service available ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
34
How much of FIPA is hidden by the JADE?
3.6. JADE Review How much of FIPA is hidden by the JADE? no need to implement the Agent Platform AMS, and DF executed at start-up no need to implement Message Transport and Parsing automatically done by the framework when sending/receiving messages no need to implement agent-management an agent is registered with the AP within its constructor simplified interface to access the services of the DF (registration, searching, …) Interaction Protocols must only be extended via handle methods ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
35
Conclusion 4. Conclusion Concept of Agent Mobility
necessary for multi-agent systems in a distributed world benefits over interprocess communication mechanisms problems of mobile agents Software Architecture of a Mobile Multi Agent Systems short description of the essential layers Developing a multi agent system with JADE behaviours ACL messages many open fields for further research Software architecture of Mobile Multi Agent Systems: Integrating of new standards (Web Services, Semantic Web, Security Issues,..) Agents on Small devices (LEAP) Agents in adhoc networks Cooperation and negotiation models,.. ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
36
Software Architecture of Multi Agent Systems
5. References Agent Mobility J.E. White: Mobile Agents; in: M. Bradshaw: Software Agents, MIT Press, 1997, pp D. Miojicic: Trend Wars: Mobile Agent Applications, IEEE Concurrency, 1999. Software Architecture of Multi Agent Systems M. Schoeman, E. Cloete: Architectural Components of the Efficient Design of Mobile Agent Systems, Proceedings of SACISIT, 2003. FIPA (Foundation of Intelligent Agents) OMG: The Mobile Agent Facility Specification JADE JADE homepage: JADE documentation D. Grisham: JADE Administrative Tutorial, 5/2003 C. Giovanni: JADE Tutorial, JADE Programming for Beginners, 12/2003 ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
37
Example of complex behavior (1)
3.6. Agent Communication Example of complex behavior (1) private class RequestPerformer extends Behaviour { private AID bestSeller; private int bestPrice; private int repliesCnt = 0; private MessageTemplate mt; private int step = 0; public void action() { switch (step) { case 0: // Send the cfp to all sellers ACLMessage cfp = new ACLMessage(ACLMessage.CFP); for (int i = 0; i < sellerAgents.length; ++i) { cfp.addReceiver(sellerAgents[i]); } cfp.setContent(targetBookTitle); cfp.setConversationId(“book-trade”); cfp.setReplyWith(“cfp”+System.currentTimeMillis()); // Unique value myAgent.send(cfp); // Prepare the template to get proposals mt = MessageTemplate.and(MessageTemplate.MatchConversationId(“book-trade”), MessageTemplate.MatchInReplyTo(cfp.getReplyWith())); step = 1; break; ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
38
Example of complex behavior (2)
3.6. Agent Communication Example of complex behavior (2) case 1: // Receive all proposals/refusals from seller agents: conversation-ID = “book-trade” ACLMessage reply = myAgent.receive(mt); if (reply != null) { if (reply.getPerformative() == ACLMessage.PROPOSE) { // offer received int price = Integer.parseInt(reply.getContent()); if (bestSeller == null || price < bestPrice) { bestPrice = price; bestSeller = reply.getSender(); } repliesCnt++; if (repliesCnt >= sellerAgents.length) step = 2; // We received all replies else { block(); break; ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
39
Example of complex behavior (3)
3.6. Agent Communication Example of complex behavior (3) case 2: // Send the purchase order to the seller that provided the best offer ACLMessage order = new ACLMessage(ACLMessage.ACCEPT_PROPOSAL); order.addReceiver(bestSeller); order.setContent(targetBookTitle); order.setConversationId(“book-trade”); order.setReplyWith(“order”+System.currentTimeMillis()); myAgent.send(order); mt = MessageTemplate.and(MessageTemplate.MatchConversationId(“book-trade”), MessageTemplate.MatchInReplyTo(order.getReplyWith())); step = 3; break; case 3: // Receive the purchase order reply reply = myAgent.receive(mt); if (reply != null) { if (reply.getPerformative() == ACLMessage.INFORM) { System.out.println(targetBookTitle+“ successfully purchased. Price = ”+bestPrice); myAgent.doDelete(); } step = 4; } else { block(); } break; } ã Developing Mobile Agent Systems with Java, Jürgen Dunkel, FH Hannover, Vers
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.