Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
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  
  Getting UDP through NAT/firewalls/whatever...  (Read 1049 times)
0 Members and 1 Guest are viewing this topic.
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Posted 2004-01-08 21:25:29 »

I came across this today on a Mac gaming mail list.  The author is Wade Williams a Systems Engineer at Cisco Systems.  I'm going to assume that makes him an authority on the matter Smiley
Reproduced without permission (it was on a public email list Smiley)
Quote
     From:         ******@mac.com
     Subject:       Re: Getting UDP through NAT/firewalls/whatever for a game.
     Date:       January 8, 2004 5:38:27 PM EST

<snip>
In a complete example, what would happen is:

1)  Client logs in with TCP connection to pass username/password, etc.  Client also tells server what port to send an unsolicited UDP packet on.

2)  Server tries unsolicited UDP connection.  If it works, it uses that for this client.

3)  If client does not receive unsolicited UDP packet in a specified amount of time, it starts sending UDP messages to the server (in essence, a UDP "ping") in order to allow the now solicited messages from the server to return.  As someone suggested, one every 15 seconds or so would probably work fine.

4)  If after sending the UDP messages to the client, the server is unable to get an acknowledgment from the client that its UDP messages are being received, the server begins sending over the TCP connection.

Now, with all that said, the code to send the UDP ping doesn't really add any significant overhead, so you're probably better off by simplifying things and leaving out steps 1 and 2, since they're unlikely to work in a large number of scenarios.

Note that if there's any way possible, you *should* provide the ability to fall back to TCP only.  This will work a lot better than you think.  It works great for our multiplayer flight sim.  UDP should be used if possible, but you'll be surprised at how well TCP works.

Wade


"solicited UDP" being defined as a process where the client repeatedly sends UDP packets to the server (above it says 1 every 15 seconds) so that the NAT/firewall keeps a mapping between the client and the port it uses on the other side.

Many of you are likely aware of this technique, but I figured I would post it for newbies.  I probably should put it on the Wiki, but first I post it here for comments.

Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2004-01-08 22:37:07 »

Nice, thanks SWP!

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (12 views)
2014-10-25 15:46:29

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (45 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!