Presentation on theme: "Tam Vu (email@example.com) Remote Procedure Call CISC 879 – Spring 03 Tam Vu (firstname.lastname@example.org) March 06, 03."— Presentation transcript:
1 Tam Vu (email@example.com) Remote Procedure CallCISC 879 – Spring 03Tam VuMarch 06, 03
2 Outline Introduction RPC mechanisms Design issues Case study: SUN RPC Programming with RPCCase study: SUN RPC
3 Introduction Problem with sockets Socket interface is straightforward ConnectRead/writeDisconnectForces read/write mechanismNot how we generally programWe usually use procedure callsTo make distributed computing look more like centralized:I/O is not the way to go
4 Introduction 1984: Birrell & Nelson Mechanisms to call procedures on other machinesProcesses on machine A can call procedures on machine BA is suspendedExecution continues on BWhen B returns, control passed back to AGoal: it appears to the programmer that a normal call is taking place
5 IntroductionRemote Procedure Call (RPC) is a high-level model for client-sever communication.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.Examples: File service, Authentication service.
6 The RPC model Blocking state client server request reply Executing stateCalls procedure and wait for replyReceives request and starts process executionSends reply and wait for next executionResumes execution
7 RPC MechanismsThe client transfer call request (the procedure name) and the arguments to the server via client stub functionstub functionmarshals arguments and places them into a message together with the remote procedure identifier.Sends message to server and waits for call return
8 RPC MechanismsServer receives the call request and passes to an appropriate server stub function.server stub function unmarshals the arguments, call the corresponding (local) service procedure.On return, the server stub marshals the output arguments into a call return message and sends back to the client.
10 RPC Mechanisms Client computer Server computer service procedure Local stubfunc.CommunicationmoduleLocalreturncallClient computerServer computerserverserviceprocedureReceivereplySendrequestUnmarshalresultsMarshalargumentsSelect procedureExecute procedure
11 Benefits Familiar procedure call interface Writing applications is simplifiedRPC hides all networks codesProgrammers don’t have to worry about details (sockets, port numbers, byte ordering)RPC: presentation layer in OSI model
12 CharacteristicsThe called procedure is in another process which may reside in another machine.The processes do not share address space.Passing of parameters by reference and passing pointer values make no sense.The called remote procedure executes within the environment of the server process.The called procedure does not have access to the calling procedure's environment.
14 Parameter passing By values By reference Trick easy, just copy data to network message.By referencemakes no sense without shared memoryTrickCopy items referenced to message bufferShip them overUnmarshal data at serverPass local pointer to server stub functionSend new value back
15 Representing data No such things as incompatibility on local systems Remote machine may have:Different byte orderingDifferent sizes of integers and other typesDifferent floating point representationsDifferent character setsNeed standard encoding to enable communication between heterogeneous systems
16 Representing data Implicit typing Explicit typing Only values are transmitted, not data type or parameter informationE.g., Sun XDR (eXternal Data Representation)Explicit typingTypes are transmitted with valuesE.g., ISO ANS.1, XML
17 Binding How to locate host and server process? Solution 1: use a central DBServer sends message to central DB indicating the services it can offerClients contact this authority whenever they need to locate a serviceSolution 2:Client needs to know server nameServer maintains a DB of available services
18 Failures Local procedure calls do not fail If they core dump, the entire process diesRPC is more vulnerable to failure:Server could generate errorsProblems in networkServer crashClient crash while server is still running code for itTransparency breaks hereApplications should be prepared to deal with RPC failure
19 Delivery guarantees Retry request message: Duplicate filtering : Client retransmits the request message until either a reply or the server is assumed to have failed.Duplicate filtering :server filters out duplicate message.Retransmission of replies:Server keeps a history of reply messages to enable lost replies retransmitted without re-executing the server operations.
20 Call Semantics Semantic of local procedure calls: exactly-once Exactly-once maybe difficult to achieve with RPCAt-least-onceThe 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)).
21 Call Semantics At-most-once 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.
22 Call Semantics At-most-once 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.
24 More issues Performance Security remote procedure call and return time can be significantly slower than that for local procedure call (1 - 3 orders of magnitude).SecurityMessages visible over the networkAuthenticate clientAuthenticate server
25 Programming with RPCMost languages (C, C++, Java,…) have no concept of remote procedure callsLanguage compilers will not generate client and server stubsCommon solution:Use a separate compiler to generate stubs (pre-compiler)
26 Programming with RPC Interface Definition Language Allow programmers to specify remote procedure interfaces (names, parameters, return values)Pre-compiler can use this to generate client and server stubsMarshalling codeUnmarshalling codeNetwork transport protocolsConform to defined interface
27 Programming with RPC Client code has to be modified Server functions Initialize RPC-related optionsTransport typeLocate host/serviceHandle failure of remote procedure callServer functionsGenerally need little or no modification
28 Case Studies: SUN RPC Interface definition language: XDR a standard way of encoding data in a portable fashion between different systems;Pre-compiler: rpcgenA compiler that takes the definition of a remote procedure interface, and generates the client stubs and the server stubs;Communication handling: TCP or UDP