This document provides an introduction and overview of Remote Procedure Call (RPC). It discusses what RPC is, why it is used, how RPC operates, how it is implemented in Windows, provides a practical example of implementing RPC, and discusses how RPC is used in QFS. Key points include that RPC allows a process to call a procedure in a different address space, possibly on a different machine, and hides the remote interaction. It operates by marshaling parameters for transmission over the network and making function calls to send the request and receive the response.
AgendaWhat’s RPC? (2)WhyRPC? (3)How RPC operates? (15)How RPC is implemented in Windows? (10)RPC, a practical example. (15)RPC in QFS. (5)References.
3.
What’s RPCInter-process communication(IPC).Another virtual address space.Another process on the same machine.Another process on different machine.Hides remote interaction.Network programming standard 1980sBuilds on named pipes or Winsock.Remote Method Invocation (RMI)
4.
Why RPC?Distributed Computing(matrix operations).Hides networking interaction.You just use the RPC as a usual method/function call.Flexible and maintainable.Easy to develop.
How RPC OperatesWhenclient code calls a remote procedure, the client stub codeRetrieves the required parameters from the client address space.Marshals1 the parameters as needed into a standard NDR2 format for transmission over the network.Calls functions in the RPC client run-time library to send the request and its parameters to the server.1 Marshalling (similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission2 Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model.
8.
How RPC OperatesTheserver performs the following steps to call the remote procedure:The server RPC run-time library functions accept the request and call the server stub procedure.The server stub retrieves the parameters from the network buffer and converts (i.e. unmarshals) them from the network transmission format to the format the server needs.The server stub calls the actual procedure on the server.
How RPC OperatesAsynchronousRPC could be achieved using:WaitForSingleObjectWaitForMultipleObjectI/O Completion port kernel object.GetQueuedCompletionStatusAlternatively, a client can poll for completion by calling RpcAsyncGetCallStatus
How RPC isimplemented in Windows?Rpcrt4.dll*: Stub file uses it for marshaling and unmarshaling.Advanced Local Procedure Call (ALPC) facilities in kernel mode as the local networking API in case of communication on the same machine.Rpcss.dll:Perform name lookup.Registration.Dynamic endpoint mapping.* If not included will cause linkage problems
13.
RPC, a PracticalExampleDecide what are methods that you’ll be RPC.Generate UUID (Universal Unique IDentifier)uuidgen /i /o”E:\Interface.idl”Developing IDL file.Developing Application Configuration File (ACF)Implementing the RPC (whether in server or standalone application)Generating stub file (VS or MIDL)
14.
RPC, a PracticalExampleDeveloping the client sideAdding client stub file amd generated header file.RpcStringBindingComposeCombines an object UUID, a protocol sequence, a network address, an endpoint and other network options into a string representation of a binding handle.RpcBindingFromStringBindingCreates a server binding handle from a string representation of a binding handle.Call RPC using RpcTryExceptFree:RpcStringFreeRpcBindingFree
15.
RPC, a PracticalExampleDeveloping the server sideRpcServerUseProtseqEpTells the RPC run-time library to use the specified protocol sequence combined with the specified endpoint for receiving remote procedure calls.RpcServerRegisterIfRegisters an interface with the RPC run-time libraryRpcServerListenA server calls RpcServerListen when the server is ready to process remote procedure calls.
16.
RPC in QFSIDL:na_qfsServer: Connector Service (na_qfs_s.cpp; qfsrpc.cpp)Client: QFS Service (na_qfs_c.cpp; NetAppFilter.cpp)