Package edu.rit.mp

Package edu.rit.mp contains the Message Protocol (MP), a transport layer protocol for sending messages using TCP. MP is intended for use in message passing parallel programming on cluster parallel computers.

Operation

A source process sends a message to a destination process through a channel. Each message includes a tag; this is just an integer that the source can use to convey metadata to the destination. Each message also includes a given number of items. Each item in a message is of a given type (the same type for all items in the message). The supported types are given in the table below. The table shows the Java type used to store the item in memory, the number of bytes used to represent the item in a message, and the range of values that can be represented.

For information on how to create channels and send and receive messages, see class ChannelGroup.

Type | Stored As | # of Bytes | Range
Boolean | `boolean` | 1 | `true`, `false`
Byte | `byte` | 1 | -128 .. 127
Short | `short` | 2 | -32768 .. 32767
Integer | `int` | 4 | -2147483648 .. 2147483647
Signed 8-bit integer | `int` | 1 | -128 .. 127
Unsigned 8-bit integer | `int` | 1 | 0 .. 255
Signed 16-bit integer | `int` | 2 | -32768 .. 32767
Unsigned 16-bit integer | `int` | 2 | 0 .. 65535
Long | `long` | 8 | -9223372036854775808 .. 9223372036854775807
Character | `char` | 2 | `'\u0000'` .. `'\uFFFF'`
Float | `float` | 4 | Same as `float`
Double | `double` | 8 | Same as `double`
Object | `Object` | Varies |

Message Format

A message consists of the following sequence of bytes:

- A magic number, 30144596 (an integer, four bytes, MSB first).
- The tag (an integer, four bytes, MSB first).
- The type of item (one byte).
- The number of items N (an integer, four bytes, MSB first).
- The item values, each item represented with the number of bytes given in the above table. For type = Object, the item values are represented as a sequence of bytes consisting of N objects serialized using Java Object Serialization.