Introduction#
In order to reduce the size of Tracker responses and decrease the memory and computational requirements of Trackers, Trackers can return the list of peer nodes as packed strings instead of as a bencoded list.
In this document, the interpretation of the keywords "MUST," "MUST NOT," "REQUIRED," "SHALL," "SHALL NOT," "SHOULD," "SHOULD NOT," "RECOMMENDED," "MAY," and "OPTIONAL" should be referred to as described in IETF RFC 2119.
Overview#
According to the BitTorrent protocol specification, peer nodes wishing to transfer files will contact a central Tracker. The Tracker will return a list of peer nodes currently transferring the file. This list of peer nodes is implemented as a series of bencoded dictionaries. Each dictionary in the list contains three fields: peer id, ip, and port.
The peer id is 20 bytes plus an additional 3 bytes of bencoding payload. The ip is a string that includes a domain name or IP address, along with an integer port number. The length of the ip is variable, but since it can be a domain name in its longest form, it cannot exceed 255 bytes, plus an additional 4 bytes of bencoding payload. Bencoded integers are also variable in length, but since they represent a port number, their length will not exceed 7 bytes, including the bencoding payload.
According to the BitTorrent protocol specification, the list of peer nodes in the BitTorrent protocol is stored as bencoded dictionaries, with each dictionary containing the fields peer id, ip, and port, representing the unique identifier, IP address, and port number of the peer node, respectively.
Therefore,
total peer list length in bytes < n * ( 23 + 259 + 7 )
A compact format is now commonly used to represent each peer node, where each peer node is represented using only 6 bytes. The first 4 bytes contain the 32-bit IPv4 address, and the remaining 2 bytes contain the port number. Both the address and port number are in network byte order.
It is recommended for trackers to default to returning the compact format. By including "compact=0" in the announce URL, the client suggests the tracker to use the original format, and similarly, "compact=1" suggests the tracker to use the compact format. However, the "compact" key-value pair is only a recommendation: the tracker can choose to return either format. "Compact" is a suggestive setting for the tracker, indicating that it may only support the compact format. However, the client must continue to support both formats.
Based on the above description, it is recommended for the tracker to return the list of peer nodes in the compact format by default. The client can suggest the tracker to use either the original format or the compact format by specifying the corresponding parameter in the announce URL. However, the final decision of which format to return lies with the tracker. The client must support both formats.
Example:
GET /announce?peer_id=aaaaaaaaaaaaaaaaaaaa&info_hash=aaaaaaaaaaaaaaaaaaaa
&port=6881&left=0&downloaded=100&uploaded=0&compact=1
The "compact format" data format in the BitTorrent protocol. In traditional BitTorrent tracker responses, a key called "peers" is used to represent the list of peer nodes, with its value being a bencoded list.
However, in the "compact format," the same "peers" key is used, but its value is a bencoded string instead of a list. Unlike the traditional format, the "compact format" does not include the ID (peer id) of the peer nodes. Although lacking the information of peer node IDs, this compact format has been widely used for many years without causing any issues.
This "compact format" is supported by most mainstream BitTorrent clients such as IMFile, qBittorrent, libtorrent, and uTorrent.
Summary#
In peer-to-peer file-sharing networks, when you connect to a Tracker to obtain information about other users sharing the file, the Tracker typically returns a list of peer nodes that are currently sharing the file. This information can include IP addresses, port numbers, etc.
The "Compact Peer Lists" in Tracker Returns Compact Peer Lists refers to a format or method used to represent a compact form of the list of peer nodes. Compared to other formats, such as detailed node lists, the compact peer node list uses less data to represent node information, thereby reducing network traffic and resource consumption.
Typically, the compact peer node list is represented in binary and uses a specific encoding scheme. It usually includes the IP address and port number of the nodes, and specific information about the nodes can be obtained by decoding and processing this list.
In conclusion, "Tracker Returns Compact Peer Lists" means that the tracker returns a list of peer nodes represented in a compact format, which can be used to establish connections with other users sharing the file.