Remote Procedure Call Concept RPC Overview Introduction RPC

  • Slides: 27
Download presentation
Remote Procedure Call Concept (RPC)

Remote Procedure Call Concept (RPC)

Overview • • • Introduction RPC Model Paradigm for Distributed Programs Conventional Procedure Call

Overview • • • Introduction RPC Model Paradigm for Distributed Programs Conventional Procedure Call Model Client/Server and RPC Sun Microsystems�� RPC Definition Remote Programs and Procedures Management for RPC�� s Communication Semantics RPC Mapping RPC Data Marshaling Summary

Introduction • Remote Procedure Call (RPC) is a protocol that one program can use

Introduction • Remote Procedure Call (RPC) is a protocol that one program can use to request a service from a program located in another computer. • RPC uses the client/server model. – The requesting program is a client and the service-providing program is the server. – Similar to a local procedure call, a RPC is a synchronous operation requiring the requesting program to be suspended until the results of the remote procedure are returned. – Threads or lightweight processes that share the same address space allow multiple RPC’s to be performed concurrently. • The RPC concept simplifies the design of client/server software – Makes the programs easier to understand – Uses symmetric data conversion (XDR)

Remote Procedure Call Model • A conceptual framework for building distributed programs – Remote

Remote Procedure Call Model • A conceptual framework for building distributed programs – Remote Procedure Call model or RPC model – Uses familiar concepts from conventional programs as the basis for the design of distributed applications

Remote Procedure Calls (RPC) • How are parameter passed in a remote procedure call,

Remote Procedure Calls (RPC) • How are parameter passed in a remote procedure call, while making it look like a local procedure call?

Client and Server Stubs Principle of RPC between a client and server program.

Client and Server Stubs Principle of RPC between a client and server program.

Steps of a Remote Procedure Call 1. 2. 3. 4. 5. 6. 7. 8.

Steps of a Remote Procedure Call 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Client procedure calls client stub in normal way Client stub builds message, calls local OS Client's OS sends message to remote OS Remote OS gives message to server stub Server stub unpacks parameters, calls server Server does work, returns result to the stub Server stub packs it in message, calls local OS Server's OS sends message to client's OS Client's OS gives message to client stub Stub unpacks result, returns to client

Distributed Programs Paradigms • Communication-Oriented Design – – ! Begin with the communication protocol

Distributed Programs Paradigms • Communication-Oriented Design – – ! Begin with the communication protocol ! Design a message format and syntax ! Design the client/server by specifying how each reacts to incoming/outgoing messages ! A communication-oriented design may lead to problems • Protocol may not provide all the needed functionality • Inexperience with protocol design could lead to inefficient protocols • Difficult to understand or modify • Application-Oriented Design – – – ! Begin with the application ! Design a conventional application program ! Build and test a working version as a conventional program ! Divide the program into several pieces to execute on separate computers ! The remote procedure call paradigm focuses on the application • Emphasizes the problem to be solved instead of the communication mechanism • Does not require major code changes when splitting procedures between local/remote machines • RPC separates the solution of a problem from the task of making the solution operate in a distributed environment

Conceptual Model for Conventional Procedure Calls

Conceptual Model for Conventional Procedure Calls

Extension of the Procedural Model

Extension of the Procedural Model

Conventional Procedure Call Execution • Single thread of control through all procedures • Execution

Conventional Procedure Call Execution • Single thread of control through all procedures • Execution begins in main and continues until it encounters a procedure call • Execution branches to the code in the procedure • Execution continues in the procedure until it encounters a return statement

Distributed Procedural Model • Single thread of execution executes in a distributed environment •

Distributed Procedural Model • Single thread of execution executes in a distributed environment • Client/Server corresponds to a procedure call and return • Client request corresponds to a procedure call • Server response corresponds to the return function

Distributed Computation • Paradigm helps programmers design distributed programs easily – ! Distributed program

Distributed Computation • Paradigm helps programmers design distributed programs easily – ! Distributed program invokes a procedure to access a remote service – ! Remote procedures are accessed the same as local procedures – ! Distributed programs are as easy to construct as conventional programs

Sun Microsystems' RPC Definition • Sun Microsystems developed a specific form of RPC (Sun

Sun Microsystems' RPC Definition • Sun Microsystems developed a specific form of RPC (Sun RPC, Open Network Computing (ONC) RPC or simply RPC) • Received wide acceptance including NFS • ONC RPC defines the format of messages • Allows the calling program to use UDP or TCP • Uses XDR to represent procedure arguments as well as data items in an RPC message header • ONC RPC includes a compiler system to aid in building distributed applications

