CSE 30264 Computer Networks Prof. Aaron Striegel Department of Computer Science & Engineering University of Notre Dame Lecture 14 – February 23, 2010.

Slides:



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

Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
Spring Remote Procedure Call (5.3) Outline Protocol Stack Presentation Formatting.
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.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
COS 420 DAY 25. Agenda Assignment 5 posted Chap Due May 4 Final exam will be take home and handed out May 4 and Due May 10 Latest version of Protocol.
Remote Procedure Call Chin-Chih Chang. Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Jan 28, 2003CS475: Internetworking with UNIX TCP/IP1 XDR, RPC, NFS Internetworking with UNIX TCP/IP Winter
CS 582 / CMPE 481 Distributed Systems Communications (cont.)
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)
Systems Architecture, Fourth Edition1 Internet and Distributed Application Services Chapter 13.
Netprog RPC Overview1 Distributed Program Design n Communication-Oriented Design –Design protocol first. –Build programs that adhere to the protocol.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 4: RPCs vs. CORBA Dr. Michael R. Lyu Computer Science & Engineering.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
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.
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,
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Sun RPC also called ONC (Open Network Computing) RPC originally designed for client-server communication for Sun Network File System (NFS) provides an.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
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.
Netprog: RPC Programming1 RPC Programming with rpcgen Issues: –Protocol Definition File –Client Programming Creating an "RPC Handle" to a server Calling.
Linux RPC Comer Chapter 21 (RPCgen Concept) RFC 1057 – RPC Spec. UNIX Network Programming - Stevens 1.
B. Prabhakaran 1 RPC Execution Local call Return Query binding server Params packing Wait Unpack result Unpack Local call Pack results Execute procedure.
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.
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
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.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Remote Procedure Call (Introduction)
1 Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)
© 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.
Client-Server Communication
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)
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
DISTRIBUTED COMPUTING
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
Distributed Program Design
Issues in Client/Server Programming
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
CS-502, Operating Systems Fall 2009 (EMC)
Lecture 6: RPC (exercises/questions)
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 6: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Last Class: Communication in Distributed Systems
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

CSE Computer Networks Prof. Aaron Striegel Department of Computer Science & Engineering University of Notre Dame Lecture 14 – February 23, 2010

Today’s Lecture Mid-Term Exam Summary Project 2 Transport –RPC Mid-Term Exam Spring 2010CSE Physical Data Network Transport Application Thursday: Guest lecture by Dr. Poellabauer

Mid-Term Exam Will hand out later in class –Average -> 83% –Maximum points: 104 Want to earn back points? –Pick one problem –Well written, well illustrated discussion of the problem –Gain back up to half of points lost on that problem Spring 2010CSE

Project 2 By popular demand –Turn in by Tuesday, March 5 PM –Wiki will update later today Extra credit –Bonus 10 points –Turn in by Thursday, March 5 PM –Add note in README Down side –Project 3 is coming next Tuesday Spring 2010CSE

Tip / Tricks – Project 2 Split your code into blocks and test separately –Send as a file Spring 2010CSE Client Test Open up socket Connect to server Read file from disk Send buffer to server Read response Display to screen

