Remote Procedure Call
Remote Procedure Call
A remote procedure call is an interprocess communication technique that is used for client-
server-based applications. It is also known as a subroutine call or a function call.
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.
The sequence of events in a remote procedure call are given as follows −
The remote procedure call is a concept that can be implemented in different ways. It is not a
standard.
There is no flexibility in RPC for hardware architecture. It is only interaction based.
There is an increase in costs because of remote procedure call.
When the procedure finishes, the results are transferred back to the calling environment, where
execution resumes as if returning from a regular procedure call.
A remote procedure call (RPC) works in the following steps in an operating system:
Step 1: The client, client stub, and RPC run time execute on the client machine.
Step 2: A client starts a client stub process by passing parameters in the usual way. The packing
of the procedure parameters is called marshalling. The client stub stores within the client's own
address space, and it also asks the local RPC Runtime to send back to the server stub.
Step 3: In this stage, the user can access RPC by making regular Local Procedural Call. RPC
Runtime manages the transmission of messages between the network across client and server,
and it also performs the job of retransmission, acknowledgment, routing, and encryption.
Step 4: After completing the server procedure, it returns to the server stub, which packs
(marshalls) the return values into a message. The server stub then sends a message back to the
transport layer.
Step 5: In this step, the transport layer sends back the result message to the client transport layer,
which returns back a message to the client stub.
Step 6: In this stage, the client stub demarshalls (unpack) the return parameters in the resulting
packet, and the execution process returns to the caller.
1. RPC Runtime
The RPC runtime system is a library of routines and services that handle the network
communications that underlie the RPC mechanism. In the course of an RPC call, client-side and
server-side runtime systems code handle binding, establish communications over an appropriate
protocol, pass call data between the client and server, and handle communications errors.
2. Stub
The function of the stub is to provide transparency to the programmer-written application code.
On the client-side: The stub handles the interface between the client's local procedure call
and the runtime system, marshaling and unmarshaling data, invoking the RPC runtime
protocol, and if requested, carrying out some of the binding steps.
On the server-side: The stub provides a similar interface between the runtime system and
the local manager procedures executed by the server.
3. Binding
How does the client know who to call and where the service resides?
The most flexible solution is to use dynamic binding and find the server at run time when the
RPC is first made. The first time the client stub is invoked, it contacts a name server to determine
the transport address at which the server resides. The binding consists of two parts:
Naming: A Serverhaving a service to offer exports an interface for it. Exporting an interface
registers it with the system so that clients can use it.
Locating: A Clientmust import an (exported) interface before communication can begin.
Retry request message: Whether to retry sending a request message when a server has
failed, or the receiver didn't receive the message.
Duplicate filtering: Remove the duplicate server requests.
Retransmission of results: To resend lost messages without re-executing the operations at
the server-side.
Characteristics of RPC
Here are the essential characteristics of remote procedure call:
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.