1

In a perfect theoretical network, i'd be able to open connections from any peer to any peer. Life however works in a different way. If I'm to create a global peer to peer application, how do I get over this connectivity hurdle without investing in my own server farm.

My goal is to build an application where packets of xml can be sent between peers.

JasonGenX
  • 4,952
  • 27
  • 106
  • 198

1 Answers1

1

You need to learn about NAT traversal techniques. The simplest solution to implement is UDP traversal. You can also consider the JXTA/JXSE framework for a TURN-like NAT traversal implementation.

In all cases, you will need at least one server with a public IP address (but that's not a farm of course...)

Community
  • 1
  • 1
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • How one pierces a router/firewall without having specific setup in that firwall/router to do port forwarding. If running my application mandated router configuration, i'd lose 98% of my target audience. – JasonGenX Apr 20 '11 at 17:08
  • Bottom issue is finding out how private IP address on LAN is translated into public address on WAN. Hence the need of a public IP server that LAN peers can contact (and punch a hole in the process). Only the server can read the translation and communicate it back to peers. If you are using a non-blocked port, then no need to reconfigure firewall/router. – Jérôme Verstrynge Apr 20 '11 at 17:12
  • that's a big if. Most routers do block ports for security. Also, what happens if an incoming transmission comes in for a scenario where you have 5 machines behind NAT, all listening on the same port, and all translate the SAME due to the fact they all use the same router? how would the router know which computer to forward the incoming transmission to? – JasonGenX Apr 20 '11 at 17:15
  • Not that big. Administrators understand the need to open ports if an application is installed on their LAN. There is even a RFC recommending this for P2P. – Jérôme Verstrynge Apr 20 '11 at 17:22
  • Router is smart enough to translate 5 requests into 5 different combinations. – Jérôme Verstrynge Apr 20 '11 at 17:23
  • I wrote a book called Practical JXTA II discussing these NAT traversal issues. It is available online for reading at Scribd. – Jérôme Verstrynge Apr 20 '11 at 17:28
  • but how will a router know where to route an incoming NEW message if there are 5 clients listening on the SAME port behind it? I can't find an answer for this anywhere. This is obviously a conflict. no? – JasonGenX Apr 20 '11 at 17:31
  • The router uses a different port outside (on the WAN-side) for each 5 connections (for example 2000, 2001... 2005). So if something comes to 2005, it knows it is for peer 5. Like, that the peers can all listen to the same port on their device. – Jérôme Verstrynge Apr 20 '11 at 18:24