[zeromq-dev] Difficulty/Confusion in understanding ZMTP

Indradhanush Gupta indradhanush.gupta at gmail.com
Sun Nov 8 15:43:10 CET 2015


On Tue, Nov 3, 2015 at 4:24 PM, Jeremy Richemont <jrichemont at gmail.com>
wrote:

> If you'd read a little further you'd have found that the value 0xFF (255)
> is reserved for saying "a second body part follows". Therefore length can
> only be between 0 (probably pointless) and 254 for a single body. I agree
> that the wording of "For frames with a length of 1 to 254 octets, the
> length SHOULD BE encoded as a single octet" is unclear whether it is
> referring to the entire packet (254 - 1 (flag) - 1 (length) == 252 bytes
> max body) or just the body part. On the other hand, reading even further
> gives:
>
> The specification of the length field is surprising (and has confused even
>> experts reading the spec). It should not include the flag field, nor other
>> possible header fields. This would allow a zero-length body to be specified
>> with a length of zero.
>
>
> So we can assume the length field is only the body length and does not
> include metadata. Since already stated that 255 is reserved, the value of
> length can be zero to 254 or an array of [0..253] which is length-1.
>
>
Thanks. This along with Pieter's reply[0] on the other thread helps to
clear out the confusion.


> Jeremy
>
>
>
> On 2 November 2015 at 17:49, Indradhanush Gupta <
> indradhanush.gupta at gmail.com> wrote:
>
>> Hi,
>>
>> I'm trying to understand the ZMTP protocol, so I was going through the
>> RFC for version 1.0 [0]. It states that:
>>
>>> The following diagram shows the layout of a frame with a length of 1 to
>>> 254 octets:
>>>
>>>             +----------------+
>>>  Octet 0    | Length         |
>>>             +----------------+
>>>  Octet 1    | Flags          |
>>>             +----------------+- ... ---------------------+
>>>  Octets 2+  | Body                     Length - 1 octets |
>>>             +------------------ ... ---------------------+
>>>
>>> But, what I don't understand is that if the total length is that of *254
>> Octets, *and the first and second octets are occupied by the *Length *and
>> the *Flags *part of the message respectively, how can the *Body *be from *Octet
>> 2 to (Length - 1)* ?  Shouldn't it be *(Length - 2) *, since the first
>> two octets are occupied already?
>>
>> The RFC also says that,
>>
>> For frames with a length of 1 to 254 octets, the length SHOULD BE encoded
>>> as a single octet.
>>
>>
>> The length being *1 Octet *itself, can store a max value of *255. *So my
>> question is, why is the max length of a frame, *254 *and not
>>
>> *255 ? *
>> What am I missing here?
>>
>> [0] - http://rfc.zeromq.org/spec:13
>>
>> Thanks,
>> --
>> Indradhanush Gupta
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
[0] - http://lists.zeromq.org/pipermail/zeromq-dev/2015-November/029765.html

-- 
Indradhanush Gupta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151108/27b7f02a/attachment.htm>


More information about the zeromq-dev mailing list