RPC (Remote Procedure Call) - Remote Procedure Call
,
which is
a
protocol for requesting services from a remote computer program over a network without knowing the underlying network technology.
The RPC protocol
assumes
the existence of some transport protocol, such as TCP or UDP, to carry information data between communicating programs. In the OSI
network communication
model, RPC spans the
transport
layer and the
application
layer . RPC makes it easier to develop applications including network
distributed
multiprogramming.
RPC uses a client/server model. The requestor is a client, and the service provider is a server. First, the client calling process sends a call message with process parameters to the server process, and then waits for a reply message. On the server side, the process stays asleep until the call message arrives. When a call message arrives, the server obtains the process parameters, calculates the result, sends a reply
message
, and then waits for the next call message. Finally, the client calls the process to receive the reply message, obtain the process result, and then the call execution continues.
There are multiple RPC modes and implementations. Originally proposed by Sun Corporation. The IETF ONC Charter revises the Sun version, making the ONC RPC protocol an IETF standard protocol. The most common model and implementation in use today is the open software-based Distributed Computing
Environment
(DCE).
content
working principle
edit
At runtime, an RPC call from the client to the server, its internal operation roughly has the following ten steps:
1. Call the client handle; execute the transfer parameters
2. Call the local system
kernel
to send network messages
3.
Message delivery
to remote
host
4. The server handle gets the message and gets the parameters
5. Execute remote procedures
6. The executed process returns the result to the server handle
7. The server handle returns the result and calls the remote system
kernel
8. The message is sent back to
localhost
9. The client handle receives the message from the kernel
10. The client receives the data returned by the handle
RPC OVER HTTP
Microsoft RPC-over-HTTP deployment (RPC over HTTP) allows RPC clients to connect to RPC server programs and execute
remote
. This is done with the help of a
middleware .
The RPC proxy runs on the IIS computer. It accepts RPC requests from the Internet, performs authentication, validation, and access checks on those requests, and if the request passes all tests, the RPC proxy forwards the request to the RPC
server
that does the real processing . With RPC over HTTP, RPC clients do not communicate directly with servers, they use RPC proxies as middleware.
Protocol structure
edit
The Remote Procedure Call
(RPC) message protocol consists of two distinct structures: call messages and reply messages. The information flow is as follows:
RPC:远程过程调用流程
RPC 调用信息:每条远程过程调用信息包括以下无符号整数字段,以独立识别远程过程:
程序号(Program number)
程序版本号(Program version number)
过程号(Procedure number)
RPC 调用信息主体形式如下:
struct call_body {
unsigned int rpcvers;
unsigned int prog;
unsigned int vers;
unsigned int proc;
opaque_auth cred;
opaque_auth verf;
1 parameter
2 parameter . . . };
RPC 答复信息:RPC 协议的答复信息的改变取决于
网络服务器对调用信息是接收还是拒绝。答复信息请求包括区别以下情形的各种信息:
RPC 成功执行调用信息。.
RPC 的远程实现不是协议第二版,返回 RPC 支持的最低和最高版本号。
在远程系统中,远程程序不可用。
远程程序不支持被请求的版本号。返回远程程序所支持的最低和最高版本号。
请求的过程号不存在。通常是呼叫方协议或程序差错。
RPC答复信息形式如下:
enum reply_stat stat
{MSG_ACCEPTED = 0,
MSG_DENIED = 1 };