Download presentation
Presentation is loading. Please wait.
Published byAbigail Wiggins Modified over 8 years ago
1
Spring 2006CS 3321 Remote Procedure Call Outline Protocol Stack Presentation Formatting
2
Spring 2006CS 3322 Why Not Use UDP or TCP? Request/reply paradigm well suited to UDP, but we need reliability TCP has too much overhead: going to the trouble of establishing connection, performing flow control, congestion control, etc, just too much for the exchange of a pair of messages.
3
Spring 2006CS 3323 RPC Timeline ClientServer Request Reply Computing Blocked From perspective of application, semantics should be identical to local procedure call
4
Spring 2006CS 3324 RCP Components Protocol Stack –May want layer for fragmenting and reassembling large messages –Definitely want layer for synchronizing request and reply messages –Definitely want layer for dispatching requests to the correct process Stubs Caller (client) Client stub RPC protocol Return value Arguments ReplyRequest Callee (server) Server stub RPC protocol Return value Arguments ReplyRequest
5
Spring 2006CS 3325 RPC Complications Pointers –Different address spaces at caller and callee –How do you do call by reference? –Solution: Call by value-result (a.k.a. call by copy/restore) (as per Programming Language Concepts by Gezzi and Jazayeri “In call by value-result, local variables denoting formal parameters are both initialized at subprogram call (as in call by value) and delivered upon termination (as in call by result).” Problems of its own: two formal parameters become aliases (I.e. two different names denote same object) A formal parameter and a nonlocal variable which is visible both by the caller and the callee become aliases
6
Spring 2006CS 3326 RPC Complications (cont). –Example of first problem: a[i], a[j] two integer actual parameters corresponding to formal parameters x and y. Routine called at time that i = j, which make x and y aliases of same variable. At initiation of routine, assume a[i] (= a[j]) = 10. Execute: –If parameters passed as call-by-reference, then result should be that a[i]=a[j]=1 at end of routine. –If parameters passed as call by value-result, then either a[i]=a[j]=0 or a[i]=a[j]=11, depending on order in which values copied from stack into actual parameters
7
Spring 2006CS 3327 Why a Layer for Fragmenting and Reassembly of Large Messages? We’re not using TCP, so no guarantee of reliability If very large packet is lost, need to resend the whole thing Instead, might want to fragment large packets and use something like selective acknowledgements.
8
Spring 2006CS 3328 Why Request/Reply Synchronization? Synchronize client with server (mimic semantics of local procedure call) Supports at-most-once semantics Slow (long running) server or crashed server? –client periodically sends “are you alive” probe, or –server periodically sends “I’m alive” notice Want to support multiple outstanding calls –Need a way to distinguish calls Even perhaps mutliple calls to same procedure Machines crash and reboot
9
Spring 2006CS 3329 Synchronous vs Asynchronous Question: How much does sender know after call to send() returns? Synchronous: Application not only knows that message was received by peer, but also that peer has returned an answer Asynchronous: Nothing (not even whether message has successfully left local machine) There’s really a continuum between these
10
Spring 2006CS 33210 Dispatcher Dispatch to appropriate procedure Synchronous counterpart to UDP Caller SELECT CHAN xCall xDemuxxPush Callee SELECT CHAN xCallDemux xDemuxxPush ServerClient Address Space for Procedures –flat: unique id for each possible procedure –hierarchical: program + procedure number Selection (demux) Synchronization
11
Spring 2006CS 33211 Potential RPC Stack Frags ETH IP SELECT Synch.
12
Spring 2006CS 33212 SunRPC IP implements fragmentation and reassembly –except no selective retransmit SunRPC implements syncrhonization –except no at-most-once semantics UDP + SunRPC implement SELECT-equivalent –UDP dispatches to program (ports bound to programs) –SunRPC dispatches to procedure within program
13
Spring 2006CS 33213 SunRPC: Identifying Remote Procedures 32-bit program number (ex. NFS is 0x00100003) 32-bit procedure number ( read is 6, write is 8) Mapping program numbers to port numbers –Port Mapper (0x00100000) at well known UDP port 111, procedure number 3 Ex. NFS read(): –Client sends request to Port Mapper at UDP 111 asking that procedure 3 be invoked to map 0x00100003 to correct UDP port. Client then sends SunRPC request to returned port with procedure number 6. SunRPC module listening at this port calls read().
14
Spring 2006CS 33214 SunRPC Header Format XID (transaction id) Server does not remember last XID it serviced Problem if client retransmits request while reply is in transit (because of short term memory about XID, server will interpret request as a new request) XID memory also problem with long network delays (LANs OK) Data MsgType = CALL XID RPCVersion = 2 Program Version Procedure Credentials (variable) Verifier (variable) 031 Data MsgType = REPLY XID Status = ACCEPTED 031
15
Spring 2006CS 33215 Presentation Formatting Marshalling (encoding) application data into messages Unmarshalling (decoding) messages into application data Data types we consider –integers –floats –strings –arrays –structs Application data Presentation encoding Application data Presentation decoding Message … Types of data we do not consider –images –video –multimedia documents
16
Spring 2006CS 33216 Difficulties Representation of base types –floating point: IEEE 754 versus non-standard –char: ASCII or EBCDIC –integer: big-endian versus little-endian (e.g., 34,677,374) Compiler layout of structures (126)(34)(17)(2) 00000010Big-endian Little-endian (2)(17)(34)(126) High address Low address 00111111 00001001 0000100100001001 0000100100000001 00111111
17
Spring 2006CS 33217 Taxonomy Data types –base types (e.g., ints, floats); must convert –flat types (e.g., structures, arrays); must pack –complex types (e.g., pointers); must linearize
18
Spring 2006CS 33218 Conversion Strategy Canonical Intermediate Form –Settle on external representation for each data type –Lots of extra work if two system use same internal representations for data types Receiver-makes-right –Sender sends data in its own internal representation (but typically must flatten complex data structures) –Every host must be able to convert data from all other machine architectures An N N solution (each of N machines must be able to handle N different architectures!) But N is typically small, and common case is machines with same architecture Third option: receiver-makes-right if machine knows it’s sending to a machine with the same architecture.
19
Spring 2006CS 33219 Taxonomy (cont.) Tagged versus untagged data Stubs –Compiled Faster, more common –Interpreted Flexible
20
Spring 2006CS 33220 eXternal Data Representation (XDR) Defined by Sun for use with SunRPC C type system (without function pointers) Canonical intermediate form Untagged (except array length) Compiled stubs
21
Spring 2006CS 33221 #define MAXNAME 256; #define MAXLIST 100; struct item { int count; char name[MAXNAME]; int list[MAXLIST]; }; bool_t xdr_item(XDR *xdrs, struct item *ptr) { return(xdr_int(xdrs, &ptr->count) && xdr_string(xdrs, &ptr->name, MAXNAME) && xdr_array(xdrs, &ptr->list, &ptr->count, MAXLIST, sizeof(int), xdr_int)); } CountName JO37HNSON List 3 4972658321 Example of rpcgen type stuff
22
Spring 2006CS 33222 Abstract Syntax Notation One (ASN-1) An ISO standard Essentially the C type system Canonical intermediate form Tagged Compiled or interpreted stubs BER: Basic Encoding Rules (tag, length, value) value type lengthvaluelengthtypevaluelength
23
Spring 2006CS 33223 Network Data Representation (NDR) Defined by DCE Essentially the C type system Receiver-makes-right (architecture tag) Individual data items untagged Compiled stubs from IDL –Interface Definition Language 4-byte architecture tag –IntegerRep 0 = big-endian 1 = little-endian –CharRep 0 = ASCII 1 = EBCDIC –FloatRep 0 = IEEE 754 1 = VAX 2 = Cray 3 = IBM
24
Spring 2006CS 33224 DCE Distributed Computing Environment A set of standards and software for building distributed systems Defined by Open Software Foundation (OSF) –Consortium of companies that included IBM, Digital, HP –Today known as Open Group DCE-RPC is RPC protocol at core of DCE system –Serves as underlying RPC protocol for Common Object Request Broker Architecture (CORBA)
25
Spring 2006CS 33225 DCE-RPC Runs on UDP Defines two-level addressing scheme with port mapper (like SunRPC) Supports at-most-once semantics –Client sends pings, server replies with “working” message to indicate it’s still churning on problem. –Could also respond with “nocall” message indicating it has no idea what you’re talking about Client can send “quit” message –Server responds with “quack” (quit ACKed)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.