ntop / n2n

Peer-to-peer VPN
GNU General Public License v3.0
6.3k stars 945 forks source link

peer-to-peer communication between equal nodes #405

Open Logan007 opened 4 years ago

Logan007 commented 4 years ago

A more peer-to-peer-like approach was discussed at several occasions. I have had some thoughts about it I want to share as a discussion starter. I am aware that there are flaws and still problems to solve.

The following thoughts mostly are per-community (each community requires their own REG/ACK/node-list/anchor nodes):

So far, so good, But… here is where it gets beyond my network knowledge and imagination:

When forwarding/routing packets or broadcasting to unknown or all destinations, it will get a bit uncertain. If no node has full overview of the network, there must be some clever forwarding and routing strategies to

  1. make sure a node can certainly be found if present
  2. make sure that all nodes can be reached for a broadcast without double-sends
  3. ensure that network does not get segmented, i.e. breaks in distinct parts.

Item no. 3 cannot happen as long as at least one anchor node is available. If all anchor nodes get lost, there should still be a good chance for the network to survive (resilience) as long as a minimum number of nodes remains.

Items no. 1 and 2 need to be addressed with some more thoughts. That might include automatic MAC-address assignment by the help of the first node registered to (for some clever routing strategy somehow related to the MAC-addresses – key-based routing?).

P. S. I found Pastry, Kademlia and Batman somewhat inspirational.

Logan007 commented 4 years ago

Actually, I the ideas of Kademlia's routing based on the XORed node ID-metrics appeal to me and I would mark them as "quite interesting". It surely will work with 48-bit MAC addresses as well. Not so sure about the purge concept in case of full k-buckets.

On the other hand, the Kademlia approach would probably produce some overhead in terms of network-traffic to find nodes and has higher memory requirements for node lists / buckets. Nothing comes for free.

Especially broadcasts need to be addressed. The approach outlined in Efficent Broadcast in Structured P2P Networks as well as section 4 of P2P based intrusion detection might help.

fengdaolong commented 4 years ago

Thank you for putting forward the point-to-point realization theory. I am busy with my work and haven't been here to follow n2n for a long time. However, no one has followed up and participated in the discussion. Maybe it is because it is too esoteric or because it has few followers. But I believe that the direction of implementation is correct, it may take a huge amount of work to implement it, and a test environment with multiple nodes must be provided to test it.

Kademlia is a very clever protocol. Using the Kademlia protocol to achieve decentralization will be great, but there are several problems that cannot be avoided:

  1. As you said, when there are a lot of nodes, the network overhead generated by Kademlia in finding nodes cannot be ignored, and it will even affect the throughput of network transmission;
  2. Due to the complexity of the network and the network restriction methods of IDC service providers, after using Kademlia to decentralize, the success rate of NAT point-to-point penetration may be reduced or become unstable;
  3. Since many IDC service providers have banned popular P2P protocols, encryption or masquerading may be necessary at the protocol level to prevent blocked ports or network traffic.
Logan007 commented 4 years ago

I am not sure if you are able to follow the discussion on n2n's Discord channel. It seems it will take a step-wise approach. First (already huge) step is to add a resilient multi-supernode support. Very promising.

I am well aware that the opening post's elaborations are more of a vision rather than tomorrow's implementation…

By the way, I thought more of Kademlia's routing concept than the complete protocol. Just using the metrics inside n2n to know where to send the packets to in case of broadcast and look-ups. The rest would remain pretty much n2n. So, it would still be the hole punching by the help of some publicly accessible hole-punching-helper.

fengdaolong commented 4 years ago

I fully support your idea and let us work together to realize it.

Logan007 commented 3 years ago

I looked a bit deeper into Kademlia and want to put down some more or less related thoughts before I forget again:

But how about other functionalities of the supernode, which need to be taken over by the p2p network?