[bittorrent] A few questions regarding extended messages and DHT

Adrian Ulrich torrent at blinkenlights.ch
Wed Oct 31 03:02:47 EDT 2007


Hi,

> * It seems that extension protocol is such that two clients that exchange extended handshake
> (link to the spec http://www.rasterbar.com/products/libtorrent/extension_protocol.html)
> could opt to map same kind of extended message to the different id, which is slightly confusing to me

While doing the handshake, the remote peer just tells you:

 #1 What eproto extensions it does support (everything listed && != 0)
 #2 What Id the peer will use to SEND eproto messages to YOU

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.


> * DHT: when generating our own ID, according to the, hm, "spec" (better call it rought sketch of the protocol :)) we should use a lot of
> entropy to get a random 160-bit value. 
> [...]
> I don't know, our IP address and/or MAC address and/or current time or such and should we save this ID accross sessions (restarts of the client). 

The DHT-ID just needs to be random, it doesn't need to be 'cryptographically secure' ;-).
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)

> on one, it preserves exactly the same ID across sessions, but on the other, the ID changes.
> What's the deal? How do other authors implement and store this ID?

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.

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.

Regards,
 Adrian






More information about the BitTorrent mailing list