Title: Presentation Formatting
1Presentation Formatting
2Overview
- Marshalling (encoding) application data into
messages - Unmarshalling (decoding) messages into
application data
3Data 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
4Difficulties
- 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
00000010
00000000
00000000
00000000
(2)
(0)
(0)
(0)
little endian
00000010
00000000
00000000
00000000
0
1
2
3
Low
High
Address
address
5Taxonomy
- 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
6Marshalling
Application Data Structure
Argument Marshaller
7Tagged versus Untagged data
- Stubs
- compiled
- interpreted
- CORBA
8Examples
- 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 nameMAXNAME
- int listMAXLIST
-
- bool_t
- xdr_item(XDR xdrs, struct item ptr)
-
- return(xdr_int(xdrs, ptr-gtcount)
- xdr_string(xdrs, ptr-gtname,MAXNAME)
- xdr_array(xdrs, ptr-gtlist, ptr-gtcount, MAXLIST,
sizeof(int), xdr_int))
10XDR
70MBps attainable on 175MHz Alpha
11Abstract Syntax Notation ASN.1
- (tag-8 bits, length-8bits, value)
- Used by Simple Network Management Protocol (SNMP)
- Canonical Intermediate form
- Length0x82 01 01257
- Each call sends 3 bytes
12NDR 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)
134-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
14Remote Procedure Calls
15Overview
16Mechanics
17Address Space for Procedures
- Flat unique id for each possible procedure
- Hierarchical program procedure within program
18SunRPC
- UDP SunRPC implement
- UDP dispatches to program (ports bound to
programs) - SunRPC dispatches to procedure w/in program
19Implementation
- 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
20SunRPC Header Format
21(No Transcript)
22RPC 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 isnt
complete
23Overview
Server
Client
Main() calls rpcopen(file)
RPC creates message and sends To TCP
Pop decodes RPC_OPEN, calls fdopen(file)
fd Handle
1 12
14 3
24Overview
Server
Client
Main() calls rpcread(Handle, buf, len)
RPC creates message and sends To TCP Waits on
semaphore
Pop decodes RPC_READ calls rvalread(fd,tmpb,len)
rpcpop copies data from message into buf,
signals semaphore
25Server
Client
Overview
Main() calls rpcwrite(Handle, buf, len)
RPC creates message and sends To TCP, waits on
semaphore
Pop decodes RPC_WRITE calls rvalwrite(fd,tmpb,le
n)
rpcpop signals semaphore
26Details
- 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.