0% found this document useful (0 votes)
7 views

Chapter 4-3

Chapter 4 discusses communication protocols in networking, emphasizing the importance of layered protocol architecture for simplifying complex communication tasks. It covers various types of communication methods, including Remote Procedure Call (RPC) and Remote Method Invocation (RMI), detailing their architectures and processes. The chapter also compares RPC and RMI, highlighting their differences in efficiency, programming ease, and security features.

Uploaded by

kasutaye192
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 4-3

Chapter 4 discusses communication protocols in networking, emphasizing the importance of layered protocol architecture for simplifying complex communication tasks. It covers various types of communication methods, including Remote Procedure Call (RPC) and Remote Method Invocation (RMI), detailing their architectures and processes. The chapter also compares RPC and RMI, highlighting their differences in efficiency, programming ease, and security features.

Uploaded by

kasutaye192
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Chapter 4: Communication (6 hrs)

4.1. Layer protocols

A protocol is a set of rules and standards that primarily outline a language that devices will use to
communicate. There are an excellent range of protocols in use extensively in networking, and that
they are usually implemented in numerous layers.

A layered protocol architecture provides a conceptual framework for dividing the complex task
of exchanging information between remote hosts into simpler tasks. When the communication is
complex, we must divide the task between different layers, so, we need to follow a protocol at each
layer, this technique we used to call protocol layering. This layering allows us to separate the
services from the implementation.

In networking, layering. means to break up the sending of messages into separate components and
activities. Each component handles a different part of the communication.

Each layer needs to receive a set of services from the lower layer and to give the services to the
upper layer. The modification done in any one layer will not affect the other layers.

4.2. Types of Communication

Communication in a distributed system refers to the process by which different components (or
nodes) of the system exchange data and coordinate actions to achieve a common goal. This
interaction is crucial for the system to function correctly, as distributed systems often consist of
multiple autonomous entities that need to work together.

Remote Procedure Call (RPC):

 Allows a program to execute a procedure on a remote server as if it were local.


 Simplifies communication by abstracting network details.

Message Passing:
 Components communicate by sending and receiving messages.
 Can be synchronous (blocking) or asynchronous (non-blocking).

Shared Memory:

 Multiple processes access a common memory space.


 Requires synchronization mechanisms to avoid conflicts.

Broadcast and Multicast:

 Broadcast: Sending messages to all nodes in the network.


 Multicast: Sending messages to a specific group of nodes.

Event-based Communication:

 Components communicate through events, often using event-driven architectures.


 Useful for decoupling components.

4.3. Remote Procedure Call

What is RPC?

Remote Procedure Call (RPC) Remote Procedure Call is a software communication protocol
that one program can use to request a service from a program located in another computer on a
network without having to understand the network’s details. RPC is used to call other processes
on remote systems like a local system. A procedure call is also sometimes known as a function
call or a subroutine call.

Is an n interprocess communication technique that is used for client-server based applications.


RPC uses the client-server model. The requesting program is a client, and the service-providing
program is the server.
A client has a request message that the RPC translates and sends to the server. This request may
be a procedure or a function call to a remote server. When the server receives the request, it sends
the required response back to the client. The client is blocked while the server is processing the
call and only resumed execution after the server is finished.
RPC Architecture

RPC architecture has mainly five components of the program:

1. Client
2. Client Stub
3. RPC Runtime
4. Server Stub
5. Server
RPC Architecture

How RPC Works?

Following steps take place during the RPC process:


1. The client calls the client stub. The call is a local procedure call with parameters pushed onto
the stack in the usual way.

2. The client stub packs the procedure parameters into a message and makes a system call to send
the message. The packing of the procedure parameters is called marshaling.

3. The client's local OS sends the message from the client device to the remote server device.

4. The server OS's transport layer passes the incoming packets to the server stub.

5. The server stub unpacks the parameters -- called unmarshaling -- from the message.

6. When the server procedure is finished, it returns to the server stub, marshaling the return values
in a message. The server stub then sends the message to the transport layer.

7. The transport layer sends the message to the client transport layer, which then returns the
message to the client stub.

8. The client stub unmarshalls the return parameters and the execution returns to the caller.

Characteristics of RPC

