XDR/RPC protocol specification

Basic XDR assumptions

The XDR standard makes the following assumption: that bytes (or octets) are portable, where a byte is defined to be eight bits of data.

Basic block size

The representation of all items requires a multiple of four bytes (or 32 bits) of data. The bytes are numbered O through n-1. The bytes are read or written to some byte stream such that byte m always precedes byte m+1. The ``n'' bytes are followed by enough (0 to 3) residual zero bytes, r, to make the total byte count a multiple of four.

Choosing the XDR block size requires a tradeoff. Choosing a small size such as two makes the encoded data small, but causes alignment problems for machines that are not aligned on these boundaries. A large size such as eight means the data will be aligned on virtually every machine, but causes the encoded data to grow too large. Four was chosen as a compromise. Four is big enough to support most architectures efficiently, except for rare machines such as the eight-byte aligned Cray. Four is also small enough to keep the encoded data restricted to a reasonable size.

The same data should encode into the same thing on all machines, so that encoded data can be significantly compared or checksummed. Forcing the padded bytes to be zero ensures this.

This section uses graphic box notation for illustration and comparison. In most illustrations, each box (delimited by a plus sign at the four 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   |
   |<-----------n bytes---------->|<------r bytes------>|
   |<-----------n+r (where (n+r) mod 4 = 0)>----------->|

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005