External data representation
External Data Representation (short: XDR ) is an abstract technical communication standard that was defined by Sun Microsystems and other companies in order to standardize the data exchange between servers and clients independent of hardware. XDR is an implementation of the presentation layer of the OSI model for network communication and is stipulated in RFC 1014 . It was updated in 1995 by RFC 1832 , which added 128-bit floating point numbers, and in 2006 by RFC 4506 , which only contains structural changes, but no changes in content.
This standard is mainly used in communication in the SUN Network File System . A number of programming languages support reading and writing of XDR data through library functions (see e.g. xdr _ * functions in libc under Unix for C , XDR module for Perl , xdrlib module for Python ).
XDR defines a representation for the most common data types such as B. integers , strings or arrays , but is itself untyped. The current standards set the XDR byte order to Big Endian , which corresponds to the Network Byte Order of TCP / IP . One XDR unit corresponds to 4 bytes. Floating point numbers are encoded in single and double precision according to the IEEE 754 standard.
Data types
Basic data types
Surname | representation | Explanations |
---|---|---|
integrity | 32 bit two's complement | |
unsigned integer | 32-bit integer | |
hyper | 64 bit two's complement | |
unsigned hyper | 64-bit integer | |
enumeration | 32 bit integer | |
bool | 32 bit integer | 0 = false, 1 = true |
float | 32 bit IEEE floating point number | |
double | 64 bit IEEE floating point number | |
quadruple | 128 bit IEEE floating point number | |
opaque [n] | Binary data of length n octets | possibly with padding, if length is not a multiple of 4 bytes |
opaque <n> | 32-bit length field, followed by binary data with the specified length | possibly with padding, if length is not a multiple of 4 bytes |
string <n> | 32 bit length field, followed by an ASCII string | possibly with padding, if length is not a multiple of 4 bytes. If the length specification is omitted, a maximum length of 2 32 -1 applies |
void | - | Empty data type that does not take up any storage space |
Compound data types
Surname | syntax | representation | Explanations |
---|---|---|---|
fixed-length array |
datatype identifier [ n]
|
n elements of datatype in a row | |
variable-length array |
datatype identifier < n>
|
32-bit length field, followed by max. n elements | If n is absent, then n = 2 32 -1 |
structure |
struct{ type1 identifier1; ...}
|
The components of the data structure in the order in which they are declared | |
discriminated union |
Other data types
Surname | syntax | representation | Explanations |
---|---|---|---|
optional-data |
datatype * identifier
|
Is stored like a discriminated union with a boolean, followed by the data field if the boolean value true is.
|
See also
Web links
- Official description of the standard ( RFC 1014 , RFC 1832 , RFC 4506 )
- A short abstract on the SUN XDR ( PDF file; 15 kB)