Communication and migration of an embeddable mobile agent platform supporting runtime code mobility

In this paper we present the design and the implementation of Mobile-C, an IEEE Foundation for Intelligent Physical Agents (FIPA) compliant agent platform for mobile C/C++ agents. Such compliance ensures the interoperability between a Mobile-C agent and other agents from heterogeneous FIPA compliant mobile agent platforms. Also, the Mobile-C library was designed to support synchronization in order to protect shared resources and provide a way of deterministically timing the execution of mobile agents and threads. The new contribution of this work is to combine the mechanisms of agent migration and their synchronization. KeywordsMobile agent; Mobile agent platform;Agent communication.


INTRODUCTION
Mobile agent is a design program with a persistent identity which migrates in the network and communicates with its environment and other agent [1].It has been applied to a variety of distributed applications, such as manufacturing [2][3][4], electronic commerce [5][6][7], network management [8,9], health care [10], and entertainment [11].During the execution, mobile agents can be dynamically created and sent to the destination systems to perform tasks with the up-to-date code.The mobility allows mobile agent to migrate from one host to another in the network and provides a several applications with flexibility and adaptability that are both able to satisfy the requirement and condition in a distributed environment.
The importance of Mobile agent technology in the design of distributed applications on the web has led the OMG (Object Management Group) to define the specifications MASIF (Mobile Agent System Interoperability Facility) for interoperability between different systems to mobile agents.Another effort is made by FIPA (Foundation for Intelligent Physical Agents) to specify the architecture and also the semantics of communication between mobile agents.
The majority of mobile agent platforms in use are Javaoriented.Multiple mobile agent platforms supporting Java mobile agent code include Mole [12], Aglets [13], Concordia [14], JADE [15], and Agents [16].Using a standard language like the mobile agent code language that provides both highlevel and low-level functionalities is a good choice to treat with the large number of distributed applications.The choice of C/C++ is a proper for a mobile agent code language because it's provides powerful functions in terms of memory access.Furthermore, C is a language which can easily interface with a variety of low-level hardware devices.Ara [17,18] and TACOMA [19] are two mobile agent platforms supporting C mobile agent code, while Ara also supports C++.Mobile agent code is compiled as byte code [20] and machine code [21] for execution in both Ara and TACOMA, respectively.Mobile-C [22][23][24][25] was originally developed as a standalone, IEEE FIPA compliant mobile agent platform to accommodate applications where low-level hardware is involved and embedded systems [26].Most of the systems are written in C/C++; Mobile-C chose C/C++ as the mobile agent language because C has an advantage for easy interfacing with control programs and underlying hardware.Additionally, Mobile-C integrated an embeddable C/C++ interpreter, Ch [27][28][29], as the Agent Execution Engine (AEE) in order to run the mobile agent code.The migration of mobile agent in Mobile-C is achieved through FIPA agent communication language (ACL) messages.Using FIPA ACL messages for agent migration in FIPA compliant agent systems simplifies agent platform, reduces development effort and easily achieves interplatform migration through well-designed communication mechanisms provided in the agent platform.Messages for agent communication and migration are presented in FIPA ACL and encoded in XML.Also, the Mobile-C library was designed to support synchronization [26] in order to protect shared resources and provide a way of deterministically timing the execution of mobile agents and threads.
In this paper we present the Mobile-C library that can embed Mobile-C into any C/C++ programs to facilitate the design of mobile agent-based applications, also the possibility www.ijacsa.thesai.org to combine the migration of the mobile agent over the network and the synchronization mechanism existing in Mobile-C.Mobile agents are an application that can control the agent platform, its modules and other mobile agents, as well as smoothly interface with a variety of low-level hardware devices.Using FIPA ACL messages for agent migration in FIPA compliant agent systems simplifies agent platform since both agent communication and migration can be achieved through the same communication mechanism provided in the agent platform.Flexible synchronization mechanisms have been added for execution and interaction of several mobile agents.This paper proposes a new approach by combining two concept migration and synchronization supports in Mobile-C.
The remainder of the article is structured as follows.In section 2, we present the concept and the properties of mobile agent.Section 3 introduces the architecture of Mobile-C.Section 3 presents the migration of mobile agent over the network from multiple hosts.Section 4 describes the program structure and implementation of the component of agency.Section 5 gives an example of a mobile agent that migrates from hosts via mobile agent messages and illustrates the synchronization support in Mobile-C.

