3

I'm building a system that relies on a central server to send the IP address and port of the first user (on mobile or desktop app) to a second user (on mobile or desktop app). The second user establishes a P2P encrypted connection with the first user, using the IP address and port sent by the central server, to send a large file directly (ideally, the actual file doesn't pass through the central server).

This system needs to work even if the users are behind different firewalls / NATs and on mobile or desktop devices, without requiring users to manually open ports.

I've been looking into NAT Traversal Protocol (Teredo IPv6), libjingle (Google's open source suite), STUN, direct socket connections, and direct VPNs between the users.

I'm confused if I'm approaching this correctly. Would all of these options solve this problem independently? Or am I approaching this wrong? Would direct IPv6 connections would straight out, even behind IPv4 routers?

alyx
  • 2,593
  • 6
  • 39
  • 64
  • 2
    You can't (yet) assume that both parties have IPv6, though if they do, then making the connection is trivially direct. You only need all these other workarounds because of the limitations of IPv4 and the monstrous kludge that is NAT. – Michael Hampton Mar 19 '14 at 02:09
  • http://stackoverflow.com/a/8524609/104458 – selbie Mar 27 '14 at 05:59
  • This project might be helpfull https://samy.pl/pwnat/ – BBK Jan 09 '19 at 20:17
  • Here is my question, related to yours, but not exactly https://stackoverflow.com/questions/54118006/vpn-with-webrtc-stun-ice – BBK Jan 09 '19 at 21:11

1 Answers1

1

P2P connection is not guaranteed to succeed always. It can fail for the following reasons: 1) Two peers are behind symmetric NAT. (Although Teredo works if one peer is behind symmetric nat.) 2) UDP is blocked 3) If the peer is behind proxy. 4) Double NAT scenarios. There are three types of ipv6 address - link local, private address & global. Two peers can connect directly over the internet if they have global address. Global address prefix is (200:....). If your building P2P system, you should have fallback mechanism in which case the central server should relay the data between the peers. This way you can make your application reliable at the time make connection faster for most peers using p2p.

dvasanth
  • 1,337
  • 1
  • 9
  • 10