Remote Procedure Call

Remote Procedure Call (RPC) is an interprocess communication technique to allow client and server software to communicate. The Microsoft RPC facility is compatible with the Open Group's Distributed Computing Environment (DCE) specification for remote procedure calls and is interoperable with other DCE-based RPC systems, such as those for HP-UX and IBM AIX UNIX–based operating systems. The RPC facility is compatible with the Open Group specification.

The Microsoft RPC mechanism is unique in that it uses other IPC mechanisms, such as named pipes, NetBIOS, or Winsock, to establish communications between the client and the server. With the RPC facility, essential program logic and related procedure code can exist on different computers, which is important for distributed applications.

RPC is based on the concepts used for creating structured programs, which can be viewed as having a backbone to which a series of ribs can be attached. The backbone is the mainstream logic of the program that rarely changes. The ribs are the procedures that the backbone calls upon to do work or perform functions. In traditional programs, these ribs are statically linked to the backbone and stored in the same executable file. RPC places the backbone and the ribs on different computers.

Windows 2000 uses dynamic link libraries (DLLs) to provide procedure code and backbone code. This enables the DLLs to be modified or updated without changing or redistributing the backbone portion.

Client applications are developed with specially-compiled stub libraries that are provided by the application program. In reality, these stubs transfer the data and the function to the RPC run-time module. This module is responsible for finding the server that can satisfy the RPC command. Once found, the function and data are sent to the server, where they are picked up by the RPC run-time component on the server. The server builds the appropriate data structure, and calls the function.

The function interprets the call as coming from the client application. The server may impersonate the client. For security, RPC can use NTLM, Kerberos, or Secure Sockets Layer (SSL). When the function is completed, any return values are collected, formatted, and sent back to the client through the RPC run-time module. When the function returns to the client application, it has the appropriate returned data or an indication that the function failed. Figure B.15 illustrates Remote Procedure Calls.

Cc958781.CNAD17(en-us,TechNet.10).gif

Figure B.15 Remote Procedure Calls

If the client and server portions of the application are on the same computer, local procedure calls (LPCs) can be used to transfer information efficiently between processes. This makes RPC a flexible and portable IPC choice.

Figure B.16 illustrates the software components of RPC.

Cc958781.CNAD26(en-us,TechNet.10).gif

Figure B.16 Windows 2000 RPC Client and Workstation Architecture

The components of RPC are:

RPC Stub    Part of an application executable file or a DLL that is generated by the Microsoft Interface Description Language (MIDL) compiler specifically for each interface.

Network Data Representation Marshaling    Marshaling is the process of packaging and unpackaging parameters into Network Data Representation (NDR) format for communication over the network.

Remote Procedure Call APIs    A series of protocol-independent APIs responsible for establishing connections and security as well as registering servers, naming, and endpoint resolution.

Datagram Runtime    A connectionless RPC protocol engine that transmits and receives requests using connectionless protocols, such as UDP.

Connection-Oriented Runtime    A connection-oriented RPC protocol engine that transmits and receives requests using connection-oriented protocols, such as TCP.

Local Runtime    A local RPC protocol engine that transmits and receives RPC requests between processes on the local computer.

RPC Name Resolution

The function of RPC name resolution is to allow clients to find RPC servers. Servers on a Windows 2000 network send messages to the Active Directory directory service by a locator, which is a software service that runs on RPC servers. The locator exports bindings, interfaces, protocols, and endpoints for servers running on the local computer. This server information is stored in Active Directory in System\RPCServices. When a client wants to find a server, it queries Active Directory. The client receives information, including server names, protocols, and endpoints that were placed in Active Directory by the server. With this information, the client can directly connect to the server. Windows 2000 still supports named pipes, mailslots and broadcast messaging for name resolution by NetBIOS.

For more information about RPC name resolution, see "Service Publication in Active Directory" in the Microsoft ® Windows ®  2000 Server Resource Kit Distributed Systems Guide .