II. MOBILE AGENTS
An agent is defined as "person who's acting on behalf of other people" [30].In the context of computer science, mobile agent is considered as an entity that moves from one machine to another in the network to perform certain tasks on behalf of the user [31].
Mobile agents have the following properties which distinguish them from other programs [32]:  Adaptability -Mobility of agent required to learn about user's behavior and adapt it to suit the user.Indeed, to evolve adequately the differences between heterogeneous systems, the agent must be able to adopt the changes during the execution.
 Autonomy-Mobile agent must be able to make his own decision to be performed to achieve the user's tasks, also he must be able to migrate from one machine to another in the network and execute the user's tasks.
 Communication -Mobile agent must have the ability to communicate with others agents of the system in order to exchange information and benefit from the knowledge and expertise of other agents.
 Mobility-Mobile agent has the ability to move from one host to another, either by moving the agent's code or by serializing both code and state to allow the agent to continue the execution in a new context.
 Persistence -A persistent agent it will be able to retain the knowledge and state over extended period of time to be accessed later on.Once the mobile agent is set up, it is not dependent on system that has been initiated and it is automatically recovered when the agent is terminated or when it is flushed from memory to the database.

III. THE ARCHITECTURE OF MOBILE-C
The system of mobile-C is shown in figure1.Agencies are the major building blocks of the system and abode in each node of a network system in order to support Stationary Agents (SA) and Mobile Agents (MA) at runtime.They serve for locating and messaging agents, moving mobile agents, collecting knowledge about other agents and providing several places where the agent can be run.The core of an agency provides local service for agents and proxies remote agencies.The principle of an agency and their functionalities can be summarized as follows [33]:  Agent Management system (AMS): The AMS manages the life cycle of agents in the system.It relates the creation, authentication, registration, deletion,execution, migration and persistence of agents.AMS is also responsible for receiving and dispatching mobile agent's .Each agent must register with an AMS in order to get a valid AID.
 Agent Communication Channel (ACC): The ACC forwardsmessages between local and remote entities.The interaction and coordination of mobile agents and host systems can be performed through agent communication language (ACL).
 Agent Security Manager (ASM): The ASM is responsible for protection of access for platform and infrastructure.
 Directory Facilitator: DF serves yellow page services.Agents in the system can register their services with DF for providing to the community.They can also look up required services with DF.
 Agent Execution Engine (AEE): AEE serves as the workhorsefor mobile agents.Mobile agents must reside inside an engine to execute.AEE has to be platform independent in order to support a mobile agent executingin a heterogeneous network.IV.MOBILE AGENT MIGRATION Mobile agent is a software agent who is able to migrate from one host to another over the network and resume the www.ijacsa.thesai.orgexecution in the new host.The migration and the execution of mobile agents are supported by a mobile agent system.In previous studies, Chen et al. have developed a mobile agent system called Mobile-C.The Mobile-C supports weak migration.The task of a mobile agent can be divided into several subtasks whichcan be executed in different hosts and listed in a list of tasks as shown in figure 2.
The task list can be modified by adding new subtasks and new conditions.Changing dynamically the task list improves the flexibility of a mobile agent.Thus, once we start the execution of a subtask in a host, the mobile agent cannot move until the end of execution.Mobile agent migration is achieved through ACL mobile agent messages encoded to XML, which convey mobile agents as the content of a message.Mobile agent message containsthe data state and the code of an agent.The data state of mobile agent include general information about mobile agent as agent name, agent owner and agent home , also the tasks that mobile agent will performed on destination hosts.The data state and code will be wrapping up into an ACL message and transmitted to a remote host trough Agent Communication Channel.Mobile agent migration based on ACL messages is simple and effective for agent migration in FIPA compliant systems because these systems have mandatory mechanisms for message communication, transmission and procession.

