XDR: External Data Representation standard
RFC 1014

Document Type RFC - Unknown (June 1987; No errata)
Last updated 2013-03-02
Stream Legacy
Formats plain text pdf html bibtex
Stream Legacy state (None)
Consensus Boilerplate Unknown
RFC Editor Note (None)
IESG IESG state RFC 1014 (Unknown)
Telechat date
Responsible AD (None)
Send notices to (None)
Network Working Group                             Sun Microsystems, Inc.
Request for Comments: 1014                                     June 1987

               XDR: External Data Representation Standard

STATUS OF THIS MEMO

   This RFC describes a standard that Sun Microsystems, Inc., and others
   are using, one we wish to propose for the Internet's consideration.
   Distribution of this memo is unlimited.

1. INTRODUCTION

   XDR is a standard for the description and encoding of data.  It is
   useful for transferring data between different computer
   architectures, and has been used to communicate data between such
   diverse machines as the SUN WORKSTATION*, VAX*, IBM-PC*, and Cray*.
   XDR fits into the ISO presentation layer, and is roughly analogous in
   purpose to X.409, ISO Abstract Syntax Notation.  The major difference
   between these two is that XDR uses implicit typing, while X.409 uses
   explicit typing.

   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. The alternative of using graphical representations
   (itself an informal language) quickly becomes incomprehensible when
   faced with complexity.  The XDR language itself is similar to the C
   language [1], just as Courier [4] is similar to Mesa. Protocols such
   as Sun RPC (Remote Procedure Call) and the NFS* (Network File System)
   use XDR to describe the format of their data.

   The XDR standard makes the following assumption: that bytes (or
   octets) are portable, where a byte is defined to be 8 bits of data.
   A given hardware device should encode the bytes onto the various
   media in such a way that other hardware devices may decode the bytes
   without loss of meaning.  For example, the Ethernet* standard
   suggests that bytes be encoded in "little-endian" style [2], or least
   significant bit first.

2. BASIC BLOCK SIZE

   The representation of all items requires a multiple of four bytes (or
   32 bits) of data.  The bytes are numbered 0 through n-1.  The bytes
   are read or written to some byte stream such that byte m always
   precedes byte m+1.  If the n bytes needed to contain the data are not
   a multiple of four, then the n bytes are followed by enough (0 to 3)

SUN Microsystems                                                [Page 1]
RFC 1014              External Data Representation             June 1987

   residual zero bytes, r, to make the total byte count a multiple of 4.

   We include the familiar graphic box notation for illustration and
   comparison.  In most illustrations, each box (delimited by a plus
   sign at the 4 corners and vertical bars and dashes) depicts a byte.
   Ellipses (...) between boxes show zero or more additional bytes where
   required.

        +--------+--------+...+--------+--------+...+--------+
        | byte 0 | byte 1 |...|byte n-1|    0   |...|    0   |   BLOCK
        +--------+--------+...+--------+--------+...+--------+
        |<-----------n bytes---------->|<------r bytes------>|
        |<-----------n+r (where (n+r) mod 4 = 0)>----------->|

3. XDR DATA TYPES

   Each of the sections that follow describes a data type defined in the
   XDR standard, shows how it is declared in the language, and includes
   a graphic illustration of its encoding.

   For each data type in the language we show a general paradigm
   declaration.  Note that angle brackets (< and >) denote
   variablelength sequences of data and square brackets ([ and ]) denote
   fixed-length sequences of data.  "n", "m" and "r" denote integers.
   For the full language specification and more formal definitions of
   terms such as "identifier" and "declaration", refer to section 5:
   "The XDR Language Specification".

   For some data types, more specific examples are included.  A more
   extensive example of a data description is in section 6:  "An Example
   of an XDR Data Description".

3.1 Integer

   An XDR signed integer is a 32-bit datum that encodes an integer in
   the range [-2147483648,2147483647].  The integer is represented in
   two's complement notation.  The most and least significant bytes are
   0 and 3, respectively.  Integers are declared as follows:

         int identifier;

           (MSB)                   (LSB)
         +-------+-------+-------+-------+
         |byte 0 |byte 1 |byte 2 |byte 3 |                      INTEGER
         +-------+-------+-------+-------+
         <------------32 bits------------>

SUN Microsystems                                                [Page 2]
RFC 1014              External Data Representation             June 1987

3.2.Unsigned Integer

   An XDR unsigned integer is a 32-bit datum that encodes a nonnegative
   integer in the range [0,4294967295].  It is represented by an
   unsigned binary number whose most and least significant bytes are 0
   and 3, respectively.  An unsigned integer is declared as follows:
Show full document text