next up previous contents
Next: Communication Protocol Up: Message Format Previous: Message Format   Contents

Layout details

Figure 5.9: Overall layout of logical message.

Further details of the message layout are schematized in Figures 5.9 through 5.11. Figure 5.9 shows the overall layout of the logical message. As explained above, there are four parts: a primary header, a primary payload, a secondary header, and a secondary payload. The figure also shows the layout of the headers.

The first byte of the primary header specifies the encoding of numeric types used throughout the two main headers and the primary payload. Currently there are two possible values for this byte: 0 indicates big-endian, 1 indicates little-endian.

The next three bytes are unused. The second 4-byte word of the the header contains the total length of the primary payload in bytes (because of the way sections are padded, this will always be a multiple of 8). Like all numbers in the parts of the message discussed here, this word is encoded according to the scheme selected by the first byte of the header.

The format of the primary payload will be described below. The secondary header only contains the length of the secondary payload in bytes. For uniformity with the primary header, this information is stored in the second 4-byte word. The first 4 bytes of the header are unused.

Note that all basic units of the message start on 8-byte boundaries. This is to avoid possible word alignment problems on some computer architectures, if the buffer operations are implemented natively.

Figure 5.10: Layout of primary payload

Now we discuss the format of the primary payload. Figure 5.10 shows that it is divided into a series of zero or more sections. These sections will be separated by padding, if necessary, to ensure that the sections all start on 8-byte boundaries. If the size of a section in bytes is $ b$, the amount of padding following the section is $ 8 \lceil b / 8 \rceil - b$ bytes.

Figure 5.11: Layout of one section in the primary payload

Figure 5.11 shows the layout of an individual section. The first byte defines the type of the elements held in the section according to the scheme:

$\displaystyle \begin{tabular}{l\vert l\vert l}
value & Java type, T & sizeof(T)...
... long & 8 \\
6 & float & 4 \\
7 & double & 8 \\
8 & Object & 0

The space occupied by an individual element in the section is defined in terms of the function sizeof(). This is defined to return 0 for object types, reflecting that the data content of objects is not stored in the primary payload.

The empty message consists of 16 bytes--the primary header defining an encoding in its first byte, and containing zero in its second word, and the secondary header containing zero in its second word.

The smallest contentful message, containing one primitive element, consists of 32 bytes: the primary header defining an encoding and specifying a size of 16 for the primary payload; an 8-byte section header specifying an element type and a length of 1; the section contents--one primitive element padded out if necessary to 8 bytes; and the secondary header specifying an empty secondary payload.

For larger messages the use of buffer space soon becomes more economical. We assume that the overheads in buffer size for short messages will be hidden by other message overheads, including the processing cost for message startup, and network latency.

next up previous contents
Next: Communication Protocol Up: Message Format Previous: Message Format   Contents
Bryan Carpenter 2004-06-09