<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Networking, Games, and Virtual Environments : NAT Traversal</title><link>http://blogs.msdn.com/johnmil/archive/tags/NAT+Traversal/default.aspx</link><description>Tags: NAT Traversal</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>NAT Traversal</title><link>http://blogs.msdn.com/johnmil/archive/2006/10/29/nat-traversal.aspx</link><pubDate>Sun, 29 Oct 2006 20:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:896633</guid><dc:creator>John L. Miller</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/johnmil/comments/896633.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johnmil/commentrss.aspx?PostID=896633</wfw:commentRss><wfw:comment>http://blogs.msdn.com/johnmil/rsscomments.aspx?PostID=896633</wfw:comment><description>&lt;P&gt;Over the years I've done a lot of work on P2P protocols. One challenge which consistently arises is devising a good P2P NAT traversal strategy, i.e. one which doesn't require all data between clients be relayed through a server. &lt;/P&gt;
&lt;P&gt;Common wisdom divides NAT's into several categories, depending upon how they map internal to external endpoints, and what traffic is allowed into the private network. For example, 'cone', 'restricted', and 'symmetric.' Several strategies are specified to allow connections with one or more endpoints behind one of these NAT's to succeed and persist.&lt;/P&gt;
&lt;P&gt;Based on these categories (and a few additional heuristics), there's are several well-researched and tested work&amp;nbsp;to choose from. STUN (UDP NAT traversal) and STUNT (TCP NAT traversal) both provide good behavioral guidelines for NAT traversal, and there are several third party implementatoins of each.&amp;nbsp;Not to be left out, Microsoft's own Teredo protocol is a NAT traversal strategy similar to IP tunneling over STUN, and is built into Windows XPSP2 and later. &lt;/P&gt;
&lt;P&gt;Unfortunately, nothing's ever as easy as you'd hope. Within each of the NAT categories mentioned earlier there is a &lt;STRONG&gt;huge&lt;/STRONG&gt; variety of behavior. Some of a given NAT's behavior is intentional, some a resource-based compromise, and some can be chalked up to bugs. I don't believe any NAT-traversal strategy can succeed against the full set of intentional behaviors within a bucket (such as 'port restricted'), let alone the other kinds of challents. And so, there will always be machines behind NAT's for which all known P2P NAT traversal algorithms fail.&lt;/P&gt;
&lt;P&gt;Still, it works well enough to be incorporated into your application. If you have a good success detection mechanism and a back-up data relay, you can ensure all of your clients can talk to each other.&lt;/P&gt;
&lt;P&gt;Here's my (unsolicited) advice.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Don't trust the reliability claims of any NAT traversal mechanism unless you've seen good data on it based on wide (thousands of seats, at the least) deployment. Many people advertise success rates based on limited testing, because doing extensive testing is Hard.&lt;/LI&gt;
&lt;LI&gt;Always have a fallback. If you really, truly need any arbitrary pair of machines to be able to talk to each other, you're going to have to have some sort of a data relay, for example a server which can relay data as well as NAT traversal signalling.&lt;/LI&gt;
&lt;LI&gt;Don't try to invent a new NAT traversal mechanism yourself without knowing what else is out there. You might be the one person in a million who can do a better job, but there's a lot of great work which has already been done and tested. Make sure you read up on STUN, STUNT, and/or Teredo before you decide to roll your own. Trust me, making your own NAT traversal and having it work well isn't easy.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Good luck!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=896633" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johnmil/archive/tags/NAT+Traversal/default.aspx">NAT Traversal</category><category domain="http://blogs.msdn.com/johnmil/archive/tags/P2P/default.aspx">P2P</category><category domain="http://blogs.msdn.com/johnmil/archive/tags/Networking/default.aspx">Networking</category></item></channel></rss>