Remote Procedure Call (Introduction)

Slides:



Advertisements
Similar presentations
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
Advertisements

RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
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)
INF 123 SW ARCH, DIST SYS & INTEROP LECTURE 8 Prof. Crista Lopes.
Distributed Systems Lecture #3: Remote Communication.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
Implementing Remote Procedure Calls Authors: Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presenter: Jim Santmyer Thanks to:
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Remote Procedure Call Chin-Chih Chang. Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located.
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.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication in Distributed Systems –Part 2
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.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
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.
1 Lecture 5 (part2) : “Interprocess communication” n reasons for process cooperation n types of message passing n direct and indirect message passing n.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Page 1 Remote Procedure Calls Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
1 Developing Application in Distributed Computing Environment (DCE)
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
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?
DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1. 2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Client-Server Communication
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Procedure Call present by :Enas Alkhoshi
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
DISTRIBUTED COMPUTING
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Distributed Program Design
Distributed Computing
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
CS-502, Operating Systems Fall 2009 (EMC)
Remote invocation (call)
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 7: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
Last Class: Communication in Distributed Systems
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

Remote Procedure Call (Introduction) What is a procedure? (review) A procedure is to execute a group of statements and syntactically a procedure call was defined to be a statement. Parameter passing: the way to pass external variable(s) into a procedure.

Remote Procedure Call (Introduction) Why we need Remote Procedure Call (RPC)? The procedures of send and receive are fundamentally engaged in doing I/O. Since I/O is not one of the key concepts of centralized systems, making it the basis for distributed computing has struck many workers in the field as a mistake. The client needs a easy way to call the procedures of the server to get some services.

Remote Procedure Call (Introduction) What is RPC mechanism? They enable clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure on the local procedure call, but the call procedure is executed in a different process and usually a different computer.

Remote Procedure Call (Introduction) 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.

Remote Procedure Call (Main characteristics) The called procedure is in another process which may reside in another machine. Since 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.

Remote Procedure Call (Limitation) Parameters passed by reference only and pointer values are not allowed. Speed: remote procedure calling (and return) time (i.e., overheads) can be significantly (1 - 3 orders of magnitude) slower than that for local procedure. This may affect real-time design and the programmer should be aware of its impact. Failure: RPC is more vulnerable to failure (since it involves communication system, another machine and another process). The programmer should be aware of the call semantics.

Remote Procedure Call (How does RPC work?) In the normal case (no failure), the following problems we should solve P1: How does the client know which procedure (names) it can call from the server? P2: How does the client transfer its call request (the procedure name) and the arguments to the server via network?

Remote Procedure Call (How does RPC work?) P3: How does the server react the request of the client? From which port? How to select the procedure? How to interpret the arguments? P4: How does the server transmit the reply back? P5: How does the client receive the reply?

Remote Procedure Call (Solution for P1) P1: How does the client know which procedure (names) it can call from the server? Solution: Server interface definition Interface definition language: RPC interface specifies those characteristics of the procedures provided by a server that are visible to the clients. The characteristics includes: names of the procedures and type of parameters. Each parameter is defined as input or output.

Remote Procedure Call (Solution for P1) In summary, an interface contains a list of procedure signatures - the names and types of their I/O arguments (to be discussed later). This interface is made known to the clients through a server process binder (to be discussed later).

Remote Procedure Call (Solution for P2 - Building client program) P2: How does the client transfer its call request (the procedure name) and the arguments to the server via network? Marshalling and communication with server: For each remote procedure call, a (client) stub procedure is generated and attached to the (client) program. Replace the remote procedure call to a (local) call to the stub procedure.

Remote Procedure Call (Solution for P2 - Building client program) The (codes in the) stub procedure marshals (the input) arguments and places them into a message together with the procedure identifier (of the remote procedure). Use IPC primitive to send the (call request) message to the server and wait the reply (call return) message (DoOperation).

