UDP/TCP打孔vs UPnP vs STUN vs? [英] UDP/TCP hole punching vs UPnP vs STUN vs?

查看:150
本文介绍了UDP/TCP打孔vs UPnP vs STUN vs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作一个P2P程序,并且需要有关通过客户端NAT的帮助. 我在这里已经阅读了许多关于stackoverflow的问题,但是我从不了解通过NAT的所有方法的弊端和好处是什么. 有多少路由器支持哪些方法? 大公司通常使用哪些方法? (BitTorrent,TeamViewer等) 我列出的三种方法的弊端/好处是什么?还有哪些?

解决方案

UPnP需要路由器中的软件支持.即使路由器具备此功能,出于安全考虑,有时也会将其关闭.

STUN使用一个简单的公共服务器来检测NAT和真实IP地址的存在.这对于执行有用工作的其他更高级别的协议很有用.

打孔是连接两台计算机的简单技术.它需要第3台公共计算机才能在NAT之后的2台计算机之间进行通信.您可以使用自定义协议运行自己的服务器,我们可以使用STUN和现有的STUN服务器. (设置只需要几个数据包,其余的都是对等的.)

当然,某些NAT防火墙与上述不兼容,因此您可能需要自定义协议. Bittorrent就是这样做的:他们使用不同的技术,具体取决于哪些客户端位于防火墙后面,而不是.

I try to make a P2P Program and need help with getting through the NAT of the clients. I have read many questions here on stackoverflow, but i never got what the drawbacks and benefits of all the Methods to get through a NAT are. How many routers support which methods? Which methods are commonly used by the big companies? (BitTorrent, TeamViewer,...) What are the drawbacks/benefits of the three methods i listed and which else exists?

解决方案

UPnP requires software support in your router. Even when routers have it, it's sometimes turned off due to security concerns.

STUN uses a simple public server to detect the presence of NAT and the real IP addresses. This is useful for other, higher-level protocols that do the useful work.

Hole punching is a simple technique to connect two computers. It requires a 3rd public computer to communicate between the 2 computers behind NAT. You could run your own server with a custom protocol, our you could use STUN and existing STUN servers. (Only a few packets are needed for setup, the rest are peer-to-peer).

Of course, some NAT firewalls are incompatible with the above, so you may need a custom protocol. Bittorrent does this: they use different techniques depending on which clients are behind firewalls and whatnot.

这篇关于UDP/TCP打孔vs UPnP vs STUN vs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