[bittorrent] Encryption, Azureus Extended Messaging and reserved bits...

David P. Mott dpmott at sep.com
Wed Sep 13 11:19:38 EDT 2006

Alan pointed out to me that this bitfield is not one of the numeric types 
that is represented as big-endian, so in this case the bits are literally 
counted left-to-right.

If it were a big-endian integer, then the MSB would come first (as you 
pointed out), and the "trailing bits" that Bram refers to would actually 
be the LSB.  I think that I had it right except for the fact that this 
bitfield is not represented in any endian-ness at all -- it's just an 
array of bytes.

It's just been too long since I looked closely at the spec.  The folks 
that used the first bit for DHT should be soundly flogged.

And yes, Bram *is* doing exactly what he suggested.  Although, I wonder 
what bits 62 and 63 are for...

Thanks for the response.


On Wed, 13 Sep 2006, Jari Sundell wrote:

> On 9/13/06, David P. Mott <dpmott at sep.com> wrote:
>> Finally, this would be *the* place to reiterate (from section 10.4
>> "Handshake") that:
>> "An email from Bram suggests that trailing bits should be used first, so
>> that leading bits may be used to change the meaning of trailing bits."
>> Ummm... along with an appropriate translation of "leading" and "trailing"
>> into LSB and MSB.  I'll take a wild guess here and say that LSB (bits)
>> should be used first... although I'm noticing that the mainline client is
>> already using bits 61 and 64.
>> WTF?
> The source of confusion lies in your understanding of endianness, it
> seems. Leading bits would be those first in the handshake, but I'm
> guessing you swapped MSB and LSB as the leading bits are the Most
> Significant in big endian.
> So Bram is doing exactly what he suggested.
> Rakshasa

More information about the BitTorrent mailing list