Jump to content

Network Data Representation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 116.74.109.77 (talk) at 06:54, 4 December 2010 (External links). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model.

Transfer Syntax NDR Most application programs treat procedure call inputs and outputs as values of structured data types such as integers, arrays and pointers. One role of IDL is to provide syntax for describing these structured data types and values. However, the RPC protocol specifies that inputs and outputs be passed in octet streams. The role of NDR is to provide a mapping of IDL data types onto octet streams. NDR defines primitive data types, constructed data types and representations for these types in an octet stream.

For some primitive data types, NDR defines several data representations. For example, NDR defines ASCII and EBCDIC formats for characters. When a client or server sends an RPC PDU, the formats used are identified in the format label of the PDU. The data representation formats and the format label support the NDR multi-canonical approach to data conversion; that is, there is a fixed set of alternate representations for data types.

This chapter describes:

   * the NDR format label
   * the set of NDR primitive data types and the supported data representation formats for these types
   * the set of NDR constructed data types and their representations.

Data Representation Format Label The NDR format label is a vector of 4 octets that identifies the particular data representation formats used to represent primitive values both in the header and in the body of an RPC PDU. The format label is itself part of the PDU header. (See RPC PDU Encodings for definitions of RPC PDUs.)

NDR Format Label illustrates the NDR format label. The four most significant bits of octet 0 indicate integer format and endian type of the floating-point representation. The four least significant bits of octet 0 indicate character format. Octet 1 indicates floating-point representation format. Octets 2 and 3 are reserved for future use and must be zero octets. Figure: NDR Format Label NDR Format Label Values lists the values associated with integer, character and floating-point formats. The values are represented in the format label in unsigned integer binary format.


Data Type Value in Label Format Character 0 ASCII

 	1 	EBCDIC

Integer and floating-point byte order 0 Big-endian

 	1 	Little-endian

Floating-point representation 0 IEEE

 	1 	VAX
 	2 	Cray
 	3 	IBM


Table: NDR Format Label Values NDR Primitive Types

NDR defines a set of 13 primitive data types to represent Boolean values, characters, four sizes of signed and unsigned integers, two sizes of floating-point numbers, and uninterpreted octets.

For characters, integers and floating-point numbers, NDR defines more than one representation format. The formats used in an RPC PDU are identified in the NDR format label.

All NDR primitive data types are multiples of octets in length. A octet is 8 bits. A bit can take the values 0 and 1. Representation Conventions

The figures representing NDR primitive types adopt the following conventions:

   * Each octet is represented by a rectangular box.
   * When the figure refers to individual bits or groups of bits within an octet, the octet box is divided by vertical lines into one or more smaller rectangles that represent the individual bits or groups of bits.
   * Within octets, bits and groups of bits are represented with the most significant bit at the left and the least significant bit at the right.
   * Most significant bit is abbreviated MSB, and least significant bit is abbreviated LSB.
   * Data types larger than one octet are depicted as a series of octet boxes arranged vertically to form a larger rectangle. The octets are ordered from top to bottom: the topmost octet appears first in the octet stream and the bottommost octet appears last.
   * Bit and octet numbering, for reference purposes, begins with 0.
   * Diagrams do not depict the specified alignment gaps, which can appear in the octet stream before an item (see Alignment of Primitive Types .)
   * When a bit is set, it has the value 1. When a bit is reset, it has the value 0.

Following the preceding rules, the order of octets, as they occur in an octet stream, can be read by reading vertically from the top octet box down to the bottom octet box. The order of bits and groups of bits in an octet, from most significant to least significant, can be read beginning at the leftmost end of an octet box and reading across to the right end. The order of bits and groups of bits in the octets of a data type can therefore be read by reading the bits from left to right in each octet, beginning with the top octet and ending with the bottom octet.

Note:

   Although NDR specifies the order of bits and groups of bits within the octet stream of some data types, it specifies an octet stream representation of data rather than a bit stream representation of data. NDR does not specify how a given octet stream is represented as a bit stream, which is typically the province of underlying network layers. 

