⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rfc1832.html

📁 this gives details of the network programming
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML><HEAD><TITLE>rfc1832</TITLE><LINK REV="made" HREF="mailto:rfc-admin@faqs.org"></HEAD><BODY BGCOLOR="#ffffff" TEXT="#000000"><H1 ALIGN=CENTER>RFC1832</H1><P ALIGN=CENTER>[ <A HREF="../../../../rfcs/index.html">Index</A> | <A HREF="../../../../rfcs/rfcsearch.html">Search</A> | <A HREF="../../../../rfcs/changed.html">What's New</A> | <A HREF="mailto:rfc-admin@faqs.org">Comments</A> | <A HREF="../../../../rfcs/rfchelp.html">Help</A> ]</P><P ALIGN=CENTER><IMG SRC="../../../../images/clrbar.gif" HEIGHT=2 WIDTH=380 ALT="---"></P><PRE>Network Working Group                                      R. SrinivasanRequest for Comments: 1832                              Sun MicrosystemsCategory: Standards Track                                    August 1995               XDR: External Data Representation StandardStatus of this Memo   This document specifies an Internet standards track protocol for the   Internet community, and requests discussion and suggestions for   improvements.  Please refer to the current edition of the "Internet   Official Protocol Standards" (STD 1) for the standardization state   and status of this protocol.  Distribution of this memo is unlimited.ABSTRACT   This document describes the External Data Representation Standard   (XDR) protocol as it is currently deployed and accepted.TABLE OF CONTENTS   1. INTRODUCTION                                              2   2. BASIC BLOCK SIZE                                          2   3. XDR DATA TYPES                                            3   3.1 Integer                                                  3   3.2 Unsigned Integer                                         4   3.3 Enumeration                                              4   3.4 Boolean                                                  4   3.5 Hyper Integer and Unsigned Hyper Integer                 4   3.6 Floating-point                                           5   3.7 Double-precision Floating-point                          6   3.8 Quadruple-precision Floating-point                       7   3.9 Fixed-length Opaque Data                                 8   3.10 Variable-length Opaque Data                             8   3.11 String                                                  9   3.12 Fixed-length Array                                     10   3.13 Variable-length Array                                  10   3.14 Structure                                              11   3.15 Discriminated Union                                    11   3.16 Void                                                   12   3.17 Constant                                               12   3.18 Typedef                                                13   3.19 Optional-data                                          14   3.20 Areas for Future Enhancement                           15   4. DISCUSSION                                               15   5. THE XDR LANGUAGE SPECIFICATION                           17   5.1 Notational Conventions                                  17   5.2 Lexical Notes                                           17   5.3 Syntax Information                                      18   5.4 Syntax Notes                                            19   6. AN EXAMPLE OF AN XDR DATA DESCRIPTION                    20   7. TRADEMARKS AND OWNERS                                    21   APPENDIX A: ANSI/IEEE Standard 754-1985                     22   APPENDIX B: REFERENCES                                      24   Security Considerations                                     24   Author's Address                                            241. 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 ONC 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)   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        +--------+--------+...+--------+--------+...+--------+        |&lt;-----------n bytes----------&gt;|&lt;------r bytes------&gt;|        |&lt;-----------n+r (where (n+r) mod 4 = 0)&gt;-----------&gt;|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 (&lt; and &gt;) 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         +-------+-------+-------+-------+         &lt;------------32 bits------------&gt;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:         unsigned int identifier;           (MSB)                   (LSB)            +-------+-------+-------+-------+            |byte 0 |byte 1 |byte 2 |byte 3 |             UNSIGNED INTEGER            +-------+-------+-------+-------+            &lt;------------32 bits------------&gt;3.3 Enumeration   Enumerations have the same representation as signed integers.   Enumerations are handy for describing subsets of the integers.   Enumerated data is declared as follows:         enum { name-identifier = constant, ... } identifier;   For example, the three colors red, yellow, and blue could be   described by an enumerated type:         enum { RED = 2, YELLOW = 3, BLUE = 5 } colors;   It is an error to encode as an enum any other integer than those that   have been given assignments in the enum declaration.3.4 Boolean   Booleans are important enough and occur frequently enough to warrant   their own explicit type in the standard.  Booleans are declared as   follows:         bool identifier;   This is equivalent to:         enum { FALSE = 0, TRUE = 1 } identifier;3.5 Hyper Integer and Unsigned Hyper Integer   The standard also defines 64-bit (8-byte) numbers called hyper   integer and unsigned hyper integer.  Their representations are the   obvious extensions of integer and unsigned integer defined above.   They are represented in two's complement notation.  The most and   least significant bytes are 0 and 7, respectively.  Their   declarations:   hyper identifier; unsigned hyper identifier;        (MSB)                                                   (LSB)      +-------+-------+-------+-------+-------+-------+-------+-------+      |byte 0 |byte 1 |byte 2 |byte 3 |byte 4 |byte 5 |byte 6 |byte 7 |      +-------+-------+-------+-------+-------+-------+-------+-------+      &lt;----------------------------64 bits----------------------------&gt;                                                 HYPER INTEGER                                                 UNSIGNED HYPER INTEGER3.6 Floating-point   The standard defines the floating-point data type "float" (32 bits or   4 bytes).  The encoding used is the IEEE standard for normalized   single-precision floating-point numbers [3].  The following three   fields describe the single-precision floating-point number:      S: The sign of the number.  Values 0 and 1 represent positive and         negative, respectively.  One bit.      E: The exponent of the number, base 2.  8 bits are devoted to this         field.  The exponent is biased by 127.      F: The fractional part of the number's mantissa, base 2.  23 bits         are devoted to this field.   Therefore, the floating-point number is described by:         (-1)**S * 2**(E-Bias) * 1.F   It is declared as follows:         float identifier;         +-------+-------+-------+-------+         |byte 0 |byte 1 |byte 2 |byte 3 |              SINGLE-PRECISION         S|   E   |           F          |         FLOATING-POINT NUMBER         +-------+-------+-------+-------+         1|&lt;- 8 -&gt;|&lt;-------23 bits------&gt;|         &lt;------------32 bits------------&gt;   Just as the most and least significant bytes of a number are 0 and 3,   the most and least significant bits of a single-precision floating-   point number are 0 and 31.  The beginning bit (and most significant   bit) offsets of S, E, and F are 0, 1, and 9, respectively.  Note that   these numbers refer to the mathematical positions of the bits, and   NOT to their actual physical locations (which vary from medium to   medium).   The IEEE specifications should be consulted concerning the encoding   for signed zero, signed infinity (overflow), and denormalized numbers   (underflow) [3].  According to IEEE specifications, the "NaN" (not a   number) is system dependent and should not be interpreted within XDR   as anything other than "NaN".3.7 Double-precision Floating-point   The standard defines the encoding for the double-precision floating-   point data type "double" (64 bits or 8 bytes).  The encoding used is   the IEEE standard for normalized double-precision floating-point   numbers [3].  The standard encodes the following three fields, which   describe the double-precision floating-point number:      S: The sign of the number.  Values 0 and 1 represent positive and         negative, respectively.  One bit.      E: The exponent of the number, base 2.  11 bits are devoted to         this field.  The exponent is biased by 1023.      F: The fractional part of the number's mantissa, base 2.  52 bits         are devoted to this field.   Therefore, the floating-point number is described by:         (-1)**S * 2**(E-Bias) * 1.F   It is declared as follows:         double identifier;         +------+------+------+------+------+------+------+------+         |byte 0|byte 1|byte 2|byte 3|byte 4|byte 5|byte 6|byte 7|         S|    E   |                    F                        |         +------+------+------+------+------+------+------+------+         1|&lt;--11--&gt;|&lt;-----------------52 bits-------------------&gt;|         &lt;-----------------------64 bits-------------------------&gt;                                        DOUBLE-PRECISION FLOATING-POINT   Just as the most and least significant bytes of a number are 0 and 3,   the most and least significant bits of a double-precision floating-   point number are 0 and 63.  The beginning bit (and most significant   bit) offsets of S, E , and F are 0, 1, and 12, respectively.  Note   that these numbers refer to the mathematical positions of the bits,   and NOT to their actual physical locations (which vary from medium to   medium).   The IEEE specifications should be consulted concerning the encoding   for signed zero, signed infinity (overflow), and denormalized numbers   (underflow) [3].  According to IEEE specifications, the "NaN" (not a   number) is system dependent and should not be interpreted within XDR   as anything other than "NaN".3.8 Quadruple-precision Floating-point   The standard defines the encoding for the quadruple-precision   floating-point data type "quadruple" (128 bits or 16 bytes).  The   encoding used is designed to be a simple analog of of the encoding   used for single and double-precision floating-point numbers using one   form of IEEE double extended precision. The standard encodes the   following three fields, which describe the quadruple-precision   floating-point number:      S: The sign of the number.  Values 0 and 1 represent positive and         negative, respectively.  One bit.      E: The exponent of the number, base 2.  15 bits are devoted to         this field.  The exponent is biased by 16383.      F: The fractional part of the number's mantissa, base 2.  112 bits         are devoted to this field.   Therefore, the floating-point number is described by:         (-1)**S * 2**(E-Bias) * 1.F   It is declared as follows:         quadruple identifier;         +------+------+------+------+------+------+-...--+------+         |byte 0|byte 1|byte 2|byte 3|byte 4|byte 5| ...  |byte15|         S|    E       |                  F                      |         +------+------+------+------+------+------+-...--+------+         1|&lt;----15----&gt;|&lt;-------------112 bits------------------&gt;|         &lt;-----------------------128 bits------------------------&gt;                                      QUADRUPLE-PRECISION FLOATING-POINT   Just as the most and least significant bytes of a number are 0 and 3,   the most and least significant bits of a quadruple-precision   floating-point number are 0 and 127.  The beginning bit (and most   significant bit) offsets of S, E , and F are 0, 1, and 16,   respectively.  Note that these numbers refer to the mathematical   positions of the bits, and NOT to their actual physical locations   (which vary from medium to medium).   The encoding for signed zero, signed infinity (overflow), and   denormalized numbers are analogs of the corresponding encodings for   single and double-precision floating-point numbers [5], [6].  The   "NaN" encoding as it applies to quadruple-precision floating-point   numbers is system dependent and should not be interpreted within XDR   as anything other than "NaN".3.9 Fixed-length Opaque Data   At times, fixed-length uninterpreted data needs to be passed among   machines.  This data is called "opaque" and is declared as follows:         opaque identifier[n];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -