Bittorrent : Why value of peers field is binary , not Bencoded list?

北城余情 提交于 2019-12-23 21:24:55

问题


I'm trying to implement Bittorent in C. First of all, before writing a code snippet, I tried to used a web browser to send the following message(URL) to the tracker server.

you may try this URL.

http://torrent.ubuntu.com:6969/announce?info_hash=%9ea%80%ed%e7/%c4%ae%c8%de%8c%b0C%81c%fbq%3cJ%22&peer_id=M7-3-5--%eck%a8%2a%7f%e6%3ah%84%f2%9d%c5&port=43611&uploaded=0&downloaded=0&left=0&corrupt=0&key=00BA7F86&event=started&numwant=4&compact=0&no_peer_id=0

I have downloaded the torrent file from this link which is named xubuntu-13.04-desktop-i386.iso and has 9e6180ede72fc4aec8de8cb0438163fb713c4a22 as SHA-1 value.

However, after sending above request, I get

HTTP/1.0 200 OK
d8:completei357e10:incompletei8e8:intervali1800e5:peers24:l\262j"\310Հp\226\310\325G?\205^%!\221x   \364\367\357e

But Bittorent specification says

peers : The value is a list of dictionaries, each with the following keys
-peer id peer's self-selected ID, as described above for the tracker request (string)
-ip peer's IP address (either IPv6 or IPv4) or DNS name (string)
-port peer's port number (integer)

Why value of peers field is binary, not Bencoded list?
Thank you in advance.


回答1:


the peers value may be a string consisting of multiples of 6 bytes. First 4 bytes are the IP address and last 2 bytes are the port number. All in network (big endian) notation.

https://wiki.theory.org/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol




回答2:


The protocol you refer to was used in the early days of bittorrent. However, as some trackers became increasingly popular without being scaled out significantly in terms of capacity, the size of the tracker responses became significant. One measure to deal with this was for clients to accept gzipped HTTP responses and the compact peer responses (which is by far the most popular format among trackers these days). The compact peer response provides a significantly smaller response with the same amount of information. It's defined in BEP23.

However, even though the responses are relatively small now, the TCP handshake and teardown still imposes a significant const, this is why many trackers are moving over to UDP BEP15.



来源:https://stackoverflow.com/questions/17439742/bittorrent-why-value-of-peers-field-is-binary-not-bencoded-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!