introduction to remote procedure call

18
Introduction to Remote Procedure Call (RPC) Abdelrahman Al-Ogail 12-11-2011

Upload: abdelrahman-al-ogail

Post on 05-Dec-2014

1.812 views

Category:

Education


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Introduction to Remote Procedure Call

Introduction to Remote Procedure Call (RPC)

Abdelrahman Al-Ogail12-11-2011

Page 2: Introduction to Remote Procedure Call

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.

Page 3: Introduction to Remote Procedure Call

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)

Page 4: Introduction to Remote Procedure Call

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.

Page 5: Introduction to Remote Procedure Call

How RPC Operates

Page 6: Introduction to Remote Procedure Call

How RPC Operates

Page 7: Introduction to Remote Procedure Call

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 transmission2 Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model.

Page 8: Introduction to Remote Procedure Call

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.

Page 9: Introduction to Remote Procedure Call

How RPC Operates

• Then same happens backward.

Page 10: Introduction to Remote Procedure Call

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

Page 11: Introduction to Remote Procedure Call

How RPC Operates

• Stub file types (_s and _c)

• IDL File

• MIDL Compiler

• Generated header

Page 12: Introduction to Remote Procedure Call

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

Page 13: Introduction to Remote Procedure Call

RPC, a Practical Example

• Decide 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)

Page 14: Introduction to Remote Procedure Call

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

Page 15: Introduction to Remote Procedure Call

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.

Page 16: Introduction to Remote Procedure Call

RPC in QFS

• IDL: na_qfs

• Server: Connector Service (na_qfs_s.cpp; qfsrpc.cpp)

• Client: QFS Service (na_qfs_c.cpp; NetAppFilter.cpp)

Page 17: Introduction to Remote Procedure Call

References

Page 18: Introduction to Remote Procedure Call

Thanks