Commit 5fef480a authored by Martin Lucina's avatar Martin Lucina

Fixes to TCP wire format specification

parent 8f90ae8d
...@@ -53,12 +53,25 @@ A 'peer address' may be specified by either of the following: ...@@ -53,12 +53,25 @@ A 'peer address' may be specified by either of the following:
WIRE FORMAT WIRE FORMAT
----------- -----------
0MQ messages are transmitted over TCP in frames consisting of the message 0MQ messages are transmitted over TCP in frames consisting of an encoded
length followed by flags byte and the message data. The length MUST correspond 'payload length', followed by a 'flags' field and the message body. The 'payload
to the length of the remaining part of the frame. length' is defined as the combined length in octets of the message body and the
'flags' field.
. A single 'frame' can be defined by the For frames with a 'payload length' not exceeding 254 octets, the 'payload
following ABNF grammar: length' shall be encoded as a single octet. The minimum valid 'payload length'
of a frame is 1 octet, thus a 'payload length' of 0 octets is invalid and such
frames SHOULD be ignored.
For frames with a 'payload length' exceeding 254 octets, the 'payload length'
shall be encoded as a single octet with the value `255` followed by the
'payload length' represented as a 64-bit unsigned integer in network byte
order.
The 'flags' field consists of a single octet reserved for future expansion and
MUST be set to `0`.
The following ABNF grammar represents a single 'frame':
.... ....
frame = (length flags data) frame = (length flags data)
...@@ -68,39 +81,36 @@ following ABNF grammar: ...@@ -68,39 +81,36 @@ following ABNF grammar:
data = *OCTET data = *OCTET
.... ....
The following diagram illustrates the layout of a frame with a 'payload length'
For messages of 0 to 253 octets in length, the message length is represented by not exceeding 254 octets:
a single octet:
.... ....
0 1 2 3 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message size | Flags | Message body ... | | Payload length| Flags | Message body ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message body ... | Message body ...
+-+-+-+-+-+-+- ... +-+-+-+-+-+-+- ...
.... ....
For messages of 254 or more octets in length, the message length is represented The following diagram illustrates the layout of a frame with a 'payload length'
by a single octet with the value `255` followed by the message length exceeding 254 octets:
represented as a 64-bit unsigned integer in network byte order:
.... ....
0 1 2 3 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0xff | Message size ... | | 0xff | Payload length ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message size ... | | Payload length ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message size | Flags | Message body ... | | Payload length| Flags | Message body ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message body ... | Message body ...
+-+-+-+-+-+-+-+ ... +-+-+-+-+-+-+-+ ...
.... ....
The flags field is reserved and MUST be set to 0.
EXAMPLES EXAMPLES
-------- --------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment