[bittorrent] A few questions regarding extended messages and DHT

ntorrent.20.draza at spamgourmet.com ntorrent.20.draza at spamgourmet.com
Wed Oct 31 04:32:14 EDT 2007

> m => { ut_pex = 5 } just means that the peer will use an id 
> of '5' to send ut_pex messages to you.
> It does NOT mean that the peer is expecting ut_pex messages 
> with an id of 5. You are free to choose (hardcode) your own
> ids for messages that YOU send.

Yeah, I figured as much after a bit more thinking. This is actually easier
to implement than to try to match the IDs based on the names of the
extensions. Thanks for a thorough answer. 

> The DHT-ID just needs to be random, it doesn't need to be 
> 'cryptographically secure' ;-).

Excellent observation :) My text did read like that :)

> Doing something like reading 320 bits from /dev/urandom and 
> sha1'ing them would be enough. I would avoid using the
> MAC or IP of the client because both are not very random. 
> (Doing this would cause hot-spots/poor distribution in the network)

You are right. I wasn't thinking about using MAC or IP directly, but a SHA-1
hash (it's exactly 160 bits long) of a combination of data. But again, you
are right, we're trying to get unique values here, the more entropy the
> The client is free to keep it's DHT-ID as long as he wishes. 
> He is also free to change his own ID but doing this while 
> running wouldn't
> be clever because you'll get removed from the other peers K-Buckets.

Of course, that's understood. During the session (between restarts of the
client) the ID must remain the same.
> IMO it's okay to change the DHT-ID after detecting an 
> IP-Change or if the client has been down for a long time.

It appears that uTorrent does something like that.

> Regards,
>  Adrian

Thanks again for a thorough answer,


More information about the BitTorrent mailing list