Adv. Network Programming RPC (Remote Procedure Call)

Slides:



Advertisements
Similar presentations
RPC Robert Grimm New York University Remote Procedure Calls.
Advertisements

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.
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.
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.
Remote Procedure Call Chin-Chih Chang. Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located.
Jan 28, 2003CS475: Internetworking with UNIX TCP/IP1 XDR, RPC, NFS Internetworking with UNIX TCP/IP Winter
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.
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)
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
Linux RPC Comer Chapter 21 (RPCgen Concept) RFC 1057 – RPC Spec. UNIX Network Programming - Stevens 1.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Remote Procedure CallCS-502 Fall Remote Procedure Call CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts,
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.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
 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.
REQUEST/REPLY COMMUNICATION
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)
B. Prabhakaran 1 RPC Execution Local call Return Query binding server Params packing Wait Unpack result Unpack Local call Pack results Execute procedure.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
Remote Procedure Call RPC
Remote Procedure Call and Serialization BY: AARON MCKAY.
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?
Remote Procedure Call (Introduction)
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.
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Chapter 3 Internet Applications and Network Programming
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.
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
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
CGS 3763 Operating Systems Concepts Spring 2013
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Distributed Program Design
Distributed Computing
Remote Procedure Call (RPC) RPC – RMI - Web Services.
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 6: RPC (exercises/questions)
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:

Adv. Network Programming RPC (Remote Procedure Call) Kubilay Akgül

RPC (Remote Procedure Call) Two Paradigms for Distributed Programs. Smilarities and Differences Conventional Procedure Calls and RPC SUN RPC Remote Program Identification RPC Mapping, Inet.d Call Semantics RPCGEN ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC Two Paradigms A programmer can use one of two approaches: Communication Oriented Design - Focus on communication program. (Message format and syntax) - Design client server components. (Reactions to messages) May miss important subtitles. Fundemental errors under stress. Few programmers have experience with protocol design Concentration on communication. Resulting programs will be difficult to understand. ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC Two Paradigms Application Oriented Design - Focus on application. - Design a conventional program that works correctly. - Build, compile and test it. - Devide the program into pieces. (Procedure level) - Communication level and data representation is transparent.  RPC ADVANCED NETWORK PROGRAMING -- RPC

Conventional Programs and RPC Smilarities CALL Caller transfers control to called procedure. Caller suspends. Only one thread of execution continues at any given time. Values in all variables are frozen. RESPONSE Control flows back to the caller A called procedure may call another procedure. (Server becomes a client) ADVANCED NETWORK PROGRAMING -- RPC

Conventional Programs and RPC Differences Server Procedures - RPC procedures must exist and be waiting to compute a response. Data Flow - RPC may accept or return arbitrary amount of data. Network Delays - Protocol, lost packets, data representation. Adress Space - Conventional programs can pass pointers as argument. Environment - RPC does not have direct access to callers I/O descriptors, OS functions... ADVANCED NETWORK PROGRAMING -- RPC

SUN Microsystems’ RPC Definition SUN defined specific form of RPC  SUNRPC Wide acceptance, many applications. (NFS) Defines format of messages and arguments. Protocol  TCP , UDP. Data Representation  XDR. Uses structure instead of multiple arguments. At most one remote procedure in a remote program can be invoked at a given time  Automatic Mutual Exclusion A complier tool helps programmers to build distributed programs automatically  RPCGEN ADVANCED NETWORK PROGRAMING -- RPC

Remote Program and Procedure Identification Program no Description 0x00000000 - 0x1fffffff defined by SUN 0x20000000 - 0x3fffffff defined by system mng. 0x40000000 - 0x5fffffff customer written appl. 0x60000000 - 0xffffffff reserved Program Number - Each program must be assigned a unique 32 - bit integer Procedure Number - Each procedure in a remote program must have an integer. (1,2,3...) Version number - Multiple versions may run at the same time. You can change details with same version number. Easy to migrate. (prog, ver, proc) ADVANCED NETWORK PROGRAMING -- RPC

