34
Remote Procedure Call

rpc

Embed Size (px)

Citation preview

Page 1: rpc

Remote Procedure Call

Page 2: rpc

RPC Model

Server processClient Process

Request Message

Reply Message

CallProcedure

Receive Request Start Execution

ResumeExecution

Send reply wait for next request

Page 3: rpc

Transparency of RPC

● Syntactic Transparency

(Same syntax as Local Procedure Call)

● Semantic Transparency

(Same semantics as Local Procedure Call)

Page 4: rpc

Semantic Transparency

● Calling process is suspended until procedure returns

● Caller can pass arguments to remote procedure

● Called procedure can return results

Page 5: rpc

Remote / Local Procedures

● Disjoint address space

● More prone to Failures (Exceptions)

● Time factor (Long Delays)

Page 6: rpc

Elements of RPC

● Client

● Client Stub

● RPC Runtime

● Server

● Server Stub

Page 7: rpc

RPC

Client Server

Client Stub

RPC Runtime

Server Stub

RPC Runtime

Client Machine Server Machine

Call Packet

Request Packet

Page 8: rpc

Stub Generation

● Automatic

● Manually

Page 9: rpc

Components of Call Messages● Identification info of remote procedure● Arguments ● Message Identification Field

● For identifying lost messages● For Matching reply to call

● Message Type Field● For identifying call messages from reply messages

( 0 - Call 1 - Reply )

● Client Identification Field● For Server to identify client● For Server to authenticate client process

Page 10: rpc

RPC SERVER

● Message not intelligible ● Not authorized client● Particular program,version, procedure no. not

available● Cannot decode arguments● Exception during execution● Successfully executed

Page 11: rpc

Reply Format

● Successful● Message ID (Same as call message ID)● Message Type● Reply Status (0 - Successful)● Result

● Unsuccessful● Message ID● Message Type● Reply Status (Non zero - Unsuccessful)● Reason for failure

Page 12: rpc

Steps involved during Marshalling

● Taking arguments or result that forms message data

● Encoding message data on senders machine– Converting into suitable stream for transmission– Placing in message buffer

● Decoding message data on receiver's comp.– Reconstruction of program objects from stream

Page 13: rpc

Server Management

● Server Implementation

● Server Creation

Page 14: rpc

Server Implementation

● Stateful Servers– Maintains Client state information from one call to

next● Stateless Servers

– Does not maintain any client state information– Client should supply all necessary parameters for

successful execution of procedure

Page 15: rpc

Server Creation Semantics

● Instance per call Servers– Server created only when call message arrives– Server exist only for the duration of one call– Server deleted after call has been executed

● Instance per Session Servers– Server exists for the entire session for which client

and server interact– Accomplished through Server Manager and Binding

Agent

Page 16: rpc

Server Creation Semantics Contd.

● Persistent Servers – Remains in existence indefinitely– Shared by many clients– Created and installed before clients use them– Accomplished through Binding agent– Interleaved for concurrent requests

Page 17: rpc

Parameter Passing

● Call by Value● Parameters copied to message

● Call by Reference– Call by move

– At the time of call parameter object is moved to destination node– After the call the argument object does not return to the caller's

node

– Call by visit– After the call the argument object returns to the caller's node

Page 18: rpc

Failure of RPC

● Call message gets lost● Response message gets lost● Callee node crashes● Caller node crashes

Page 19: rpc

Call Semantics

● How often remote procedure may be executed under fault conditions

● Possibly or May-Be Call Semantics● Last-One Call Semantics● Last-Of Many Call Semantics● At-Least-Once Call Semantics● Exactly -Once Call Semantics

Page 20: rpc

Call Semantics contd.

● Possibly or May-Be Call Semantics– Caller times out and continues execution– No guarantee of delivery of call or execution of

procedure● Last-One Call Semantics

– Retransmissions based on timeouts until response is delivered

– Side effects are possible – Orphan call may violate last-one semantics

Page 21: rpc

Call Semantics contd.

● Last-of Many Call Semantics

– Neglect orphan calls by using call identifiers

– Call id identify each call

– Accepts response for matched call id else ignore

● At-Least-Once Call Semantics

– Timeout retransmissions

– Ignore Orphan calls

Page 22: rpc

Call Semantics contd.

● Exactly-Once Call Semantics– Most desirable– Strongest Call Semantics– Based on

● Timeouts● Retransmissions● Call Id's (Same id for repeated calls)● Reply Cache associated with callee

Page 23: rpc

Communication Protocol

● Request Protocol (R protocol)– No result returned – No confirmation of procedure execution– Asynchronous RPC– 1 packet per call

● Request/Reply Protocol– Servers reply is regarded as ack. for client– Subsequent call from client acts as ack. for server's

reply of previous call– 2 Packets per call

Page 24: rpc

Communication Protocol

● Request/Reply/Acknowledge-Reply Protocol(RRA)– Clients ack. Reciept of reply– Server deletes from reply cache after receiving ack

from client.– 3 packets per call– What happens if ack. From client is lost

Page 25: rpc

RRA Protocol

● If Ack. is lost– Unique Message ID in order– Client acknowledges only if it has recvd. Replies to

all previous requests– Ack is interpreted as ack. For all reply messages

corresponding to req messages with lower message id's

– Loss of ack. is harmless

Page 26: rpc

Complicated RPC

● Long duration calls/gaps between calls– Periodic probing of server by client– Periodic generation of ack by server (if execution not

completed within expected time)● Arguments / Results too large to fit in single

datagram packet– Use several physical RPC for one logical RPC– Multigram messages with single ack.

Page 27: rpc

Client Server Binding

● Process by which client becomes associated with server so that call can take place- BINDING

● Binding Issues– Server Naming– Server Locating – Binding Time

Page 28: rpc

Server Naming

● Use of Interface name

● Interface Name

Type (Version no.)

Instance ( server providing services within the interface)

Page 29: rpc

Server Locating

● Broadcasting– First response is used

● Binding Agent– Named server used to bind client to server by providing

the client with location information of server– Maintains binding table to map server's interface name

to server locations– Servers register with the binding agent

● Identification info , handle used to locate it

Page 30: rpc

Binding Agent

Client Process Server Process

Server RegistersClient Req for server location

Server's location info

Client calls server

Binding Agent

Page 31: rpc

Binding Time

● Binding at compile time– Client and server models are programmed and linked

together● Binding at Link time

– Through binding agent– Server's handle is cached by client to avoid

subsequent calls to binding agent● Binding at Call time

– Indirect call method

Page 32: rpc

Binding at Call time(Indirect Call)

Client Process Server Process

Client passes server'sinterface name, arg

result,handle

Subsequent calls

Binding Agent

RPC call

Result

Page 33: rpc

Binding at Call timeIndirect Call

Page 34: rpc

Assignments

● Examples of – R Protocol – RR Protocol– RRA Protocol

● Lightweight RPC(LRPC)