Remote Programs and Procedures • RPC defines a remote program as the basic unit

Remote Programs and Procedures • RPC defines a remote program as the basic unit of software that executes on a remote machine • Each remote program corresponds to a server and contains a set of one or more procedures plus global data • The procedures inside a remote program all share access to its global data

Identifying Remote Programs and Procedures • The ONC RPC standard specifies that each remote

Identifying Remote Programs and Procedures • The ONC RPC standard specifies that each remote program be assigned a unique 32 -bit integer to identify it • ONC RPC assigns an integer to each remote procedure inside a given remote program • The procedures are numbered: 1, 2, … N • ONC RPC divided the set of program numbers into 8 groups of 32 -bit numbers • Each remote program is assigned a unique number • ONC RPC includes an integer version number for each remote program – ! The RPC specification permits a computer to run multiple versions of a remote program

Mutual Exclusion for Procedures in a Remote Program • The ONC RPC mechanism specifies

Mutual Exclusion for Procedures in a Remote Program • The ONC RPC mechanism specifies that at most one remote procedure can execute in a remote program at one time • RPC provides automatic mutual exclusion among procedures within a given remote program • Important for remote programs that maintain a shared data area

Communication Semantics • ONC RPC does not enforce reliable semantics • Can use TCP

Communication Semantics • ONC RPC does not enforce reliable semantics • Can use TCP or UDP as a transport protocol – ! When using UDP as the transport protocol the application must be able to tolerate zero-or-more execution semantics – ! Each remote procedure call needs to be idem potent • The standard does not specify additional protocols or mechanisms for reliable delivery • RPC semantics are defined as a function of the underlying transport protocol

RPC Retransmission • ONC RPC includes a simple timeout and retransmission strategy – !

RPC Retransmission • ONC RPC includes a simple timeout and retransmission strategy – ! Does not guarantee reliability – ! Default timeout mechanism implements a fixed timeout with a fixed number of retries

Map a Remote Program to a Protocol Port • TCP/UDP use 16 -bit protocol

Map a Remote Program to a Protocol Port • TCP/UDP use 16 -bit protocol numbers • RPC uses 32 -bit numbers to identify remote programs – ! RPC programs can outnumber protocol ports – ! Unable to map RPC program to protocol ports directly – ! Each RPC program can obtain a protocol port number if port assignments are temporary

Dynamic Port Mapping • ONC RPC mechanism includes a dynamic mapping service to solve

Dynamic Port Mapping • ONC RPC mechanism includes a dynamic mapping service to solve the identification problem • Each machine that supports RPC provides a mechanism that allows a mapping of RPC program numbers to protocol ports

RPC Port Mapper Algorithm • 1. Create a passive socket bound to the well

RPC Port Mapper Algorithm • 1. Create a passive socket bound to the well known port assigned to the ONC RPC port mapper service (111) • 2. Repeatedly accept request to register a RPC program number or to look up a protocol port given an RPC program number

ONC RPC Message Format • ONC RPC does not use a fixed format for

ONC RPC Message Format • ONC RPC does not use a fixed format for messages – ! The standard defines the general format of RPC messages – ! The XDR language defines the data items – ! The XDR language defines how to assemble a message

Data Marshaling Arguments • RPC must represent all arguments in an external form for

Data Marshaling Arguments • RPC must represent all arguments in an external form for transfer • Complex data structures must be encoded into a compact representation – ! marshal, linearize or serialize • Client side marshals the arguments into the message and the server side un-marshals them

Authentication • RPC uses several forms of authentication – ! Simple scheme that relies

Authentication • RPC uses several forms of authentication – ! Simple scheme that relies on UNIX – ! Complex scheme that uses the Data Encryption Standard (DES) • RPC leaves the format and interpretation up to the authentication subsystem

Example RPC Message

Example RPC Message

Summary • The remote procedure model helps make distributed programs easy to design and

Summary • The remote procedure model helps make distributed programs easy to design and understand • The RPC model views each server as implementing one or more procedures • A message from a client corresponds to a call and a response from the server corresponds to a return • Remote procedures accept arguments and return one or more results Sun Microsystems developed the de-facto standard form of remote procedure call (ONC RPC) • ONC RPC use a dynamic binding mechanism called the RPC Port Mapper