title: How to get the first peer from a torrent-magnet link?
body: <p>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.</p>
  
  <p>When you get a magnet link like below, it contains no initial peer - only the BitTorrent Info Hash (btih) and the file name.</p>
  
  <pre><code>magnet:?xt=urn:btih:bbb6db69965af769f664b6636e7914f8735141b3&amp;dn=ubuntu-12.04-desktop-i386.iso
  </code></pre>
  
  <p>According to <a href="http://www.makeuseof.com/tag/bittorrent-magnets-work-technology-explained/">BitTorrent &amp; Magnets: How Do They Work? (MakeUseOf)</a></p>
  
  <blockquote>
    <p>If you click a magnet link that does not specify a tracker (<code>tr</code>) <strong>the first peer will be found using DHT</strong>. Once you’ve got a peer, peer exchange kicks in too.</p>
  </blockquote>
  
  <p>The <a href="http://en.wikipedia.org/wiki/Distributed_hash_table">DHT article on Wikipedia</a> does not specify how to find a peer, but in the <a href="http://en.wikipedia.org/wiki/Kademlia">Kademlia article</a> (upon which BitTorrent DHT is based), it says</p>
  
  <blockquote>
    <p>A node that would like to join the net must first go through a bootstrap process. In this phase, <strong>the joining node needs to know the IP address and port of another node</strong>—a bootstrap node (obtained from the user, or from a stored list)—that is already participating in the Kademlia network.</p>
  </blockquote>
  
  <p>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 <em>know</em> the node in advance. Or is the DHT in fact <em>not</em> decentralized?</p>