Remote Procedure Calls, TLI, STREAMS

Similar documents
Remote Procedure Call Implementations

Process Concept: views of a process Process Scheduling CSCI 6730/ 4730 Operating Systems

Lecture 12 RPC RPC RPC. Writing an RPC Program. Sun RPC RPC. February 9+11, 2005

Chapter 3: Processes: Outline. Operating Systems. Remote Procedure Calls (RPC) Client-Server Remote Machine Communication Mechanisms

Remote Procedure Calls (RPC)

Chapter 3: Client-Server Paradigm and Middleware

Presentation Services. Presentation Services: Motivation

Distributed Systems 8. Remote Procedure Calls

Distributed Program Design Typical Sockets Approach. Remote Procedure Call. Remote Subroutine

6 Remote Procedure Call (RPC)

CSE 333 SECTION 3. POSIX I/O Functions

Remote Procedure Call

ECE 435 Network Engineering Lecture 2

RPC Programming. Some knowledge of C & Unix A network with at least two connected machines.

ECE 435 Network Engineering Lecture 2

The RPC abstraction. Procedure calls well-understood mechanism. - Transfer control and data on single computer

Last Class: RPCs. Today:

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

CSE 333 SECTION 3. POSIX I/O Functions

RPC Paradigm. Lenuta Alboaie Andrei Panu

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Lecture 8: February 17

NFS Design Goals. Network File System - NFS

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

Remote Procedure Call (RPC) and Transparency

Desarrollo de Aplicaciones en Red. El modelo de comunicación. General concepts. Models of communication. Message Passing

CSC209 Review. Yeah! We made it!

Sun Remote Procedure Call Mechanism

7 Distributed File Systems

Remote Procedure Calls CS 707

TELE402. Internetworking. TELE402 Lecture 1 Protocol Layering 1

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

System Models and Communication

Introduction and Overview Socket Programming Lower-level stuff Higher-level interfaces Security. Network Programming. Samuli Sorvakko/Nixu Oy

CS307 Operating Systems Processes

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCE 455/855 Distributed Operating Systems

Preface to the First Edition Preface to the Second Edition Acknowledgments UNIX Operating System Environment p. 1 UNIX: Past and Present p.

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

UNIT 1 TCP/IP PROGRAMMING CONCEPTS

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

ECE 650 Systems Programming & Engineering. Spring 2018

Elementary TCP Sockets

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

[MS-UNMP]: User Name Mapping Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

Inter-process Communication: RPC

EECS122 Communications Networks Socket Programming. Jörn Altmann

Transactions on Information and Communications Technologies vol 10, 1995 WIT Press, ISSN

Distributed Systems. 03. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Fall 2017

Outline. Interprocess Communication. Interprocess Communication. Communication Models: Message Passing and shared Memory.

Application Programming Interfaces

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy

Distributed Systems Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2016

A Client-Server Exchange

Communication. Distributed Systems Santa Clara University 2016

Chapter 3: Process Concept

Chapter 3: Process Concept

PRINCIPLES OF OPERATING SYSTEMS

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

CS Programming In C

DISTRIBUTED PROCESSING SOFTWARE ENVIRONMENTS

416 Distributed Systems. RPC Day 2 Jan 11, 2017

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Sockets Sockets Communication domains

CSC 271 Software I: Utilities and Internals

Chapter 4: Processes

CS240: Programming in C

Oral. Total. Dated Sign (2) (5) (3) (2)

Chapter 3: Processes. Operating System Concepts 9 th Edition

CS454/654 Midterm Exam Fall 2004

CS 417 9/18/17. Paul Krzyzanowski 1. Socket-based communication. Distributed Systems 03. Remote Procedure Calls. Sample SMTP Interaction

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

416 Distributed Systems. RPC Day 2 Jan 12, 2018

Process. Program Vs. process. During execution, the process may be in one of the following states

SunLink OSI 8.1 TLI Programmer s Reference

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

External Data Representation (XDR)

XDR External Data Representation. XDR as a case study XDR

CS349/SE382 A1 C Programming Tutorial

A Fast Review of C Essentials Part I

CSCI 171 Chapter Outlines

CSE 333 Lecture 16 - network programming intro

Kurt Schmidt. October 30, 2018

Socket programming in C

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

CHAPTER 3 - PROCESS CONCEPT

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

structs as arguments

RMI: Design & Implementation

Interprocess Communication

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Transcription:

Remote Procedure Calls, TLI, STREAMS 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 1 Goals of this Lecture Understand the design of remote procedure calls in general and the design and programming of the Sun Remote Procedure Call Package in particular. Understand the general concept of Unix STREAMS and their use for designing modular communication drivers. Understand the the general concept of the Transport Layer Interface (TLI) as a generalisation of the original socket interface. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 2 1

General RPC Design Client Process Server Process Local Procedure Call Client Routines Client "Stub" (Un)-Marshalling Server Routines Server- "Stub" Local Procedure Call System Call Network Routines Local Kernel Network Communication Network Routines Remote Kernel Data Conversion And Notification W.R. Stevens: UNIX Network Programming, Figure 18.1 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 3 Sun RPC - Published 1988 - RPC-Protocol 2, RFC-1057 - RPC-Data Description Language (XDR), RFC-1014 - Source code for Unix is available: "rpcgen", XDR Coding Library, Run-time Library - Now termed ONC (Open Network Computing) 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 4 2

Parameter Passing - Call by value - Call by reference - Sun RPC only allows one (structured) argument or result value. - Multiple arguments or results must be packed into a single struct. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 5 Server / Client Binding - Finding a remote server - Finding the required service on the remote server - Sun RPC uses the standard Unix method for finding servers on the Internet (gethostbyname, DNS), some implementations also support the clnt_broadcast() library call to find servers. - All server programs, program versions and remote procedures are identified with unique numbers. - A portmapper process (Linux: rpcbind) using port 111 on each system serves as the central local registry for available RPC services. It is possible to have server programs started via the inetd daemon (rpcgen compile option and a corresponding entry in /etc/inetd.conf). 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 6 3

The RPC Portmapping Sequence 1) The server creates a socket and registers program number, program version, procedures, and port number. 2) The client contacts the port mapper, requesting a program, version and remote procedure number. If known, the portmapper returns the corresponding port number. 3,4) The client can now invoke the remote procedure with the server. portmapper Daemon (1) (2) (3) (4) RPC Client RPC Server Local System Remote System W.R. Stevens: UNIX Network Programming, Figure 18.4 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 7 Selecting the Transport Protocol - RPC is independent from transport services /protocols - Mapping to popular transport services /protocols - Sun RPC supports the use of TCP and UDP In case of UDP, the size of arguments or results may not exceed 8192 bytes 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 8 4

Exception Handling - In addition to local errors, further errors may occur within the server system and during data transport. - Cancellation of operations on the server by the client - Termination of the client before the server has finished - Sun RPC uses automatic re-sending of packets in case of UDP, and recognises lost connections in TCP (keepalive option on socket, see setsockopt). - Sun RPC does not support a separate control channel. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 9 Call Semantics - Procedure is executed exactly once - Procedure is executed at most once - Procedure is executed at least once (only acceptable for idempotent operations) - Sun RPC uses unique transaction numbers for each call. - The server maintains a cache of recent requests, and the results returned, and re-sends the associated results in case of duplicate remote procedure calls. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 10 5

Security Considerations - Security within the local system - Security within the network subsystem - Security within the RPC package - Security within RPC-based applications - Sun RPC supports 3 security levels: Null, Unix, DES - Null is the default value. - Unix contains a timestamp, the hostname of the sending system, as well as the user ID and group ID of the client process, and all groups the client process belongs to. - Usage of the DES level is described in RFC-1057. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 11 Data Representation (XDR) I - Byte Ordering: big endian - Signed Integer Format: 2 s complement - Floating Point Format: proprietary - Supported Data Types: 32 bit logical value (boolean) Signed / unsigned 32 bit integer Signed / unsigned 64 bit integer 32 and 64 bit floating point values ASCII character set 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 12 6

Data Representation (XDR) II - Further Supported Data Types: Enumeration Structs Fixed-length single-dimensional array Variable-length single-dimensional array Discriminated union Fixed-length opaque data Variable-length opaque data 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 13 RPC Programming Example Server Procedures Server dir_proc.c cc list_svc Server Stub list_svc.c RPC Specification list.x rpcgen list.h list_xdr.c RPC Runtime Library Client Main Program rls.c list_clnt.c Client Stub cc Client rls W.R. Stevens: UNIX Network Programming, Figure 18.3 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 14 7

The XDR Specification: list.x /* list.x: Remote directory listing protocol */ const MAXNAMELEN = 255; /* maximum length of a name */ typedef string nametype<maxnamelen>; /* a directory entry */ typedef struct namenode *namelist; /* a link in the listing */ /* A node in the directory listing */ struct namenode { nametype name; /* name of directory entry */ namelist next; }; /* next entry */ /* The result of a READDIR operation */ union readdir_res switch (int errno) { case 0: namelist list; /* no error: return dir listing */ default: void; }; /* error; nothing to return */ program DIRPROG { version DIRVERS { readdir_res READDIR (nametype) = 1; } = 1; } = 0x33333333; 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 15 Program Number Registration Distributed namespace administration See /etc/rpc (exact path and filename depending on Unix variant used) 0x00000000 0x1FFFFFFF: administered by ONC 0x20000000 0x3FFFFFFF: defined by user 0x40000000 0x5FFFFFFF: dynamically assigned 0x60000000 0xFFFFFFFF: reserved for future use 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 16 8

/* rls.c: remote directory listing client */ #include <stdio.h> #include <rpc/rpc.h> #include "list.h" extern int errno; main (ac, av) int ac; char **av; { CLIENT *cl; char *server; char *dir; readdir_res *result; namelist nl; if (ac!= 3) { fprintf (stderr "usage: %s host directory\n", av[0]); exit (1); } /* Remember what our command line argument refers to */ server = av[1]; dir = av[2]; The Client Program: rls.c I 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 17 The Client Program: rls.c II /* Create client handle used for calling MESSAGEPROC on the * server designated on the command line. We tell the RPC * package to use the TCP protocol when contacting the server.*/ cl = clnt_create (server, DIRPROG, DIRVERS, "tcp"); if (cl == NULL) { /* Couldn't establish connection with server. * Print error message and die. */ clnt_pcreateerror (server); exit (1); } /* Call the remote procedure readdir on the server side */ result = readdir_1 (&dir, cl); if (result == NULL) { /* An error occurred while calling the server. * Print error message and die. */ clnt_perror (cl, server); exit (1); } 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 18 9

The Client Program: rls.c III } /* Okay, we successfully called the remote procedure. */ if (result -> errno!= 0) { /* A remote system error occurred. * Print error message and die. */ errno = result -> errno; perror (dir); exit (1); } /* Successfully got a directory listing. * Print it out. */ for (nl = result->readdir_res_u.list; nl!= NULL; nl = nl->next) printf ("%s\n", nl -> name); exit (0); 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 19 The Server Procedure: dir_proc.c I /* dir_proc.c: remote readdir implementation */ #include <rpc/rpc.h> #include <sys/dir.h> #include <stdio.h> #include "list.h" extern int errno; extern char *malloc(); extern char *strdup(); readdir_res * readdir_1_svc (dirname) nametype *dirname; { DIR *dirp; structdirect *d; namelist nl; namelist *nlp; static readdir_res res; /* must be static */ fprintf (stderr, "RPC-INVOKE-REQUEST: list directory %s\n", *dirname); /* Open directory */ dirp = opendir (*dirname); if (dirp == NULL) { res.errno = errno; fprintf (stderr, "RPC-ERROR: errno == %d\n", errno); return (&res); } 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 20 10

