8

I just read an article about the process of "punching holes" with the UDP protocol. I understand how it's done, but I have one last question to clear up things. We have the rendezvous server and client A,B.

Client A punched a hole already for client B. Client B receives the NAT IP and the NAT port from the rendezvous server and starts to send data to the same port as the rendezvous server. Let's say I happen to know a second port the NAT has open for UDP connections. Could I send my packets through this second port also? Or is the port distinguished for every outgoing UDP connection? If so, how come we can use the same port for Client B and the rendezvous server? Wouldn't the NAT open a new port when Client A punches the hole and Client B had to know what new port the NAT opened for this specific connection?

I hope my question is somewhat understandable.

2 Answers 2

6

The NAT device will keep a table with currently open connections so that it can send return packets to the internal host that opened the connection. An entry in the state table could look something like this:

Internal Source IP | Internal S-Port | External S-Port | Destination IP | D-Port
192.168.1.12         10123             10123             203.0.113.1      5555

When a packet is received (from the external side) the NAT device will check the Source IP, Source Port and Destination Port of the packet and compare it to the Destination IP, D-Port and External S-Port fields in its connection table. When it finds a match it will forward the packet to Internal Source IP on Internal S-Port.

UDP hole punching depends on the fact that Internal and External Source Ports are the same. This is normally the case unless you have a second internal host that uses the same Source port to connect to the same external Destination/D-Port combination.

When we assume that Internal and External S-Port are the same then both clients A,B can communicate their source port to the rendezvous server which will then relay the information back to the other client respectively.

0
0

There is an answer under similar question, pointed out "Symmetric NAT" which this type of NAT is called. Moreover, the answer mentioned the solution (TURN) under such situation.

Solution doesn't involve Symmetric NAT is called STUN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.