Introduction to RPC Mechanism in Distributed Applications
The Remote Procedure Call (RPC) mechanism allows calls to procedures residing outside the calling process's address space. RPC simplifies distributed computing by providing simple call semantics, a well-defined interface, and efficient communication. This mechanism enables communication between client and server processes through a message-passing scheme, ensuring data isolation and secure parameter exchange.
Uploaded on Feb 26, 2025 | 0 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
3.1 Introduction 3.2 RPC Model 3.3 RPC Mechanism 3.4 Stub Generation 3.5 RPC Messages 3.6 Marshaling Arguments & Results 3.7 Communication Protocol for RPCs 3.8 Client-Server Binding 3.9 Exception Handling 1
3.1 Introduction RPC mechanism enables a call to be made to a procedure that does not reside in the address space of the calling procedure The remote procedure may be on the same computer as the calling process or on a different computer RPC is the popular mechanism used for distributed applications 2
Introduction Contd. RPC Features Simple & Familiar call Semantics Specification of well defined interface Ease of use: Clean and simple semantics makes it easier to build distributed computations Generality Efficiency: Procedure calls are simple enough for communication to be quite rapid RPC can be used as IPC mechanism 3
3.2 RPC Model Similar to procedure call model Caller places procedure arguments in pre-specified location Control is then transferred to the procedure Procedure is executed in a newly created execution environment that includes copies of arguments After the procedure s execution is over, control returns to the calling point with result 4
3.2 RPC Model Contd. As the caller and callee processes have disjoint address spaces, the remote procedure has no access to the data and variables of the caller s environment. Therefore the RPC facility uses a message passing scheme for information exchange. 5
3.2 RPC Model Contd. The server process is normally dormant, awaiting the arrival of a request message. When one arrives: Server process extracts the procedure s parameters, Computes the result Sends a reply message Awaits the next call message 6
3.2 RPC Model Contd. Typical model of Remote Procedure Call Caller Callee (client process) (server process) Request message (contains remote procedure s parameters) Call procedure and Wait for reply Receive request; Start Procedure Execution Procedure Executes Send Reply; Wait for next request Resume Reply message (contains result of procedure execution) Execution 7
3.3 RPC Mechanism Client Server client server Execute Return Call Call Return Client stub Server stub Unpack Pack Unpack Pack RPCRuntime RPCRuntime wait Receive send Receive Send Call packet Result packet 8
3.3 RPC Mechanism Contd. RPC Mechanism involves following procedure through the elements of programs Client: User process that initiates a procedure call. It s a 1. normal local call that initiates a corresponding procedure in the next element i.e. Client Stub Client Stub: On receipt of a call request from the client, 2. it packs the specification of target procedure and arguments into a message and then asks the local RPC Runtime to send it to the next element i.e. Server stub 9
3.3 RPC Mechanism Contd. RPC Runtime: Handles transmission of messages across 3. the networks between client and server machines. The RPC Runtime on the client machine receives the call request message from the client stub and sends it to the server machine Server Stub: On receipt of the call request message from 4. the local RPC Runtime, server unpacks it and makes a perfectly normal call to invoke the appropriate procedure in the server 10
3.3 RPC Mechanism Contd. Server: On receiving a call request from the server stub 5. server executes the appropriate procedure and returns the result of the procedure execution to the server stub 6. Server Stub: On receipt of the result of procedure execution from the server, server stub packs the result into a message and then asks the local RPC Runtime to send it to the client stub 11
3.3 RPC Mechanism Contd. 7. RPC Runtime: The RPC Runtime on the server machine receives the message containing the result of procedure execution from the server stub and sends it to the client machine 8. Client Stub: On receipt of result of the procedure execution, it unpacks the result and passes to the client 12
3.4 Stub Generation Stubs can be generated in one of the two ways Manually: 1. RPC implementer provides a set of translation functions from which a user can construct his or her own stubs Simple to implement Can handle complex parameter types 13
3.4 Stub Generation Contd. 2. Automatically: More commonly used method for stub generation Uses Interface Definition Language (IDL) that is used to define the interface between client and server 14
3.5 RPC Messages Two types of messages involved in RPC system: 1. Call messages sent by client to server for requesting execution of a particular remote procedure. 2. Reply messages that are sent by server to client for returning result of remote procedure execution. 15
3.5 RPC Messages Contd. Typical RPC Call Message Format Remote Procedure Identifier Arguments Message Message Client Program Version Procedure Identifier Type Identifier Number Number Number 16
3.5 RPC Messages Contd. Basic Components Identification information of the remote procedure 1. to be executed 2. The arguments necessary for the execution of the procedure 17
3.5 RPC Messages Contd. Additional Components Message identification field consisting sequence number 3. A message type field (0 for call message and 1 for reply 4. message) A client identification field that may be used for two 5. purposes Identify the client a. The authentication of the client process b. 18
3.5 RPC Messages Contd. Reply Messages Message Message Reply Status Result Identifier Type (successful) Successful Reply Message Format Message Message Reply Status Reason for Identifier Type (unsuccessful) Failure Unsuccessful Reply Message Format 19
3.5 RPC Messages Contd. Possible conditions upon receipt of RPC Call Message: Call message is not intended to it 1. Client is not authorized by checking client s identifier field 2. Remote program, version or procedure in remote procedure 3. identifier is not available with it An attempt is made to execute remote procedure but remote 4. procedure is not able to decode the supplied arguments Exception conditions (divide by 0 etc.) occur while executing 5. the remote procedure Specified remote procedure is executed successfully 6. 20
3.6 Marshalling Arguments & Results Marshaling : Encoding and Decoding of message data Marshalling involves following actions: Taking the arguments (client process) or the result 1. (server process) form data to be sent to remote procedure Encoding the message data of step 1 from the sender s 2. computer and placing them into a message buffer Decoding the message data on receiver s computer 3. 21
3.6 Marshalling Arguments & Results Contd.: Marshaling procedure may be classified into 2 groups: Those provided as a part of RPC software 1. 2. Those that are defined by the users of the RPC software 22
3.7 Communication Protocols for RPCs Based on the needs of different systems, the following protocols are proposed for use in RPCs: 3.7.1 The Request Protocol Also known as R protocol Used in RPCs in which the called procedure has nothing to return as a result of the procedure execution and the client requires no confirmation that the procedure has been executed 23
3.7 Communication Protocols for RPCs Contd. R Protocol Contd. An RPC that uses R protocol is known as asynchronous RPC For an asynchronous RPC, the RPC Runtime does not take responsibility for retrying a request in case of communication failure This protocol provides may-be call semantics 24
3.7 Communication Protocols for RPCs 3.7.1 The R-Protocol Client Server Request message Procedure execution First RPC Request message Next RPC Procedure execution 25
3.7 Communication Protocols for RPCs 3.7.2 The Request-Reply (RR) Protocol Client Server Request message First RPC Procedure execution Reply message Also serves as ack for request message Request message Procedure execution Next RPC Reply message Also serves as ack for reply of previous RPC 26
3.7 Communication Protocols for RPCs 3.7.2 The Request-Reply (RR) Protocol Also known as RR protocol Used to design systems involving simple RPC which is one in which all the arguments as well as the results fit in a single packet buffer and the duration of a call and intervals between calls are both short 27
3.7 Communication Protocols for RPCs RR Protocol Contd.: Uses implicit ack which eliminates explicit ack messages. Server s reply message is treated as an ack. Subsequent call from a client is treated as an ack of the server s reply message of the previous call made by that client 28
3.7 Communication Protocols for RPCs 3.7.2 The Request-Reply (RR) Protocol Transmission of two packets per call (one from client and one from server). Lost Messages: time outs and retries technique Provides at-least-once call semantics if duplicate request messages are not filtered out. Servers can support exactly-once call semantics by keeping records of the replies . 29
3.7 Communication Protocols for RPCs 3.7.3 The Request / Reply / Ack-Reply (RRA) Protocol Client Server Request Msg Procedure Execution First RPC Reply Msg Ack-Reply Msg Request Msg Next RPC Procedure Execution Reply Msg Ack-Reply Msg Fig.: The Request/Reply/Ack-Reply (RRA) Protocol 30
3.7 Communication Protocols for RPCs 3.7.3 The Request / Reply / Ack-Reply (RRA) Protocol Also known as RRA protocol. In RR protocol, if server has a large number of clients, it may require large storage to store information. To overcome this, RRA protocol can be used, which requires clients to ack the receipt of reply messages so that a server can delete information from its server cache. Transmission of three messages per call (two from the client and one from the server). 31
3.8 Client Server Binding The process by which a client becomes associated with a server so that calls can take place is known as binding. Need proper handling of following Issues: 1. How does a client specify a server? 2. How does the binding process locate the specified server? 3. When is it proper to bind a client to a server? 4. Is it possible for a client to change a binding during execution? 5. Can a client be simultaneously bound to multiple servers that provide the same service? 32
3.8 Client Server Binding Contd. 3.8.1 Server Naming The specification by a client of a server with which it wants to communicate is a naming issue. An interface name has two parts: 1. Type: Specifies the interface itself 2. Instance: Specifies a server providing the services within that interface 33
3.8 Client Server Binding Contd. 3.8.2 Server Locating Interface name of a server is its unique identifier Locating Issue: When a client specifies interface name of a server, server must be located before client s request message can be sent to it Two locating mechanisms used are: Broadcasting Binding Agent 34
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Broadcasting A message to locate desired server is broadcast to all nodes from the client node. Node on which the desired server is located returns a response message Easy to implement 35
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Broadcasting Suitable for small networks Expensive for large networks due to increase in message traffic due to the involvement of all nodes in broadcast processing 36
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Binding Agent A binding agent is a name server used to bind a client to a server by providing the client with the location information of the desired server A binding agent maintains a binding table, which is a mapping of a server s interface name to its location 37
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Binding Agent All servers register themselves with the binding agent as a part of their initialization process To locate a server, client contacts the binding agent If the server is registered with the binding agent, it returns the handle (location information) of the server to requesting client 38
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. 1. The server registers itself with the binding agent. Binding Agent 2. The client requests the binding agent for the server s location. 2 3 1 3. The returns location information to the client. binding the agent server s Client Process Server Process 4 4. The server. client calls the The binding agent mechanism for locating a server in case of RPC 39
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. A binding agent interface has three primitives: 1. Register is used by a server to register itself with the binding agent 2. Deregister is used by a server to deregister with the binding agent 3. Lookup is used by a client to locate a server 40
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Binding Agent Advantages 1. Method can support multiple servers having same interface type 2. When multiple servers provide same service, clients can be spread evenly over servers to balance load 3. Binding agent refuse to bind unauthorized clients to servers 41
3.8 Client Server Binding Contd. 3.8.2 Server Locating Contd. Binding Agent Disadvantages 1. Overhead involved in binding clients to servers is large and becomes significant when many client processes are short lived 2. A binding agent must be robust against failures 3. Distributing binding function and replicating information among several binding agents becomes an extra overhead 42
3.8 Client Server Binding Contd. 3.8.3 Binding Time Binding at Compile Time: Client and server modules are programmed as if they were intended to be linked together 43
3.8 Client Server Binding Contd. 3.8.3 Binding Time Contd.: Binding at Link Time: A server process exports its service by registering itself with the binding agent as a part of its initialization process. A client then makes an import request to the binding agent for the service before making a call. The binding agent binds the client and the server by returning to the client the server s handle. 44
3.8 Client Server Binding Contd. 3.8.3 Binding Time Contd. Binding at Call Time: A client is bound to a server at the time when it calls the server for the first time during its execution. A commonly used approach for binding at call time is the indirect call method as shown in the figure below. 45
3.8 Client Server Binding Contd. 3.8.3 Binding Time Contd. 1. Client interface name and arguments of the RPC call to binding agent. process passes server s Binding agent 2. Binding agent sends an RPC call message to server with arguments 1 4 2 3. Server returns result of request processing to binding agent. 3 4. Binding agent returns this result to the client along with the server s handle. Client process Server process 5 Binding at call time by the method of indirect call 5. Subsequent calls are sent directly from the client process to the server process using the handle. 46
3.8 Client Server Binding Contd. 3.8.4 Changing Binding The client or server of a connection may wish to change the binding at some instance of time due to some change in the system state 47
3.8 Client Server Binding Contd. 3.8.5 Multiple Simultaneous Binding A client may be bound simultaneously to all or multiple servers of the same type This gives rise to multicast communication because when a call is made, all the servers bound to the client for that service will receive and process the call 48
3.9 Exception Handling When a remote procedure cannot be executed successfully and a client cannot contact the server of the RPC an error occurs. Effective exception handling mechanism must be included. 49
3.9 Exception Handling Contd.: One approach to do this is to define an exception condition for each possible error type and raising an error when error of that type occurs Other approach is to return a well-known value to the process, making a system call to indicate failure and to report the type of error by storing a suitable value in a variable in the environment of the calling program 50