Simple distributed communication mechanism

Simple distributed communication mechanism

Look into the figure mentioned below. It shows three cases marked as a,b and c. In all the 3 cases Obj1 wants to communicate with Obj2.

Communication Models- Communication Models

How are the three cases different to each other?

In Case A, Obj1 and Obj2 are collocated in the same address space of process P1 which is running on Machine M1.

In Case B, Obj1 and Obj2 are located in different address spaces of process P1 and P2 respectively which are running on Machine M1.

In Case C, Obj1 and Obj2 are located in different address spaces of process P1 and P2 respectively running on different Machine M1 and M2 respectively.

Technically Case A is an example of Local Communication model as Obj1 and Obj2 are collocated in the address space of process P1 while Case B and C are examples of remote or distributed communication model as Obj1 and Obj2 are located across different address spaces belonging to different processes.

Please note – For a call to be considered as a remote call, the processes in which these objects are based has to be different.

The following are the prerequisites for Object Communication.

  1. The called object should be existing.
  2. The calling object should know the address of the called object.
  3. Calling object should know the type of the called object.

If all of these prerequisites are true, Obj1 can communicate with Obj2.

In Case A, if Obj1 knows the address of Obj2 along with other prerequisites, Ob1 can interact with Obj2.

Now can we think as to how will Obj1 communicate with Obj2 in Case B and Case C.

As we know Case B and C are examples of remote/distributed communication model. In Case B even if Obj1 knows the address of Obj2 , the communication cannot take place between the same because the address spaces are different. As Obj1 and Obj2 are in different address spaces whatever address of Obj2 which Obj1 was aware of will become invalid within the address space of Process P1. The same is the case in Case C as well.

So how will the communication happen in Case B and Case C?

Whenever I pose this question to my participants in my training programs, the usual answer that I get is I can use a proxy or a stub to do this task.

Now ask yourself .. Do you actually need a proxy or a stub to do this task?

I can say .. you don’t need a proxy or a stub for this purpose. Even without using proxies/ stubs this task can be achieved .Proxies or stubs can definitely make Obj1 communicate with Obj2 … but this is not the reason they should be used.

The below mentioned analogy can help us find out the answer for the same

Please look into the figure mentioned below

Figure Figure - Analogy.

Lets say that there are two friends P1 and P2 staying in Delhi and both of them have landline telephone connections.

Now for P1 to communicate to P2 the pre requisite is that P1 should know the telephone number of P2 and P2 should be willing to talk.

Let say P1 knows the telephone number of P2 which is 555555 and P2 is also willing to speak to P1.

So P1 makes a call to P2 and the communication happens. This is Case A of the previous figure

But let me tweak this situation a bit.

Lets say now P1 moves to Mumbai and P2 continues to stay in Delhi.

So P1 knows the telephone number of P2 which is 5555555 ,but this time he is not able to speak to P2 .

Can we think about the reason?

The address space of Mumbai and Delhi is different, hence although you know the telephone number of your friend P2 , still P1 will not be able to communicate with P2.

So how do we solve this problem?

I am sure we all know the answer. now P1 dial 011-5555555 ie the address space code followed by the telephone number and you will see it works.

This is case B of the previous figure

Now let me change the situation a bit more.

Lets say now P1 moves to London and P2 continues to stay in Delhi.

I hope you will realize if P1 just dials just 5555555, its not going to work out, so how does P1 solve this problem?

He will now dial 0091-011-555555 i.e. the country code followed by the city code followed by the number and now P1 is able to communicate with P2.

This is case C of the previous figure.

What can we infer out of this discussion?

Every object has a fully qualified address. The moment the client knows the fully qualified address of the target object, he can communicate with the target object.

For software objects the fully qualified address is a combination of the ip address of the machine, the pid of the process and the relative memory location address wrt the pid.

Once a person knows the fully qualified address of a software object , a person can directly open a connection to that memory location using simple unix or java sockets.

Now do we need to use proxies? No.

This is called as a Simple Distributed Communication Mechanism (SDCM) wherein objects involved in the communication, interacts with each other using the fully qualified address of each other.

But there are certain limitations of Simple Distributed Communication Mechanism.

For SDCM to work out, the source object should be able to compute the fully qualified address, which can only be done if the location/address of the target object doesn’t change.

Remote Procedure Calls(RPCs) and Remote Function Calls (RFCs) are excellent examples of SDCM.

 
Hemant Jha
Founder - VPlanSolutions
Researcher, Trainer

www.VPlanSolutions.co.in