Remote Procedure Call Chin-Chih Chang. Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located.

Slides:



Advertisements
Similar presentations
CSE 486/586 Distributed Systems Remote Procedure Call
Advertisements

RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
End-to-End Protocols Outline Reliable Byte-Stream Simple Demultiplexer
RPC Remote Procedure Call Dave Hollinger Rensselaer Polytechnic Institute Troy, NY.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Lecture 8-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2012 Indranil Gupta (Indy) September 20, 2012 Lecture 8 RPCs and Distributed.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
CS6223: Distributed Systems Remote Procedure Call (RPC)
CS Distributed Computing Systems Chapter 5: Distributed Objects and Remote Invocation Chin-Chih Chang, From Coulouris, Dollimore.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
Outcomes What is RPC? The difference between conventional procedure call and RPC? Understand the function of client and server stubs How many steps could.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication Chapter 2. Communication Due to the absence of shared memory, all communication in distributed systems in based on exchanging messages over.
Netprog RPC Overview1 Distributed Program Design n Communication-Oriented Design –Design protocol first. –Build programs that adhere to the protocol.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
.NET Mobile Application Development Remote Procedure Call.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
Linux RPC Comer Chapter 21 (RPCgen Concept) RFC 1057 – RPC Spec. UNIX Network Programming - Stevens 1.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
Remote Procedure CallCS-502 Fall Remote Procedure Call CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts,
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Sun RPC also called ONC (Open Network Computing) RPC originally designed for client-server communication for Sun Network File System (NFS) provides an.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CSE Computer Networks Prof. Aaron Striegel Department of Computer Science & Engineering University of Notre Dame Lecture 14 – February 23, 2010.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
Page 1 Remote Procedure Calls Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Netprog: RPC Programming1 RPC Programming with rpcgen Issues: –Protocol Definition File –Client Programming Creating an "RPC Handle" to a server Calling.
Netprog: RPC Programming1 RPC Programming with rpcgen Issues: –Protocol Definition File –Client Programming Creating an "RPC Handle" to a server Calling.
1 Developing Application in Distributed Computing Environment (DCE)
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
B. Prabhakaran 1 RPC Execution Local call Return Query binding server Params packing Wait Unpack result Unpack Local call Pack results Execute procedure.
CS 425/ECE 428/CSE 424 Distributed Systems (Fall 2009) Lecture 18 Distributed Objects (II) Sections , Chapter
Remote Procedure Calls CS587x Lecture Department of Computer Science Iowa State University.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
Remote Procedure Call RPC
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
Chap 35 Remote Procedure Calls RPC allows one host to make a procedure call that appears to be part of a local process (fig 35.1), but is really executed.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1. 2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call.
Remote Procedure Call (Introduction)
Lecture 8-1 Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013 Indranil Gupta (Indy) September 19, 2013 Lecture 8 RPCs and Distributed.
1 Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
CSE 486/586 Distributed Systems Remote Procedure Call
Multithreading SUN RPC is by default single threaded, it provides an iterative server rpcgen takes two options –M and –A M makes the server code thread.
Adv. Network Programming RPC (Remote Procedure Call)
Edition 5, © Addison-Wesley 2012
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Slides for Chapter 5: Distributed objects and remote invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Distributed Program Design
Distributed Computing
Remote Procedure Call Hank Levy 1.
CS-502, Operating Systems Fall 2009 (EMC)
Remote invocation (call)
Remote Procedure Call Hank Levy 1.
Remote Procedure Call Hank Levy 1.
Last Class: Communication in Distributed Systems
Presentation transcript:

Remote Procedure Call Chin-Chih Chang

Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located on other machines. RPC uses the client/server model. The requesting program is a client and the service-providing program is the server. The client stub acts as a proxy for the remote procedure. The server stub acts as a correspondent to the client stub.

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

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

Steps of a Remote Procedure Call

Passing Value Parameters Steps involved in doing remote computation through RPC 2-8

RPC in Practice - DCE RPC The Distributed Computing Environment (DCE) RPC is developed by the Open Software Foundation (OSF)/Open Group. DCE is a middleware executing as an abstraction layer between (network) operating systems and distributed applications. Microsoft derived its version of RPC from DCE RPC (e.g., MIDL compiler, etc.) DCE includes a number of services: –Distributed file service –Directory service –Security service –Distributed time service

DCE RPC The main goal of the DCE RPC is to make it possible for a client to access a remote service by simply calling a local procedure. Developing a RPC application: –Writing a client and a server: Let the developer concentrate on only the client- and server- specific code; let the RPC system (generators and libraries) do the rest. Interface Definition Language (IDL) is used to specify the variables (data) and functions (methods). –Binding a client to a server –Performing an RPC

Writing a Client and a Server The steps in writing a client and a server in DCE RPC. 2-14

Client-to-Server Binding (DCE RPC) Issues: Client must locate server machine and locate the server. Execution of Client and Server –The server registers its procedures with the portmapper. –Client must locate server machine: The client contacts the portmapper to determine which port the server is listening to. –The client communicates with the server on the assigned port. DCE uses a separate daemon for each server machine.

Binding a Client to a Server Client-to-server binding in DCE. 2-15

