remote procedure call

25
Remote Procedure Call

Upload: istas

Post on 05-Jan-2016

33 views

Category:

Documents


0 download

DESCRIPTION

Remote Procedure Call. Introduction. Remote Procedure Call (RPC) is a high-level model for client-sever communication. It provides the programmers with a familiar mechanism for building distributed systems. Examples: File service, Authentication service. Introduction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Remote Procedure Call

Remote Procedure Call

Page 2: Remote Procedure Call

Remote Procedure Call (RPC) is a high-level model for client-sever communication.

It provides the programmers with a familiar mechanism for building distributed systems.

Examples: File service, Authentication service.

Introduction

Page 3: Remote Procedure Call

Introduction

Why we need Remote Procedure Call (RPC)?

– The client needs a easy way to call the procedures of the server to get some services.

– RPC enables clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure calls in high-level languages.

– RPC is modeled on the local procedure call, but the called procedure is executed in a different process and usually a different computer.

Page 4: Remote Procedure Call

How to operate RPC?

◦When a process on machine A calls a procedure on machine B, the calling process on A is suspended, and the execution of the called procedure takes place on B.

◦ Information can be transported from the caller to the callee in the parameters and can come back in the procedure result.

◦No message passing or I/O at all is visible to the programmer.

Introduction

Page 5: Remote Procedure Call

The RPC model

Blocking state

client server

request

reply

Executing state

Call procedure and wait for reply

Receive request and start process executionSend reply and wait for next executionResume

execution

Page 6: Remote Procedure Call

The called procedure is in another process which may reside in another machine.

The processes do not share address space.◦ Passing of parameters by reference and passing

pointer values are not allowed.◦ Parameters are passed by values.

The called remote procedure executes within the environment of the server process. ◦ The called procedure does not have access to

the calling procedure's environment.

Characteristics

Page 7: Remote Procedure Call

Simple call syntax

Familiar semantics

Well defined interface

Ease of use

Efficient

Can communicate between processes on the same machine or different machines

Features

Page 8: Remote Procedure Call

Exception handling

◦ Necessary because of possibility of network and nodes failures;

◦ RPC uses return value to indicate errors;

Transparency

◦ Syntactic achievable, exactly the same syntax as a local procedure call;

◦ Semantic impossible because of RPC limitation: failure (similar but not exactly the same);

Design Issues

Page 9: Remote Procedure Call

Based on concepts of stubs Stub is a code used for converting

parameter used in procedure call RPC involves Client & Server Process Mechanism involves following five

elements:◦ The Client ◦ The Client Stub ◦ The RPCRuntime◦ The Server Stub◦ The Server

RPC Mechanism

Page 10: Remote Procedure Call

RPC Mechanism

Return Call Call Return

Unpack Pack Unpack Pack

Receive Send Receive Send

Client Stub

RPC Runtime RPC Runtime

Server Stub

Client Server

Call Packet

Result Packet

Client Machine Server Machine

Page 11: Remote Procedure Call

1. Client procedure calls client stub in normal way2. Client stub builds message, calls local OS3. Client's OS sends message to remote OS4. Remote OS gives message to server stub5. Server stub unpacks parameters, calls server6. Server does work, returns result to the stub7. Server stub packs it in message, calls local OS8. Server's OS sends message to client's OS9. Client's OS gives message to client stub10. Stub unpacks result, returns to client

Steps of a Remote Procedure Call

Page 12: Remote Procedure Call

Client: ◦ Initiates RPC◦ Makes a local call that invokes a corresponding

procedure in the client stub Client Stub:

◦ Receiving a call request from client: Packs the specification of the target procedure & the

arguments into a message Asks local RPCRuntime to send it to server stub

◦ Receiving result of procedure execution Unpacks the result & passes it to the client

Page 13: Remote Procedure Call

RPCRuntime:◦ Client Machine

Receive call request message from Client Stub & sends to server machine

Receives the message containing the result of procedure execution from the server machine & sends to client stub

