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

1

6

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:

  • When P1 and P2 both are on non-symmetric-NAT (Full/Restricted cone), I don't face any problem.
  • When P1=Non-Symmetric and P2=Symmetric:
  • -----router-1 (Symmetric-NAT) + router-2 (non-Symmtric) = Success
  • ---- router-3 (Symmetric-NAT) + router-2 (non-Symmtric) = *Failure*

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?

Coffer answered 19/7, 2012 at 9:20 Comment(1)
I know this is a old question, but if one peer is full cone and the other is symmetric i believe there wont be any problem because full cone directly receives the first message and replies back to the endpoint it received. and then the tunnel will be created.Booster
T
1

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 :)

Thane answered 8/11, 2013 at 5:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.