2. Agenda What’s RPC? (2) Why RPC? (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 RPC Inter-process communication (IPC). Another virtual address space. Another process on the same machine. Another process on different machine. Hides remote interaction. Network programming standard 1980s Builds 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.
7. How RPC Operates When client code calls a remote procedure, the client stub code Retrieves 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 transmission 2 Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model.
8. How RPC Operates The server 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.
10. How RPC Operates Asynchronous RPC could be achieved using: WaitForSingleObject WaitForMultipleObject I/O Completion port kernel object. GetQueuedCompletionStatus Alternatively, a client can poll for completion by calling RpcAsyncGetCallStatus
11. How RPC Operates Stub file types (_s and _c) IDL File MIDL Compiler Generated header
12. How RPC is implemented 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 Practical Example Decide what are methods that you’ll be RPC. Generate UUID (Universal Unique IDentifier) uuidgen /i /o”E:nterface.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 Practical Example Developing the client side Adding client stub file amd generated header file. RpcStringBindingCompose Combines an object UUID, a protocol sequence, a network address, an endpoint and other network options into a string representation of a binding handle. RpcBindingFromStringBinding Creates a server binding handle from a string representation of a binding handle. Call RPC using RpcTryExcept Free: RpcStringFree RpcBindingFree
15. RPC, a Practical Example Developing the server side RpcServerUseProtseqEp Tells the RPC run-time library to use the specified protocol sequence combined with the specified endpoint for receiving remote procedure calls. RpcServerRegisterIf Registers an interface with the RPC run-time library RpcServerListen A server calls RpcServerListen when the server is ready to process remote procedure calls.
16. RPC in QFS IDL: na_qfs Server: Connector Service (na_qfs_s.cpp; qfsrpc.cpp) Client: QFS Service (na_qfs_c.cpp; NetAppFilter.cpp)