How do magnet links work?
I’m getting that question often and there isn’t any short explanation link. Well, til now.
Magnet links are just a draft for an URL notation that includes a data specific to the resource you want to access. For
torrents, that’s a hex’d hash of the torrent and the torrent name.
In order to find something based on that, there’s no magic.
It needs to bootstrap. The procedure works via a DHT (Distributed Hash Table) which is also used for decentralized
torrent trackers (and before that, Kademlia, which is/was made by an eMule guy).
This basically means your client needs to connect somewhere and ask who has that torrent hash you have from your magnet
link (instead of asking the trackers and/or peers directly when you have a .torrent file). This process is up to the
client but generally is one of (or any/all of them):
Ask a master node such as router.bittorrent.com and router.bitcomet.com (it’ hard-coded). That does mean that
blocking access to that generally kills magnet links!
Asks nodes it has cached from previous torrents (granted that you downloaded any torrent before).
Asks nodes from a peer, granted that you have or had another torrent running.
Now some still asks, and what’s PEX?
PEX is Peer EXchange and is not directly related. It’s used to ask from more peers from your already known peers
(without having to ask a tracker or using DHT).
Torrent clients using torrent files generally also use DHT to find peers and not only trackers.
- Torrent files
Fast peer discovery as long as a tracker is up.
Slower discovery and thus torrent start, since it needs to bootstrap before it can find any peers.