The Carrier Protocol is meant to multiplex a collection of Secure Protocol connections between two hosts. In order to facilitate interleaving the multiple protocol streams, the carrier packets are limited in size, and the packet boundaries do not necessarily correspond to the packet boundaries of the underlying protocol.
The carrier protocol is meant to be used over a sequenced, reliable, secure connection. Basically, it's meant to run over an SSL connection on a TCP/IP connection.
Authentication is very straight forward, since this is assumed to be over an SSL connection. The Client simply provides a json object with the fields "username" and "password" (having the appropriate values). The Server responds with a json success object with the fields "success" and "reason", where success is a boolean and reason is an optional string explaining what went wrong if success is false.
Once authentication is complete, there is one basic packet which can be sent back and forth. The protocol uses an escape-byte style, where 0x7f is the start-of-packet byte, 0x7e is the escape byte, and the sequence 0x7e 0x0f is the escape sequence for 0x7f and 0x7e 0x0e is the escape sequence for 0x7e.
For channel allocation, see channels.
Byte Count | Data Type | Value | Description |
1 | unsigned byte | 0x7f | Start of Packet byte |
4 | unsigned integer | Channel ID | |
2 | unsigned short | count | the number of bytes in the packet |
count | bytes | the data payload |
There is one pre-assigned channel in the carrier protocol: the control channel, on channel 0.
The carrier protocol control channel consists entirely of json messages. The packets are of the form:
Byte Count | Data Type | Value | Description |
1 | unsigned byte | Packet ID | |
[variable] | String | json message |
The string is a j-string, which is to say, an unsigned short followed by that many UTF-8 characters.