1 / 31

Remote Procedure Calls

Remote Procedure Calls. External Data Representation (Ch 19) RPC Concept (Ch 20). Client / Server Between Systems The Problem:. Transfer of data between systems depends on local data representation. This can vary on at least 4 parameters: Data Size : integer may be 16 bits or 32 bits

fynn
Download Presentation

Remote Procedure Calls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)

  2. Client / Server Between SystemsThe Problem: • Transfer of data between systems depends on local data representation. This can vary on at least 4 parameters: • Data Size : integer may be 16 bits or 32 bits • Byte Ordering: Big endian vs. little endian

  3. Client / Server Between SystemsThe Problem: • Transfer of data between systems depends on local data representation. This can vary on at least 4 parameters: • Data Size : integer may be 16 bits or 32 bits • Byte Ordering: Big endian vs. little endian • Data Representation: Strings null terminated vs. length + value • Alignment: May align on full word boundaries (16 or 32 or 64, etc.)

  4. Client / Server Between SystemsThe Problem: • If each program has to accommodate multiple serving platforms, complexity goes up. N2 problem!! As the number of platforms goes up, the number of combinations becomes: (N)(N-1) 2

  5. Client / Server Between SystemsOne Solution: • eXternal Data Representation (XDR) • Developed by Sun Microsystems • A standard for representing data over the network. • Includes a set of library routines for converting data between local format and XDR format (either direction).

  6. int 32 bits unsigned int 32 bits bool 32 bits enum arbitrary hyper 64 bits unsigned hyper 64 bits float 32 bits double 64 bits opaque arbitrary String arbitrary fixed array arbitrary counted array arbitrary structure arbitrary discriminated union arbitrary. void 0 symbolic constant arbitrary optional data arbitrary XDR Data Types

  7. XDR Data Conversion • Objective: • Gather all parameter data into a buffer in XDR format • Procedure: • Create a buffer (xdrmem_create)

  8. XDR Data Conversion • Objective: • Gather all parameter data into a buffer in XDR format • Procedure: • Create a buffer (xdrmem_create) #include <rpc/xdr.h> #define BUFSIZE 4000 ... XDR * xdrs; char buf[BUFSIZE]; xdrmen_create(xdrs, buf, BUFSIZE, XDR_ENCODE);

  9. xdr_bool (xdrs, ptrBool); xdr_bytes (xdrs,str,strSize,maxsize); xdr_char (xdrs, ptrChar); xdr_double(xdrs, prtDouble); xdr_enum(xdrs, ptrInt); xdr_float(xdrs, ptrFloat); xdr_int (xdrs, ptrInt); xdr_long (xdrs, ptrLong); xdr_opaque (xdrs, ptrChar, count); xdr_pointer (xdrs, ptrObj,pbjSize, xdrObj); xdrs_short (xdrs, ptrShort); xdrs_u_char (xdrs, ptrUchar); xdrs_u_int (xdrs, ptrUint); xdrs_u_long (xdrs, ptrUlong); xdrs_u_short (xdrs, ptrUshort); xdr_union (xdrs, ptrDiscrim, ptrUnion, choiceFcn, default); xdr_vector (xdrs, ptrArray, size, elemSize, elemProc); xdr_void ( ); XDR Data Conversion Routines

  10. XDR Data Conversion • Add data items in order to the buffer (after converting to XDR format) int myInt; ... myInt = 260; xdr_int(xdrs, &myInt);

  11. XDR Data Example • Query on remote user. Return logon time, void, or error code.

  12. XDR Data Example • Query on remote user. Return logon time, void, or error code. const MAX_TIME_BUF = 30; union time_results switch (int status) { case 0: char timeval [MAX_TIME_BUF]; case 1: void; case 2: int reason; };

  13. Distributed Programming2 Approaches • Communications Oriented Design • Start with a protocol for distributed communication • Develop Program around that protocol

  14. Distributed Programming2 Approaches • Communications Oriented Design • Start with a protocol for distributed communication • Develop Program around that protocol • Application Oriented Design • Start with a working Application • Split the program and add a protocol that communicates between segments

  15. Main proc1 proc2 proc3 proc4 proc5 proc6 proc7 Applications Conceptual Model

  16. Main proc1 proc2 proc3 proc5 proc6 Applications Conceptual Model proc4 proc7

  17. Procedural Model1 machine Main A B call B call A

  18. Procedural Model1 machine / multiple machines Main A B call B call A

  19. Remote Procedure Arguments • Programming languages use positional notation to identify arguments (1st argument, 2nd argument, etc.) • Overhead associated with collecting and managing multiple arguments can be reduced by aggregating the needed procedure arguments into a single passed parameter (e.g. a C language struct). • While multiple arguments are allowed with RPC, good programming suggests using only 1.

  20. Remote Procedure CallProgram Identification • Program Name • 32 bit value to identify program • 0x00000000 - 0x1fffffff Sun Microsystems • 0x20000000 - 0x3fffffff Local procedures • 0x40000000 - 0x5fffffff transient • rest reserved • Program version number • Procedure Number

  21. RPC Communications • Communications Semantics • May be specified using UDP or TCP • RPC semantics defined in terms of the underlying protocol. Reliability not enforced by RPC, but by the underlying transport protocol.

  22. RPC Retransmission • RPC library includes a simple timer and retransmission capability. • A response is characterized as “the remote procedure has been executed at least once”. • No response is characterized as “the remote procedure was executes 0 or more times”.

  23. RPC Retransmission • RPC library includes a simple timer and retransmission capability. • A response is characterized as “the remote procedure has been executed at least once”. • No response is characterized as “the remote procedure was executes 0 or more times”. • This implies that procedures that use UDP must be “idempotent”. (Multiple executions do not change the result.)

  24. RPC Procedure Location • RPC identifies procedures with a 32 bit number. • Allows for far more services than ports available • Typically only a few services running at any time. • Need some sort of “directory service” that can correlate desired procedure with a protocol port number. • This directory service is called the Portmapper server.

  25. RPC Port Identification • RPC portmapper at “well known port” 111 • Programs register with the portmapper • Stores data pairs of the form • (RPC program #, version #): protocol port #

  26. Procedure Registration and Use 6 RPC service RPC client 5 4 2 Port Mapper 3 1

  27. RPC Message Passing • All data parameters are passed as a single “struct” • struct rpc_msg { enum msg_type { unsigned int mesgid; CALL = 0; union switch (msg_type mesgt) REPLY = 1; { }; case CALL: call_body cbody; case REPLY: rply_body rbody; } body; };

  28. RPC Message Passing struct call_body { unsigned int rpcvers; unsigned int rprog; unsigned int rprogvers; unsigned int rproc; opaque_auth cred; opaque_auth verf; /* args */ };

  29. RPC Message Authentication • Two parts to authentication • credentials (what info is provided) • verifier (who vouches for that info) • 4 levels of authentication • none • UNIX • short form • secure (DES)

  30. Example RPC Message • Call to NFS to get attributes for a file Message ID Message type (0 for call) RPC Version Number (2) Remote Program (0x186a3 for NFS) Remote Program Version (2) Remote Procedure (1 for GETATTR) UNIX Authentication Arguments (if any)

  31. Summary • Remote Procedure Call communications method developed by Sun to facilitate inter-machine / interprocess communications • XDR used to manage inter-platform data transfer • RPC uses application oriented design approach • Portmapper used to locate remote procedures • RPC messages structured to maximize data reuse

More Related