External Data Representation XDR - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

External Data Representation XDR

Description:

Network management and debugging is easier. CS539 Client/Server Computing. 9 ... types and allows for the definition of compound data types ('structs'), fixed ... – PowerPoint PPT presentation

Number of Views:133
Avg rating:3.0/5.0
Slides: 18
Provided by: course61
Category:

less

Transcript and Presenter's Notes

Title: External Data Representation XDR


1
Lecture 11
  • External Data Representation (XDR)

2
Overview
  • Data Representation
  • N-Squared Conversion Problem
  • Network Standard Byte Order
  • De Facto XDR Standard
  • XDR Data Types
  • XDR Library Routines
  • Building XDR Messages
  • Summary

3
Data Representation
  • Each computer architecture provides its own
    representation of data
  • LSB at the lowest memory address
  • MSB at the lowest memory address
  • Client/Server applications must contend with data
    representation

decreasing memory address
increasing memory address
0
0
1
4
4
1
0
0
4
N-Squared Conversion Problem
  • The underlying issue of data representation is
    software portability
  • Asymmetric Data Conversion
  • Converts directly from the clients
    representation into the servers implementation
  • Must write a client-server pair for each pair of
    architectures
  • The programming effort is proportional to the
    square of the number of different data
    representations (N2 N) / 2

5
N-Squared Conversion Problem (Cont)
If client-server software is designed to convert
from the clients native data representation
directly to the servers native data
representation asymmetrically, the number of
versions of the software grows as the square of
the number of architectures
6
N-Squared Conversion Problem (Cont)
  • Solving the N-squared conversion problem
  • Develop client/server software so that it can be
    compiled and executed on a variety of machines
  • Results in a highly portable program
  • Makes accessing services easier

7
Network Standard Byte Order
  • Solves the data representation problem by
    converting the native byte order to a network
    standard byte order
  • TCP/IP protocol software uses symmetric data
    conversion
  • Both ends perform the required conversion
  • Only one version of the protocol is needed
  • Both client and server perform a data conversion
  • Data is represented in a standard
    machine-independent format
  • The standard format is known as external data
    representation (XDR)
  • Advantage of symmetric conversion
  • Added flexibility neither the client nor the
    server needs to understand the architecture of
    the other
  • Disadvantage of symmetric conversion
  • Computational overhead using an intermediate
    format introduces additional computation

8
Network Standard Byte Order (Cont)
  • Converting between heterogeneous representations
    requires extra CPU cycles
  • Conversion my result in a larger stream of bytes
  • Symmetric conversion is still advantageous
  • Simplifies programmer
  • Reduces errors
  • Increases interoperability
  • Network management and debugging is easier

9
De Facto XDR Standard
  • Sun Microsystems devised an external data format
    called eXternal Data Representation (XDR)
  • XDR is a standard for the description and
    encoding of data
  • XDR specifies data formats for most data types
    that clients/servers exchange
  • XDR specifies that 32-bit binary numbers should
    be represented in big endian order
  • Client/Servers using XDR must agree on the exact
    format of messages exchanged
  • XDR uses a language to describe data formats. The
    language can only be used only to describe data
    it is not a programming language.
  • This language allows one to describe intricate
    data formats in a concise manner.

10
XDR Data Types
  • The XDR standard defines various basic data types
    and allows for the definition of compound data
    types (structs), fixed-size and variable-size
    arrays as well as unions.
  • XDR provides representations for most C
    programming structures

11
Implicit Types
  • Client/Servers using XDR must agree on the exact
    format
  • Encoding does not identify its type or length
  • XDR message cannot be decoded unless it knows the
    exact format and types of all data fields

12
Software Support for XDR
  • Data must be converted from native format to the
    XDR representation before sending across the
    network
  • Data must be converted from XDR representation to
    native format when receiving data from the
    network
  • XDR conversion libraries are used to eliminate
    potential conversion errors
  • Converting floating point representation to the
    XDR standard

13
XDR Library Routines
  • XDR routines can convert data items from the
    machines native format to the XDR format and
    vice-versa
  • Most XDR implementations use a buffer paradigm
  • Uses a program to allocate a buffer large enough
    to hold the external format of a message
  • The application calls XDR conversion routines for
    each data item in the message
  • After encoding each data item and placing it in
    the XDR stream the application can send the
    message

14
Building an XDR Message
  • The XDR buffer paradigm uses a buffer to hold the
    external representation of the message
  • Need an XDR Pointer
  • XDR xdrs
  • Buffer to hold the data
  • Using functions you can create and add to the
    buffer, and get data from the buffer
  • xdrmem_create(xdrs, buf, BUFSIZE, XDR_ENCODE)
  • xdr_int(xdrs, i)

15
XDR Stream Buffer
stream header
0
1
2
3
4
5
6
An XDR stream that has been initialized for
ENCODE and already contains 7 bytes of data
stream header
0
1
2
3
4
5
6
0
0
1
4
XDR stream after a call to xdr_int appends a
32-bit integer with value 260
16
XDR Streams, I/O, TCP UDP
  • Method 1 Build entire message, then write
  • Method 2 Open Standard I/O stream (FILE object)
    and create using xdrstdio_create()
  • now each read/write will convert on the fly
  • Method 3 Open UDP datagram interface
  • use xdrrec_create() and send data in datagrams

17
Summary
  • Client/Server programs must contend with data
    representation problems
  • Asymmetric conversion
  • The client or server converts from its native
    format to the remote machines native format
  • N-Squared Conversion Problem
  • Symmetric Conversion
  • Uses a standard network representation
  • Requires both the client/server programs convert
    between the standard format and native format
  • Increased flexibility but added computational
    overhead
Write a Comment
User Comments (0)
About PowerShow.com