Introduction to C++ Remote Procedure Call (RPC)

7,762 views
7,683 views

Published on

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,762
On SlideShare
0
From Embeds
0
Number of Embeds
563
Actions
Shares
0
Downloads
92
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction to C++ Remote Procedure Call (RPC)

  1. 1. Introduction to Remote Procedure Call (RPC)<br />Abdelrahman Al-Ogail<br />12-11-2011<br />
  2. 2. Agenda<br />What’s RPC? (2)<br />Why RPC? (3)<br />How RPC operates? (15)<br />How RPC is implemented in Windows? (10)<br />RPC, a practical example. (15)<br />RPC in QFS. (5)<br />References.<br />
  3. 3. What’s RPC<br />Inter-process communication (IPC).<br />Another virtual address space.<br />Another process on the same machine.<br />Another process on different machine.<br />Hides remote interaction.<br />Network programming standard 1980s<br />Builds on named pipes or Winsock.<br />Remote Method Invocation (RMI)<br />
  4. 4. Why RPC?<br />Distributed Computing (matrix operations).<br />Hides networking interaction.<br />You just use the RPC as a usual method/function call.<br />Flexible and maintainable.<br />Easy to develop.<br />
  5. 5. How RPC Operates<br />
  6. 6. How RPC Operates<br />
  7. 7. How RPC Operates<br />When client code calls a remote procedure, the client stub code<br />Retrieves the required parameters from the client address space.<br />Marshals1 the parameters as needed into a standard NDR2 format for transmission over the network.<br />Calls functions in the RPC client run-time library to send the request and its parameters to the server.<br />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<br />2 Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model. <br />
  8. 8. How RPC Operates<br />The server performs the following steps to call the remote procedure:<br />The server RPC run-time library functions accept the request and call the server stub procedure.<br />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.<br />The server stub calls the actual procedure on the server.<br />
  9. 9. How RPC Operates<br />Then same happens backward.<br />
  10. 10. How RPC Operates<br />Asynchronous RPC could be achieved using:<br />WaitForSingleObject<br />WaitForMultipleObject<br />I/O Completion port kernel object.<br />GetQueuedCompletionStatus<br />Alternatively, a client can poll for completion by calling RpcAsyncGetCallStatus<br />
  11. 11. How RPC Operates<br />Stub file types (_s and _c)<br />IDL File<br />MIDL Compiler<br />Generated header<br />
  12. 12. How RPC is implemented in Windows?<br />Rpcrt4.dll*: <br />Stub file uses it for marshaling and unmarshaling.<br />Advanced Local Procedure Call (ALPC) facilities in kernel mode as the local networking API in case of communication on the same machine.<br />Rpcss.dll:<br />Perform name lookup.<br />Registration.<br />Dynamic endpoint mapping.<br />* If not included will cause linkage problems<br />
  13. 13. RPC, a Practical Example<br />Decide what are methods that you’ll be RPC.<br />Generate UUID (Universal Unique IDentifier)<br />uuidgen /i /o”E:Interface.idl”<br />Developing IDL file.<br />Developing Application Configuration File (ACF)<br />Implementing the RPC (whether in server or standalone application)<br />Generating stub file (VS or MIDL)<br />
  14. 14. RPC, a Practical Example<br />Developing the client side<br />Adding client stub file amd generated header file.<br />RpcStringBindingCompose<br />Combines an object UUID, a protocol sequence, a network address, an endpoint and other network options into a string representation of a binding handle.<br />RpcBindingFromStringBinding<br />Creates a server binding handle from a string representation of a binding handle.<br />Call RPC using RpcTryExcept<br />Free:<br />RpcStringFree<br />RpcBindingFree<br />
  15. 15. RPC, a Practical Example<br />Developing the server side<br />RpcServerUseProtseqEp<br />Tells the RPC run-time library to use the specified protocol sequence combined with the specified endpoint for receiving remote procedure calls.<br />RpcServerRegisterIf<br />Registers an interface with the RPC run-time library<br />RpcServerListen<br />A server calls RpcServerListen when the server is ready to process remote procedure calls.<br />
  16. 16. RPC in QFS<br />IDL: na_qfs<br />Server: Connector Service (na_qfs_s.cpp; qfsrpc.cpp)<br />Client: QFS Service (na_qfs_c.cpp; NetAppFilter.cpp)<br />
  17. 17. References<br />
  18. 18. Thanks <br />

×