CS6223: Distributed Systems Remote Procedure Call (RPC)

Slides:



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

CSE 486/586 Distributed Systems Remote Procedure Call
RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call Design issues Implementation RPC programming
Spring Remote Procedure Call (5.3) Outline Protocol Stack Presentation Formatting.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Distributed Systems Lecture #3: Remote Communication.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
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.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering.
.NET Mobile Application Development Remote Procedure Call.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
Communication Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
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.
Chapter 4: Interprocess Communication‏ Pages
Politecnico di Milano © 2001 William Fornaciari Operating Systems R P C Remote Procedure Call Lecturer: William Fornaciari Politecnico di Milano
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.
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.
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)
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.
1 Conventional Procedure Call read(fd,buf,nbytes) a)Parameter passing in a local procedure call: the stack before the call to read b)The stack while the.
Remote Procedure Call RPC
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.
Remote Procedure Call (Introduction)
1 Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)
Topic 3: Remote Invocation Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Prof. Leonardo Mostarda University of Camerino
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Procedure Call present by :Enas Alkhoshi
CMSC621: Advanced Operating Systems Advanced Operating Systems
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
7. End-to-end data Rocky K. C. Chang Department of Computing
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
XDR External Data Representation
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
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:

CS6223: Distributed Systems Remote Procedure Call (RPC)

2 An Example of Local Procedure Call /* save a string to file msg.dat */ savemsg(char *msg) { FILE *fp; fp = fopen("msg.dat", "w+"); fprintf(fp, "%s\n", msg); fclose (fp); } main() { char *str = "This is an example of LPC."; savemsg(str); }

3 Moving the local procedure to a remote machine main() { char *str = "This is an example of RPC."; char *remote_host = "sus1.cs.cityu.edu.hk"; CLIENT *clnt; clnt = clnt_create(remote_host, MSGPROG, MSGVER, "netpath"); if (clnt == (CLIENT *) NULL) { clnt_pcreateerror(host); exit(1); } savemsg_1(&str, clnt); } ………… savemsg_1(char **argp; struct svc_req *rqstp) { FILE *fp; fp = fopen("msg.dat", "w+"); fprintf(fp, "%s\n", *argp); fclose (fp); } server: client:

4 Remote Procedure Call 1984: Birrell & Nelson –Mechanism to call procedures on other machines –Process on machine A can call a procedure on machine B A is suspended Execution continues on B When B returns, control passed back to A Goal: Make a remote procedure call looking the same as a local call to programmers.

5 RPC implementation The RPC compiler auto-generates stub/skeleton routines to make an RPC to the user as if it is a local call. What stub routines do: marshalling / unmarshalling parameters and return values handling different data formats between different machines detecting and handling failures of client/server processes and the networks service routines server skeleton client stub client program message passing client server

6 Compilation in SUN RPC server skeleton (main) service routines data conversion client program (main) client stub RPC compiler interface definition C compiler server executable C compiler client executable

7 Demo of RPC Interface file msg.x: program MSGPROG { version MSGVER{ int SAVEMSG(string)= 1; string READMSG(int)= 2; } = 2; } = ; Generate stub routines by: rpcgen –a msg.x Compile program by: cc –o object xxx.c

8 Steps in a RPC client program (msg_client.c) service routines client stub (msg_clnt.c) server skeleton network routines 1. Client calls stub (push parameters onto stack)

9 Steps in a RPC client programservice routines client stub (msg_clnt.c) network routines 2. Clnt_stub marshals parameters to message & makes an OS call (client blocked) server skeleton

10 Steps in a RPC client program client stub network routines 3. Network message sent to server server skeleton service routines

11 Steps in a RPC client program client stub network routines 4. Deliver message to server stub & unblock server server skeleton (msg_svr.c) service routines

12 Steps in a RPC client program client stub network routines 5. Svr-stub unmarshals parameters & calls service routine (local call) server skeleton (msg_svr.c) service routines (msg_server.c)

13 Steps in a RPC client program client stub network routines 6. Return to the stub from service routine server skeleton service routines

14 Steps in a RPC client program client stub network routines 7. Svr_stub marshals return-value & requests OS to send out message server skeleton service routines

