Jump to content
  • Advertisement
Sign in to follow this  
sylefeb

TCP/UDP through routers, firewalls, etc ...

This topic is 3868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I am developing a networked game. I have my own network library build upon basic TCP / UDP. One issue that I am starting to worry about is that many players will be behind routers. Is there anything I can do to avoid having players manually setup their router packet forwarding? I saw games successfully dealing with this issue (eg. a friend of mine plays two instances of WoW on two different computers behind his router, and he did not have to set up anything). Any idea how this is done? I know more on graphics than networking, so this may be a naive question ... my apologies in advance Thanks!

Share this post


Link to post
Share on other sites
Advertisement
If you use UDP, there is technique for getting through routers called NAT traversal. With TCP you either have leave it to the user to configure their router or offer to use Universal Plug and Play aka UPnP to configure it for them assuming it's supported and enabled.

Share this post


Link to post
Share on other sites
Quote:
Original post by sylefeb

(eg. a friend of mine plays two instances of WoW on two different computers behind his router, and he did not have to set up anything). Any idea how this is done?


It's the function of NAT.

Quote:
If you use UDP, there is technique for getting through routers called NAT traversal. With TCP you either have leave it to the user to configure their router or offer to use Universal Plug and Play aka UPnP to configure it for them assuming it's supported and enabled.


Only apply for hosting a server. Outgoing connections are generally not affected.

And in order to avoid other issues, many services use port 80.

Share this post


Link to post
Share on other sites
I thought this article from the FAQ explains NAT punchthrough pretty well.

Wish I had stumbled upon it before I had to figure it it all out on my own, hehe.

In a few words, your outgoing connections from the client will be transparently handled by the NAT (as long as outgoing connections aren't blocked, but that's not default behaviour unless you're behind a corporate firewall or something) - that is its main function. You'll only need to configure it if you're hosting a server - and want people to connect to you on a specific port.

Edit: Looks like Antheus has beat me to the... punch.

Share this post


Link to post
Share on other sites
I am too struggling with this.

The PC I run server on does not use router so no need to config this PC, right?

But the client (my friend in this case) has a router. We want him to be able to connect to me properly without having to configure his router for port-forwarding.

I do not understand the NAT Article properly, or I dont understand the API properly maybe, I am not sure..

I am using SDL_Net, TCP protocol

Anyone happen to have an example I could look at? The problem is clearly when I try to call :
temp_client.outdata = SDLNet_TCP_Open(temp_client.ipaddress);

I used :
SDLNet_ResolveHost(temp_client.ipaddress,SDLNet_ResolveIP(temp_client.ipaddress),80);

(tought maybe port 80 would work, but nope)

I can resolve his host with no problem..
Since I can also manage to accept an INCOMING connection from him I can recieve data (like a port for example?) if that helps in any way..

Share this post


Link to post
Share on other sites
Quote:
The PC I run server on does not use router so no need to config this PC, right?


That's correct.

Port forwarding is not needed for any client making an outgoing connection.

You only need port forwarding if you want to accept incoming connections, and have a router/firewall between the internet and the accepting machine. Thus, you may need port forwarding to "host" a game where players can host (like Quake).

The reason you can run multiple players behind a single router is that each connection gets its own port on the external router, and a unique connection for TCP is the entire 4-tuple "source ip address, source tcp port, destination ip address, destination tcp port."

Share this post


Link to post
Share on other sites
Well but there´s been talk about this NAT punshtrough..

Basicly what I mean is there´s TCP games out there which do not require manually Router config, is there not?

I want to do what they are doing..

EDIT :
Because basicly forwarding ports isnt something every average Joe can handle, so they wouldnt be able to use my application then...

[Edited by - Twixly on April 18, 2008 1:48:58 PM]

Share this post


Link to post
Share on other sites
You don't need to understand NAT punchthrough; you need to understand NAT.

With NAT, multiple *clients* behind a single NAT is not a problem (unless you use UPnP, which is a basically broken idea). And, with NAT, "client" means "initiator of a connection" (as opposed to "acceptor of a connection," which is a server).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!