[p2p-hackers] traversing NAT and Java

Adam Fisk afisk at speedymail.org
Sat Sep 17 20:33:27 UTC 2005


You could also create a Socket subclass that delegates to the TFTP 
implementation in the Jakarta Commons Net project.  This doesn't do the 
hole punching for you per se, but all you really have to do is send a 
packet in each direction just prior to starting the TFTP transfer, 
ideally using some for of session offer/answer protocol like SIP.  There 
is also a reliable UDP socket in LimeWire that subclasses Socket that 
you could extract pretty easily, but the transfer is a little sluggish. 

JXTA doesn't do any hole punching, unfortunately.  It just relays 
everything through non-firewalled relays.  It works and the API is 
elegant, but it's not very efficient.

As a larger point, though, the hole punching itself is much less of an 
issue than knowing which holes to punch.  The ICE draft lays out really 
the ideal way to do it, but it's complicated.  A simpler version using 
SIP and SDP may be the way to go, or you may have some home-grown 
solution that lets peers know the holes to punch.

Also keep in mind all the cases you have to deal with, such as symmetric 
NAT's.  Relaying is required in some instances, so you could look at 
TURN or use JXTA.  Again, ICE handles this very robustly, but it's not 
trivial, especially if you're implementing it from scratch.

-Adam


Davide Carboni wrote:

>Hi, I'm looking for a good and reusable Java implementation of NAT
>traversal solution like connection reversal,  UDP/TCP hole punching
>etc.
>I'm aware that JXTA provides NAT traversal but I do not want to
>redesign my applications with JXTA. I'm also aware of P2PSockets which
>hides JXTA under the hood but I've tried it without success and the
>project seems a little "inactive".
>
>Bye
>Davide
>  
>



More information about the P2p-hackers mailing list