I want to connect two devices that are in different locations but connected to internet, a computer running windows 10 and a smartphone android. The application is a simple UDP socket to transmit data between them, but I have different scenarios.
1st Scenario. PC with Public IP and Smartphone behind 3G/4G CG-NAT) The PC opens de UDP socket and the Smartphone connects to the public IP, easy and fast.
2nd Scenario. PC behind a NAT with public IP and Smartphone behind 3G/4G NAT)
Option A) The PC configures a port forwarding to the NAT to it’s internal IP and then the Smartphone connects to that public IP. Easy but not fast because client has to configure the NAT.
Option B) Use UDP HOLE PUNCHING to open a hole on the NAT and then the client connects to it.
3rd Scenario. PC and Smartphone both behind CG-NAT. Here is my problem, PC sometimes is behind a CG-NAT, maybe because of ISP using this technique or maybe connected to internet using Wifi Hotspot from another Smartphone. As far as I know, I can’t configure CG-NAT with any protocol (UPnP, PCP, etc…), so I can’t do port forwarding. UDP Hole Punching is neither an option because of the “port randomize”, so the ISP changes my source port when going outside the CG-NAT and this changes for each connection.
I’m developing a project that relies on this, direct connection between a PC and Smartphone without technical details, and working always that both clients have internet, never mind if firewalled, behind NAT’s, etc… I was thinking about using a 3rd cloud server with public IP to connect them BUT just for stablishing the connection, not to forward all the traffic because this adds latency and traffic costs to my project which are not affordable. So… is there any technique to give a solution to my problem?
Thanks!