NAT punch through

Started by
1 comment, last by Thorgrim 17 years, 6 months ago
I've recently been looking into making a game matching lobby, and am probably going to try to add NAT punch through. The only problem is that I would prefer to run a simple web host for the match making Lobby Server, so the Lobby Server itself can't really do the punch through. So I had another idea, how about if when a client connects to the server, it gives the server its IP. If the client is not behind NAT, everything can continue as usual, clients just use that IP. However, if the server is behind NAT, then the server will randomly assign the IP of another user who is in the lobby, and who does not have NAT, to this new server. Now, when a client attempts to connect to this server, he will instead connect to this other IP, lets call it the "delegated matchmaker", and this user will perform the matchmaking for the other 2. If the delegated matchmaker disconnects from the lobby, then another client is delegated, and so on. In this way, all the lobby needs to do is store an extra IP for any servers behind NATs. The only case I can think of where it would not work, is if the lobby only contains players who are all behind a NAT. But that shouldn't happen to often hopefully. Has anyone done something like this before? Can anyone see potential problems? Maybe some peer-peer software works in a similar way? (I haven't looked into that yet)
Advertisement
Yes, you can do this. As you say, there's some risk of everybody being behind NAT, though.

In fact, even if a user is behind NAT, he can be an introducer if he is using static port forwarding, so you should probably check for that, too.

You could always use your cable/DSL connection as a backup matchmaker (using port forwarding) if nobody else is available. I would not recommend relying on there always being players with no NAT available.
enum Bool { True, False, FileNotFound };
Yeah, thats not a bad idea...

It's not like it's a commercial game or anything though, so anything is better than forcing all players to un block ports.

Thanks for the comments anyway.

This topic is closed to new replies.

Advertisement