Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (5 posts)

NAT Punch-through in p2p games

Last post 12/18/2007 3:22 PM by Brandon Bloom. 4 replies.
  • 12/16/2007 2:51 PM

    NAT Punch-through in p2p games

    Hi.
    I am using System.Net for my online games, so i don't have to force my players to pay 99$ for a XNA Creators Club membership. How would you do NAT Punch-through with System.Net, so that firewalls don't block game connections? I found this paper on the internet: http://www.mindcontrol.org/~hplus/nat-punch.html , but still don't understand it. How can to players behind a firewall suddenly start talking to each other, just because they both had a connection to my "master" server? Also, has anyone a NAT Punch-through C# sample they would like to share?

    Thanks
  • 12/16/2007 4:56 PM In reply to

    Re: NAT Punch-through in p2p games

    1) Its extremely non-trivial
    2) It doesn't always work, especially if you don't have a wide range of home routers to test
    3) You'll need to run your own dedicated server to perform the punch through process

    UPnP may be "good enough" without doing all the world involved in a NAT punch-through. Start there.
  • 12/17/2007 12:35 PM In reply to

    Re: NAT Punch-through in p2p games

    The main problem with implementing your own NAT traversal (apart from just that this is very complicated) is that every NAT is slightly different. There isn't any one single algorithm that you just code up and then it works: instead you have to tune your code for hundreds of different NAT behaviors, build up a giant database of how NAT systems from different vendors work, design heuristics to detect what kind of NAT (or NATs) you are behind, then figure out how to tweak your algorithms so they work slightly differently from one NAT to another.

    This is not fun, not sexy, and requires a huge testing lab to get access to all the different hardware and network configurations.

    There is a good reason why there are so few successful NAT traversal implementations out there today! The one provided by LIVE is the best I know of, and that wasn't exactly cheap to develop :-)
  • 12/18/2007 2:05 PM In reply to

    Re: NAT Punch-through in p2p games

    Ok, so i have to forget all about NAT traversal. But UPnP could be a good feature, since most modern routers support UPnP, right? Or is using UPnP also very comlicated?
  • 12/18/2007 3:22 PM In reply to

    Re: NAT Punch-through in p2p games

    I'm sure the Win32 APIs or some Microsoft library somewhere can do this.... running a Google for "C# UPnP".......aaaaaannnddd....here:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/network_address_translation_traversal_reference.asp

    Looks like it is COM. Should be pretty easy to use with Visual Studio. Just add a reference to it; that will generate a .net wrapper. There are probably tutorials and stuff online.
Page 1 of 1 (5 posts) Previous Discussion Next Discussion