I'm doing some mobile project, that need to P2P communication with two devices.
And I faced with problem. (cause it's rare that smartphone have public ip)
I found some answers. It is 'UDP Hole Punching'.
I guess I understand about 'UDP Hole Punching' 100% conceptually, and write some codes. But it doesn't work.
This is my situation.
Device A connected NAT(A) for Wi-Fi.
Device B connected NAT(B) for Wi-Fi.
NAT(A) and NAT(B) is different one.
Relay Server S bind socket and waiting for devices. (S is WebServer but Network Status is good.)
At the first, A and B send dummy packet to S. Then S save UniqueID(to tell A and B), Public IP, Port.
And S send information to each device A and B.
Like this:
- IP Address and Port Number about A. -> send to B
- IP Address and Port Number about B. -> send to A
Now A and B send UDP packet to other device based on information(IP Address and Port Number) from S.
(15 per second. using same socket that used server-device session)
But it's not working. (actually intermittently work. maybe once in 10 times? and I don't know why success and fail. there is no any tiny little common relation.)
I think it's not NAT Type problems. I tested South Korea and 90% NAT in South Korea is not Symmetric Cone.