15 Steps in a RPC client program client stub network routines 8. Transfer message over network server skeleton service routines

16 Steps in a RPC client program client stub network routines 9. Deliver message to client (unblock client) server skeleton service routines

17 Steps in a RPC client program client stub network routines 10. Clnt_stub unmarshals return-value & returns to client program… server skeleton service routines

18 Compilation in SUN RPC server skeleton (main) service routines data conversion client program (main) client stub RPC compiler interface definition C compiler server executable C compiler client executable

19 Writing the programs Programmers need to write two pieces of programs: Client program –Specify server’s location –Parameters and return value of RPC are pointers Service routines –Generally the same as local procedures, except the parameters and parameter types

20 Interface definition (1) Define machine/OS/language-independent data types and data structures Specify interfaces: program # and version # Define remote procedures: procedure #, parameters, return type constant and type definitions /*optional */ program IDENTIFIER { version VERSION_ID { procedure list } = value; … } = value; program MSGPROG { version MSGVER{ int SAVEMSG(string)= 1; string READMSG(int)= 2; } = 3; } = ;

21 Interface definition (2) one program block in an interface definition one or more sets of versions in the program block one or more sets of procedures in each version block one argument in each procedure by default –If more than one parameter is required, use a struct to group them –“–N” option in “rpcgen” allows multiple arguments

22 Incompatible data representation (1) Different byte ordering –Big endian: Most significant byte in low memory (e.g. Sun Sparcs) –Little endian: Most significant byte in high memory (e.g. Pentiums) The problem was solved in the IP protocol suite by forcing everyone to use big endian byte ordering for all 16 and 32 bit fields by htons (host-to-network-short) and htonl functions. main() { unsigned int n; char *a = (char *) &n; n = 0x ; printf("%02x, %02x, %02x, %02x\n", a[0], a[1], a[2], a[3]); } Output on a Sparc: 11, 22, 33, 44 Output on a Pentium: 44, 33, 22, 11

23 Incompatible data representation (2) Different sizes of integers and other types Different floating point representations Different character sets Alignment requirements Need standard data representation and associated encoding /decoding functions to enable communication between heterogeneous systems –e.g. Sun’s RPC uses XDR (eXternal Data Representation)

24 Interface Definition Language (IDL) SUN XDR (eXternal Data Representation) A subset of ASN.1 (ITU), a standard data representation for message exchanges between clients and servers. Data types and structs are translated into C language by rpcgen (see XXX.h, generated by rpcgen). A set of encode/decode routines (see XXX_xdr.c) to convert between XDR and the local representations.

25 Student registration system: regist.x const MAXSUBJ = 64; typedef char id[8]; typedef char code[8]; struct registargs { code subj_code; id stud_id; }; struct status { code subj_code; int regist_stat; }; struct regist_status { int total_regist; struct status subjs_status ; }; program REGISTPROG { version REGISTVER { int REGIST(registargs) = 1; int DEREGIST(registargs) = 2; regist_status VIEW_STATUS(id) = 3; } = 1; } = ;

26 Important data types simple data types: similar to C array fixed-length: type-name identifier[n]; variable-length: type-name identifier ; type-name identifier<>; array of strings string identifier ; string identifier<>; different from array of char in representation (explained later)

27 Important data types constant/enumeration/type defintion/struct: similar to C const MAXSIZE = 512; enum state { BUSY=1, IDLE=2, TRANSIT=3 }; typedef long counter; typedef char code[8]; struct status { code subj_code; int regist_stat; };

28 Data representation/alignment (1) The basic data item size is 4 bytes. All variables or data structures should be aligned in 4-bytes. Variable-length objects, e.g., variable-length arrays, structures, and strings, have a length in front of them.

29 Data representation/alignment (2) simple data types –int, unsigned int, char, bool, float, etc.: 4 bytes –double, etc.: 8 bytes array –sequence of representations of individual elements –variable-length array has a 4-byte length in the front string –an integer of string length, followed by a sequence of chars, one for a byte –a residue of (n mod 4) bytes are stuffed to make the total byte count a multiple of 4, e.g. string “exam-paper_01” is represented as: