Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peer-to-Peer decentralized network - message to all peers

I need to create a file-sharing peer-to-peer network (without a central server).

I read a lot of information on the topic. The requirement is to make sure every peer in the network keeps a full list of the other peers and a full list of all the files on the network.

I know it's not the best way to do it, but it's a requirement so ... Another (in my opinion weird) requirement is that the communication between the peers should be implemented with the HTTP protocol and JSON-serialized.

This means every peer will act as a web-server and will also have a way to connect to every other peer.

So I want to know a good way to deliver a message from one peer to all others without having a single peer to connect directly to the others (too many connections).

I've been looking for a way to somehow route the message a few levels so the traffic will be somewhat distributed. As I know and can connect to any peer on the network I can effectively construct a route before the message is sent and then tell some peers to reroute it. But how do I figure out the best route? And what happens if there's a bugged peer which can't reroute the message?

EDIT: I'm sorry if I didn't make it clear. The message should be received by ALL peers on the network, not just one target.

EDIT 2: You can think of what I want to do as a network of web servers. They should be able to hold data distributed (not part of the question) but every one of them needs to know what resources are available on the network (a hash-table). A client can upload stuff on one of the servers (doesn't matter which one). When that happens ALL others need to know of this change to update their hash-tables. The same applies if a new server joins the network. My question is how to propagate this message without having a single server to connect to all the others, which clearly will generate a lot of traffic on a single server.

like image 330
stormbreaker Avatar asked Feb 16 '12 10:02

stormbreaker


1 Answers

I see your question divided in two components:

No central server

Popular p2p entities these days are botnets, which have C&C servers, and do use HTTP too. They tend to exploit DNS by using some kind of an algorithm to generate domain names. You need something to seed/bootstrap the process, otherwise the p2p platform won't start. Evolution can be done by propagation, that is, peers can get an initial list from a central location, then build up the DHT as they learn more from querying other peers (i.e. get more responses back).

For a p2p network without a central server, you can do a local network scan or use an implementation of zeroconf protocols such as SSPD. The restriction here is that you cannot grow beyond your local network. For instance, say you'd like to multicast beyond your LAN, what IPs/ranges are you going to try reach?

Messaging all peers

There is no guarantee for this to succeed, because you do not know at a given point in time which peers are active, and no single peer has a full copy of the DHT. Flooding is generally the way this is accomplished. You can adopt the query flooding strategy, but don't expect an answer back. You can use the same strategy for searches, where you actually want the answer back. In case you want to reach say only past 5 levels, you simply include a counter with the hash/id, that the peers decrement before propagating the message on, and stop when the counter reaches 0.

A big hurdle with this project is NAT. So, not only peers will need to know each others external IP and port. If you are within a LAN this is not much of a problem.

like image 151
Candide Avatar answered Oct 15 '22 12:10

Candide