1 / 26

Presentation Formatting

Presentation Formatting. application. application. data. data. Presentation. Presentation. Encoding. Decoding. . . . message. message. message. Overview. Marshalling (encoding) application data into messages Unmarshalling (decoding) messages into application data.

lilian
Télécharger la présentation

Presentation Formatting

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. Presentation Formatting

  2. application application data data Presentation Presentation Encoding Decoding . . . message message message Overview • Marshalling (encoding) application data into messages • Unmarshalling (decoding) messages into application data

  3. Data Types • Data types we consider: • integers • floating point numbers • character strings • arrays • structures • Types of data we do not consider (now): • images • video • multimedia documents

  4. Difficulties • Representation of base types • floating point: IEEE 754 versus non-standard • integer: big-endian versus little-endian • Compiler layout of structures (0) (0) (0) (2) big endian 00000000 00000000 00000000 00000010 (2) (0) (0) (0) little endian 00000010 00000000 00000000 00000000 0 1 2 3 Low High Address address

  5. 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 • Conversion Strategy • canonical intermediate form • receiver-makes-right (an N x N solution) • N machine architectures must be able to handle N representations

  6. Marshalling Application Data Structure Argument Marshaller

  7. INT 4 4byte integer Interface Descriptor for Call Procedure P P P Spec arguments arguments Code Code Client Stub Server Stub Compiler Stub marshalled marshalled arguments arguments RPC RPC message Tagged versus Untagged data • Stubs • compiled • interpreted • CORBA

  8. Examples XDR: eXternal Data Representation • Defined by Sun for use with SunRPC • C type system (without function pointers) • Canonical intermediate form • Untagged (except array length) • Compiled stubs

  9. #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)); }

  10. count name 3 7 J O H N S O N list 3 497 8321 265 XDR 70MBps attainable on 175MHz Alpha

  11. Abstract Syntax Notation ASN.1 • (tag-8 bits, length-8+bits, value) • Used by Simple Network Management Protocol (SNMP) • Canonical Intermediate form • Length=0x82 01 01=257 • Each call sends 3 bytes

  12. Integer Char FloatRep Extension 1 Extension 2 Rep Rep NDR: Network Data Representation • Defined by DCE (CORBA) • Essentially the C type system • Receiver-makes-right (architecture tag) • Individual data items untagged • Compiled stubs from Interface Definition Language (IDL)

  13. 4-byte architecture definition tag • IntegrRep • 0 = big-endian • 1 = little-endian • CharRep • 0 = ASCII • 1 = EBCDIC • FloatRep • 0 = IEEE 754 • 1 = VAX • 2 = Cray • 3 = IBM

  14. Remote Procedure Calls

  15. Client Server blocked request blocked computing reply blocked Overview

  16. caller callee (client) (server) return return args args value value client server stub stub reply reply req req RPC RPC Protocol Protocol network Mechanics

  17. Address Space for Procedures • Flat: unique id for each possible procedure • Hierarchical: program + procedure within program

  18. SUNRPC UDP IP ETH SunRPC • UDP + SunRPC implement • UDP dispatches to program (ports bound to programs) • SunRPC dispatches to procedure w/in program

  19. Implementation • Port Mapper program exists at well known UDP port (111) • The Port Mapper translates program numbers (32 bits) to UDP port numbers • The 32 bit procedure number is then used to make the remote call • NFS read procedure = 6

  20. XID XID MsgType MsgType = CALL = REPLY RPCVersion Status = = 2 ACCEPTED Program Version Procedure Credentials (variable) Verifier (variable) SunRPC Header Format

  21. RPC Lab • Write code to implement open, read and write commands to remote file • You pass off against your own code • The TA code is there to give you an example of how things might work • Can be implemented on top of IP if TCP isn’t complete

  22. “file” “file” RPC_OPEN RPC_OPEN Call Response RPC_OPEN Handle Overview Server Client Main() calls rpc::open(“file”); RPC creates message and sends To TCP Pop decodes RPC_OPEN, calls fd=open(“file”);

  23. len Handle RPC_READ Call Response RPC_READ tmpb data rval Overview Server Client Main() calls rpc::read(Handle, buf, len) RPC creates message and sends To TCP Waits on semaphore Pop decodes RPC_READ calls rval=read(fd,tmpb,len); rpc::pop copies data from message into buf, signals semaphore

  24. buf data len Handle RPC_WRITE Call Response RPC_WRITE Server Client Overview Main() calls rpc::write(Handle, buf, len) RPC creates message and sends To TCP, waits on semaphore Pop decodes RPC_WRITE calls rval=write(fd,tmpb,len); rpc::pop signals semaphore

  25. Details • Passoff • Open remote file • Read from within file • Read beyond end (you should only return amount actually available) • Write beyond end • Read total data • Copy new version of test file before each run.

More Related