written 8.8 years ago by | • modified 8.8 years ago |
RPC system model
- The RPC model is similar to the procedure call model which is used to transfer control and data within a program.
- In a procedure call, the caller places arguments to the procedure which transfers the control to the instructions consisting of the body. This body is executed in a new environment which has several copies of the arguments. Once the execution is over the control is returned to the calling point and a result is returned.
- RPC mechanism is an extension of the procedure call mechanism.
- A call is made to a procedure that is not in the address space of the calling process. This call can be on same or different machine.
- Since caller and callee have different address spaces, the remote procedure cannot access data variables of the caller’s environment. Due to this RPC uses message passing scheme to exchange information between caller n callee.
The following diagram describes the processes of RPC model:
1.The caller or client process sends a call request message to the callee or server process and then waits for a reply. The request message consists of remote procedure parameters.
2.On receiving the message, the server process executes the procedure and returns a result in a reply message that is sent to client process.
3.When the client receives the reply message, the result of the execution is extracted and the caller’s execution is resumed.
- In short the server waits for a request message to process the procedure parameters, compute the result and send a reply to the client and wait for next message.
- Example: An implementation may choose to have RPC calls to be asynchronous, so that the client may do useful work while waiting for the reply from the server. Another possibility is to have the server create a thread to process an incoming request, so that the server can be free to receive other requests.
RPC Implementation Mechanism
- RPC mechanism uses the concepts of stubs to achieve the goal of semantic transparency.
- Stubs provide a local procedure call abstraction by concealing the underlying RPC mechanism.
- A separate stub procedure is associated with both the client and server processes.
- RPC communication package known as RPC Runtime is used on both the sides to hide existence and functionalities of a network.
- Thus implementation of RPC involves the five elements of program:
- Client
- Client Stub
- RPC Runtime
- Server stub
- Server
The client, the client stub, and one instance of RPC Run time execute on the client machine.
The server, the server stub, and one instance of RPC Run time execute on the server machine.
Remote services are accessed by the user by making ordinary LPC.
1. Client
- A Client is a user process which initiates a RPC
- The client makes a normal call that will invoke a corresponding procedure in the client stub.
2. Client Stub
Client stub is responsible for the following two tasks:
i. On receipt of a call request from the client, it packs specifications of the target procedure and arguments into a message and asks the local RPCRuntime to send it to the server stub.
ii. On receipt of the result of procedure execution, it unpacks the result and passes it to the client.
3. RPCRuntime
- Transmission of messages between Client and the server machine across the network is handled by RPCRuntime.
- It performs Retransmission, Acknowledgement, Routing and Encryption.
- RPCRuntime on Client machine receives messages containing result of procedure execution from server and sends it client stub as well as the RPCRuntime on server machine receives the same message from server stub and passes it to client machine.
- It also receives call request messages from client machine and sends it to server stub.
4. Server Stub
Server stub is similar to client stub and is responsible for the following two tasks:
i. On receipt of a call request message from the local RPCRuntime, it unpacks and makes a normal call to invoke the required procedure in the server.
ii. On receipt of the result of procedure execution from the server, it unpacks the result into a message and then asks the local RPCRuntime to send it to the client stub.
5. Server
When a call request is received from the server stub, the server executes the required procedure and returns the result to the server stub.