Data encapsulation of datagrams
A standard encapsulation scheme is used for all datagrams. Each datagram is preceded by a 4-byte length tag stating the datagram length in bytes. An identical length tag is appended to the end of the datagram. The datagram length number is excluding both length tags.
Format
long Length;
struct DatagramHeader
  {
  long DatagramType;
  struct {
    long LowDateTime;
    long HighDateTime;
  } DateTime;
  };
- -
datagram content
- -
long Length;
};
Note
Data encapsulation does not include the NetCDF4 file format.
Description
All datagrams use the same header. The datagram type field identifies the type of datagram. ASCII quadruples are used to ease human interpretation and long-term maintenance. Three characters identify the datagram type and one character identifies the version of the datagram. The actual content of the datagram may, however, change from one version to the next.
The DateTime structure contains a 64-bit integer value stating the number of 100 nanosecond intervals since January 1, 1601. This is the internal "filetime" used by the Windows® operating systems. The data part of the datagram contains any number of bytes, and its content is highly datagram-dependent.
Common computers fall into two categories:
•  Intel-based computers write a multibyte number to file starting with the LSB (Least Significant Byte).
•  HP, Sun and Motorola do the opposite. They write the MSB (Most Significant Byte) to file first.
The byte order of the length tags and all binary fields within a datagram is always identical to the native byte order of the computer that writes the data file. It is the responsibility of the software that reads the file to perform byte swapping of all multibyte numbers within a datagram if required. Byte swapping is required whenever there is an apparent mismatch between the head and the tail length tags. Hence, the two length tags may be used to identify the byte order of the complete datagram.
The Intel processors allow a multibyte number to be located at any RAM address. However, this may be different on other processors; a short (2 byte) must be located at an even address, a long (4 byte) and a float (4 byte) must be located at addresses that can be divided by four. Hence, the numeric fields within a datagram is specified with this in mind.