I read this paper a while ago about the possibility of running P2P communications using UDP over NAT without the need to specifically foward the ports on either side. Just wondering if this is possible using java’s implementation of UDP. if it is, this’d be a great feature to put in a game, as it could possibly work for some types of firewalls as well, and not everyone knows how to foward ports on their ADSL modem.
many people don’t even know there is a setup page or how to get to it.
here’s the theory:
Client A tries to connect to client B (as if B were running as server)
this causes A’s router to begin fowarding replies on that port from B back to A.
Client B tries to connect to A. same thing happens: B’s router will now foward packets from A back to B
to put it very basically, both routers have been tricked into thinking the other is the server, and as both are now fowarding packets from the other to the right place, from now on, UDP packets will be recieved. now all that needs to be done is decide who is really the server and who is the client. probably a case of rolling a random number and seeing who’s highest.
of course for this to work, both clients need to know the other’s IP address. this could be achieved easily via MSN, or in more advanced cases, using a lobby server.
what’s the point to all this? well it would be nice to see this used in a few games, as it would allow players to host games from behind NAT routers and maybe some types of firewalls and would still work where there is no NAT. i have never heard of it being used in java before though.