rpcs steps in one rpc
play

RPCs Steps in one RPC an early middleware model. Its an extension - PowerPoint PPT Presentation

RPCs Steps in one RPC an early middleware model. Its an extension of local Before call a remote procedure, client initiates a connection to procedure calling. server. Programs are organized as a set of modules. Each module When


  1. RPCs Steps in one RPC � an early middleware model. It’s an extension of local � Before call a remote procedure, client initiates a connection to procedure calling. server. � Programs are organized as a set of modules. Each module � When client process calls a remote procedure, client stub: defines its interface: procedures variables. � Retrieves the required parameters from the client address space. � Advantage of communicating through interface, is that � Translates the parameters into a standard network data programmer can update the implementation, keep its representation (NDR) format for transmission over the network. interface, and don’t need to update the implementation in � Calls functions in the RPC client run-time library to send the request and its parameters to the server. other modules. � At the server side, � Direct variable access is not allowed in distributed situation. � The server RPC run-time library functions accept the request � RPC vs. LPC: and call the server stub procedure. � Error handling: In RPC, failures of the remote server and � The server stub retrieves the parameters from the network buffer failures of network. and converts them from the network transmission format to the � Performance: RPCs operate much slower than LPCs. format the server needs. � Authentication: insecure networks, authentication is � The server stub calls the actual procedure on the server. necessary. � After the remote procedure returns its data to the server stub, the server stub converts return value to the network message and � RPC uses client/server model call the RPC run-time library functions. � Service interface � The server RPC run-time library functions transmit the reply � response-based transient synchronous communication message to the client computer. � Remote procedures appear local through stub functions. � At the client side, � Two stubs: client stub and server stub. � The client RPC run-time library receives the return values and � In RPC, stubs are compiled and linked with the applications. returns them to the client stub. � The client stub converts the data into the format used by the client. The stub returns the result to the calling program. � The calling procedure continues. 1

  2. Sun RPC Version 2 RPC message � A server may support more than one version of a remote � written in Interface definition language (IDL), also called program in order to be compatible with changing protocols. RPC language � Transport protocols � transaction identifier, xid. � RPC is transport independent and RPC does not try to � used for client RPC layer to matching reply messages implement any kind of reliability. with call messages, and may be used by server process to detect retransmissions. � The application may need to know the type of transport � Body of an RPC call message: protocol underneath RPC: message size, semantics. � The client and server must agree on their transport � RPC version number: always equal to 2 here. protocol choices. � Remote program number: (in hexadecimal) � Requirement of RPC protocol: • 0 - 1fff,ffff defined by Sun � Unique specification of a remote procedure. • 2000,0000 - 3fff,ffff defined by user � Matching reply messages to call messages. • 4000,0000 - 5fff,ffff transient. � Authenticating the client to server and authenticating • 6000,0000 – ffff,ffff reserved. server to client. � Remote program version number � Failure reasons: � Remote procedure number • RPC protocol mismatches. � two authentication fields: the credential and verifier • Remote program protocol version mismatches. � the procedure parameters • Misspecification of a procedure's parameters. � Body of a reply message • Reasons why remote authentication failed. � Requirement: contain enough information to distinguish • Other reasons why the desired procedure was not different error conditions called. � accepted reply message or rejected reply message 2

  3. enum reject_stat { RPC_MISMATCH = 0, /* RPC version number != 2 */ enum accept_stat { AUTH_ERROR = 1 /* remote can't authenticate caller */ SUCCESS = 0, /* RPC executed successfully */ }; PROG_UNAVAIL = 1, /* remote hasn't exported program */ PROG_MISMATCH = 2, /* remote can't support version # */ PROC_UNAVAIL = 3, /* program can't support procedure */ union rejected_reply switch (reject_stat stat) { GARBAGE_ARGS = 4 /* procedure can't decode parameters */ case RPC_MISMATCH: }; struct { unsigned int low; unsigned int high; } mismatch_info; struct accepted_reply { case AUTH_ERROR: opaque_auth verf; auth_stat stat; union switch (accept_stat stat) { }; case SUCCESS: /* * procedure-specific results start here */ enum auth_stat { case PROG_MISMATCH: AUTH_BADCRED = 1, /* bad credentials (seal broken) */ struct { AUTH_REJECTEDCRED = 2, /* client must begin new session */ unsigned int low; AUTH_BADVERF = 3, /* bad verifier (seal broken) */ unsigned int high; AUTH_REJECTEDVERF = 4, /* verifier expired or replayed */ } mismatch_info; AUTH_TOOWEAK = 5 /* rejected for security reasons */ default: }; /* * Void. Cases include PROG_UNAVAIL, PROC_UNAVAIL, * and GARBAGE_ARGS. */ void; } reply_data; }; 3

  4. Other Uses of RPC Protocol DES Authentication Verifiers � Batching: � Content: an encrypted timestamp � a client sends a large sequence of call messages to a server. The � Rules: client doesn’t wait for a reply from the server, and the server � The server can decrypt this timestamp does not send replies to batch calls. A sequence of batch calls is � If it is close to the real time, then the client must have terminated by a simple remote procedure call operation. And encrypted it correctly. server will send a reply message to that last call message. � The only way the client could encrypt it correctly is to � Broadcast : know the "conversation key“ K. � the client sends a broadcast call to the network and waits for numerous replies. Servers that support broadcast protocols only � If the client knows K, then it must be the real client. reply when the call is successfully processed, and not reply if � K is generated by the client, and client sends it to the server in some error happens. Broadcast calls use the Port Mapper RPC its first RPC call, using a public key scheme. (Diffie-Hellman service . with 192-bit keys, next week) � agree on the current time � Network Time Protocol � a simple time request � 1 st transaction: the client sends an encrypted timestamp and "window" to the server. � Additional check in 1 st transaction: the client sends an encrypted "window verifier", equal to the window minus 1. � For any other transaction, the server checks for two things: (1) the timestamp is greater than the previous one. (2) compare current real time with the timestamp plus window. � The client check the verifier returned from the server: the encrypted timestamp minus one second. 4

  5. const PMAP_PORT = 111; /* port number of port mapper */ Portmapper program protocol A mapping of (program, version, protocol) to port number � Broadcasting struct mapping { unsigned int prog; unsigned int vers; unsigned int prot; unsigned int port; }; � PMAPPROC_CALLIT : allows a client to call a remote procedure without knowing its port number. broadcasting. const IPPROTO_TCP = 6; /* protocol number for TCP/IP */ � Its parameters are the program number, version number, const IPPROTO_UDP = 17; /* protocol number for UDP/IP */ procedure number, and parameters of the remote procedure. Portmapper procedures � Note that: program PMAP_PROG { • This procedure only sends a reply if the procedure was successfully version PMAP_VERS { executed. bool PMAPPROC_SET(mapping) = 1; • The portmapper communicates with the remote program using bool PMAPPROC_UNSET(mapping) = 2; UDP only. unsigned int PMAPPROC_GETPORT(mapping) = 3; • The procedure returns the remote program's port number, and the pmaplist PMAPPROC_DUMP(void) = 4; reply message from the remote procedure. call_result PMAPPROC_CALLIT(call_args) = 5; � Steps for Sun RPC } = 2; � Define the RPC Interface in a .x file. Such as MyRPCService.x } = 100000; � Use rpcgen to compile the .x file: % rpcgen MyRPCService.x. struct call_args { � Code the server implementation: you can use implementation template struct call_result { and fill in the details. unsigned int prog; unsigned int port; � Build the server: compile server stub, server implementation and link to unsigned int vers; opaque res<>; RPC library to build an executable file. unsigned int proc; }; � Write a client: establish a connection to corresponding server process opaque args<>; via clnt_create . Then, compile & link the client implementation and }; client stub. How to broadcast messages to multiple instances of a service on � Run server and client different machines? 5

Recommend


More recommend