

It notifies these clients that it would like to participate in the swarm, and asks them for the connection information of any peers they already know of who are participating in the swarm. When it wants to participate in a swarm for a given torrent, it searches the DHT network for several other clients whose IDs are as close 3 as possible to the infohash. It then bootstraps its connection to the DHT network using either hard-coded addresses of clients controlled by the client developer, or DHT-supporting clients previously encountered in a torrent swarm. The first time a client joins the DHT network it generates a random 160-bit ID from the same space as infohashes. A DHT is a big distributed index which maps torrents (identified by infohashes) to lists of peers (identified by IP address and ports) who are participating in a swarm for that torrent (uploading/downloading data or metadata). It does this using a separate peer-to-peer network 2 operating a "distributed hash table" (DHT). The first thing it needs to is find other peers who are downloading the torrent. Your client may know nothing about the torrent except for its infohash. Some magnet links include trackers or web seeds, but they often don't. The "infohash" is the hash of the encoded info data.


torrent file contains a data structure with two top-level keys: announce, identifying the tracker(s) to use for the download, and info, containing the filenames and hashes for the torrent. This is the same value that peers (clients) use to identify torrents when communicating with trackers or other peers. Where did the first peer come from? It was fresh and there were no other torrents.Ī BitTorrent magnet link identifies a torrent using 1 a SHA-1 or truncated SHA-256 hash value known as the "infohash". In a VM, I tried a magnet link with uTorrent (which was freshly installed) and it managed to find peers. How does this work?Īlso, what is the hash of? Is it a hash of an array of all the file hashes together? Maybe it's a hash of the actual torrent file required (stripping certain information)? I have no idea how the client finds peers. So how does the BitTorrent client find the actual file? I turned on URL Snooper to see if it visits a page (using TCP) or does a lookup or the like, but nothing happened. There's no room for an IP address or anything, it's just a SHA1. I saw base32 mentioned, knowing it's 5 bits per character and 32 characters, I found it holds exactly 160bits, which is exactly the size of the SHA1. The wiki says xt means "exact topic" and is followed by the format ( btih in this case) with a SHA1 hash. Curious about how it works, I looked up the specs and didn't find any answers.
