user739711
user739711

Reputation: 1872

UDP Hole punching: one Symmitric and another non-symmetric NAT

I am trying to implement P2P with Hole Punching. Here is the flow:

  1. Both Peers(P1,P2) will send 1 packet to server(S).
  2. Server(S) replies back to both telling others IP:PORT
  3. P1 and P2 receive this UDP packet knowing other's external/public ip:port.
  4. P1,P2 start sending packet to other peers public IP:PORT.
  5. Once peers receive other peer's packet, I assume the hole is punched and will give this socket to my Application.

I tested this on different routers, here is the outcome:

Until 4th Step its fine. But in 5th step, no peer receives the packet of other peer. I was expecting that at-least *'peer behind non-Symmetric NAT' will receive the packet of other.*

Anybody has any idea whats happening?

Upvotes: 6

Views: 2302

Answers (1)

John La Rooy
John La Rooy

Reputation: 304127

There is a paper here

Basically they use two servers S1 and S2.

By looking at the outbound ports they are often able to predict what outbound port would be used when P1 sends a packet to P2 and vice versa.

Apparently many routers just use incrementing/decrementing or some skip size

There is no guarantee of predicting the correct port. They end up sending a bunch of packets to different ports hoping that one will get through.

I have a different idea how to approach it, I'll need to find a symmetric-NAT to test it out :)

Upvotes: 1

Related Questions