Remote Procedure Call (Solution for P3 - Building server program) P3: How does the server react the request of the client? From which port? How to select the procedure? How to interpret the arguments? Despatching, Unmarshalling, communication with client: A despatcher is provided. It receives the call request message from the client and uses the procedure identifier in the message to select one of the server stub procedures and passes on the arguments.

Remote Procedure Call (Solution for P3 - Building server program) For each procedure at the server which is declared (at the sever interface) as callable remotely, a (server) stub procedure is generated. The task of a server stub procedure is to unmarshal the arguments, call the corresponding (local) service procedure. On return, the stub marshals the output arguments into a reply (call return) message and sends it back to the client.

Remote Procedure Call (Solution for P4 - Building server program) P4: How does the server transmit the reply back? On return, the stub marshals the output arguments into a reply (call return) message and sends it back to the client.

Remote Procedure Call (Solution for P5 - Building client program) P5: How does the client receive the reply? The stub procedure of the client unmarshals the result arguments and returns (local call return). Note that the original remote procedure call was transformed into a (local) call to the stub procedure.

Remote Procedure Call (Summary of RPC steps) 1. The client provides the arguments and calls the client stub in the normal way. 2. The client stub builds (marshals) a message (call request) and traps to OS & network kernel. 3. The kernel sends the message to the remote kernel. 4. The remote kernel receives the message and gives it to the server dispatcher. 5. The server dispatcher selects the appropriate server stub. 6. The server stub unpacks (unmarshals) the parameters and call the corresponding server procedure.

Remote Procedure Call (Summary of RPC steps) 7. The server procedure does the work and returns the result to the server stub. 8. The server stub packs (marshals) it in a message (call return) and traps it to OS & network kernel. 9. The remote (receiver) kernel sends the message to the client’s kernel. 10. The client’s kernel gives the message to the client stub. 11. The client stub unpacks (umarshals)the result and returns to client.

Remote Procedure Call (Summary of RPC steps) Figure 2-18 (Tanenbaum95)

Remote Procedure Call (Binding) Locating a remote procedure To achieve configuration flexibility, linking to remote procedure is usually done dynamically through the use of a binder process. A RPC binder provides mapping of a server’s name to the server’s address. The binder’s address is pre-assigned and is made known system-wide.

Remote Procedure Call (Binding) A client accessing a service first looks up the service’s address from the binder. Remote procedure calls can then use the server’s address in its IPC primitives (used in the client stub). When a server is relocated, the client’s codes need not be changed. Only the server’s re-registration is required.

Remote Procedure Call (Implementation - Interface processing) Interface processing: Integrating the RPC mechanism with client and server programs in conventional programming languages. The Interface language is required. Both client and server assign the same unique procedure identifier to each procedure in an interface (they are numbered 0,1,2 …) and the procedure identifier is included in request message It processes dispatching of request messages to the appropriate procedure in the server, and marshalling and unmarshalling of arguments in the client and server.

Remote Procedure Call (Implementation - Interface processing) Interface definitions written in an Interface Definition Language (IDL); Interface compiler compiling the IDL performs the following tasks: Generate stub procedures for the client and dispatcher & stub procedures for the server to correspond to each procedure signature in the interface. The stub procedures (dispatcher & stub procedures) will be linked with the client (server) program.

Remote Procedure Call (Implementation - Interface processing) Use the signatures of the procedures in the interface - which define the argument and result types - to generate (un)-marshalling operations in each stub procedure. Generate procedure headings for each procedure in the service. The service supplies the bodies of these procedures. Communication handling: transmitting and receiving request and reply messages, e.g. TCP, UDP.

Case Study: SUN RPC Interface definition language: XDR Interface compiler: rpcgen Communication handling: TCP or UDP Version: RPCSRC 3.9 (4.3BSD UNIX)

Case Study: SUN RPC SUN RPC consists of the following parts: rpcgen: a compiler that takes the definition of a remote procedure interface, and generates the client stubs and the server stubs; XDR: a standard way of encoding data in a portable fashion between different systems; A run-time library to handle all the details.

Case Study: SUN RPC Simple example: the client calls using RPC and the server have the following two functions: bin_date_1 returns the current time as the number of seconds since 00:00:00 GMT, January 1, 1970. str_date_1 takes a long integer value from the previous function and converts it into an ASCII string that is fit for human consumption.

RPC specification file Case Study: SUN RPC server program data_proc.c server procedure date.x RPC specification file rdate.c client main function CC data_svc rdate server stub data.h data_svc.c data_clnt.c RPC run-time library rpcgen client program client stub CC

Case Study: SUN RPC Generate the executable client program: cc -o rdate rdate.c date_clnt.c -lnsl Generate the executable server program: cc -o date_svc date_proc.c date_svc.c -lnsl

Case Study: SUN RPC date.x 0x20000000 - 0x3fffffff is defined by user; program DATE_PROG { version DATE_VERS { long BIN_DATE(void) = 1; /* procedure number = 1 */ string STR_DATE(long) = 2; /* procedure number = 2 */ } = 1; /* version number = 1 */ } = 0x31234567; /* program number = … */ 0x20000000 - 0x3fffffff is defined by user;

Case Study: SUN RPC date.h (generated by rpcgen) #define DATE_PROG ((u_long) 0x31234567) #define DATE_VERS ((u_long) 1) #define BIN_DATE ((u_long) 1) extern long *bin_date_1(); #define STR_DATE ((u_long) 2) extern char **str_date_1();

Case Study: SUN RPC rdate.c /* client program for remote date service. */ #include <stdio.h> #include <rpc/rpc.h> /* standard RPC include file */ #include “date.h” /* generated by rpcgen */ main(argc, argv) int argc; char *argv[];

Case Study: SUN RPC { CLIENT *cl; /* RPC handle */ char *server; long *lresult; /* return value from bin_date_1 */ long **sresult; /* return value from str_date_1 */ if (argc != 2) { fprintf(stderr, “usage: %s hostname\n”, argv[0]); exit(1); } server = argv[1];

Case Study: SUN RPC /* create the client handle */ if ((cl = clnt_create(server, DATE_PROG, DATE_VERS, “udp”)) == NULL) { /* couldn’t establish connection with server */ clnt_pcreateerror(server); exit(2); } /* first call the remote procedure “bin_date” */ if ((lresult = bin_date_1(NULL, cl)) == NULL) { clnt_perror(cl, server); exit(3); printf(“time on host %s = %ld\n”, server, *lresult);

Case Study: SUN RPC /* now call the remote procedure “str_date” */ if ((sresult = str_date_1(lresult, cl)) == NULL) { clnt_perror(cl, server); exit(4); } printf(“time on host %s = %s\n”, server, *sresult); clnt_destroy(cl); /* done with the handle */ exit(0);

Case Study: SUN RPC date_proc.c /* remote procedure; called by server stub */ #include <rpc/rpc.h> /* standard RPC include file */ #include “date.h” /* generated by rpcgen */ /* return the binary date and time */ long *bin_date_1() { static long timeval; /* must be static */ long time(); /* UNIX function */

Case Study: SUN RPC timeval = time((long *) 0); return(&timeval); } /* convert a binary time and return a human readable string */ char **str_date_1(long *bintime) { static long *ptr; /* must be static */ char *ctime(); /* UNIX function */ ptr = ctime(bintime); /* convert to local time */ return(&ptr); /* return the address of pointer */

Case Study: SUN RPC clnt_create: create an RPC handle to the specified program and version on a host; static variable: if we do not use static variables, their values would be undefined after return statement passes control back to the server stub that calls our remote procedure.

Case Study: SUN RPC Steps involved in RPC calls rdate (client) portmapper daemon date_svc (server) 1 Remote system 3 2 4

Case Study: SUN RPC 1. The server program calls a function in the RPC library, svc_register, register its program number and version to the remote system. This function contacts the port mapper process to register itself. 2. The client program calls clnt_create to contact the port mapper to find out the UDP port for the server. 3. Call bin_date_1 remote function and receive its return value. 4. Call str_date_1 remote function and receive its return value.