RPC Mapping Machine address + Program no  ?  correct server port UDP and TCP  16 bit protocol port numbers. RCP  32 bit program numbers. Servers uses well known ports. RPC servers use ephemeral ports. They takes different ports after each time they restart. Machine address + Program no  ?  correct server port ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC PORT MAPPER, RPCBIND Uses a database of dynamic port mapping. (TCP/UDP port = 111) Starts in multiuser mode. Server’s main function calls svc_create - Determines protocols supported by clients - Creates end-points, Binds port to TCP and UDP. - Contacts RPCBIND and registers itself (port, prog, ver). - Goes to sleep. Client calls clnt_create (server_IP, prog_no, ver, protocol) - Usually makes a UDP connection to RPCBIND on servers machine. ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC PORT MAPPER, RPCBIND V2  historical (just TCP UDP) v3,4  newer protocols Uses /etc/rpc Solaris % rpcinfo -p program vers proto port service 100000 4 tcp 111 rpcbind 100000 3 tcp 111 rpcbind 100000 2 tcp 111 rpcbind 100000 4 udp 111 rpcbind 100000 3 udp 111 rpcbind 100000 2 udp 111 rpcbind .... 824377344 1 udp 42972 server 824377344 1 tcp 40849 server Solaris % rpcinfo -d sprayd 1 ... unregisters sprayd demon. Solaris % pkill -HUP inetd ... inetd reads the /etc/inetd.conf file and registers sprayd again. ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC - Inetd RPCgen created servers may be invoked by inetd. /etc/inetd.conf file needs ti be updated. ... Rstatd/2-4 tli rpc/datagram_V wait root /usr/.../rpc.rstatd rpc.rstatd Inetd - creates endpoint, registers to RPCBIND. - listens for ports, fork, exec, waits until server terminates. Server - std. input is a xti endpoint (no need to re-register). - waits for ~2 minutes before terminate ( to prevent new fork and exec) - generates SIGCHLD to inetd. ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC Call Semantics Procedure calls can be placed into one of these categories: 1. Exactly once 2. At most once 3. At least once 4. Zero or more ADVANCED NETWORK PROGRAMING -- RPC

Call Semantics - Scenarios TCP Reply received: Exactly Once No reply: At most once (server may have crashed) UDP without server cash Reply received: at least once No reply: zero or more UDP with server cash No reply: At most once ADVANCED NETWORK PROGRAMING -- RPC

Stub Procedure Consept & RPCGEN Sun RPC specifications are extensive and complicated without a software tool. Assistance: 1. XDR library routines: internal data items  XDR standard 2. RPC untime library: correctly make call, receive call, registration... 3. RPCgen: A program generater ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC Stub Procedures Additional procedures added to program to implement RPC. Client Side Stub : They replaces the called procedure. Server Side Stub : They replaces the caller procedure. Computer 1 Computer 2 PROC A Server Stub Client Stub Proc B ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPCGEN Rpcgen reads an input file that contains a specification of remote program. IT produces four output (source code) files. If specification file has name Q.x all output files will begin with Q. - Q.h Declarations of constants and types used in the code generated for both client and server. - Q_xdr.c XDR procedure calls used in the client and server to marshal arg. - Q_clnt.c Client side stub procedure. - Q_svc.c Server side stub procedure. ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example Specification file struct square_in { /* input (argument) */ long arg1; }; struct square_out { /* output (result) */ long res1; program SQUARE_PROG { version SQUARE_VERS { square_out SQUAREPROC(square_in) = 1; /* procedure number = 1 */ } = 1; /* version number */ } = 0x31230000; /* program number */ ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example Client.c (Client main function) #include "unpipc.h" /* our header */ #include "square.h" /* generated by rpcgen */ int main(int argc, char **argv) { CLIENT *cl; square_in in; square_out *outp; if (argc != 3) err_quit("usage: client <hostname> <integer-value>"); cl = clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, "tcp"); in.arg1 = atol(argv[2]); if ( (outp = squareproc_1(&in, cl)) == NULL) err_quit("%s", clnt_sperror(cl, argv[1])); printf("result: %ld\n", outp->res1); exit(0); } Client handle ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example Server Procedure #include "unpipc.h" #include "square.h" square_out * squareproc_1_svc(square_in *inp, struct svc_req *rqstp) { static square_out out; out.res1 = inp->arg1 * inp->arg1; return(&out); } ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example Client executable Solaris % rpcgen -C square.x Solaris % cc -c client.c -o client.o Solaris % cc -c square_clnt.c -o square_clnt.o Solaris % cc -c square_xdr.c -o square_xdr.o Solaris % cc -o client client.o square_clnt.o square_xdr.o libunpipc.a -lnsl Server executable Solaris % cc -c server.c -o server.o Solaris % cc -c square_svc.c -o square.svc.o Solaris % cc -o server server.o square_svc.o square_xdr.o libunpipc.a -lnsl ADVANCED NETWORK PROGRAMING -- RPC

ADVANCED NETWORK PROGRAMING -- RPC RPC Example ADVANCED NETWORK PROGRAMING -- RPC