[bittorrent] DHT: How to reply to get_peers when I have neither any peers nor closer nodes?

Adrian Ulrich torrent at blinkenlights.ch
Wed Nov 15 15:46:08 EST 2006

Hi Josef,

> [...] clear how one should handle the case of a get_peers query while having 
> neither any peers for the given info hash yet, nor any closer nodes. 

Read the Kademlia Specs:

>   FIND NODE takes a 160-bit ID as an argument.
>   The recipient of a the RPC returns IP address, UDP port,
>   Node ID triples for the knodes it knows about closest to
>   the target ID. These triples can come from a single k-bucket,
>   or they may come from multiple k-buckets if the closest k-bucket
>   is not full. In any case, the RPC recipient must return
>   k items (unless there are fewer than k nodes in all its
>   k-buckets combined, in which case it returns every
>   node it knows about).

So it's perfectly legal to reply with *GOOD* nodes not closer to the

(GOOD = Nodes that are still alive)

> I'm not sure if that means the client is broken, or my get_peers reply is 
> malformed.

The client is broken. I'm also getting this 0-token replys.
Just drop them :-)

> Somehow the transaction is an eight-byte string too instead of 
> the required single character string, so it's probably a broken client.

This is a different issue: A lot of implementations are sending too long
transaction-id's. I'd recommend to accept them but avoid send them


            A. Top posters
            Q. What's the most annoying thing on Usenet?

More information about the BitTorrent mailing list