◦ Server Machine Receives the message containing the result of

procedure execution from the server stub & sends it to client machine

Receive call request message from the client machine & sends it to server stub

Page 14: Remote Procedure Call

Server Stub:◦ Receiving a call request from local RPCRuntime:

Unpacks & makes a normal call to invoke the appropriate procedure in Server

◦ Receiving result of procedure execution Packs the result into a message Asks local RPCRuntime to send it to client stub

Server:◦ Receiving a call request from the server stub

Executes the appropriate procedure Returns the result of execution to the server stub

Page 15: Remote Procedure Call

Manually◦ The RPC implementor provides a set of translation

functions from which a user can construct his/her own stubs

◦ It is simple to implement and can handle very complex parameter types

Automatically◦ Uses Interface Definition Language(IDL)

Define interface between a client & a server Interface Definition-> a list of procedure names supported

by the interface, with the types of their arguments & results It helps the client & server to independently perform

compile-time type checking & to generate appropriate calling sequence

Stub Generation

Page 16: Remote Procedure Call

Two Types of Messages involved

◦ Call Messages Sent by the client to the server for requesting

execution of particular remote procedure

◦ Reply Messages Sent by the server to the client for returning the

result of remote procedure execution

RPC Messages

Page 17: Remote Procedure Call

Two basic fields in a call message are as follows:◦ The identification information of the remote procedure

to be executed◦ The arguments necessary for the execution

Other additional fields are:◦ A message identification field that consist of sequence

number◦ A message type field that used to distinguish call

messages from reply message◦ A client identification field -> 2 purposes:

To allow the server of RPC to identify the client To allow the server to check the authentication of the client

process for executing the concerned procedure

Call Messages

Page 18: Remote Procedure Call

Two message format◦ A successful message format

◦ Msg Message Reply Status◦ identifier Type (successful) Result

◦ An unsuccessful message format◦ ◦ Msg Message Reply Status Reason for ◦ identifier Type (unsuccessful) Failure

Reply Message

Page 19: Remote Procedure Call

The transfer of message data between two computers requires encoding & decoding of the message data

This operation in RPCs is known as Marshaling◦ Actions involved in Marshaling

Taking the arguments Encoding the message data on sender’s computer Decoding the message data on receiver’s computer

Marshaling Arguments & Result

Page 20: Remote Procedure Call

Two issues in server management◦ Server Implementation

Stateful Server Stateless Server

◦ Server Creation Instance-per-call server Instance-per-session server Persistent servers

Server Management

Page 21: Remote Procedure Call

Based on the style of implementation, it is of two types

Stateful Servers◦ Maintains clients’ state information◦ For eg: Consider a server for byte stream files that

allows the following operations on file: Open(filename, mode) Read(fid, n, buffer) Write(fid, n, buffer) Seek(fid, position) Close(fid)

Server Implementation

Page 22: Remote Procedure Call

Open(filename,mode)

Return(fid)

Return(bytes 0 to 99)

Return(bytes100 to199)

Read (fid, 100, buf)

Read (fid, 100, buf)

fid Mode R/W ptr

Client Process Server Process

Stateful File Server

Page 23: Remote Procedure Call

Stateless Servers◦ Does not maintain any client state information

◦ For eg: Consider a server for byte stream files that allows the following operations on files is stateless:

Read(filename, position, n ,buffer)

write(filename, position, n ,buffer)

Page 24: Remote Procedure Call

Return(bytes 0 to 99)

Return(bytes100 to199)

Read (fid, 100, buf)

Read (filename, 100, buf)

Client Process Server Process

Stateless File Server

fid Mode R/W ptr

Page 25: Remote Procedure Call

Based on time duration for which RPC servers survive, it is classified into three

Instance-per-Call Servers◦ Exist only for the duration of a single call◦ Created by RPCRuntime -> when a call message

arrives Instance-per-Session Servers

◦ Exist for the entire session for which a client & a server intract

Persistent Servers◦ Remains in existence indefinetely

Server Creation Semantics