udp 打孔器和端口限制锥 NAT

发布于 2024-12-13 14:03:45 字数 694 浏览 6 评论 0原文

我想了解当端口限制锥体 NAT 后面的两台主机建立连接时,udp 打洞是如何工作的。

据我了解,它发生在几个阶段并涉及三个主机。

主机 A 和主机 B 位于端口限制锥 NAT 后面。

主机 C 是一台服务器,可以接收来自主机 A 和 B 的数据包。

  1. A 向 C 发送数据包。
  2. C 发送数据包。
  3. C 接收来自 A 的数据包并确定 A 的外部地址:端口对 B 向 C 发送数据包。 C 接收来自 B 的数据包并确定 A 的外部地址:端口对 B B 的外部地址:端口
  4. 对 C 将 B 的外部地址:端口发送到 A
  5. C 将 A 的外部地址:端口发送到 B
  6. A 将 packet_1 发送到 B 的外部地址
  7. B 将 packet_2 发送到 A 的外部地址

问题是:

A 后面如何限制锥NAT从 B 接收到一个数据包,该数据包也在 限制锥 NAT?

端口受限锥形 NAT 不允许接收其发送的报文中源地址:端口对与目的地址:端口对不匹配的报文。为什么A和B之间发送的其他数据包会到达A和B?

是否因为端口限制锥体 NAT 将 packet_2 视为来自 B 的响应?

所以 packet_1 会丢失,但 packet_2 会到达 B。我说得对吗?

先感谢您。

I would like to understand how udp hole punching works when two hosts each behind the port restricted cone NAT establish connection.

As I understood, it happens in several stages and involves three hosts.

Host A and host B are behind the port restricted cone NAT.

Host C is a server that can receive packets from the hosts A and B.

  1. A sends a packet to C.
  2. C receives packet from A and determines A's external address:port pair
  3. B sends a packet to C.
  4. C receives packet from B and determines B's external address:port pair
  5. C sends the external address:port of B to A
  6. C sends the external address:port of A to B
  7. A sends packet_1 to B's external address
  8. B sends packet_2 to A's external address

The questions are:

How can A behind the restricted cone NAT receive a packet from B which is also behind the
restricted cone NAT?

The port restricted cone NAT do not allow packets, in which the source address:port pair does not match the destination address:port pair of packets sent by it, to be received. Why do other packets sent between A and B arrive to A and to B?

Is it because the port restricted cone NAT considers packet_2 as the response from B?

So packet_1 will be lost but packet_2 arrives to B. Am I right?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

擦肩而过的背影 2024-12-20 14:03:45

仅供参考,这里有一篇论文,它解决了您的问题并提供了 NAT 的详细概述。 pdf 版本可在此处获取。

FYI, here's a paper that addresses your questions and provides a detailed overview of NAT. A pdf version is available here.

潜移默化 2024-12-20 14:03:45

首先,受限圆锥 nat 意味着如果 A 与 C 通话,假设 B 不在 nat 后面,则 B 无法使用 A 和 C 之间打的孔与 A 通信。意思是,nat 遍历在这种情况下不起作用。

位于受限锥体 NAT 后面的 A 如何接收来自 B 的数据包
这也位于受限锥体 NAT 的后面?

在这种情况下,则是另一种情况,称为发夹状态。也就是说,nat后面的B可以使用A从nat后面翻译过来的地址吗?有些人妥善处理了这个案子,有些则不然。

在您的情况下,即使您的 nat 正确处理发夹条件,B 的数据包也不会因为“受限锥体”而被转发。所以,结果是一样的。

为什么A和B之间发送的其他数据包会到达A和B?

在你的情况下他们不会。

First, restricted cone nat means if A talks to C, B cannot use the hole punched between A and C to communicate with A assuming B is not behind the nat. Meaning, nat traversal does not work in this case.

How can A behind the resctricted cone NAT receive a packet from B
which is also behind the restricted cone NAT?

In this case, it is a different situation, called hairpin condition. In other words, can B behind the nat use A's translated address from behind the nat? Some nats handle this case properly, others don't.

In your case, even if your nat handles hairpin conditions properly, B's packets won't be forwarded because of 'restricted cone'. So, the result is the same.

Why do other packets sendeded between A and B arrive to A and to B?

They won't in your case.

七禾 2024-12-20 14:03:45
A sends packet_1 to B's external address
B sends packet_2 to A's external address


How can A behind the restricted cone NAT receive a packet from B which is also behind the restricted cone NAT?

Is it because the port restricted cone NAT considers packet_2 as the response from B?

So packet_1 will be lost but packet_2 arrives to B. Am I right?

您完全正确,请阅读有关如何 Skype 有效,这就是您要找的

A sends packet_1 to B's external address
B sends packet_2 to A's external address


How can A behind the restricted cone NAT receive a packet from B which is also behind the restricted cone NAT?

Is it because the port restricted cone NAT considers packet_2 as the response from B?

So packet_1 will be lost but packet_2 arrives to B. Am I right?

You're absolutely right, please read about how skype works, it's what you looking for

眼波传意 2024-12-20 14:03:45

我写了一个:PyPunchP2P。看看是否有人可以利用它。

I've written one: PyPunchP2P. See if someone can make use of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文