Jump to content
  • Advertisement
Sign in to follow this  

Local NAT vs Internet NAT

This topic is 2199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Still having issues with Android and it is the last thing I have to do before selling my game.

My diagram is such as the matchmaking server and my phone are on the same router. I'm trying to play someone behind another router.


I assume that because of the server and my phone being on the same end, that connecting to the server, the routing/translation is different. Here is what I mean:

I know for a fact that both phones/routers can holepunch.
For each new port I can predict the next port to open.
I test this by opening ports in sequence and pinging the server. Each new port is the old one plus 256 for both routers.

So now I am at the point that I know both peoples next ports to open up. I don't do anything with those ports except try to connect to each other. They never send to anyone else but each other, and yet I can never have them talk to each other.

The only thing I can think of is that my phone is on the same LAN as the server and therefore those ports that the servers sees are some kind of internal ports, and that when I actually go outside the network, those ports would be completely different. That's the only thing I can think of. And when I send to the server I use the routers internet IP and not 192.168.0.x.

Anyone? I'm getting desperate.

Another small diagram:
Internal phone ports vs What the server sees. Guess next port and send each player what those ports should be.
port: 35000 -> 48270 || 35001 -> 48526 || 35002 -> 48782 || next port I save is 49038

port: 35000 -> 48370 || 35001 -> 48626 || 35002 -> 48882 || next port I save is 49138

Both phones then send to each IP and port that should be the next opened and nothing ever happens. They send and receive on those ports over and over ever 2 seconds. Edited by dpadam450

Share this post

Link to post
Share on other sites
Well that didn't help. But I sat on this issue ALLLLLL day hoping someone would help. And yet it did. Remember those good functions htons and ntohs for winsock? Yea so I just started up the client/server, and checked where the reply to client was actually coming from and it was not the servers dedicated/port forwarded port (8004) but instead (17439). So I was like damn it must be that conversion. Pop ntohs(17439) and what do you get? 8004!!! woooooo. Now lets hope this works tomorrow when I test.

And hairpin was not the the issue although it is hairpining. Damn issue was I never sent the right ports!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!