p2p打孔有什么难处? [英] What's so hard about p2p Hole Punching?

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

问题描述

我正在尝试一些p2p网络.经过研究后,我了解到的最大障碍之一是"如果客户端位于NAT/防火墙后面怎么办" ,后来我发现了打孔技术,但并不一定保证它能正常工作.

据我所知,我不理解为什么它可能会失败,这是我到目前为止所知道的:



根据上图,这就是我了解如何建立成功连接的方式.

I am trying to experiment with some p2p networking. Upon doing some research, one of the biggest obstacle I learnt is "What if a client is behind a NAT/Firewall", later on I discovered about Hole Punching but that it is not always guaranteed to work.

As far a I understand, I don't understand why it might fail, This is what I know so far:



Based on the diagram above, this is how I understand how a successful connection can be established.

  1. Alice 通过创建与目录服务器的连接来加入网络(1).发生这种情况时, Alice的 NAT会创建从其公共IP到其本地IP的映射.
  2. 目录服务器接收连接,并将 Alice的公共ip:port存储在目录中
  3. 鲍勃执行相同的(2),加入网络并将其ip:port发布在目录中
  4. 爱丽丝希望与鲍勃进行交流.因此,她从目录中查找 Bob的 ip:port. (3)
  5. Alice 在她从服务器获取的 Bob的 ip:port上发送数据. (5)
  6. 由于 Bob 也具有从ip:port到其本地ip:port的映射,因此NAT仅将在 Bob的公共ip:port上接收到的所有数据转发到他的电脑.
  7. 爱丽丝的作品
    我希望我对自己所理解的解释很清楚.我的问题是,对此有何困难或不可靠?我肯定很想念一些东西.你能解释一下这是什么吗?
  1. Alice joins the network (1) by creating connection to a directory-server. When this happens, Alice's NAT creates a mapping from her public ip to her local ip.
  2. The directory server receives the connection and store Alice's public ip:port in the directory
  3. Bob does the same (2), Joins the network and publishes his ip:port in the directory
  4. Alice wants to communicate with bob. So she looks up Bob's ip:port from the directory. (3)
  5. Alice sends data on Bob's ip:port which she got from the server. (5)
  6. Since Bob also has a mapping from is ip:port to his local ip:port, the NAT simply forwards any data received on Bob's public ip:port to his computer.
  7. Same works for Alice
    I hope I was clear in my explanation of what I understand. My question is, what is so hard or unreliable about this? i must be clearly missing something. Can you explain me what it is?

推荐答案

一个问题是,爱丽丝NAT服务器中的NAT映射将在固定时间或不活动一段时间后超时.

One problem is that the NAT mappings in Alice's NAT server will time out, either after a fixed time, or after a period of inactivity.

第二个潜在问题是NAT服务器可能会限制Alice的NAT映射仅对Alice建立的TCP连接或Alice与所连接的初始IP"she"之间的连接良好". (换句话说,爱丽丝与鲍勃之间的直接通信可能会被阻止.)

A second potential problem is that the NAT server could make the restriction that Alice's NAT mapping is only "good" for TCP connections established by Alice, or connections between Alice and the initial IP "she" connected to. (In other words, direct communication between Alice & Bob may be blocked.)

以此类推.

问题在于NAT服务器的行为高度依赖于管理组织的配置/策略决策的方式.这些决定中的许多决定可能意味着您特定的P2P使用模式将无法可靠地工作……或根本无法工作.

The problem is that the behaviour of a NAT server is highly dependent on how the managing organization's configuration / policy decisions. Many of these decisions could mean that your particular P2P usage pattern won't work reliably ... or at all.

那么我关于打孔的整个想法是错误的吗?

So then is my whole idea about hole punching wrong?

不.这只是意味着它不会一直有效.

No. It just means that it won't always work.

这篇关于p2p打孔有什么难处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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