Alignment of Primitive Types

NDR enforces NDR alignment of primitive data; that is, any primitive of size n octets is aligned at a octet stream index that is a multiple of n. (In this version of NDR, n is one of {1, 2, 4, 8}.) An octet stream index indicates the number of an octet in an octet stream when octets are numbered, beginning with 0, from the first octet in the stream. Where necessary, an alignment gap, consisting of octets of unspecified value, precedes the representation of a primitive. The gap is of the smallest size sufficient to align the primitive. Booleans

A Boolean is a logical quantity that assumes one of two values: TRUE or FALSE. NDR represents a Boolean as one octet. It represents a value of FALSE as a zero octet, an octet in which every bit is reset. It represents a value of TRUE as a non-zero octet, an octet in which one or more bits are set.

The Boolean Data Type illustrates the boolean data type as it appears in the octet stream. Figure: The Boolean Data Type Characters

NDR represents a character as one octet. Characters have two representation formats: ASCII and EBCDIC.

Character Data Type illustrates the character type as it appears in the octet stream. Figure: Character Data Type Integers and Enumerated Types

NDR defines both signed and unsigned integers in four sizes:

small

   An 8-bit integer, represented in the octet stream as 1 octet.

short

   A 16-bit integer, represented in the octet stream as 2 octets.

long

   A 32-bit integer, represented in the octet stream as 4 octets.

hyper

   A 64-bit integer, represented in the octet stream as 8 octets.

NDR represents signed integers in twos complement format and represents unsigned integers as unsigned binary numbers. There are two integer formats: big-endian and little-endian. If the integer format is big-endian, the octets of the representation are ordered in the octet stream from the most significant octet to the least significant octet. If the integer format is little-endian, the octets of the representation are ordered in the octet stream from the least significant octet to the most significant octet.

NDR Integer Formats illustrates the integer types in big-endian and little-endian format. Figure: NDR Integer Formats Enumerated Types

NDR represents enumerated types as signed short integers (2 octets). Floating-point Numbers

NDR defines single-precision and double-precision floating-point data types. It represents single-precision types in 4 octets and double precision types in 8 octets.

NDR supports the following floating-point data representation formats for single-precision and double-precision floating-point types:

   * IEEE single-precision and double-precision floating-point formats, which comply with the IEEE 754 standard.
   * VAX F_floating and G_floating formats as defined in the VAX11 Architecture document.
   * Cray floating-point format, as defined in the documentation produced by Cray Research, Inc.
   * IBM short and long formats, as defined in the System/370 document.

NDR Floating Point Types is a conversion chart that shows how NDR single-precision and double-precision floating-point types correspond to the supported floating-point formats.


NDR Values Conversion Values

 	IEEE 	VAX 	Cray 	IBM

Single Single (4 octets) F (4 octets) Single (4 octets) Short (4 octets) Double Double (8 octets) G (8 octets) Double (8 octets) Long (8 octets)


Table: NDR Floating Point Types

The representation of a floating-point number comprises three fields:

   * The sign bit, which indicates the sign of the number. Values 0 and 1 represent positive and negative, respectively. This field is 1 bit in length.
   * The exponent of the number (base 16 in IBM format, base 2 in all others), biassed by an excess. The size of this field varies according to the format, as does the excess.
   * The fractional part of the number's mantissa (base 16 in IBM format, base 2 in all others). This field is also called the number's coefficient. The size of this field varies according to the format.

NDR allows implementations to use different degrees of precision in representing floating-point numbers. When the receiver is unmarshaling a floating-point number, and the number cannot be represented exactly in the receiver's floating-point format, the received (input) data is rounded such that the representable value nearest the infinitely precise result is delivered. If two representable values are equally near, the one with its least significant bit 0 (zero) is delivered.

The integer representation field of the NDR format label indicates whether floating-point values are transmitted in big-endian or little-endian format. See NDR Format Label Values for the mapping between format label values and data representations.

The remainder of this section describes how floating-point numbers are represented in the octet stream in IEEE, VAX, Cray and IBM formats.