简体   繁体   English

NAT后面的两个主机用于P2P文件传输的协议是什么?

[英]What protocol to use for P2P file transfer for two hosts behind NAT?

I am trying to build an application that does p2p file transfer between hosts using Java. 我正在尝试构建一个使用Java在主机之间进行p2p文件传输的应用程序。 It works fine for hosts that have public IPs, but failed when I test it on my home computer. 对于具有公共IP的主机,它工作正常,但是当我在家用计算机上对其进行测试时,它失败了。

Then I find that all computers in my house have same IP. 然后我发现家里的所有计算机都具有相同的IP。 So, I conclude that my ISP uses NAT overloading. 因此,我得出的结论是,我的ISP使用NAT重载。 If my ISP does that, chances are lots of other ISPs do NAT too. 如果我的ISP这样做,那么很多其他ISP也会进行NAT。 I want my application also works even behind NAT. 我希望我的应用程序甚至在NAT之后也可以使用。

I did some research and found that UDP may be more suitable in this case because UDP hole punching works much better than TCP hole punching. 我进行了一些研究,发现UDP可能更适合这种情况,因为UDP打孔比TCP打孔好得多。 Is it true? 是真的吗 To be honest, I prefer to use TCP, but if UDP works better then I have to use UDP. 老实说,我更喜欢使用TCP,但是如果UDP工作得更好,那么我必须使用UDP。 (I know UDP is not reliable. I need to build some rdt protocol on top of UDP.) Or are there any other good algorithms that I missed? (我知道UDP是不可靠的。我需要在UDP之上构建一些rdt协议。)或者我错过了其他好的算法吗?

You can simple use UDT for this purpose. 为此,您可以简单地使用UDT。 It is an open source, high-performance and well-tested protocol written on top of UDP. 它是在UDP之上编写的开放源代码,高性能和经过良好测试的协议。 Basically its Reliable UDP with support for P2P connections and specially optimised for high-performance data transfer. 基本上,它的可靠UDP支持P2P连接,并针对高性能数据传输进行了特别优化。

The Actual UDT project is hosted at following location, http://udt.sourceforge.net/ 实际的UDT项目托管在以下位置, http://udt.sourceforge.net/

The Java version of UDT can be found here, http://sourceforge.net/projects/udt-java/ 可在以下位置找到UDT的Java版本: http://sourceforge.net/projects/udt-java/

我建议在两个同级之间使用一台服务器,即使该服务器不是您的服务器-也许是Google Drive还是Dropbox?

您是否尝试过使用任何STUN方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM