Remote Procedure Call (RPC)

Remote Procedure Call (RPC)

Remote Procedure Call CS-4513 Distributed Systems Hugh C. Lauer Slides include materials from Modern Operating Systems, 3rd ed., by Tannenbaum, Operating System Concepts, 7th ed., by Silbershatz, Galvin, & Gagne, Distributed Systems: Principles & Paradigms, 2nd ed. By Tanenbaum and Van Steen, and Distributed Systems: Concepts and Design, 4th ed., by Coulouris, et. al. CS-4513, D-Term 2010 Remote Procedure Call 1 Review Definition — Protocol • Formal set of rules that govern the formats, contents, and meanings of messages from computer to computer, process to process, etc. • Must be agreed to by all parties to a communication • May be defined in terms of other protocols • E.g., 7-layer OSI model CS-4513, D-Term 2010 Remote Procedure Call 2 Message-oriented Protocols • Many in widespread use • Traditional TCP/IP and Internet protocols • Difficult to design and implement • Especially with more sophisticated applications • Many difficult implementation issues for each new protocol and each platform • Formatting • Uniform representation of data • Client-server relationships • … CS-4513, D-Term 2010 Remote Procedure Call 3 Alphabet Soup of many, many Protocols • TCP, UDP, IP, NCP, SMTP, SNNP, NNTP, FTP, TFTP, POP, IMAP, HTTP, VMRL, … • Appletalk, Netware, … • Remote Procedure Call, NFS, … • CORBA, GLOBE, JINI, … • Network Streaming, … • … CS-4513, D-Term 2010 Remote Procedure Call 4 Message-oriented Protocols • Many in widespread use • Traditional TCP/IP and Internet protocols • Difficult to design and implement • Especially with more sophisticated applications • Many difficult implementation issues for each new protocol and each platform • Formatting • Uniform representation of data • Client-server relationships • … CS-4513, D-Term 2010 Remote Procedure Call 5 Problem • How to make sense out of many different kinds of protocols • How to design new protocols for new, more sophisticated applications • How to automate the nitty-gritty of protocol design and testing CS-4513, D-Term 2010 Remote Procedure Call 6 Solution — Remote Procedure Call (RPC) • The most common framework for newer protocols and for middleware • Used both by operating systems and by applications – NFS (Network File System) is implemented as a set of RPCs – DCOM, CORBA, Java RMI, etc., are just RPC systems • Seminal reference – Birrell, Andrew D., and Nelson, Bruce, “Implementing Remote Procedure Calls,” ACM Transactions on Computer Systems, vol. 2, #1, February 1984, pp 39- 59. (.pdf) CS-4513, D-Term 2010 Remote Procedure Call 7 Reading Assignment • Tanenbaum, 8.2.4 • Also online tutorials on this slide:– CS-4513, D-Term 2010 Remote Procedure Call 8 Remote Procedure Call (RPC) • Fundamental idea: – – Server process exports an interface of procedures or functions that can be called by client programs • similar to library API, class definitions, etc. • Clients make local procedure/function calls – As if directly linked with the server process – Under the covers, procedure/function call is converted into a message exchange with remote server process CS-4513, D-Term 2010 Remote Procedure Call 9 Ordinary procedure/function call count = read(fd, buf, bytes) CS-4513, D-Term 2010 Remote Procedure Call 10 Remote Procedure Call • Would like to do the same if called procedure or function is on a remote server CS-4513, D-Term 2010 Remote Procedure Call 11 Solution — a pair of Stubs • A client-side stub is a function that looks to the client as if it were a callable function of a local service – I.e., same API as the service’s implementation of the function • Service-side stub looks like a local client calling the service – I.e., like a hunk of code invoking the service function • The client program thinks it’s invoking a local service – but it’s really calling into the client-side stub • The service program thinks it’s called by a local client – but it’s really called by the service-side stub • The stubs send messages to each other to make the RPC happen transparently (almost!) CS-4513, D-Term 2010 Remote Procedure Call 12 RPC Stubs Tanenbaum & Van Steen, Fig 4-7 CS-4513, D-Term 2010 Remote Procedure Call 13 RPC Stubs Not shown in this textbook figure are Steps 7, 8, and 9, where the server process returns a result to Tanenbaum & Van Steen, Fig 4-7 server stub, which packages it and sends it across network to client CS-4513, D-Term 2010 Remote Procedurestub. Call 14 RPC Stubs – Summary • Client-side stub • Server-side stub – Looks like local server – Looks like local client function to the client function to server – Listens on a socket for – Same interface as message from client local function stub – Bundles arguments – Un-bundles arguments into a message, sends to local variables to server-side stub – Makes a local function – Waits for reply, un- call to server bundles results – Bundles result into – returns reply message to client stub CS-4513, D-Term 2010 Remote Procedure Call 15 Result – a very useful Abstraction • The hard work of building messages, formatting, uniform representation, etc., is buried in the stubs • Where it can be automated! • Designers of client and service can concentrate on semantics of application • Programs behave in familiar way CS-4513, D-Term 2010 Remote Procedure Call 16 Questions? CS-4513, D-Term 2010 Remote Procedure Call 17 RPC – Issues • How to make the “remote” part of RPC invisible to the programmer? • What are semantics of parameter passing? – E.g., pass by reference? • How to bind (locate & connect) to servers? • How to handle heterogeneity? – OS, language, architecture, … • How to make it go fast? CS-4513, D-Term 2010 Remote Procedure Call 18 RPC Model • A server defines the service interface using an interface definition language (IDL) – the IDL specifies the names, parameters, and types for all client-callable server functions • A stub compiler reads the IDL declarations and produces two stub functions for each service function – Server-side and client-side CS-4513, D-Term 2010 Remote Procedure Call 19 RPC Model (continued) • Linking:– – Server programmer implements the service’s functions and links with the server-side stubs – Client programmer implements the client program and links it with client-side stubs • Operation:– – Stubs manage all of the details of remote communication between client and server CS-4513, D-Term 2010 Remote Procedure Call 20 RPC Stubs Tanenbaum & Van Steen, Fig 4-7 CS-4513, D-Term 2010 Remote Procedure Call 21 Marshalling and Unmarshalling Arguments • Marshalling – the packing of function parameters into a message • Unmarshalling – the extraction of parameters from a message • Function call:– – Client stub marshals the arguments into message – Server stub unmarshals the arguments and uses them to invoke the service function • Function return:– – Server stub marshals return values into message – Client stub unmarshals return values and returns them as results to client program CS-4513, D-Term 2010 Remote Procedure Call 22 Issue #1 — Data Representation • Big endian vs. little endian Sent by Pentium Rec’d by SPARC After inversion CS-4513, D-Term 2010 Remote Procedure Call 23 Data Representation (continued) • IDL must also define representation of data on network – Multi-byte integers – Strings, character codes – Floating point, complex, … – … • example: Sun’s XDR (eXternal Data Representation) • Each stub converts machine representation to/from network representation • Clients and servers must not try to cast data! CS-4513, D-Term 2010 Remote Procedure Call 24 Issue #2 — Pointers and References read(int fd, char* buf, int nbytes) • Pointers are only valid within one address space • Cannot be interpreted by another process • Even on same machine! • Pointers and references are ubiquitous in C and C++ • Even in Java implementations! CS-4513, D-Term 2010 Remote Procedure Call 25 Pointers and References — Restricted Semantics • Option: call by value – Sending stub dereferences pointer, copies result to message – Receiving stub conjures up a new pointer • Option: call by result – Sending stub provides buffer, called function puts data into it – Receiving stub copies data to caller’s buffer as specified by pointer CS-4513, D-Term 2010 Remote Procedure Call 26 Pointers and References — Restricted Semantics (continued) • Option: call by value-result – Caller’s stub copies data to message, then copies result back to client buffer – Server stub keeps data in own buffer, server updates it; server sends data back in reply • Not allowed:– – Call by reference – Aliased arguments CS-4513, D-Term 2010 Remote Procedure Call 27 Questions? CS-4513, D-Term 2010 Remote Procedure Call 28 Observation — Remote Procedure Call • It should not be possible for a client to tell whether the service is implemented by • The same process • A different process in the same machine • A process on a different machine • It should not be possible for a service to tell whether the client is implemented by • The same process • A different process on the same machine Except with respect• toA failuresprocess on a different machine Client and server processes can fail CS-4513, D-Term 2010 Remote Procedure Call 29 independently Three More RPC Topics • Transport • Connection vs. connectionless protocol • Asynchronous RPC • RPC Binding CS-4513, D-Term 2010 Remote Procedure Call 30 Transport of Remote Procedure Call • Option — TCP • Connection-based, reliable transmission • Useful but heavyweight, less efficient • Necessary if repeating a call produces different result • Alternative — UDP • Unreliable transmission • If message fails to arrive within

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    44 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us