Magnet Links

What are magnet links and how do you use magnet links when torrenting?

In this article, we’ll start with a simple definition, magnet link usage, and then dive into a more technical explanation if you’re interested. Let’s dive in.

What is a Magnet Link?

In BitTorrent, Magnet Links are hyperlinks that contain all the information required to locate peers for a specific torrent file. They replace centralized torrent trackers, making BitTorrent more resilient and efficient.

Any peer with a complete copy of the torrent file can generate a magnet URI. When combined with peer-discovery mechanisms like DHT, the BitTorrent protocol can operate fully decentralized without requiring any physical tracker infrastructure.

What’s does a Magnet Link consist of?

Magnet Links contain specific metadata about the torrent file.

The only required component of a magnet link is the URN identifier, which is a cryptographic hash of the complete torrent file.

This serves as a unique identifier (like a library ISBN number) allowing your torrent client to locate peers with pieces of the same file.

Advantages of Magnet Links

Magnet Links have several advantages over legacy tracker-based torrents:

  1. Decentralized: They work even if the tracker site goes down or is blocked by an ISP
  2. No file download: Don’t require downloading a .torrent file. This helps reduce the (small) risk of malware and malicious .torrent files.
  3. Legal Risk: May reduce the liability of torrent databases in some jurisdictions
  4. Availability: Find more peers (when combined with DHT) than tracker-based torrents alone.

Disadvantages

In general, Magnet Links are superior to traditional trackers, but they still suffer from a few weaknesses.

  1. Reliance on DHT: Unless the Magnet Link contains the address of a specific HTTP tracker, you’ll need a DHT enabled and working to download the file successfully.
  2. Port Forwarding: Sometimes port forwarding issues can cause magnet links not to work properly. This can happen if you’re behind multiple routers. It is also occasionally an issue when using a SOCKS proxy server that doesn’t support DHT.

How to use Magnet Links

All modern torrent clients support magnet links, and will open them automatically just like they would a physical .torrent file.

Example of a magnet link for a linux torrent

To download a torrent with a magnet link:

  1. Search or browse for a torrent that offers a magnet lin
  2. Click the link to open the magnet URI
  3. Your default torrent should automatically recognize and load the magnet link
  4. Click OK to add the torrent to your queue (if required by your client)
Click to open the magnet link in qBittorrent (modal)

After that, your torrent client should load the metadata directly from the link and start querying the hash table looking for peers to leach from.

How Magnet Links Work

Magnet links are an elegant solution that have made the BitTorrent protocol easier to use and more resilient.

Let’s look at the basics of how they work. Here’s what happens when you open a magnet link in your web browser:

1. Resolve the link

Your browser will follow the link and recognize that it belongs to the BitTorrent protocol

2. Open the default app

Your device will open whichever torrent client (or other app) is the default for BitTorrent magnet URIs.

3. Extract the Hash (URN)

Each magnet link contains a unique URN identify which is a cryptographic hash of the full torrent file. It serves a unique identifier that can be used to lookup peers in the DHT hash table.

4. Locate a peer

If your magnet link doesn’t contain an HTTP link for a specific tracker, your client will query the DHT to try and find a match for the URN.

It starts by asking the ‘nearest’ clients. These are the ones the client has stored in its own DHT address table. If none of these peers have the file, they will pass along the request to the peers in their own address table.

This process continues until either:

  1. A peer with a with the URN in their hash table has been located
  2. The request times out

5. Discover more peers

Once your client has found a peer matching your magnet’s URN, it will query that peer for the address of additional peers with the same file. As each new peer is located, you’ll have a larger list of additional peers to query.

By repeating this process, your client can discover most (if not all) of the DHT-enabled peers sharing that file. These comprise your torrent swarm.

As your list available peers grows, so should your download speed an file availability.

6. Become a Seeder

Once you have the complete file, your client will start seeding the file. It will also be a node in the DHT, helping other peers locate additional peers for this torrent.

Leave a Comment