Sign in to follow this  
makerm2

SDL_net UDP punchthrough NAT problems

Recommended Posts

Hi - sorry if I missed a post - I've searched here and google on this... I am trying to use NAT UDP Punchthrough to have 2 clients behind firewalled NATs communicate directly to eachother [using a common public initialization server]. I've tried this with SDL_net. My test program seems to work fine when the ports are forwarded on at least 1 client correctly (the clients both connect to the server, and send eachother packets on the IP/port the server relays to each client)... Clients receive UDP packets from eachother. However, if both clients are behind a NAT, and they try to send UDP packets to eachother, none get through - I've tried sending 1 packet, and sending many packets (for a 4 second duration), with no luck. My main computer that I am trying this on uses a normal linksys router... The only thing I think might be causing this is in SDL_net, I am not binding ip addresses to a channel - I am just 'listening locally' and specifying each packet's IP address... But then again, that doesn't seem logical as my program works if one of the clients has it's ports forwarded. I've read up a lot about this, and the only thing that should really matter is which public IP / port each client is sending from - and those are the ip/ports the server is relaying... Am I missing something? Any help would be very much appreciated, as I've been trying for a week to solve this =]

Share this post


Link to post
Share on other sites
In your second case (when it doesn't work), do you have both (or at least one) NAT routers set to open/forward proper ports?

Without port forwarding on at least one router, you will not be able to communicate, unless data is proxied by the server.

Or did I misunderstand your situation?

Share this post


Link to post
Share on other sites
Well, according to: http://www.mindcontrol.org/~hplus/nat-punch.html , and several other articles, you can send packets directly between 2 nats that do not have any ports forwarded.

snippet from article:
"
Hey! Joe just sent a packet straight to Bob!

Bob does the same thing going the other way. Suddenly, with a little help from the introducer server out on the network, these friends can talk to each other. The cool thing is that whatever traffic goes on between these peers does NOT go through the central server. Other than letting the clients find each other ("matchmaking") the server gets out of the way.
"

Has anyone had any experience doing this? I've tried to find example code for SDL_net to no avail...

Share this post


Link to post
Share on other sites
Do you have access to the firewalls on both ends? Do you have access to the network interfaces on both ends, so you can dump the packets and see what's being sent?

It may be that one of the firewalls is using symmetric NAT instead of the better cone NAT, and thus allocating a new port for the second stream (out to the other client), which means that NAT will fail. This is one of the reasons why UDP NAT is "90%" compatible, not 100%.

tcpdump or Ethereal ought to show you what's going on on each side of each NAT, if you can hook it up correctly.

Share this post


Link to post
Share on other sites
It works, and I feel kinda dumb ^^ It was my work's symmetric NAT that was causing the problems... I just had to include another normal linksys router'd computer and all works as expected... ty guys for the help =p

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this