Development of a JADE Based Distributed Instant ...

2 downloads 0 Views 373KB Size Report
Development of a JADE Based Distributed Instant Messaging System. By. Mu'azu, Muhammed Bashir [email protected] [email protected].
Development of a JADE Based Distributed Instant Messaging System

By

Mu’azu, Muhammed Bashir [email protected] [email protected] +234-803-7272365 Department of Electrical Engineering, Ahmadu Bello University, Zaria, Nigeria Garba, Michael Tanimu Department of Electrical Engineering, Ahmadu Bello University, Zaria, Nigeria Jibril, Yusuf [email protected] +234-803-3172990 Department of Electrical Engineering, Ahmadu Bello University, Zaria, Nigeria And Boyi, Jimoh [email protected] Department of Electrical Engineering, Ahmadu Bello University, Zaria, Nigeria Abstract Intelligent software agents are a powerful abstraction for visualizing and structuring complex software that act on behalf of the user to find and filter information, negotiate for services, automate complex tasks, or collaborate with other agents to solve complex problems. This work used the Java Agent Development Environment (JADE) to implement a distributed instant messaging or “chat” system. The JADE Instant Messenger application consists of three actual agents: UserAgent, ChatAgent, and ChatRoomAgent and is implemented as peer-to-peer implying that users have flexibility to create and participate in decentralized systems without servers. The developed application was tested on two hosts on an IP based network. Keywords: JADE, Agent, Instant Messaging, Class, GUI

*Mu’azu, Muhammed Bashir (Dr) [email protected] [email protected] Department of Electrical Engineering, Ahmadu Bello University, Zaria, Nigeria ICAI’07- The 2007 International Conference on Artificial Intelligence

1.0 Introduction This work is aimed at using the Java Agent Development Environment (JADE) to implement a distributed instant messaging or “chat” system. JADE, a free open source and Foundation for Intelligent Physical Agents (FIPA) standards compliant platform for agent development, wraps the more mundane functionality in a higher level object based framework leaving the designer to focus on architectural issues of greater significance. Instant messaging or IM is a form of real-time communication between two or more people based on typed text. The text is conveyed via computers connected over a network such as the Internet [1]. A client program connects to an instant messaging service and conversations occur in real time. A presence information service indicates whether listed contacts are available at any time. Popular instant messaging services on the public Internet include Qnext, Windows Live Messenger, AOL Instant Messenger, Yahoo! Messenger, Skype, Google Talk, .NET Messenger Service, Jabber, QQ, Excite/Pal iChat and ICQ. Instant Messaging facilitates collaboration and is finding increasing popularity in corporate environments where its non-intrusive nature is valuable. There have been several attempts to create a unified standard for instant messaging: IETF' s SIP (Session Initiation Protocol) and SIMPLE (SIP for Instant Messaging and Presence Leveraging Extensions), APEX (Application Exchange), Prim (Presence and Instant Messaging Protocol), the open XML-based XMPP (Extensible Messaging and Presence Protocol), more commonly known as Jabber and OMA' s (Open Mobile Alliance) IMPS (Instant Messaging and Presence Service) created specifically for mobile devices. 1.1 Software Agents The basis of software agents is delegation. The owner of an agent delegates a task which is autonomously performed by the agent on behalf of the user, while communicating with the user to receive instructions and providing the user with the results. An agent must be able to monitor the state of its own execution environment and make necessary decisions to ensure completion of its tasks [3]. Agent based systems are intrinsically peer to peer. Agents in a centralized or distributed environment collaborate by exchanging messages [4]. Software agents achieve results by executing behaviors. The JADE class library contains an abstraction of the agent behavior class jade.core.behaviours.Behaviour and several subclasses that specify various customized behaviors. In order to cause an agent to execute a behavior, the addBehaviour() method of the Agent class should be called. Agents must execute several behaviors simultaneously; this is achieved through non-preemptive multitasking [4]. Each behavior is allocated a time slot in a roundrobin fashion and executed. Completed behaviors are removed from the behavior queue. 1.3 JADE JADE is the Java Agent Development Environment, a middleware that assists in the development of multi-agent systems. It includes a runtime environment, class library and graphic tools [3]. Each running instance of the JADE runtime environment is called a container. Each container is capable of holding a large number of agents. A set of related containers is called a platform and each platform requires one main container with which all others register upon creation. Each container therefore requires the IP address and port of the main container to which it should connect upon initialization. There is a one-to-one mapping between main containers and platforms as shown in the Figure 1. Each main container (platform) contains two special agents that are always present in any platform.

2

Figure 1: JADE Platform and Containers 2.0 Research Objectives & Methodology The design goals are described by the following statements. The software should 1. Enable users to collaborate on any IP network - LAN or the Internet. 2. Scale well when confronted with a large number of users. 3. Be robust and relatively fault tolerant. 4. Function as a peer to peer (P2P) system without the need for centralized servers. 5. Give users the ability to create and manage arbitrary collaborative systems of communicating users centered on machines of their choosing. 6. Provide security from eavesdropping and message spoofing. 7. Be cross-platform, allowing flexibility in the choice of operating systems and underlying hardware. In order to achieve these goals the following methodology is adopted. 1. The Java II Platform from Sun Microsystems is the development language of choice. The latest version of the Java Platform is freely available at http://java.sun.com. The download includes the Java compiler, runtime environment or virtual machine, the jar tool for packaging and deployment and other useful utilities. Comprehensive documentation of the Java Platform and a good tutorial are also maintained here. 2. Borland’s JBuilder, an Integrated Development Environment or IDE for Java, is used for the actual coding. It’s CodeInsight, MemberInsight, syntax highlighting and GUI designers greatly facilitate development. The JBuilder IDE is proprietary software; however, Borland offers a free download of JBuilder Foundation on its website at www.borland.com. The file is rather large but comes bundled with the Java Platform which is installed along with the IDE. 3. Agent Development is performed using the JADE (Java Agent Development Environment), a set of java class libraries freely available on the internet. The Jade Platform and its documentation can be obtained from http://jade.tilab.com. Free registration is required before proceeding to the download page. Jade is available under the GPL or GNU Public license. 2.0 Design Implementation. The JADE Instant Messenger application consists of three actual agents: 1. UserAgent: Each user in the collaborative environment is represented by a UserAgent, possessing a graphical user interface which allows the User to see other UserAgents or Chat Rooms present in the system and initiate a conversation. The UserAgentGUI is the main application window and is inherited from the javax.swing.JFrame class. 2. ChatAgent: This is created when a user connects to another UserAgent. The ChatAgentGUI is a nested panel that resides within the UserAgentGUI along with other ChatAgents that collectively represent all open conversation sessions. Each user may have multiple ChatAgents but should have only one UserAgent. 3. ChatRoomAgent: These agents represent chat rooms where multiple users may broadcast messages to other members of the chat room. Chat rooms also have a GUI as they are inherited from ChatAgents and allow basic management by the creator. 2.1 UserAgentGUI. The application main window as seen by each user is shown in Figure 2.

3

Figure 2: UserAgentGUI Upon initialization, this javax.swing.JFrame subclass initializes the GUI elements and displays itself using the GridBagLayout layout manager. GridBagLayout, the most flexible layout manager in the Java Swing library, allows dynamic resizing and maintenance of a consistent look across different platforms, display sizes and window sizes. Most of the GridBagLayout design was done with JBuilder’s GUI designers and fine-tuned in code. The GUI buttons allow the user to send messages to his UserAgent instructing it to initialize the creation of chat sessions, chat rooms, etc. It is pertinent to note that the GUI cannot be updated directly from the agent code on account of the disparity in the thread processing models of JADE and Swing. Agents run in a single thread, whereas Swing objects possess a separate event dispatching thread. Method calls must therefore be made threadsafe by calling the javax.swing.SwingUtilities.invokeLater() or javax.swing.SwingUtilities.invokeAndWait() static methods of the javax.swing.SwingUtilities class when an update needs to be performed. This allows asynchronous updates to the GUI and is consistently followed throughout the code. 2.2 ChatAgentGUI. This is a nested JPanel in a JTabbedPane in the UserAgentGUI window. Multiple sessions are possible and may be switched between by clicking on the associated tabs which display the agent identifier (AID) of the chatagent associated with that session. The messages are displayed using HTML formatting in a JEditorPane object. This feature allows for future extensibility to create more engaging user experiences, incorporate graphics and tables and enable configurable fonts and color schemes. Messages are entered in a plain text field without formatting in the bottom of the GUI as in Figure 3. Both Text displays are wrapped in scroll panes allowing transparent scrolling when the display area becomes insufficient to contain the entire text body.

Figure 3: ChatAgentGUI 2.3 ChatRoomAgent. This agent is a descendant of the ChatAgent. Most of the functionality differs in subtle detail. The primary feature of and differences between the ChatRoomAgent and ChatAgent are:

4

1.

2. 3.

There exists a one-to-many relationship between ChatRoomAgents and ChatAgents. Each ChatRoomAgent appears to be a ChatAgent but acts as a “router” of messages between all members of the Chat room. By following the same protocols as the ChatAgents, the ChatRoomAgent allows unmodified ChatAgents to communicate transparently with the chat room. The ChatRoomAgent is then responsible for broadcasting these messages to all other ChatAgents. ChatRoomAgents must register with the Directory Facilitator. This allows users to connect to them. ChatRoomAgents may be created from the UserAgentGUI by clicking on “New…”; A dialog appears requesting for the name of the new chat room as in Figure 4.

Figure 4: New Chat Room Dialog 4.

ChatRoomAgentGUIs have functionality that allow management of the ChatRoom as in Figure 5. A list of chatroom members is visible, allowing the creator and administrator to select any member of the chatroom and have him evicted for whatever reason. The chat room may also be locked, preventing any further users from joining the chatroom

Figure 5: Chat Room Management Interface 5.

