UDP hole punching not going through on 3G

后端 未结 2 839
心在旅途
心在旅途 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: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

提交回复
热议问题