5

My P2P app needs to locate peers, but I don't want to hard-code a DNS address...

One example I've seen is bootstrapping via IRC, but I'd like to do this over HTTP/s if possible.

What are my options and techniques for bootstrapping a P2P app?

2
  • In effect most networks are decentralized meshes as you are talking about creating; so some good learning may be found in looking at the fundamental functioning parts of networks. How is it you plug a machine into a router and automatically can find all the other devices on that router? Looking at how DNS manages registrations, bootp/dhcp manages provisioning, and how these things handle being networked to share their facts (how do DNS entries propagate?)... and then after that, just go read up on meshes and some of the techniques they use in Erlang where meshes are a common design. – Jimmy Hoffa Nov 21 '13 at 22:20
  • Try this: stackoverflow.com/q/15956819/472495 – halfer Nov 22 '13 at 0:01
7

It's the easiest if you have a "mothership". Nowadays it doesn't have to be a single server, a SPOF, there are tons of cheap CDN (content delivery network) and cloud solutions.

Otherwise, borrow an idea from a software that is the most successful: bittorrent. Distributed hash tables (DHT) are simply beautiful. And if I'm not mistaken, you can piggyback your own software on the DHT network. DHT doesn't have to be bittorrent-specific, but there are millions of hosts in the bittorrent DHT network already, so why not use it for anything that you like? It's a huge free resource, the protocol is trivial, but there are already lots of libraries for it, it's like a gold mine.

Of course, DHT needs to be bootstrapped as well, but it's an already solved problem. You can collect a big list of known DHT hosts, or just probe randombly, it is so huge that either can work.

Bittorrent's DHT is simple: every torrent has a hash, and the DHT network stores a peer list for each hash. All you have to do is make up a fake, fixed hash for your needs and store that in the DHT. You can help bootstrapping if you create a few DHT nodes yourself that are close to your fixed hash, but it won't be necessary.

Well, it's actually not a completely free resource, if you participate in the DHT network, then you should also participate in the storage of other hashes, and other peers will use your peers as a service.

5
  • Is Bitcoin considered a DHT like BitTorrent? I'm more familiar with Bitcoin internals than BT. Any suggested starting points for learning BT? (keywords, etc). My main language is C# – halfbit Jan 7 '14 at 14:47
  • DHT is an umbrella term, it's useful to start with wikipedia: en.wikipedia.org/wiki/Distributed_hash_table. Bittorrent DHT is specified here, it's quite simple: bittorrent.org/beps/bep_0005.html. It also envolves bencode'ing, it's also quite simple: wiki.theory.org/BitTorrentSpecification#Bencoding. Other than that, it's just sending packets through the network, nothing too serious. – fejesjoco Jan 7 '14 at 14:52
  • DHT won't work until p2p bootstrap. – Basilevs Jan 7 '14 at 20:50
  • Technically, yes, DHT needs its own bootstrapping. But it is a viable peer location facility in itself, with all its problems already solved, and with a really huge network. – fejesjoco Jan 7 '14 at 20:53
  • No Bitcoin is no DHT. It uses an unstructured p2p network. – Alexander Theißen May 5 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.