Tips / Tricks – Project 2 Split your code –Write your handler in a thread friendly Spring 2010CSE void * handleClient (void * pData) { int clientSocket; nClientSocket = *( (int *) pData); // Handle client

Tips / Tricks – Project 2 Split your code –Write your handler in a thread friendly Spring 2010CSE int main ( … ) { // Server socket magic // Listen while(1) { cSocket = accept (…); handleClient(&cSocket);

Tips / Tricks – Project 2 Split your code –Test your XML parsing separately –Read in a file and parse the results –Go simple XML Spring 2010CSE <add CalName=“Test” Month=“3” Day=“16” … />

Project 2 – Other Notes Client side –Support two modes Send the file and display the response (easier) Respond to arguments / build XML –You can write two different clients if that makes things easier Server side –Your server does not need to persist data after restart –Files / storage are great but not required –You could have two different servers as well, one for multi-thread, one for single thread Spring 2010CSE

Spring 2010CSE Remote Procedure Call Outline Concept of RPC SunRPC

Spring 2010CSE RPC Timeline

Spring 2010CSE RPC There exists a way for processes to represent a task: procedure/function. main() func() func(12); return 5; Client Server

Spring 2010CSE RPC main() func() stub(12);return 5; Client Server skeleton stub func(12);return 5; RequestReply

Spring 2010CSE Stubs Stub is a function with the same interface as func(); it converts the function call into a network response and a network response into a function return. Skeleton converts requests into function calls and function returns into network replies. RPC System: used to generate both stub and skeleton (automatically).

Spring 2010CSE SunRPC Widely used Remote Procedure Call system: –Sun Microsystems, implemented in most Unix systems –NFS distributed file system is based on Sun RPC Designed to call remote C procedures. Platform-independent.

Spring 2010CSE SunRPC Header Format XID (transaction id) Server does not remember last XID it serviced Problem if client retransmits request while reply is in transit

Spring 2010CSE RPC One computer can be server for multiple procedures: –server may host several programs (identified by program number) –each program may have several subsequent versions (version number) –each version may contain one or more procedures (procedure number) Program numbers are 32-bit hexadecimal values (0x ) –As user, you can choose any program number between 0x and 0x3FFFFFFF, but they have to be unique (not several programs with same number on same machine) Version and procedure numbers are integers (1,2,...) (prog, vers, proc)

Spring 2010CSE Sun RPC Program Numbers FROMTOVALUES ASSIGNED BY 0x x1fffffffSun Microsystems, Inc. 0x x3fffffffSystem manager at a user’s site 0x x5fffffffTransient (temporary) 0x x7fffffffReserved 0x x9fffffffReserved 0xa xbfffffffReserved 0xc xdfffffffReserved 0xe xffffffffReserved

Spring 2010CSE Sun RPC Program Numbers NAMENUMBERDESCRIPTION portmap100000port mapper rstatd100001rstat, rup, perfmeter rusersd100002remote users nfs100003network file system ypserv100004yp (NIS) mountd100005mount, showmount dbxd100006DMXprog (debugger) ypbind100007NIS binder...

Spring 2010CSE Writing an RPC Program client.c add.x serverproc.c add_clnt.c add.h add_xdr.c add_scv.c client.o add_clnt.o add_xdr.o add_svc.o serverproc.o server client You write these files rpcgen generates these files You compile every C file You obtain a client & server

Spring 2010CSE Example Step 1: Write a specification file (add.x) struct add_in { /* Arguments of procedure */ long arg1; long arg2; }; typedef long add_out; /* Return value */ program ADD_PROG { version ADD_VERS { add_out ADD_PROC(add_in) = 1 /* Procedure# = 1 */ } = 1; /* Version# = 1 */ } = 0x ; /* Program# = 0x */

Spring 2009CSE Example Contains specifications of: –‘add_in’ (arguments) –typedef ‘add_out’ (return values) –program ‘ADD_PROG’ (0x ) –1 version ‘ADD_VERS’ (1) –1 procedure ‘ADD_PROC’ (1) Your procedures can only take ONE input argument and return ONE output return value (use structures for more): –more readable (structure entries should have meaningful names)

Spring 2009CSE Example Step 2: generate stubs rpcgen add.x ‘add.h’ contains declarations: #define ADD_PROG 0x /* Program nb */ #define ADD_VERS 1 /* Version nb */ #define ADD_PROC 1 /* Procedure nb */ add_out * add_proc_1 (add_in *, CLIENT *); add_out * add_proc_1_svc (add_in *, struct svc_req *); –add_proc_1 is the stub (called by client) –add_proc_1_svc is the actual procedure that you will write and run at the server

Spring 2009CSE Example ‘add_clnt.c’: implementation of ‘add_proc_1’ ‘add_svc.c’: contains program which calls your procedure ‘add_proc_1_svc’ when request received ‘add_xdr.c’: marshall/unmarshall routines

Spring 2009CSE Example Step 3: write server procedure: ‘serverproc.c’ #include “add.h” add_out *add_proc_1_svc(add_in *in, struct svc_req *rqstp) { static add_out out; out = in->arg1 + in->arg2; return(&out); } –rqstp contains some information about the requester (IP address, etc.)

Spring 2009CSE Example Step 4: compile the server Need to compile together your procedure, the (generated) server program, the (generated) marshall/unmarshall procedures and the nsl library (contains the RPC runtime). $ gcc -c serverproc.c $ gcc -c add_svc.c $ gcc -c add_xdr.c $ gcc -o server serverproc.o add_svc.o add_xdr.o -lnsl To start the server:./server

Spring 2009CSE Example Step 5: write a client program client.c #include “add.h” int main(int argc, char **argv) { CLIENT *cl; add_in in; add_out *out; if (argc!=4) {printf(“Usage:...\n”); return 1;} cl = clnt_create(argv[1], ADD_PROG, ADD_VERS, “tcp”); in.arg1 = atol(argv[2]); in.arg2 = atol(argv[3]); out = add_proc_1(&in, cl); if (out == NULL) {printf(“Error: %s\n”, clnt_sperror(cl, argv[1])); } else { printf{“We received the result: %ld\n”, * out); } clnt_destroy(cl); return 0; }

Spring 2009CSE Example Create a client structure with clnt_create #include CLIENT *clnt_create(char *host, u_long prog, u_long vers, char *proto); –host: name of server machine –prog, vers: program/version number –proto: transport protocol (“tcp” or “udp”) You can call add_proc_1 to send the RPC When finished, destroy client structure (client structure can be used multiple times without being destroyed and recreated).

Spring 2009CSE Example Step 6: compile the client $ gcc -c client.c $ gcc -c add_clnt.c $ gcc -c add_xdr.c $ gcc -o client client.o add_clnt.o add_xdr.o -lnsl

Spring 2009CSE Example Step 7: try it out –start your server:./server –send a request:./client machine.cse.nd.edu 8 34 We received the result: 42

Spring 2009CSE Mutual Exclusion Sun RPC: at most one remote procedure in a remote program can be invoked at a given time. Automatic mutual exclusion among procedures within a given remote program. No synchronization needed. Some versions of rpcgen allow one to generate server code which implement one-thread-per- client (Solaris does, Linux doesn’t).

Spring 2009CSE Inside SunRPC (un)marshalling routines client program client stub RPC runtime server procedure server stub RPC runtime (un)marshalling routines ClientServer

Spring 2009CSE Low-Level RPC: Port Mapper Did you notice that we did not specify a port number for our ‘add’ server? –Could be done with well-known port number for RPCs –But then we could not run multiple servers in the same machine simultaneously RPC: port mapper –server running on port 111 –when your server starts, it does not bind its socket to a specific port; instead it ‘registers’ whatever port number it has been given by the system to the local port mapper –when you create a client with ‘clnt_create’, you automatically contact the remote port mapper to ask for the port number of the server you want to contact

Spring 2009CSE Port Mapper ClientServer You can request the port mapper by hand: $ rpcinfo -p wizard.cse.nd.edu program vers proto port tcp 111 portmapper udp 111 portmapper udp tcp54211 Port mapper S1: Create an unbound socket (assigned port=11293) S2: Register: program 0x version 1 running on port S3: Portmap requested: on which port is program 0x version 1? S4: Portmap response: port S5: Run procedure 1 with parameter: “0x18A6B332F0” S6: Result is “0x6464”