Advertisement

how to connect peer-to-peer behind router

Started by March 10, 2006 04:45 AM
8 comments, last by alexscorpion 18 years, 11 months ago
description: some inet supliers connects you to router and you have some IP but it is "unreal", "fake". i made network program but it fails to connect to such IP. the connections within the router area are possible as well, but from outside aren't! the question is: how some programs do connect to such "fake" IPs. Skype do, ICQ not so well, because chat is possible but you can't receive files. So, how to establish connection to my game users behind routers?
What man is a man, that makes world no better?
See The Forum FAQ; Q9, and the link.

You can "punch through" the router if you're using UDP (TCP is much harder and not as well supported), if you have an external server for matchmaking. If you want a purely peer-to-peer service without having a matchmaker server, then you just have to tell the accept()ing client to open the correct port on his/her router.
Advertisement
As more and more people start to use upnp capable routers, this will largely become a non-issue. In fact, I currently only support two methods, manual forwarding, i.e. making the user setup forwarding manually, and upnp forwarding. Though it does not solve the issue of multiple machines behind a nat, it does help. As then the one that does program the router forwarding can become an introducer for the other computers behind the router.

[Edited by - Mastaba on March 12, 2006 10:28:19 AM]
.
Mastaba: the UPnP device cannot be an "introducer" in the typical sense of the word, because the NAT punch mechanism won't work the same when half of the clients are behind the same NAT. If you assume that the NAT guards a LAN (and thus transmission is cheap) then you can use the UPnP client as a forwarder to the others -- that's not the same as introducer.

UPnP won't work through larger NATs, though, like a college, or a company, or an ISP. In fact, there are locations where you can't ever set up manual forwarding, so some form of punch-through with introduction is still necessary. It's such a simple technique -- you need to have a match-maker anyway, right?
enum Bool { True, False, FileNotFound };
i feel like lamer here :-|. i couldn't grasp anything that you said. would you repeat at low-level what manual forwarding is? i'm not complitely new at network programming (see here ) but most of the terms you used i never knew...
What man is a man, that makes world no better?
By "manual forwarding" I meant "port forwarding" while by "forwarder" I meant a machine that received data on one address, and then forwarded it to other machines explicitly.
enum Bool { True, False, FileNotFound };
Advertisement
so this is only hardware, notjing programmable?
What man is a man, that makes world no better?
For port forwarding, yes, it's specific to your firewall (although Universal Plug and Play may let your software control your firewall -- not sure this is a good idea :-)

For peer-to-peer NAT punch-through using introducers, it is programmable, but requires that at least one well-known host is visible to the greater internet (as described in my web page. If the terminology is currently over your head, then I suggest that you start working on basic networking first; once you're skilled at that, the additional gnarl of NAT will make more sense.
enum Bool { True, False, FileNotFound };
10x, i read it, it's cool with many links. i will set link to it at my site.

[Edited by - alexscorpion on March 17, 2006 4:03:31 AM]
What man is a man, that makes world no better?
i got the idea but what about the introducer? i can't figure out how to establish that practically? should i write my oun server or to use existing one? and hoe to connect to the other guy using introducer? how would the server know where i wish to connect? the real world application is still foggy to me.
What man is a man, that makes world no better?

This topic is closed to new replies.

Advertisement