Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the first peer from a torrent-magnet link?

I've been trying to understand the torrent-magnet technology, but I can't seem to figure out how you get connected to the first peer when opening a magnet link.

When you get a magnet link like below, it contains no initial peer - only the BitTorrent Info Hash (btih) and the file name.

magnet:?xt=urn:btih:bbb6db69965af769f664b6636e7914f8735141b3&dn=ubuntu-12.04-desktop-i386.iso 

According to BitTorrent & Magnets: How Do They Work? (MakeUseOf)

If you click a magnet link that does not specify a tracker (tr) the first peer will be found using DHT. Once you’ve got a peer, peer exchange kicks in too.

The DHT article on Wikipedia does not specify how to find a peer, but in the Kademlia article (upon which BitTorrent DHT is based), it says

A node that would like to join the net must first go through a bootstrap process. In this phase, the joining node needs to know the IP address and port of another node—a bootstrap node (obtained from the user, or from a stored list)—that is already participating in the Kademlia network.

But where does it know that node from? I don't see an address or anything present in the magnet link. Since it's decentralized (trackerless), I wouldn't expect it to know the node in advance. Or is the DHT in fact not decentralized?

like image 952
kba Avatar asked Mar 04 '13 21:03

kba


People also ask

How do I extract a magnet link?

Step 1: Open the uTorrent application on your device and click the “Add Torrent +” button. Step 2: Copy and paste the magnet link to the pop-up window to add magnet link to uTorrent. Then click “Add torrent”. Step 3: Select the exact files which you want to download from the magnet link.

What is magnet URI uTorrent?

Magnet links are an increasingly popular way to make downloading and sharing bittorrent files even faster and easier! Sometimes called "magnet URIs," magnet links let you download your favorite content using a plain-text link. Just copy and paste the link into e-mails and instant messages and you're good to go!

Are magnet links Safe?

1. Malware and Viruses. Torrent files and magnet links themselves aren't dangerous, they just configure your torrent client to upload and download whatever it is you're torrenting. The risk is that the actual files you download might contain malware.


1 Answers

For the most part, when you start a bittorrent client, bootstrap off of:

  1. nodes from your last session, that were saved to disk
  2. other peers that you have on any of the swarms you're on

There are a few well-known bootstrap nodes which clients can use if they have no other means of finding any. Essentially the only case this happens is when you install a client for the first time, and the first torrent you download is a magnet link without a tracker.

You can then hit router.utorrent.com:6881. I believe transmission, azureus and bitcomet run similar routers, and possibly other clients as well.

By "router", I mean a node that appear to behave like any other node in the DHT, but probably has a different mechanism for determining which nodes to hand out, and probably is optimized specifically for the use case of just introducing dht nodes to each other.

UPDATE: you can run your own DHT bootstrap machine, here's the source code.

like image 123
Arvid Avatar answered Sep 17 '22 13:09

Arvid