V. THE PROGRAM STRUCTURE AND IMPLEMENTATION OF
COMPONENT OF AGENCY An agency is a principle program running in each node of the network [23].When the execution of an agency is started, the system is initialized and threads are created for all of the components in the agent platform.
After the initialization of the system, the agency waits for defined events.When the agency receives a request to run a mobile agent, it creates a new thread and embeds an Embeddable C/C++ Interpreter -Ch into the thread for executing mobile agent code.After the mobile agent migrates to the other hosts, this thread is terminated automatically (figure 3).If the agency receives a system termination request, the execution of agent platform and the system itself will be finished.In the current implementation, each mobile agent runs in an embeddable Ch inside its own thread.Amongproperties of mobile agents is the ability to immigrate to perform tasks that exist in the remote host.The purpose of this example is to use an embeddable mobile agent system to protect shared resources by used the synchronization and combines it with the migration of mobile agents from hosts.
The Mobile-C library allows synchronization via mutex.The mutex is a program that allows multiple threads to share the same resource, but not simultaneously.
The example below demonstrates the capabilityof a Mobile-C mutex to protect a resource that may be shared between two or more agents in several hosts.As shown in program 1, a mobile agent is transferred by an agency in the host fsts1 visits remote host fsts2 then host fsts3 .The mobile agent message is represented in Extensible Markup Language (XML), it contains information of the mobile agent and tasks that will be performed on destination hosts.The general information of a mobile agent contains:agent name, agent owner, and the home of the agent.The task information for example the statement <TASK task="2" num="0"> shows that this mobile agent has two tasks to perform and no task has been done yet.The DATA element overall information about the number of element, the name of the task's return variable, the completeness of the task and the host to perform the task.The sub-element DATA ELEMENT contains the return data from the execution task and the sub-element AGENT_CODE contains a C program which will be executed in remote host.<NAME>mobileagent</NAME> <OWNER>fsts</OWNER> <HOME>fsts1.fsts.ac.ma:5125 </HOME> <TASK task= "2" num= "0"> <DATA number_of_elements ="0" name = "results_fsts2" complete = "0" server = "fsts2.fsts.ac.ma:5138"> <DATA_ELEMENT></ DATA_ELEMENT > <AGENT_CODE> Mobile agent code on fsts2 </AGENT_CODE> </DATA> <DATA number_of_elements ="0" name = "results_fsts3" complete = "0" server = "fsts3.fsts.ac.ma:5135"> <DATA_ELEMENT></ DATA_ELEMENT > <AGENT_CODE> Mobile agent code on fsts3 </AGENT_CODE> </DATA> </TASK> Program 1: The content of the mobile agent message from the host fsts1 to fsts2 and to host fsts3 As shown in Program2, the mobile agent 1" MA1" initialize a mutex with an ID 55 via the function mc_SyncInit() and defines two functions, SetN1() and GetN1() in the host fsts2 .After visiting this host, the mobile agent 1 "MA1" visits the host fsts3 and defines also two functions, SetN2() and GetN2().The result obtained from the host fsts2 is sent to the host fsts3 and the return data will be included in the subelement DATA_ELEMENT.<NAME>MA1</NAME> <OWNER>fsts</OWNER> <HOME> fsts1.fsts.ac.ma:5125 </HOME> <TASK task= "2" num= "0"> <DATA number_of_elements ="0" name = "results_fsts2" complete = "0" server = "fsts2.fsts.As shown in Program 3, the task of the mobile agent 2"MA2" is to perform the operation setting the variable.The operation includes locking the mutexthrough the function mc_MutexLock(), setting the global variable by calling www.ijacsa.thesai.orgACL messages which is encoded in XML, and the execution of mobile agents is resumed by the task progress pointer.The Mobile-C library supports the synchronization among mobile agents and threads because the synchronization functions protect shared resources and provide a way of deterministically timing the execution of mobile agents and the migration to a remote host.
In our future work, this framework will be tested and extended in various types of industrial applications like ecommerce and network management.

Figure 1 .
Figure 1.The system architecture of agencies in Mobile-C.

Figure 2 .
Figure 2. Agent migration based on a task list and a task progress pointer.

Figure 3 .Figure 4 .
Figure 3.The program structure of an agencyAccording to the FIPA specifications, each agency should provide mechanisms to receive and send messages.This requirement is satisfied by three components: listening thread, connecting thread and ACC processing thread as shown in Figure4.The listening thread serves to listen for client connections.When a new connection client is accepted, it will be added to the connection list.Also, the connecting thread is responsible for making connections with other hosts.The ACC processing thread processes the lists of client connections and requests for connecting remote hosts.The ACC facilitates remote agent to agent communication and remote agent platform to agent platform communication via ACL messages.Remote horizontal communication in Mobile-C is implemented on top of TCP/IP and the transport protocol uses HTTP (HyperText Transfer Protocol).