Users are presented with a list of all available chatrooms in the platform.

2.4 General Application Notes Transmitted messages are encrypted and signed enroute, verified and decrypted at their destination in method calls to the SecurityHelper object. The intrinsic portability of the Java Platform implies seamless function on other operating systems. This application should function unmodified on Linux or MacOS. Packaging was performed using the JAR tool or Java Archiver. All classes were packaged into a single file with a manifest referring to the JADE libraries. The JADE platform requires the Java II Runtime Environment version 1.4 or higher installed and configured on any host system. JADE is incompatible with previous Java releases. 2.5 Deployment. Compilation of the source code results in the creation of a number of Java Class files, these 38 files are cumbersome to handle and are therefore bundled into a single Java Executable Archive with the Jar tool present in the Java development environment. The resulting “jar“ file is compressed in the standard zip format, providing convenient handling and a reduced footprint. A separate folder containing support java archives, including JADE and the JBuilder libraries is also present. 2.6 Installation and Configuration.

5

Before running the application, it is necessary to edit the main.conf file which contains settings for the JADE platform which will be invoked. The “agents” section carries the name of the local UserAgent to be created. # ------ Agents -----gui=true agents=username:agentim.UserAgent The highlighted bold text above should be modified. Other parameters may also be changed as appropriate to the platform [2]. 3.0 Running the Platform. The application is tested on two hosts on an IP based network. To start the main container of the JADE platform on the first host, the following command is entered in a shell at the application root folder: java -cp gmtproject.jar jade.Boot -conf main.conf The –cp command switch refers to the main application file gmtproject.jar the manifest of which contains references to all relevant support libraries. The –conf command switch specifies the configuration file. A container is now added to this platform by starting JADE on the second host with the following command: java -cp gmtproject.jar jade.Boot –container –host host1_ip_addr -conf main.conf The UserAgent of host1 is used to initiate a chat session with host2 by selecting the user from the list and clicking connect as in Figure 6.

Figure 6: UserAgent Initiating Chat Conversely, host 2 connects to host1 and receives the message. A reply may now be sent.

Figure 7: UserAgent in Conversation

6

Messages may now be sent from either user to the other as illustrated in Figure 7. A chat room may also be created to enable group collaboration with multiple users. In Figure 8, donald creates a chat room named “conference” which is joined by steven and another user, yusuf as in Figure 9.

Figure 8: Chat Room Management All messages sent to the chat room are received by all members.

Figure 9: User in ChatRoom 3.1 Preliminary Testing Conclusions. The instant messaging capability of the application has been achieved. However, fault tolerance and robustness are untested and may require further work and debugging. Instant Messaging and electronic mail remain some of the most widely used network and Internet applications. Services and applications designed specifically for this purpose are ubiquitous. Some newer concepts of instant messaging try to make a decentralized instant messaging system via peer-to-peer technology. In such a system, a distributed hash table lookup is used to determine if buddies are online or not. This approach tries to make instant messaging independent of a central authority [1]. 4.0 Conclusions and Recommendations

7

Software agents are a viable approach to distributed system development. These applications benefit from the inherent robustness, versatility, security and other key features of the agent platform utilized. Instant messaging can be successfully implemented as a distributed agent system. Some of the constraints of this work include: 1. The system is, in reality, a hybrid system requiring a main container to perform platform management. 2. System scalability was not tested on account of the large number of hosts required. 3. Security was not subjected to systematic attack to evaluate vulnerabilities. 4. The application developed was not tested on other platforms to determine portability or platform specific bugs. 5. Agents did not utilize any ontology or domain expertise. In order to improve upon this work, the following are recommended: 1. Error handling and robustness: Future development should include code to handle unreliable networks and unpredictability in the agent lifecycle which may result from system crashes or power failures. 2. Account Management: No manner of centralized account management is implemented in the application, as a result UserAgents do not have names that would be recognizable to users or persistent between sessions. Some mechanism is necessary to grant users ability to create and manage unique persistent identities. 3. User Profiles: This was not implemented in the application because Account Management is a requirement. 4. Configurability: The user should be allowed to specify application options such as display properties. 5. Centralized Launcher: A tool is needed to allow users create new JADE platforms or connect to a known pool of already running platforms from a GUI as well as manage their accounts and profiles. 6. Documentation: Consistent and user friendly documentation is conspicuously absent.

References 1. “Instant Messaging”, http://en.wikipedia.org/wiki/Instant_messaging.htm 2. Eckel B. (2000), “Thinking in JAVA”, 2nd Edition, Prentice Hall USA. 3. Bellifemine F., Caire G., Poggi A., Rimassa G. (2005), “JADE Programming for Beginners”, Telecom Italia Lab. 4. Bellifemine F., Caire G., Poggi A., Rimassa G. (2003), “JADE: A White Paper”, Telecom Italia Lab. 5. Bellifemine F., Caire G., Poggi A., Rimassa G. (2005), “JADE Programmer Guide”, Telecom Italia Lab.

8

Suggest Documents