首页 文章

什么时候使用TCP打孔技术?

提问于
浏览
3

我正在研究 TCP hole punching 技术并从本文中获得了一些知识:TCP_hole_punching . 但我不明白以下部分:

Network Drawing
      Peer A ←→ Gateway A ← .. Network .. → Gateway B ←→ Peer B  

      Types of NAT
      The availability of the TCP-hole-punching technique depends 
      on the type ofcomputer port allocation used by the NAT. When 
      two peers, A and B, instantiate TCP   connections by binding 
      to local ports Pa and Pb, respectively, **they need to know 
      the remote  endpoint NAT port in order to make the connection**.

这里有一些问题,有人可以帮忙解释一下吗?任何帮助或建议将不胜感激!

Q1 . 假设我们在NAT1后面运行一个客户端应用程序,在NAT2后面运行一个服务器应用程序 . 他们将进行消息传递和文件传输通信 . 该模式将是服务器侦听并接受来自客户端的连接 . Do they need to use the TCP hole punching to keep the tcp connection work?

Q2 . Is the TCP hole punching technique necessary only when it's peer to peer communication and both parties are connecting to each other (e.g., 2x CONNECT(), no LISTEN(), ACCEPT(), etc.)?

Q3 . 在上面的文字中,"they need to know the remote endpoint NAT port in order to make the connection"是什么意思? Why do they need to know the remote endpoint NAT port?Don't they only need to know the local port of the other machine?

例如,假设该对是(ClientA,publicIPA,LocalPortA),(ClientB,publicIPB,LocalPortB) . 如果ClientA想通过TCP与ClientB通信,它可能会执行以下操作:

clientBAddr.port = LocalPortB;
         clientBAddr.ip = inet_addr(publicIPB);
         connect(fdA, clientBAddr,...);

为什么需要知道NATPortA和NATPortB等信息?如果clientA和clientB不关心NATA和NATB,有什么问题吗?

1 回答

  • 1

    由于这篇文章重新开放,直到现在还没有人留下答案,我想根据这篇文章自己回答:Peer-to-Peer Communication Across Network Address Translators

    关于Q1,是的 . 如果没有像打孔一样的机制,一方用来与另一方同步的数据包将被路由器丢弃 .

    关于Q2,没有确切的 . 听力套接字无法直接使用 . 你需要其他技巧 .

相关问题