View
218
Download
0
Tags:
Embed Size (px)
Citation preview
Implementing Remote Procedure Calls
Authors: Andrew D. Birrell and Bruce Jay Nelson
Xerox Palo Alto Research Center
Presenter: Jim SantmyerThanks to: Philip Howard
Christopher Holm
Make Distributed Computing easier
Remote Procedure Calls
What is a Remote Procedure Call?
• Application invokes (remote) procedure and suspends
• Parameters are passed across the network to remote Server
• The remote Server executes the procedure
• Results are returned to calling application
• Application resumes as if result returned from a local procedure call
Why RPC
Procedure calls are: well known and therefore easily understood
It is a Mechanism for transfer of control and data within a running program on a single computer
Same mechanism can be used to transfer control and data across a network
RPC Design Issues
• Semantics of a call in the presence of remote machine or communication failures.
• Procedure calls that pass data by reference
• Machine Architecture differences: byte order
• Binding: what Servers are available and where
• Network Packet transmissionProtocol, Security
RPC Structure
User application And Server application– Written by developer– Could compile and link as a single program
User and Server Stubs– User creates interface definition– RPC generation tool use to create
stubs(Lupine)
RPCruntime is existing part of system
Server Application Tasks
Export Interface
Register Interface
Services requests
May report Server errors to User application.
User Application Tasks
Bind to Server– Client imports the interface exported by server
Makes (remote) procedure calls as normal
Handles remote machine and communication failures.
User Stub Task
• Packing parameters into one or more packets– Marshalling
• Calls RPCruntime to send packets to server
• Receive result packets from RPCruntime,
• Unpacks result and returns to User application– Unmarshalling
Server Stub Task• Receive packets from RPCruntime
• Unpacks parameters
• Dispatches procedure call to Server application
• Packs returned result (Marshalling)
• Call RPCruntime to return result to user application
RPC StructureCaller
RPCRuntime
Transmit packet(s)
Receive packet(s)
Send packet
NetworkNetwork
NetworkNetwork
Receive packet
User StubUser
Procedure call
procedure return
Packarguments
Unpackresult(s)
Callee
RPCRuntime
Receivepacket(s)
Transmitpacket(s)
Server Stub Server
Procedure call
Procedure return
Unpackarguments
Packresult(s)
Receive packet
Send packet
Interface
Interface
importer exporter
importer exporter
Threaded
Event Driven
Binding Process(Server)
• Server exports interface– Notifies RPCRuntime of Service
• Table array: Interface Name, Dispatcher, ID– Registers Service in Database
• Type, Instance
Database
RPCRuntime
UpdateDatabase
Server Stub Server
ExportInterface
ExportInterface
Callee
Binding Process(Caller)
• Client imports interface, – Database lookup,
• Type (service)• Instance (address)
Caller
RPCRuntimeUser StubUser
ImportInterface
ImportInterface
QueryDatabase
InterfaceInfo
InterfaceInfo
InterfaceInfo
Database
Who’s available?
AvailableInterfaces
Binding Process(Caller)
RPCRuntimeUser StubUser
ImportInterface
ImportInterface
QueryDatabase
InterfaceInfo
InterfaceInfo
InterfaceInfo
Database
Who’s available?
AvailableInterfaces
Caller
RPCRuntime calls Server– Verifies service is available– Returns ID, and table index
• User stub records address, ID, index
RPC Network Protocol
• Optimized for small request/response packets, • Less load on Server
• Must guarantee procedure invoked at most once
• Probe packets (are you there?)– Report network errors to application,– Unknown if procedure invoked.
• Deadlock or endless loop of server is not handled
Simple Call Example• All information fits in one packet
• Efficient for frequent callsCaller sends procedure callServer turns responseCaller sends procedure callServer turns response
Only two packets
foo(a,&b) foo(int a, int *b)
return;
callid
callid
Complicated CallCaller
RPCRuntime
Transmit first packet
Receiveresult
User
Procedure call
procedure return
Callee
Server
Procedure call
procedure return
RPCRuntime
Call[Ids, packet=0]
Ack[Ids, packet=0]
Call[Ids, packet=1]Transmit next packet
Transmit ack
Receivepacket 0
Receivepacket 1
Receive ack
Retransmit next packet
Call[Ids, packet=1, needAck] Receivepacket 1
Transmit ack
Ack[Ids, packet=1]Receive
ack
Transmitresult
Transmit ack
request
Result[Ids]
Result[Ids, needAck]Receiveresult
Transmit ack
Ack[Ids]Receive
ack
Optimizations
• Process Pools with process ID for reuse
• Reply packets count as acknowledgement
• Low connection overhead
• Low cost to establish connection
• Reduced Process switching
• Modified network stack for RPC special case
Security
• Validation of caller and callee
• End to end encryption of data