Reaching behind routers with UDP?

Hey.
I’m trying to make a small space shooter type game just for kicks…
After pondering for a long time (and reading the UDP vs. TCP thread) Ive pretty much come to the conclusion that UDP would be the best alternative given the need for limiting stuttering and delays caused by re-sends (and the fact that i dont care if i loose packets)…

I’ve previously played around with TCP, creating a server that listened for connections and allowed all connected clients to chat with each other. This worked great as the server was just receiving TCP connections and then responding down the same tunnel.

This tunnel does however not exist with UDP… So how do i respond to the given clients that are behind routers?
There must be a solution for this since there are basically no FPS shooting games that you as a client need to set up port forwarding for.
I’m pretty sure UT3, BF2, HL2, Quake, etc… use UDP and ive never set up any forwardning when using them.

Thanks for the help :slight_smile:

Sounds like you want NAT punch through.

[quote]if two computers both behind NAT try to connect
[/quote]
Hmm, so is this not a problem if I always have one computer not behind NAT (the server) I though UDP dident create a way for the other computer to respond back.

The client will always make the first connection to the server (asking if it can connect), the server will never be behind a NAT.
I then want the server to respond to this request…

This is where i thought the problem was. That using UDP it could not respond to the client if the client was behind a NAT.
Was this a missunderstanding on my part?

Failing NAT Punch Through (which requires a 3rd party machine to arbitrate for it) wasn’t there some way of doing this with UPnP?

Cas :slight_smile:

Although UDP is technically stateless, most NAT firewalls will actually maintain a mapping of source IP to outgoing IP+port. So as long as your client talks to the NAT-less server first the server can respond. So yeah, if you’ve only got a nat on the client end you don’t need to do anything.

great, that removes a headacke :wink:
for those not so lucky, i found this while googling, a java library to configure UPnP (http://en.wikipedia.org/wiki/UPnP) devices

The link goes to an example of a NAT mapping using the lib
http://www.sbbi.net/site/upnp/docs/natmappings.html

[quote]most NAT firewalls will actually maintain a mapping of source IP to outgoing IP+port.
[/quote]
Gonna try that out, right away, I’l post back with success/failure :wink:

Tested it now, if the person behind the NAT makes a connection to the server the server can respond :wink: