DOC PREVIEW
Rutgers University CS 417 - Remote Procedure Calls

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 417: Distributed Systems 10/1/2012 © 2012 Paul Krzyzanowski 1 Distributed Systems 8. Remote Procedure Calls Paul Krzyzanowski [email protected] 1 Problems with the sockets API The sockets interface forces a read/write mechanism Programming is often easier with a functional interface To make distributed computing look more like centralized computing, I/O (read/write) is not the way to go 2 RPC 1984: Birrell & Nelson – Mechanism to call procedures on other machines Remote Procedure Call Goal: it should appear to the programmer that a normal call is taking place 3 Regular procedure calls You write: x = f(a, “test”, 5); The compiler parses this and generates code to: a. Push the value 5 on the stack b. Push the address of the string “test” on the stack c. Push the current value of a on the stack d. Generate a call to the function f In compiling f, the compiler generates code to: a. Push registers that will be clobbered on the stack to save the values b. Adjust the stack to make room for local and temporary variables c. Before a return, unadjust the stack, put the return data in a register, and issue a return instruction 4 Implementing RPC No architectural support for remote procedure calls Simulate it with tools we have (local procedure calls) Simulation makes RPC a language-level construct instead of an operating system construct The OS gives us sockets The compiler creates code to send messages to invoke remote functions 5 Implementing RPC The trick: Create stub functions to make it appear to the user that the call is local The stub function contains the function’s interface 6CS 417: Distributed Systems 10/1/2012 © 2012 Paul Krzyzanowski 2 client server Stub functions network routines server functions server stub (skeleton) network routines 1. Client calls stub (params on stack) client functions client stub 7 client server Stub functions server functions server stub (skeleton) network routines 2. Stub marshals params to net message client functions client stub network routines Marshalling = put data in a form suitable for transmission over a network (serialized) 8 client server Stub functions 3. Network message sent to server client functions client stub network routines server functions server stub (skeleton) network routines 9 client server Stub functions 4. Receive message: send it to server stub client functions client stub network routines server functions server stub (skeleton) network routines 10 client server Stub functions 5. Unmarshal parameters, call server function client functions client stub network routines server functions server stub (skeleton) network routines 11 client server Stub functions 6. Return from server function client functions client stub network routines server functions server stub (skeleton) network routines 12CS 417: Distributed Systems 10/1/2012 © 2012 Paul Krzyzanowski 3 client server Stub functions 7. Marshal return value and send message client functions client stub network routines server functions server stub (skeleton) network routines 13 client server Stub functions 8. Transfer message over network client functions client stub network routines server functions server stub (skeleton) network routines 14 client server Stub functions 9. Receive message: client stub is receiver client functions client stub network routines server functions server stub (skeleton) network routines 15 client server Stub functions 10. Unmarshal return value, return to client code client functions client stub network routines server functions server stub (skeleton) network routines 16 Benefits • Procedure call interface • Writing applications is simplified – RPC hides all network code into stub functions – Application programmers don’t have to worry about details • Sockets, port numbers, byte ordering • Where is RPC in the OSI model? – Layer 5: Session layer: Connection management – Layer 6: Presentation: Marshaling/data representation 17 RPC has challenges 18CS 417: Distributed Systems 10/1/2012 © 2012 Paul Krzyzanowski 4 Parameter passing Pass by value – Easy: just copy data to network message Pass by reference – Makes no sense without shared memory 19 Pass by reference? 1. Copy items referenced to message buffer 2. Ship them over 3. Unmarshal data at server 4. Pass local pointer to server stub function 5. Send new values back To support complex structures – Copy structure into pointerless representation – Transmit – Reconstruct structure with local pointers on server 20 Representing data No such thing as incompatibility problems on local system Remote machine may have: – Different byte ordering – Different sizes of integers and other types – Different floating point representations – Different character sets – Alignment requirements 21 Representing data IP (headers) forced all to use big endian byte ordering for 16- and 32-bit values Big endian: Most significant byte in low memory – SPARC ≤ V9, Motorola 680x0, older PowerPC Little endian: Most significant byte in low memory – Intel IA-32, x64 Bi-endian: Processor may operate in either mode – ARM, PowerPC, MIPS, SPARC V9, IA-64 (Intel Itanium) main() { unsigned int n; char *a = (char *)&n; n = 0x11223344; printf("%02x, %02x, %02x, %02x\n", a[0], a[1], a[2], a[3]); } Output on an Intel: 44, 33, 22, 11 Output on a PowerPC: 11, 22, 33, 44 22 Representing data Need standard encoding to enable communication between heterogeneous systems – e.g. Sun’s RPC uses XDR (eXternal Data Representation) – ASN.1 (ISO Abstract Syntax Notation) – JSON (JavaScript Object Notation) – Google Protocol Buffers – W3C XML Schema Language 23 Representing data Implicit typing – only values are transmitted, not data types or parameter info – e.g., Sun XDR Explicit typing – Type is transmitted with each value – e.g., ISO’s ASN.1, XML, protocol buffers, JSON 24CS 417: Distributed Systems 10/1/2012 © 2012 Paul Krzyzanowski 5 Where to bind? Need to locate host and correct server process 25 Where to bind? – Solution 1 Maintain centralized DB that can locate a host that provides a particular service (Birrell & Nelson’s 1984 proposal) 26 Where to bind? – Solution 2 A server on each host maintains a DB of locally provided services Solution 1 is problematic for Sun NFS – identical file servers serve different file systems 27 Transport protocol TCP or UDP? Which one should we use? • Some


View Full Document

Rutgers University CS 417 - Remote Procedure Calls

Download Remote Procedure Calls
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Remote Procedure Calls and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Remote Procedure Calls 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?