Chapter 4-3
Chapter 4-3
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.
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.
Message Passing:
Components communicate by sending and receiving messages.
Can be synchronous (blocking) or asynchronous (non-blocking).
Shared Memory:
Event-based Communication:
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.
1. Client
2. Client Stub
3. RPC Runtime
4. Server Stub
5. Server
RPC Architecture
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
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.
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
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.
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.
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.
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).
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.
8. RPC does not provide any security. While it provides client level security.
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.