Click here to Skip to main content
6,595,444 members and growing! (18,908 online)
Email Password   helpLost your password?
Development Lifecycle » Design and Architecture » Design and Strategy     Intermediate License: The Code Project Open License (CPOL)

Achieving Software Mobility

By Rezaul Hoque

Achieving Software Mobility
C#, Windows
Posted:2 Feb 2008
Updated:3 Feb 2008
Views:7,242
Bookmarked:7 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
12 votes for this article.
Popularity: 3.32 Rating: 3.07 out of 5
2 votes, 16.7%
1
2 votes, 16.7%
2

3
2 votes, 16.7%
4
6 votes, 50.0%
5

Introduction

Can we have Softwares move from one machine to another on their own. We certainly can. Mobility of a software on its own opens a whole new door to the way we think of consuming services on servers. To consume a service from another machine, the general or more talked ways are to a invoke a web service or to make a RPC/RMI call. But if we can introduce the attribute of mobility in a software, it can travel to another machine and consume a service and either hop to more servers or come back home.

Background

Lets first try to understand a bit about remote method invocation before I move down to object mobility. Remote Method Invocation (RMI) is a common way nowadays via which we can have services or objects residing on remote machines and can call those functions from a local machine.

It�s pretty interesting how it is done. Over here we will not go into the details of how it is implemented, but simply here is a picture that might help you visualize what is going on.

rmi.jpg

The coding complexity is not huge but what is happening under the hood which is a bit tricky to understand. Again in short using RMI we can actually call a function of an object which is not residing in the same machine.

Software Mobility

Now, what if instead of our software being able to call a function on the remote object we could have our object itself travel over the network. Sounds interesting, then fasten your seat belt and read on how it is done.

This is a pretty interesting concept called Object or Agent mobility or in more general Terms Software Mobility. We can send in an object over the network which will wake up on another machine and then it can do some specified task, and then come back. Pretty interesting isn�t it. Here is a picture to visualize it.

agentmobility.jpg

So now what we have here is instead of calling a function of a remote object we are sending our own object to go to another remote machine and do some processing over there and then come back with results. If we can make our objects intelligent and they have mobility then we can do wonders.

The implementation portion is not rocket science at all so here is a bit of idea how it is done. It is two folded:

  1. How to transfer objects from one machine to another.
  2. How to receive and send back the object

The first question is simple to answer. We need to learn how to transfer objects via networks. Be carefull to serialize the class whose object you will be sending accross the network using Serializable attribute. I will let the reader figure out how to trasnfer a object over the network using a TCP Connection. I will just say it can be done.

For the second question, we should make our server aware of the fact that they will and can receive such objects, so on receiving such an object it will know which function of the object to call to start the object and the object should in turn know which function of the server to call to be able to get back home. As the Sever should have some mechanism to throw back an object, the server will get the home address (home ip) of the object from its data and then throw him back functions. Therefore in short there should be a specified interface an agent should follow so that based on that interface the remote machine can call up some functions of the agent. And also the server should have a defined interface so that the agent can call the remote machines function. For a bit of more clarification here are interfaces that may get you started off.

IAgentServer

interface IAgentServer
{
    /**
     * The agent wants to be sent to address ip and port.
     * 
     * @param Agent     - reference to an agent object ("this")
     * @param DstAddr    - destination address (IP Address)
     * @param DstPort    - destination port
     * 
     */
     public void AgentMigrate(IMobileAgent Agent, String DstAddr, int DstPort);



    /**
     * The agent wants to be sent back to home. From the host it came.
     * 
     * @param agent    - reference to an agent object ("this")
     * 
     */
    public void AgentSendBackToHome(IMobileAgent Agent);



    /**
     * Server returns the fileName avaliable to perform a search on.
     * 
     */
    public string AgentGetSearchFileName();

}
          

IMobileAgent

interface IMobileAgent
{
    /**
     * An AgentServer invokes this method. It is used to tell an agent
     * This method should invoke the method start of the object that
     * represents the agent.
     * 
     * @param Srv - reference to that server object that received the agent object
     */
    public void AgentArrived(IAgentServer Srv);


    /**
     * Print results extracted from different servers
     * 
     */ 
    public void PrintResults();
    
}  

Apart from the implementations of this interfaces you will need another class or function which will create, initialize the object and throw it to a server and wait to receive the object back, when it is thrown back by the server.

Please note, the server should be listening on a specified port all the time and will receive the objects. On getting an object it will call the objects AgentArrived(�) function. When the object decides it wants to go back to home it will call the servers AgentSendBackToHome (�) function. The agent might or can travel to another server instead of going home and that can be achieved by the agent calling the servers AgentMigrate(..) function.

Points of Interest

An example and usage of this object mobility is in distributed search, where we can have multiple agents with different AI in them traveling to different servers and extracting information and then coming back from where they started. All the results of the agents can be deduced to a meaningful search result. For a moment think wild and I am sure you will come up with dozen of other useful things you can do, since now you know something like this can be done. And top of it is it not cool that your software is actually roaming around the network.

I hope this post sheds a bit of light on Object mobility. And now its time to play around with this and make interesting stuff. Have fun !

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Rezaul Hoque


Member
My name is Reza, currently doing Masters in Software Engineering of Distributed Systems at KTH - The Royal Institute of Technology, (Sweden).

My area of interest is building large scalable systems in a Distributed environment and Peer to peer streaming over the internet.

Anything that needs to be scaled massively on the internet is of interest to me !
Occupation: Software Developer
Location: Sweden Sweden

Other popular Design and Architecture articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
GeneralDon't make simple things more complex than they are Pinmembersergueis17:02 11 Feb '08  
GeneralRe: Don't make simple things more complex than they are [modified] PinmemberRezaul Hoque3:04 12 Feb '08  
GeneralRe: Don't make simple things more complex than they are Pinmembersergueis18:14 18 Feb '08  
GeneralWhy not web services? PinmemberMember 15763383:53 5 Feb '08  
GeneralRe: Why not web services? PinmemberRezaul Hoque4:39 5 Feb '08  
Generalhow to save the state of the mobile object? Pinmembermozay12:51 2 Feb '08  
GeneralRe: how to save the state of the mobile object? PinmemberRezaul Hoque13:05 2 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 3 Feb 2008
Editor:
Copyright 2008 by Rezaul Hoque
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project