UDP hole punching not going through on 3G

后端 未结 2 838
心在旅途
心在旅途 2021-01-30 07:12

I\'m trying to implement in a software a hole punching feature. The thing is, I\'m implementing this with an already made TCP Server to communicate with Users.

Here\'s w

相关标签:
2条回答
  • 2021-01-30 07:38

    The NAT you are behind is symmetric, or it changes your outgoing port number depending on your destination. Hole punching through symmetric NAT requires a different method (either TURN or UDP multi-hole punching). Try doing it this way: https://drive.google.com/file/d/0B1IimJ20gG0SY2NvaE4wRVVMbG8/view?usp=sharing

    0 讨论(0)
  • 2021-01-30 07:55

    Unfortunately, there is no 100% reliable way to perform NAT hole punching with UDP. At best, you can make some guesses about how NATs and firewalls will probably behave most of the time. But there will always be exceptions and they may not be rare.

    In this case, it sounds like you are using a central server to let two peers figure out each-others external port and then start sending data at each other. That's a pretty good algorithm. The problem is that the external port routing may vary depending on the destination. In other words, if A to B has an external port of 5000, there is no guarantee that A to C will also come from 5000. So having a central server record the port it sees may not help to connect anyone else.

    Here are a few related questions with some more details.

    • UDP Hole Punching Algorithm
    • UDP Hole Punching not possible with mobile provider
    • UDP hole punching host-specific failure
    0 讨论(0)
提交回复
热议问题