Sun RPC/ONC (Open Network Computing) RPC It is designed for client-server communication over Sun NFS network file system. UDP or TCP can be used. Generally, if UDP is used, the message length is restricted to 64 KB, but KB in practice. The Sun XDR is originally intended for external data representation (XDR). Valid data types supported by XDR include int, unsigned int, long, structure, fixed array, string (null terminated char *), binary encoded data (for other data types such as lists).

Sun/ONC RPC Steps to create a Sun RPC application: 1.Create the IDL file ( sum.x ), the client main code ( rsum.c ), and the server function code ( sum_serv.c ) 2.Run the RPC generator ( rpcgen sum.x ) to generate client stub ( sum_clnt.c ), server stub ( sum_svc.c ), header file ( sum.h ), and data coversion file ( sum_xdr.c ). 3.Compile the client and server programs ( make ). 4.Start the server ( server ). 5.Run the client ( rsum hostname 10 ).

Interface Definition Language The notation of Sun RPC IDL:  a program number and a version number are supplied.  The procedure number is used as a procedure definition.  Single input parameter and output result are being passed.

Files interface in ONC IDL const MAX = 1000; typedef int FileIdentifier; typedef int FilePointer; typedef int Length; struct Data { int length; char buffer[MAX]; }; struct writeargs { FileIdentifier f; FilePointer position; Data data; }; struct readargs { FileIdentifier f; FilePointer position; Length length; }; program FILEREADWRITE { version VERSION { void WRITE(writeargs)=1;1 Data READ(readargs)=2;2 }=2; } = 9999;

Sun/ONC RPC The interface compiler rpcgen can be used to generate the following from the interface definition.  client stub procedures (sum_clnt.c)  server main procedure, dispatcher (system calls) and server stub procedures (sum_svc.c)  XDR marshalling and unmarshalling procedures used by dispatcher and client, server stub procedures. (sum_xdr.c) Binding:  portmapper records program number, version number, and port number.  If there are multiple instance running on different machines, clients make multicast remote procedure calls by broadcasting them to all the port mappers.

ONC RPC Interface Compiler

ONC RPC Authentication:  Additional fields are provided in the request-reply message.  Server program should check the authentication and then execute.  Different authentication protocols can be supported - none, UNIX style, shared key, Kerberos style.  A field in RPC header indicates which style is used.

Example (ONC RPC) long sum(long) example  client localhost 10  result: 55 Need RPC specification file (sum.x)  defines procedure name, arguments & results Run (interface compiler) rpcgen sum.x  generates sum.h, sum_clnt.c, sum_xdr.c, sum_svc.c  sum_clnt.c & sum_svc.c: Stub routines for client & server  sum_xdr.c: XDR (External Data Representation) code takes care of data type conversions

RPC IDL File (sum.x) struct sum_in { long arg1; }; struct sum_out { long res1; }; program SUM_PROG { version SUM_VERS { sum_out SUMPROC(sum_in) = 1; /* procedure number = 1*/ } = 1; /* version number = 1 */ } = 0x ; /* program number */

Example (Sun RPC) Program-number is usually assigned as follows:  0x x1fffffff defined by SUN  0x x3fffffff defined by user  0x x5fffffff transient  0x xffffffff reserved

RPC Client Code (rsum.c) #include ''sum.h'' main(int argc, char* argv[]) { CLIENT* cl; sum_in in; sum_out *outp; // create RPC client handle; need to know server's address cl = clnt_create(argv[1], SUM_PROG, SUM_VERS, ''tcp''); in.arg1 = atol(argv[2]); // number to be squared // Call RPC; note convention of RPC function naming if ( (outp = sumproc_1(&in, cl)) == NULL) err_quit(''%s'', clnt_sperror(cl, argv[1]); printf(''result: %ld\n'', outp->res1); }

RPC Server Code (sum_serv.c) #include "sum.h" sum_out* sumproc_1_svc (sum_in *inp, struct svc_req *rqstp) { // server function has different name than client call static sum_out out; int i; out.res1 = inp->arg1; for (i = inp->arg1 - 1; i > 0; i--) out.res1 += i; return(&out); } // server's main() is generated by rpcgen

Compilation Linking rpcgen sum.x cc -c rsum.c -o rsum.o cc -c sum_clnt.c -o sum_clnt.o cc -c sum_xdr.c -o sum_xdr.o cc -o client rsum.o sum_clnt.o sum_xdr.o cc -c sum_serv.c -o sum_serv.o cc -c sum_svc.c -o sum_svc.o cc -o server sum_serv.o sum_svc.o sum_xdr.o

Internal Details of ONC RPC Initialization  Server runs: register RPC with port mapper on server host (rpcinfo –p)  Client runs: clnt_create contacts server's port mapper and establishes TCP/UDP connection with server Client  Client calls local procedure (client stub: sumproc_1), that is generated by rpcgen. Client stub packages arguments, puts them in standard format (XDR), and prepares network messages (marshaling).  Network messages are sent to remote system by the client stub.  Network transfer is accomplished with TCP or UDP.

Internal Details of ONC RPC Server  Server stub (generated by rpcgen) unmarshals arguments from network messages. Server stub executes local procedure (sumproc_1_svc) passing arguments received from network messages.  When server procedure is finished, it returns to server stub with return values.  Server stub converts return values (XDR), marshals them into network messages, and sends them back to client Back to Client  Client stub reads network messages from kernel  Client stub returns results to client function