Here are the essential characteristics of RPC:

 The called procedure is in another process, which is likely to reside in another machine.
 The processes do not share address space.
 Parameters are passed only by values.
 RPC executes within the environment of the server process.
 It doesn’t offer access to the calling procedure’s environment.

4.4. Remote Method invocation

RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in
one system (JVM) to access/invoke an object running on another JVM.

Remote Object Invocation (ROI) is a communication mechanism used in distributed systems that
allows a program to invoke methods on an object located on a different machine or process as if it
were local.
RMI creates a public remote server object that enables client and server-side communications
through simple method calls on the server object.

Stub Object: The stub object on the client machine builds an information block and sends this
information to the server.
The block consists of

 An identifier of the remote object to be used


 Method name which is to be invoked
 Parameters to the remote JVM
Skeleton Object: The skeleton object passes the request from the stub object to the remote
object. It performs the following tasks
 It calls the desired method on the real object present on the server.
 It forwards the parameters received from the stub object to the method.
Working of RMI
The communication between client and server is handled by using two intermediate objects: Stub
object (on client side) and Skeleton object (on server-side) as also can be depicted from below
media as follows:
Architecture of an RMI Application

In an RMI application, we write two programs, a server program (resides on the server) and
a client program (resides on the client).

 Inside the server program, a remote object is created and reference of that object is made available
for the client (using the registry).
 The client program requests the remote objects on the server and tries to invoke its methods.

The following diagram shows the architecture of an RMI application.


Let us now discuss the components of this architecture.

 Transport Layer − This layer connects the client and the server. It manages the existing
connection and also sets up new connections.
 Stub − A stub is a representation (proxy) of the remote object at client. It resides in the client
system; it acts as a gateway for the client program.
 Skeleton − This is the object which resides on the server side. stub communicates with this
skeleton to pass request to the remote object.
 RRL(Remote Reference Layer) − It is the layer which manages the references made by the client
to the remote object.

Working of an RMI Application

The following points summarize how an RMI application works −

 When the client makes a call to the remote object, it is received by the stub which eventually passes
this request to the RRL.
 When the client-side RRL receives the request, it invokes a method called invoke() of the
object remoteRef. It passes the request to the RRL on the server side.
 The RRL on the server side passes the request to the Skeleton (proxy on the server) which finally
invokes the required object on the server.
 The result is passed all the way back to the client.

Marshalling and Unmarshalling

Whenever a client invokes a method that accepts parameters on a remote object, the parameters
are bundled into a message before being sent over the network. These parameters may be of
primitive type or objects. In case of primitive type, the parameters are put together and a header is
attached to it. In case the parameters are objects, then they are serialized. This process is known
as marshalling.

At the server side, the packed parameters are unbundled and then the required method is invoked.
This process is known as unmarshalling.

RMI Registry

RMI registry is a namespace on which all server objects are placed. Each time the server creates
an object, it registers this object with the RMIregistry (using bind() or reBind() methods). These
are registered using a unique name known as bind name.

To invoke a remote object, the client needs a reference of that object. At that time, the client fetches
the object from the registry using its bind name (using lookup() method).

The following illustration explains the entire process −


S.NO RPC RMI

RPC is a library and OS dependent


1. Whereas it is a java platform.
platform.

RMI supports object-oriented


2. RPC supports procedural programming.
programming.

RPC is less efficient in comparison of


3. While RMI is more efficient than RPC.
RMI.

4. RPC creates more overhead. While it creates less overhead than RPC.
S.NO RPC RMI

The parameters which are passed in RPC While in RMI, objects are passed as
5.
are ordinary or normal data. parameter.

6. RPC is the older version of RMI. While it is the successor version of RPC.

There is high Provision of ease of While there is low Provision of ease of


7.
programming in RPC. programming in RMI.

8. RPC does not provide any security. While it provides client level security.

While it’s development cost is fair or


9. It’s development cost is huge.
reasonable.

There is a huge problem of versioning in While there is possible versioning using


10.
RPC. RDMI.

There is multiple codes are needed for While there is multiple codes are not
11.
simple application in RPC. needed for simple application in RMI.

Can be complex due to low-level


12. Generally simpler to use and implement
implementation

You might also like