Archived

This topic is now archived and is closed to further replies.

Seyss

How does a magnet link work? (first IP to connect)

Recommended Posts

Ok,

I've read countless articles on the web and they all hide the most basic information:

What is the first IP my torrent client connect to when opening a magnet link? I know once it finds the first IP, others can be fetched using Peer Exchange.

Give me an example of what is contained in a magnet link. All those hex values are what?

Thanks!

Share this post


Link to post
Share on other sites

I'm sorry that I have to bump this thread, but I have the same exact question and answering the question "How does DHT find IPs?" with "It finds them using DHT" is not a good answer at all.

When I tried Googling for information on this, this was the only relevant link I found. It's ridiculous how hard it is to find information on this open technology.

Share this post


Link to post
Share on other sites

The first IP you connect to (besides a DNS) is a server that provides a list of public IP's. These IPs can be used as entry points into the DHT network. This list is usually provided by the same people who make the bitTorrent client, though of course technically you can find a participating IP by any method that works (like asking a friend).

After you enter the network, you'll discover more IPs by using DHT lookups. It's likely that these IPs will be stored locally on your hard drive so you can just connect directly next time without fetching the bootstrap list first.

The magnet link contains a hash -- basically a unique ID -- which identifies the file you're looking for. It doesn't contain any IPs, nor does it need to. A hash is mathematically calculated from the exact contents of the file. Due to the extreme calculations involved, a hash nearly never refers to any other file on the planet. It's almost impossible to spoof.

Other users on the DHT network know about this hash -> contents relation, so when you say "someone, gimme the exact sequence of bytes that match this hash", they do, and you have your file!

Hope that explains things.

Share this post


Link to post
Share on other sites

Magnet Links, How do they work???

Srsly though, the poster before me is correct. Hash functions take in a big file and output a short string of characters which are (nearly) unique for that file. Some common hash functions you can read about are md5 and sha1.

Since a file will always output the same "digest", you can use that instead of filenames to refer to the content you want.

Share this post


Link to post
Share on other sites

technically, that's incorrect, dfine. a hash functions takes input of arbitrary length and produces output of fixed length. the input doesn't have to be big or a file.

Share this post


Link to post
Share on other sites

The initial bootstrap DHT peer on uTorrent is router.utorrent.com

Nobody answered the OPs question, I had the same question myself.

After the initial load, a cache of DHT peers is kept and used.

More reading:

http://stackoverflow.com/questions/1181301/how-does-a-dht-in-a-bittorent-client-get-bootstrapped

http://stackoverflow.com/questions/10999786/how-pex-protocol-magnetic-links-finds-it-first-ip

Share this post


Link to post
Share on other sites