So far I assumed a client would just search for peers in the dht and use bep 9 in order to get the metadata, however when trying it myself and opening Wireshark I couldn't find any usage of bep 9. Does the client automatically try trackers or something similar with the Infohash? Or is there something else you can do in the dht with only an infohash to get the metadata without bep 9?
Asked
Active
Viewed 169 times
1 Answers
1
The DHT does not store the torrent metadata, it provides contacts to peers (via get peers
) from which you can then download the metadata via the peer protocol and the extensions described in BEP 9.
There also are some websites that store torrents under a path based on their infohash, a client might also try one of those to fetch it.

the8472
- 40,999
- 5
- 70
- 122
-
Can you give examples to such sites? – raz Feb 21 '23 at 13:44
-
No, that's out of scope per SO rules. – the8472 Feb 21 '23 at 15:05
-
oh alright, jumping back to bep 9, in order to get the entire metadata, would you just continuesly ask for more pieces until you get an error for a none existing piece? Or just until the size is smaller than 16k? – raz Feb 21 '23 at 15:33
-
the size is signalled in the extension header – the8472 Feb 21 '23 at 17:00
-
do you know a filter in Wireshark to check in real time how an extended handshake and bep 9 protocol looks? – raz Mar 10 '23 at 17:24
-
1Not off the top of my head. You'll have to capture a TCP connection from the beginning, The extended handshake should happen fairly early. Wireshark has bittorrent dissectors, so it should recognize the packets as bittorrent messages and their IDs. – the8472 Mar 10 '23 at 19:24
-
Do you know what id is bep 9? I think Wireshark has filters for ids – raz Mar 10 '23 at 21:51
-
btw will bencoding libraries be able to decode the data message (which consists of the dictionary and a payload attached outside) or would I need any special manipulation to separate the payload from the dictionary? – raz Mar 11 '23 at 09:26
-
1they're all extended messages, so message id 20. the extension-IDs inside that are assigned dynamically. as for the bencoding, it depends on the library, all it has to do is not to consume additional bytes beyond the final `e` and not complain about the surplus bytes. – the8472 Mar 11 '23 at 13:23
-
alright I found in wireshark an example, probably my last question regarding this topic but is the handshake message bencoded or is only the m dictionary bencoded? – raz Mar 12 '23 at 13:53