Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  P2P UDP over NAT  (Read 4191 times)
0 Members and 1 Guest are viewing this topic.
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Posted 2004-08-26 13:56:43 »

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.
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-08-26 14:18:48 »

Yep, it works, I've implemented it a couple of times for hobby projects.

Kev

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #2 - Posted 2004-08-26 14:50:35 »

does it work for firewalls as well? if they're basic 'outbound only' firewalls, they should work the same i suppose... (if not, it's as likely they don't work for any UDP, cause as far as i know, there's no distinction between a UDP 'request' and 'reply')

also, do you know if it limits the inbound traffic to the IP of the computer the outbound was sent to? or is this specific to the hardware?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2004-08-26 15:00:58 »

It works on _my_ firewall (belkin box) and worked on my old Linux firewall. It does indeed limit traffic to that originated from the IP and port you originally sent to.

Kev

Offline tom
« Reply #4 - Posted 2004-08-26 21:53:02 »

This method is also known as solicited udp.

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #5 - Posted 2004-08-29 23:05:48 »

As I understand it, this most often does not work.   Basically the A or B does not know what port to send to on the other end until a packet actually does get through.  This is caused by the firewall remapping ports, so if you send the from port 9999 in your code, the packet may leave from port 2222 on the firewall.

That leads to the need for one end to open a port so that the UDP packet can be accepted by that side and examined to see the port number that it must reply to, which will be in the UDP packet as the port on other side's firewall.

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #6 - Posted 2004-08-30 05:06:50 »

in which case, for firewalls, we're back where we started in terms of the user needing to know how to setup port fowarding and stuff.

but most ADSL modems are just designed to act as gateways to a local LAN using NAT. Good for security and both good and bad for the inexperienced.
As far as i know, they usually use the same port.

eg. if you can connect succesfully to a game of starcraft, then the packets must be coming in ok, and unless the starcraft host is smart enough to reply on any port other than the standard 6112 (and i think it's not...?), this would mean you couldn't even join a game on battle.net if your firewall wasnt set up properly for it.

however using this method, if you can join games ok, you should be able to host them as well, as battle.net would act as the go-between to let the host know someone's trying to connect and their IP.

maybe battle.net could implement a patch in starcraft where b-net notifies the host of the ip of anyone trying to join and the host sends out a single UDP packet to that IP, which allows them to join. even if it only worked for 30% of their affected players, those would be very happy people indeed. (i used to be one of them until i figured out our modem)

does anyone know how long it takes for the router to stop fowarding packets when the clients have both stopped talking to each other? or is there some way for them to detect the disconenct somehow
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2004-08-30 05:21:39 »

The timeout is firewall/forwarder specific.

Going back to the point, isn't the point that you have something in the middle that organises the connection. You 2 hosts first connect the organisation server in the middle via TCP. They then send UDP packets to the organisation server on ports agreed upon between the org server and the clients. The org server then tells each host its opponents IP and UDP port which the hosts begin sending to. After a few packets have been bounced both hosts start getting packets and the UDP connection is established. You still need to send a steady pulse of packets to keep the connection open.

Maybe I've missed something, it has been a while...

Kev

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #8 - Posted 2004-08-31 22:07:23 »

You could also look into uPnP.

I noticed that the Azureus BitTorrent client (written in Java, Open Source etc..) will automatically configure my router/firewall to forward the port it needs - very nice!

Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (239 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!