<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://eddyzhoufeng.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2feddyzhoufeng.spaces.live.com%2fcategory%2fP2P%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>流　　浪　　的　　枫　　之　　羽: P2P</title><description /><link>http://eddyzhoufeng.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=catP2P</link><language>en-US</language><pubDate>Tue, 02 Sep 2008 03:49:30 GMT</pubDate><lastBuildDate>Tue, 02 Sep 2008 03:49:30 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://eddyzhoufeng.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>-2510522667657978555</live:id><live:alias>eddyzhoufeng</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>P2P穿透NAT的思路</title><link>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!798.entry</link><description>&lt;div&gt;
&lt;div&gt;在微软的 NAT 技术文档&amp;quot;How NAT Works&amp;quot;中可以发现: http://technet2.microsoft.com/WindowsServer/en/library/0f4bad59-5237-4452-a693-708ac61fe1671033.mspx 如果无法打开, 你自己到微软的网站搜索得到链接. If a client on the private network makes a TCP connection to two different computers on the public network from the same source port, the NAT driver will choose different source ports for those mappings. If a client on the private network sends UDP packets to two different computers on the public network from the same source port, the NAT driver will use the same source port for both mappings. 所以必须使用 UDP 穿透. TCP 穿透据说已经实现, 但是太依赖技巧性, 而且不成熟. How NAT determines whether an inbound packet matches an existing dynamic or static mapping. For UDP, however, an inbound packet must match only the protocol, destination address, and destination port of a mapping — the source address and source port of the packet are effectively ignored. This “loose matching behavior” applies only if the private port is greater than 1024. Allowing this behavior for ports below 1024 would introduce a security risk... NAT 对内网同一个 IP:PORT 使用同一条映射, 所以任何机器都可以根据这条映射, 往内网 IP:PORT 对应的 公网 IP:PORT 发送 UDP 数据报(会被 NAT 转发给内网 IP:PORT). 要让其它人能知道这条映射, 内网 IP:PORT 只需要在 NAT 的 UDP idle-time 时间内往固定的外网服务器发送报告, 外网服务器就可以从 UDP 包中提取 公网 IP:PORT. 另外, 一篇 rfc 草案也能帮助你: http://midcom-p2p.sourceforge.net/draft-ford-midcom-p2p-01.txt&lt;/div&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2510522667657978555&amp;page=RSS%3a+P2P%e7%a9%bf%e9%80%8fNAT%e7%9a%84%e6%80%9d%e8%b7%af&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=eddyzhoufeng.spaces.live.com&amp;amp;GT1=eddyzhoufeng"&gt;</description><comments>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!798.entry#comment</comments><guid isPermaLink="true">http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!798.entry</guid><pubDate>Mon, 05 Nov 2007 07:40:27 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://eddyzhoufeng.spaces.live.com/blog/cns!DD28D4EF61AE1D45!798/comments/feed.rss</wfw:commentRss><wfw:comment>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!798.entry#comment</wfw:comment><dcterms:modified>2007-11-05T07:40:27Z</dcterms:modified></item><item><title>我对P2P中UDP穿越NAT的理解供参考</title><link>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!769.entry</link><description>&lt;div&gt;今天晚上和SPP讨论了下这个问题，于是把问题给想明白了！&lt;/div&gt;
&lt;div&gt;其实就是把服务器放在公网，A和B在局网中，A和B   登录服务器后，服务器记录了A和B   NAT后的的IP和端口，此时无论是A向B还是B向A发信息，都不会成功。只有当A或B通过服务器知道对方的IP和端口后，就可以先向对方的IP和端口发送信息，虽然不成功，但实际是通知本地防火墙允许接收来处对方IP和端口的数据报，这就是打洞或穿越的过程，这步结束后，A和B就可以相互发送信息，而不再需要通过服务器中转了。&lt;/div&gt;
&lt;div&gt;PS:A发信息给B虽然会被拒绝，   但是对于一般的锥形Nat的路由器来说，A已经打了一个洞给B了，所以下次B发信息给A就可以经由那个洞直接进入了!&lt;/div&gt;
&lt;div&gt;示例代码：&lt;/div&gt;
&lt;div&gt;&lt;a href="http://free5.ys168.com/?feng5166"&gt;http://free5.ys168.com/?feng5166&lt;/a&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2510522667657978555&amp;page=RSS%3a+%e6%88%91%e5%af%b9P2P%e4%b8%adUDP%e7%a9%bf%e8%b6%8aNAT%e7%9a%84%e7%90%86%e8%a7%a3%e4%be%9b%e5%8f%82%e8%80%83&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=eddyzhoufeng.spaces.live.com&amp;amp;GT1=eddyzhoufeng"&gt;</description><comments>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!769.entry#comment</comments><guid isPermaLink="true">http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!769.entry</guid><pubDate>Wed, 17 Oct 2007 14:15:24 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://eddyzhoufeng.spaces.live.com/blog/cns!DD28D4EF61AE1D45!769/comments/feed.rss</wfw:commentRss><wfw:comment>http://eddyzhoufeng.spaces.live.com/Blog/cns!DD28D4EF61AE1D45!769.entry#comment</wfw:comment><dcterms:modified>2007-10-19T05:09:56Z</dcterms:modified></item></channel></rss>