Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)"— Presentation transcript:

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

2 2 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 Byte Ordering: Big endian vs. little endian

3 3 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 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 4 Client / Server Between Systems The Problem: If each program has to accommodate multiple serving platforms, complexity goes up. N 2 problem!! As the number of platforms goes up, the number of combinations becomes: (N)(N-1) 2

5 5 Client / Server Between Systems One 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 6 XDR Data Types int32 bits unsigned int32 bits bool32 bits enum arbitrary hyper64 bits unsigned hyper64 bits float32 bits double64 bits opaque arbitrary String arbitrary fixed arrayarbitrary counted array arbitrary structure arbitrary discriminated union arbitrary. void0 symbolic constant arbitrary optional data arbitrary

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

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

9 9 XDR Data Conversion Routines 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 ( );

10 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 11 XDR Data Example Query on remote user. Return logon time, void, or error code.

12 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 13 Distributed Programming 2 Approaches Communications Oriented Design –Start with a protocol for distributed communication –Develop Program around that protocol

14 14 Distributed Programming 2 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 15 Applications Conceptual Model Main proc1proc2proc3proc4 proc5proc6proc7

16 16 Applications Conceptual Model Main proc1proc2proc3 proc5proc6 proc7 proc4

17 17 Procedural Model 1 machine call A call B MainA B

18 18 Procedural Model 1 machine / multiple machines call A call B MainA B

19 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 20 Remote Procedure Call Program Identification Program Name 32 bit value to identify program –0x00000000 - 0x1fffffffSun Microsystems –0x20000000 - 0x3fffffffLocal procedures –0x40000000 - 0x5ffffffftransient –restreserved Program version number Procedure Number

21 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 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 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 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 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 26 Procedure Registration and Use RPC service Port Mapper RPC client 1 2 3 4 5 6

27 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 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 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 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 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


Download ppt "1 Remote Procedure Calls External Data Representation (Ch 19) RPC Concept (Ch 20)"

Similar presentations


Ads by Google