Port-Forwarding and IP Distances

Community Forums/General Help/Port-Forwarding and IP Distances

Oddball(Posted 2011) [#1]
I'm a bit a novice when it comes to coding multiplayer stuff and was wondering if anyone could help with a few questions I have?

Firstly, the app which is acting as the server opens a port to receive data, but it will be unable to receive anything if the port hasn't been set for port-forwarding on the router. Now I know how to do this manually through my router, but I was wondering if there is a way that the app itself can do this for those players who aren't very technically minded?

Secondly, is there a way to determine the physical distance between to IP address? This would be extremely useful for pairing up players who are near each other and therefore reduce lag somewhat. I have seen other multiplayer games do this so it must be possible.

Any info would be most useful.


jfk EO-11110(Posted 2011) [#2]
I'm not an expert eighter. I think port forwarding isn't possible by code, esp. not in user (nonadmin) mode. And isn't port forwarding set in the router hardware anyway?? As far as I know portforwarding and firewall configuration is still one of those things multiplayers will have to go trough and it's also an ongoing issue for a dedicated community of howto-googlers. I could be wrong tho.

The physical distance (I think you only care about the lag?) might be calculated, simply by checking the lag to a certain user. Once there was PING, but I think nowadays many firewalls prevent ping calls from being answered. But since your game is running, you can easily do your lag test with some homemade tcp or udp handshakes by your own. What really matters is your MP archithecture. Is it peer to peer, or is there a central server? I assume you want a central server that manages many games where people can participate, but each game has its own local gameserver running, eg. for 8 users or so, and you want these game servers to be optimized geographically(?)
What you could do is a lag check from every player to every local gameserver (listed on the main server). So the game would download a list of IPs of local game servers and test the lag to each one of them.

Last edited 2011


Oddball(Posted 2011) [#3]
Non of the modern multiplayer games require you to set up port-forwarding, so if they're not doing it from code what are they doing?

I have a global list of games in play. I thought it would help to order that list by physical distance to assist the user in finding the least laggy connection. I'm not sure it'd be practical to contact all the games on the list just to test lag.

I did some heavy googling but came up empty.


xlsior(Posted 2011) [#4]
Now I know how to do this manually through my router, but I was wondering if there is a way that the app itself can do this for those players who aren't very technically minded?


There is a uPnP protocol that can have a computer initiate *some* router changes, but unless the router is compatible and configured to allow it, it won't work...
See here: http://en.wikipedia.org/wiki/Universal_Plug_and_Play
Universal plug & play NAT traversal through IGD.

In most cases you'll be out of luck, unfortunately.

One way many 'big name' games work around it is by having central servers: the clients make an outgoing connection to the server, and the server then relays the info from the various players to each other over this tunnel. Since it's outgoing rather than an unsolicited incoming connection this will work through any router.


Oddball(Posted 2011) [#5]
Thanks xlsior. I think I'm getting the idea now. I'd need a central server to allow access without port-forwarding. I don't think that would be practical for my needs. Oh well.


BlitzSupport(Posted 2011) [#6]
You should only need a central server to start the players talking to each other -- you don't have to have a central server controlling the whole game:

http://www.gnu-darwin.org/www001/src/ports/devel/raknet/work/Help/natpunchthrough.html

http://www.mindcontrol.org/~hplus/nat-punch.html

http://en.wikipedia.org/wiki/UDP_hole_punching


Oddball(Posted 2011) [#7]
This NAT punching sounds like just what I need, but I can't make heads nor tails of how to implement it. Does anyone have a BlitzMax example I could pick apart, nothing too complex.