Remote Procedure Call CISC 879 Spring 03 Tam






























- Slides: 30
Remote Procedure Call CISC 879 – Spring 03 Tam Vu (tvu@mail. eecis. udel. edu) March 06, 03 1
Outline n Introduction RPC mechanisms Design issues n Programming with RPC n Case study: SUN RPC n n 2
Introduction n Problem with sockets q Socket interface is straightforward n n n q Forces read/write mechanism n n q Connect Read/write Disconnect Not how we generally program We usually use procedure calls To make distributed computing look more like centralized: n I/O is not the way to go 3
Introduction n 1984: Birrell & Nelson q q Mechanisms to call procedures on other machines Processes on machine A can call procedures on machine B n n A is suspended Execution continues on B When B returns, control passed back to A Goal: it appears to the programmer that a normal call is taking place 4
Introduction n Remote Procedure Call (RPC) is a high-level model for client-sever communication. n RPC enables clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure calls in high-level languages. n Examples: File service, Authentication service. 5
The RPC model server client Calls procedure and wait for reply request Receives request and starts process execution reply Resumes execution Blocking state Sends reply and wait for next execution Executing state 6
RPC Mechanisms n The client transfer call request (the procedure name) and the arguments to the server via client stub function n stub function q q marshals arguments and places them into a message together with the remote procedure identifier. Sends message to server and waits for call return 7
RPC Mechanisms n Server receives the call request and passes to an appropriate server stub function. n server stub function unmarshals the arguments, call the corresponding (local) service procedure. n On return, the server stub marshals the output arguments into a call return message and sends back to the client. 8
RPC Mechanisms n Client stub receives call reply, unmarshals value, returns to client code 9
RPC Mechanisms Client computer Local return Local call Unmarshal results Marshal arguments Receive reply Send request service procedure Execute procedure client stub func. Server computer server stub func. Communication module Unmarshal arguments Marshal results Select procedure Receive request Send reply 10
Benefits n Familiar procedure call interface n Writing applications is simplified q q n RPC hides all networks codes Programmers don’t have to worry about details (sockets, port numbers, byte ordering) RPC: presentation layer in OSI model 11
Characteristics n n The called procedure is in another process which may reside in another machine. The processes do not share address space. q n Passing of parameters by reference and passing pointer values make no sense. The called remote procedure executes within the environment of the server process. q The called procedure does not have access to the calling procedure's environment. 12
Design issues 13
Parameter passing n By values q n By reference q n easy, just copy data to network message. makes no sense without shared memory Trick q q q Copy items referenced to message buffer Ship them over Unmarshal data at server Pass local pointer to server stub function Send new value back 14
Representing data n No such things as incompatibility on local systems n Remote machine may have: q q n Different byte ordering Different sizes of integers and other types Different floating point representations Different character sets Need standard encoding to enable communication between heterogeneous systems 15
Representing data n Implicit typing q q n Only values are transmitted, not data type or parameter information E. g. , Sun XDR (e. Xternal Data Representation) Explicit typing q q Types are transmitted with values E. g. , ISO ANS. 1, XML 16
Binding n n How to locate host and server process? Solution 1: use a central DB q q n Server sends message to central DB indicating the services it can offer Clients contact this authority whenever they need to locate a service Solution 2: q q Client needs to know server name Server maintains a DB of available services 17
Failures n Local procedure calls do not fail q n RPC is more vulnerable to failure: q q n If they core dump, the entire process dies Server could generate errors Problems in network Server crash Client crash while server is still running code for it Transparency breaks here q Applications should be prepared to deal with RPC failure 18
Delivery guarantees n Retry request message: q n Duplicate filtering : q n Client retransmits the request message until either a reply or the server is assumed to have failed. server filters out duplicate message. Retransmission of replies: q Server keeps a history of reply messages to enable lost replies retransmitted without re-executing the server operations. 19
Call Semantics n n n Semantic of local procedure calls: exactly-once Exactly-once maybe difficult to achieve with RPC At-least-once q q q The client assumes that the RP is executed at least once (on return from the RP). Can be implemented by retransmission of the request message on time-out. Acceptable only if the server’s operations are idempotent. That is f(x) = f(f(x)). 20
Call Semantics n At-most-once q q When a RPC returns, the remote procedure (RP) is assume to have been called exactly once or not at all. Implemented by the server's filtering of duplicate requests and caching of replies. 21
Call Semantics n At-most-once q q q This ensure the RP is called exactly once if the server does not crash during execution of the RP. When the server crashes during the RP's execution, the partial execution may lead to erroneous results. In this case, we want the effect that the RP has not been executed at all. 22
Call Semantics 23
More issues n Performance q n remote procedure call and return time can be significantly slower than that for local procedure call (1 - 3 orders of magnitude). Security q q q Messages visible over the network Authenticate client Authenticate server 24
Programming with RPC n Most languages (C, C++, Java, …) have no concept of remote procedure calls q n Language compilers will not generate client and server stubs Common solution: q Use a separate compiler to generate stubs (pre-compiler) 25
Programming with RPC n Interface Definition Language q n Allow programmers to specify remote procedure interfaces (names, parameters, return values) Pre-compiler can use this to generate client and server stubs q q Marshalling code Unmarshalling code Network transport protocols Conform to defined interface 26
Programming with RPC n Client code has to be modified q Initialize RPC-related options n n q n Transport type Locate host/service Handle failure of remote procedure call Server functions q Generally need little or no modification 27
Case Studies: SUN RPC n Interface definition language: XDR q n Pre-compiler: rpcgen q n a standard way of encoding data in a portable fashion between different systems; A compiler that takes the definition of a remote procedure interface, and generates the client stubs and the server stubs; Communication handling: TCP or UDP 28
References n n n http: //www. cisco. com/univercd/cc/td/doc/product/software/ioss 390/ios 390 rp/rprpcgen. htm http: //pandonia. canberra. edu. au/OS/l 14_1. html http: //www. cs. cf. ac. uk/Dave/C/node 33. html 29
Thank you! 30