The Server Procedure: dir_proc.c II } /* Free previous result */ xdr_free (xdr_readdir_res, &res); /* Collect directory entries * Memory allocated here will be freed by xdr_free() * next time readdir_1_svc is called */ nlp = &res.readdir_res_u.list; while (d = readdir (dirp)) { nl = *nlp = (namenode *) malloc (sizeof (namenode)); nl -> name = strdup (d -> d_name); nlp = & nl -> next; } *nlp = NULL; /* Return the result */ res.errno = 0; closedir (dirp); fprintf (stderr, "RPC-INVOKE-RESULT: sending directory result\n"); return (&res); 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 21 all: rls: list_svc: list.h: rls.o: list_clnt.o: list_xdr.o: list_svc.o: dir_proc.o: The Makefile rls list_svc rls.o list_clnt.o list_xdr.o cc rls.o list_clnt.o list_xdr.o -o rls list_svc.o dir_proc.o list_xdr.o cc list_svc.o dir_proc.o list_xdr.o -o list_svc list.x rpcgen list.x rls.c list.h cc -c rls.c list_clnt.c list.h cc -c list_clnt.c list_xdr.c list.h cc -c list_xdr.c list_svc.c list.h cc -c list_svc.c dir_proc.c list.h cc -c dir_proc.c neat: rm -f *.o core a.out list.h \ list_clnt.c list_xdr.c list_svc.c clean: rm -f rls list_svc *.o core \ a.out list.h list_clnt.c list_xdr.c list_svc.c 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 22 11

Layer Integration RPC Application Presentation Session Cntl Transport Network Data Link Physical NFS RPC XDR RPC Library TCP UDP IP Ethernet Link Logical Link Control Ethernet Token Ring S.G. Kochan/P.H. Wood: UNIX Networking, Figure 4.1 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 23 Use and Limits of RPC - Servers are mostly stateless: all operations are independent from each other robust against errors within the client, server or network - Performance (local versus remote procedures) - Service strategies (single server, 1 server per client, ) - Distribution strategies (where to put servers) 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 24 12

The Transport Layer Interface (TLI) Developed by AT&T as a common communications interface First released as part of System V Release 3 (1986) Part of the System V Interface Definition (SVID) First release without a provider module (i.e. without connection to TCP/IP) Further development of TLI with Sun Microsystems 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 25 Basic Concepts of TLI Common communications interface for all data transport mechanisms below (TCP/IP, OSI, Novell, ) Corresponds to the interface between session layer (5) and transport layer (4) of the OSI reference model. TLI is only an interface to the lower protocol layers and translates TLI requests into the native protocol operations of the underlying service. TLI must be explicitly bound to every program wishing to use it. 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 26 13

The Functional Model of TLI Calling TLI Functions application TLI functions user program kernel Operating system protocol software Calling Operating System Functions D. Comer, Internetworking with TCP/IP, Vol. III 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 27 TLI Terminology Transport Endpoint (TEP): - Actual State - Actual Event - Implementation as a finite state machine Communication Descriptors: - Provided as file descriptors - Device special files are used to select a transport service (e.g. /dev/tcp) Addressing: - No pre-defined format - When using TCP/IP as the transport service, the known structure sockaddr_in is used (Quelle: M. Vogt, TIK, ETHZ) 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 28 14

Client TLI Call Sequence Server t_open t_bind t_connect t_open t_bind t_listen t_open t_bind t_accept t_snd t_rcv t_close D. Comer, Internetworking with TCP/IP, Vol. III t_rcv t_snd t_close 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 29 TLI versus Sockets TLI Interface User address space Sockets Complete subsystem Kernel address space t_listen + t_accept listen + accept (Quelle: M. Vogt, TIK, ETHZ) 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 30 15

STREAMS Designed by D. Ritchie for System V Release 3 Programming environment for the development of communication protocols Toolbox design with re-usable modules Provides implementation of commonly used modules Mapping of existing communication services (pipes, terminal-i/o etc.) onto STREAMS services Not supported by some Unix variants (e.g. Linux) 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 31 STREAM Components Stream Head: interface between kernel address space and user address space STREAMS Device Driver: mapping between a generic data format and the specific data format required for a device Messages: data travelling through a stream requiring memory allocation etc. Module: self-contained data processing step within a STREAM 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 32 16

Design of a STREAM fd[0] fd[1] q_info head head q_info open() close()... Stream functions read queue write queue q_next read queue q_next write queue Further modules can be introduced to a stream (push) or removed from a stream (pop). open() close()... Stream functions Each module has a read and a write queue and provides two procedures: put (calling a neighbour module when passing data) und service (flow control). The Streams Scheduler calls each module cyclically. There are special modules for communication (e.g. multiplexers). 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 33 Summary: RPC, STREAMS, TLI User-accessible API RPC TLI User Space Sockets STREAMS Kernel Space 13 RPC, TLI, STREAMS Hannes Lubich, 2003 2005 Page 34 17