[go: up one dir, main page]

WO2009124450A1 - 一种基于UPnP和STUN技术相结合的NAT穿越方法 - Google Patents

一种基于UPnP和STUN技术相结合的NAT穿越方法 Download PDF

Info

Publication number
WO2009124450A1
WO2009124450A1 PCT/CN2009/000235 CN2009000235W WO2009124450A1 WO 2009124450 A1 WO2009124450 A1 WO 2009124450A1 CN 2009000235 W CN2009000235 W CN 2009000235W WO 2009124450 A1 WO2009124450 A1 WO 2009124450A1
Authority
WO
WIPO (PCT)
Prior art keywords
nat
node
port
traversal
upnp
Prior art date
Application number
PCT/CN2009/000235
Other languages
English (en)
French (fr)
Inventor
王劲林
任浩
鲁逸峰
苏少炜
冯侦探
Original Assignee
中国科学院声学研究所
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中国科学院声学研究所 filed Critical 中国科学院声学研究所
Priority to JP2011503325A priority Critical patent/JP5185435B2/ja
Priority to US12/937,337 priority patent/US8560607B2/en
Publication of WO2009124450A1 publication Critical patent/WO2009124450A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • H04L61/2575NAT traversal using address mapping retrieval, e.g. simple traversal of user datagram protocol through session traversal utilities for NAT [STUN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks

Definitions

  • the invention relates to the field of computer network P2P streaming media technology, in particular to a NAT traversing method based on a combination of UPnP and STUN technologies.
  • P2P Peer-to-Peer
  • P2P mode since each node has the functions of a client and a server, each node sends data to other nodes while receiving data from other nodes, so that the uploading capability of the client node can greatly reduce the flow. The burden of the media server.
  • NAT network address translation
  • NAT can well support basic Internet applications such as web browsing.
  • a general application protocol such as HTTP
  • a TCP/UDP header can be converted to achieve traversal; however, it is difficult to support P2P streaming applications. The reasons include:
  • the characteristics of the NAT determine that the host in the NAT can initiate a connection to the host outside the NAT. It is not allowed for the external host to directly establish a connection with the host in the NAT. This means that when the external host wants to request media data from the intranet host, the connection cannot be established. Therefore, the two hosts cannot exchange data.
  • mapping relationship dynamic mapping is to establish a mapping for each session of the internal and external network hosts, but does not guarantee that the same mapping is added every time the same session. Since the communication port used by the communication node for multimedia communication in the P2P streaming media system is dynamically negotiated between the two parties when the connection is established, no matter which mapping addition method is used, the dynamic communication between multiple peer nodes in the P2P streaming media application cannot be satisfied. .
  • NATs can be classified into the following types according to port mapping: Full NAT (Restricted Cone); Port Restricted Cone; Symmetric NAT, the first three NATs can be collectively referred to as Cone NATs. Their main difference is that the filtering rules for data packets passing through NAT are different.
  • Tunnel-based traversal By encapsulating the data stream that needs to be traversed in a certain tunnel, thereby bypassing NAT, this is the basic idea based on tunnel traversal.
  • the tunneling mechanism requires multimedia terminals and servers to support the tunnel, which is a relatively large constraint.
  • UPnP.-UPnP is an extension of the plug-and-play technology in the network environment. It sends control information to the NAT device through the user control point to add port mapping to implement NAT traversal.
  • UPnP does not require modifications to existing equipment, but requires a NAT-enabled gateway or router to support UPnP functionality.
  • Most large-scale gateways currently support UPnP solutions and are simple to configure, so most P2P applications use UPnP technology to solve NAT traversal problems. However, it is not excluded that the gateway does not support the UPnP function or is disabled by the administrator in some network environments.
  • STUN STU adopts another idea to implement NAT traversal.
  • the host in the internal network obtains the external address on the egress NAT through the traversal server located in the external network, and then directly uses the external address as its own when communicating with other nodes. The communication address, so that NAT traversal can be achieved.
  • the biggest advantage of the STUN protocol is that there is no need to make any changes to existing NAT devices, and the STUN mode can be used in multiple NAT-connected network environments.
  • the limitation of STUN is that it is not suitable for supporting the traversal of TCP connections, and the STU protocol does not support the traversal of symmetric NAT.
  • NAT traversal methods based on traversal agents, forwarding servers (TURN), and application layer gateways (ALGs).
  • the object of the present invention is to solve the above problems, and the present invention breaks through the single traversing method conventionally used in the prior art, and proposes a NAT traversing method based on the combination of UPnP and STUN technologies, which adopts two traversing methods.
  • a method of estimating the port mapping distribution based on the sample value estimation based on NAT to add port mapping (referred to as port addition sample estimation) is proposed for port guessing to avoid The blindness caused by the forwarding of the three-party proxy and the blindness of the simple port incremental guessing method;
  • the communication parties in the P2P streaming media system are located behind the NAT, it is proposed to use the ordinary communication node with sufficient bandwidth in the external network to act as the secondary relay node.
  • the method (referred to as node relay assistance) mitigates the pressure on the relay server, thereby effectively eliminating system communication bottlenecks.
  • a step of the NAT traversal method based on the combination of UPnP and STUN techniques of the present invention includes:
  • the user node joining the P2P streaming media system first broadcasts a message for searching the UPnP device through the simple service discovery protocol SSDP on the intranet:
  • name is “WANIPConnection” and type is “service”, which means searching for UPnP service;
  • the name is the control command AddPortMapping to the UPnP device, and args is a number of parameters required by the UPnP standard.
  • the user node can establish a connection with the external network node to perform data interaction, thereby implementing NAT traversal;
  • extIP and extPort are the NAT external IP and port obtained by STUN traversal, and natType is the NAT type judged during the traversal process.
  • the step (3) further includes:
  • NAT is a cone NAT
  • the user node communicates with other nodes by using the obtained external address port to implement NAT traversal;
  • the user node uses the port to add a sample estimation method to perform NAT traversal.
  • the port adds a sample estimation method, and the steps thereof include: After the symmetric NAT, the user node initiates three connections to the STUN server located in the external network, and obtains the mapping port added by the connection through the server feedback, and sets it as ⁇ , corpse 2 , 3 , and the user node changes according to the three numbers. Do the following:
  • the user node initiates a TV-3 connection to the STUN server again, and together with the three mapped ports that are initially obtained, form a sample observation value of the TV, and sets the sample observation value to be included in the [ ] interval, and divides the interval into a sub-interval ( ⁇
  • each subinterval ( , ⁇ ( ⁇ ..., ⁇ -1) contain ⁇ observations, which are obtained according to the definition of Bernoulli's law of large numbers and probability density:
  • the graph of ⁇ ⁇ ( ⁇ ) is the distribution histogram of the port map population on [ ].
  • the NAT traversal method based on the UPnP and STUN technologies further includes a node relay assisting method. If both the communication parties in the P2P streaming media system are located after the NAT, the user node allows a part of the bandwidth to be located at the ordinary communication node of the external network.
  • the auxiliary relay node referred to as node relay assistance, relieves the pressure on the relay server.
  • the external network node joining the P2P streaming media system first registers with the relay server, and the relay server reserves a list of external network nodes;
  • the relay server uses the heartbeat mechanism to detect the registered external network node, and selects the M nodes with the smallest RTT as the relay auxiliary candidate node;
  • the relay server When the intranet user node registers with the relay server, the relay server registers the user node information, and transmits a list of the external network nodes to the user node;
  • the intranet user node randomly selects N (N ⁇ M) external network nodes to initiate a connection, and selects the node with the smallest RTT as its own secondary relay node, and simultaneously sends registration information to the secondary relay node;
  • Point information when the user node communicates with other post-NAT nodes, first query the registration list of the relay auxiliary node, and if the communication node is in the registration list of the relay auxiliary node, use the auxiliary relay node to relay, otherwise use Relay server relay.
  • UPnP and STUN are effectively combined. After the failure of UPnP to traverse NAT, the STUN method is used to perform secondary traversal of NAT. By taking advantage of the advantages of the two traversal methods, the success rate of traversal is effectively improved.
  • port addition sample estimation a method of estimating the port mapping distribution based on the sample value estimation of port mapping based on NAT (referred to as port addition sample estimation) is proposed for port guessing to avoid defects and simple port increment caused by third-party proxy forwarding. The blindness of the guessing method.
  • FIG. 1 is a schematic diagram of a prior art P2P streaming media system including NAT;
  • FIG. 2 is a flowchart of a NAT traversal method based on the combination of UPnP and STUN technologies according to the present invention
  • FIG. 3 is a sample distribution histogram example obtained by the port adding sample estimation method according to the present invention
  • FIG. 4 is a node relay assisting method according to the present invention
  • Flow chart Flow chart. detailed description
  • the present invention proposes a combined NAT traversal method, which effectively combines the two commonly used traversal methods ⁇ UPnP and STUN. After the UPnP traverses the NAT failure, the STUN method is used to perform secondary traversal of the NAT.
  • the advantages of each method of crossing are effective to improve the success rate of crossing.
  • the architecture of a P2P streaming media system with NAT is shown in Figure 1.
  • the data source server and the data relay server are responsible for the streaming and forwarding of media data.
  • the index server serves as the central index server of the P2P network in the area to store information of all nodes in the P2P network in the area.
  • User communication nodes A and B are located in an internal LAN behind NAT device A
  • user communication nodes C and D are located in another internal LAN behind NAT device B
  • user communication node E is an external network node.
  • the communication node E is to request data from the communication node A. Due to the existence of the NAT, the connection cannot be directly established, and the data request of the E is filtered by the NAT device A, so the communication node A is to perform NAT traversal.
  • the communication node A first uses the UPnP method to add a port mapping, and if successful, can establish a connection with the external network node E.
  • the specific steps of the method include:
  • the user node A newly joining the P2P streaming media system first passes the Simple Service Discovery Protocol SSDP. Broadcasting search for UPnP devices in the intranet:
  • name should be "WANIPConnection” and type "service”, which means searching for UPnP service;
  • node A If the search for the UPnP service is successful, node A sends a request to add a port mapping to the control URL of the NAT gateway through the Simple Object Access Protocol SOAP:
  • the name is the control command AddPortMapping to the UPnP device, and args is a number of parameters required by the UPnP standard.
  • the user node A can establish a connection with the external network node E to perform data interaction, thereby implementing NAT traversal;
  • the step (3) further includes:
  • NAT is another three kinds of tapered NATs other than symmetric NAT, in the future, the user node A can use the obtained external address port to communicate with the external network node E to implement NAT traversal;
  • the node A adopts the port adding sample estimation method to implement NAT traversal, and the port adds a sample estimation method, and the steps include: - the node A located after the symmetric NAT sequentially initiates to the STUN server located in the external network Three times of connection, and through the server feedback to get the mapping port added by the three connections, set, corpse 2 , P 3 , according to the change rule of these three numbers to do the following:
  • the graph is the distribution histogram of the port mapping population on the whole (as shown in Figure 3).
  • the communication node A wants to request data from the communication node C. Since both parties cannot establish a connection directly after the NAT, the relay assistance method proposed by the present invention is used to forward the two by using the communication node E as a relay auxiliary node. Connection request, the steps include -
  • the external network node that joins the P2P streaming media system E first registers with the relay server, and the relay server reserves a list including the external network E nodes;
  • the relay server When the intranet node A registers with the relay server, the relay server registers the information of the node A, and simultaneously transmits a list including the external network node E;
  • the intranet node A selects the node E with the smallest round trip delay as its own auxiliary relay node, and sends registration information to it at the same time;

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Small-Scale Networks (AREA)

Description

一种基于 UPnP和 STUN技术相结合的 NAT穿越方法 技术领域
本发明涉及计算机网络 P2P流媒体技术领域,特别涉及一种基于 UPnP和 STUN 技术相结合的 NAT穿越方法。 背景技术
随着互联网的发展和宽带应用的普及,利用网络进行流媒体直播正在成为网络应 用的热点。 传统的基于客户端 /服务器架构的流媒体系统由于服务器带宽和处理能力 的限制导致其可扩展性极差。 P2P(Peer-to-Peer)对等网络技术作为一种有效的解决方 案在最近几年得到了极大的推广。在 P2P模式下,由于每个节点都具有客户端和服务 器的功能,每个节点在从别的节点接收数据的同时还向其他节点发送数据,这样利用 客户端节点的上传能力可以极大减轻流媒体服务器的负担。
另一方面,为了节省网络地址空间和保障网络安全, 当前互联网中较多的采用了 NAT(网络地址转换)技术。它是一种将 IP地址从一个编址域映射到另外一个编址域的 方法, 如最典型的应用是把 RFC1918定义的私有非注册地址内部隔离编址域映射到 能在互联网路由的全局统一注册地址外部编址域。 NAT设备能够为内网编址域与外 网编址域之间的每条网络连接实施动态 IP地址转换并设置相应的报文过滤规则, 让 不满足条件的报文不能够穿透 NAT。
NAT可以很好地支持网页浏览等基本的因特网应用, 对 HTTP等端口固定的一 般应用协议,只需要转换 TCP/UDP头即可实现穿越;但是很难支持 P2P流媒体应用, 其原因包括:
( l )NAT的特点决定了只能由 NAT内的主机主动向 NAT外部的主机发起连接, 外部的主机想直接和 NAT内的主机建立连接是不被允许的。 这意味着当外网主机想 向内网主机请求媒体数据时将无法建立连接, 因而, 两台主机无法进行数据交换。
( 2 ) NAT 端口映射分为静态和动态两种: 静态映射是静态添加内部
ter
Figure imgf000003_0001
)的映射关系;动态映射是为内外网主机 的每次会话都建立一次映射, 但不保证每次相同的会话添加相同的映射。 由于 P2P 流媒体系统中通信节点进行多媒体通信使用的通信端口是连接建立时双方动态协商 的,因此无论哪种映射添加方式,都无法满足 P2P流媒体应用中多个对等节点间动态 通信的需要。
因此, P2P流媒体应用必须要在一定程度上解决 NAT穿越的问题, 否则系统将 无法正常工作。 传统 NAT根据端口映射方式可分为以下几种典型类型: 全 NAT(Full Cone); 受 限 NAT(Restricted Cone); 端口受限 NAT(Port Restricted Cone); 对称 NAT(Symmetric NAT), 其中前三种 NAT又可统称为锥形 NAT (Cone NAT) 它们的主要差别在于对 通过 NAT的数据报文的过滤规则不同。
目前常用的 NAT穿越方法有如下几种:
(1)基于隧道的穿越: 通过把需要穿越的数据流封装在某种隧道中, 从而绕过 NAT,这是基于隧道穿越的基本思想。隧道机制需要多媒体终端和服务器能够支持隧 道, 这是一个比较大的限制条件。
(2) UPnP.-UPnP是即插即用技术在网络环境中的扩展,它通过用户控制点向 NAT 设备发送控制信息添加端口映射实现 NAT穿越。 UPnP不需要对现有设备进行改造, 但要求集成 NAT功能的网关或路由器支持 UPnP功能。 目前大多数大型网关都支持 UPnP解决方案并且配置简单,因而大多数 P2P应用都采用 UPnP技术解决 NAT穿越 问题。 但是不排除在部分网络环境下网关不支持 UPnP功能或该功能被管理员关闭。
(3) STUN: STU 采用另一种思路实现 NAT穿越, 内网中的主机通过位于外网 的穿越服务器预先得到出口 NAT上的对外地址, 然后在与其它节点通信时直接使用 该对外地址作为自己的通信地址, 这样就可以实现 NAT穿越。 STUN协议最大的优 点是无需对现有 NAT设备做任何改动,同时 STUN方式可在多个 NAT串联的网络环 境中使用。 STUN的局限性在于不适合支持 TCP连接的穿越, 另外 STU 协议也不 支持对称 NAT的穿越。
另外,还有基于穿越代理、转发服务器 (TURN)以及应用层网关 (ALG)等多种 NAT 穿越方法。
目前, 多数 P2P流媒体系统仅采用单一的 NAT穿越方法, 由于每种方法都有其 局限性或限制条件 同时, 当几种方法互相结合使用时, 难以找到恰当的结合点使每 种方法都能正常工作, 因而不能保证穿越成功率。 另外对称 NAT的穿越目前尚没有 较髙效的穿越方法,都要借助第三方穿越代理辅助进行穿越或采用简单的端口递增猜 测方法。媒体数据在经过第三方代理转发时增大了数据包的延迟和丢包的可能性, 同 时也增大了系统部署开销;而现在较为通用的端口递增猜测方法只是经验性的在 NAT 已添加的映射端口号上加 1作为 NAT下次添加的端口映射的猜测结果。 这种方法在 数理统计上不是最优的,因为没有充分根据 NAT添加端口映射的样本值分析 NAT行 为。 同时对于通信双方都位于 NAT后的情况, 由于谁也不知道对方 NAT映射的公网 IP地址和端口号, 造成双方都无法主动发起连接请求。 针对这种情况目前较多采用 基于中继服务器的穿越方式,但由于每个中继服务器都有通信负载的上限,一旦内网 节点通信超过服务器负载上限,容易造成中继服务器崩溃; 同时由于服务器的带宽有 限, 髙并发的网络流量将会使服务器网络拥塞造成丢包, 形成通信瓶颈。 发明内容
本发明的目的在于,为了解决上述问题,本发明突破了现有技术当中惯有的单一 的穿越方法, 提出了一种基于 UPnP和 STUN技术相结合的 NAT穿越方法, 该方法 将两种穿越方法有效的结合起来,, 保证 NAT穿越的成功率; 对于对称 NAT的穿越, 提出采用基于 NAT添加端口映射的样本值估计端口映射分布的方法 (简称端口添加 样本估计)进行端口猜测, 以避免由于第三方代理转发造成的缺陷和简单端口递增猜 测方法的盲目性; 对于 P2P流媒体系统中通信双方都位于 NAT后的情况, 提出采用 让部分带宽充裕位于外网的普通通信节点充当辅助中继节点的方法(简称节点中继辅 助)来缓解中继服务器的压力, 从而有效消除系统通信瓶颈。
为实现上述目的, 本发明的一种基于 UPnP和 STUN技术相结合的 NAT穿越方 法的步骤包括:
( 1 )加入 P2P流媒体系统的用户节点首先通过简单服务发现协议 SSDP在内网 中广播搜索 UPnP设备的消息:
void Search(char* name, const char* type);
根据 UPnP标准要求, name为" WANIPConnection", type为" service", 表示搜索 UPnP服务;
(2)如果搜索 UPnP服务成功, 则通过简单对象访问协议 SOAP向 NAT网关的 控制 URL发送添加端口映射的请求:
void InvokeCommand(char* name, char* args);
其中, name为向 UPnP设备下达的控制命令 AddPortMapping, args为 UPnP标 准要求的若干参数, 填加端口映射后用户节点就可与外网节点建立连接进行数据交 互, 从而实现 NAT穿越;
(3 )如果搜索失败, 则用户节点启动 STUN功能模块对 NAT进行二次穿越: void GetMapAddr(int& extIP, int& extPort, NatType& natType);
其中, extIP和 extPort为 STUN穿越获得的 NAT外部 IP和端口, natType是在 穿越过程中判断的 NAT类型。
所述(3 ) 步骤进一步包括:
1 )如果 NAT是锥形 NAT, 用户节点用得到的外部地址端口与其它节点通信, 实现 NAT穿越;
2)若 NAT是对称 NAT, 用户节点采用端口添加样本估计法实行对 NAT穿越。 所述端口添加样本估计法, 其步骤包括: 位于对称 NAT后的用户节点向位于外网的 STUN服务器依次发起三次连接, 并 通过服务器反馈得到三次连接添加的映射端口,设为 ^,尸2, 3 ,用户节点根据这三个 数的变化规律做如下处理:
2a)若 ,P2,P3为等差数列, 则猜测对称 NAT添加端口映射的方法为依次递增 等差数列的公差 d, 位于对称 NAT后的用户节点在原外部端口的基础上递增 作为 自己新的外部通信端口, 并填入数据交互的负载中, 就可与其它节点进行通信;
2b)若 ,^,尸3不是等差数列, 则添加的端口映射是随机的, 此时根据添加端口 样本值对端口映射的总体 ^进行估计:
用户节点再次向 STUN服务器发起 TV— 3次连接, 与开始得到的三个映射端口 共同组成容量为 TV的样本观察值, 设样本观察值都包含在 [ ]区间内, 将区间分 成 Μ个子区间 (Μ<Λ
α = η0ι<...<ηΜ_]Μ
设每个子区间 ( , ^^( 山…,^^— 1)包含 ^个观察值,根据贝努里大数定律 和概率密度的定义得到:
Figure imgf000006_0001
φΝ (χ)的图形就是端口映射总体 在 [ ]上的分布直方图,通过分析 φΝ (X) 的图形在哪个 区间取值较大就可判断 NAT映射端口一般分布在哪个子区间, 在 该范围较小的子区间内,再采用遍历的方法猜测对称 NAT下次会话添加的端口映射, 就可有效提高猜测的命中率。
所述基于 UPnP和 STUN技术相结合的 NAT穿越方法, 进一步包括节点中继辅 助的方法, 如果 P2P流媒体系统中通信双方都位于 NAT后, 用户节点让部分带宽充 裕位于外网的普通通信节点充当辅助中继节点,简称节点中继辅助,来缓解中继服务 器的压力。
所述节点中继辅助, 其步骤包括:
1 )加入 P2P流媒体系统的外网节点首先向中继服务器注册, 中继服务器保留一 份外网节点的列表;
2)中继服务器采用心跳机制对注册的外网节点进行探测,并选择 RTT最小的 M 个节点作为中继辅助候选节点;
3)内网用户节点向中继服务器注册时, 中继服务器注册该用户节点信息的同时, 向用户节点传送一份位于外网节点列表;
4) 内网用户节点随机选择 N(N < M)个外网节点发起连接, 并选择 RTT最小的 节点作为自己的辅助中继节点, 同时向辅助中继节点发送注册信息;
5)用户节点确定自己中继节点的同时, 得到在该中继节点上注册的其它通信节 点信息, 用户节点与其他 NAT后节点通信时, 首先査询自己中继辅助节点的注册列 表,若待通信节点在中继辅助节点的注册列表中,用该辅助中继节点中继, 否则用中 继服务器中继。
本发明的优点在于-
1、 UPnP和 STUN进行有效结合, 在 UPnP穿越 NAT失败后再采用 STUN方法 对 NAT进行二次穿越, 通过汲取两种穿越方法各自的优点有效提高穿越成功率。
2、 对于对称 NAT的穿越, 提出釆用基于 NAT添加端口映射的样本值估计端口 映射分布的方法(简称端口添加样本估计)进行端口猜测, 以避免由于第三方代理转 发造成的缺陷和简单端口递增猜测方法的盲目性。
3、对于 P2P流媒体系统中通信双方都位于 NAT后的情况,提出采用让部分带宽 充裕位于外网的普通通信节点充当辅助中继节点的方法(简称节点中继辅助)来缓解 中继服务器的压力, 从而有效消除系统通信瓶颈。 附图说明
图 1为现有技术含有 NAT的 P2P流媒体系统的架构;
图 2 为本发明基于 UPnP和 STUN技术相结合的 NAT穿越方法的流程图; 图 3为本发明端口添加样本估计方法得到的一种样本分布直方图示例; 图 4为本发明节点中继辅助方法的流程图。 具体实施方式
本发明提出一种组合的 NAT穿越方法, 将目前常用的两种穿越方法 ~~ UPnP 和 STUN进行有效结合,在 UPnP穿越 NAT失败后,再采用 STUN方法对 NAT进行 二次穿越, 通过汲取两种穿越方法各自的优点有效提高穿越成功率。
含有 NAT的 P2P流媒体系统的架构, 如图 1所示。 图中数据源服务器和数据中 转服务器负责媒体数据的流化和转发,索引服务器作为所在区域的 P2P网络的中心索 引服务器保存了该区域 P2P网络中所有节点的信息。用户通信节点 A和 B位于 NAT 设备 A后的一个内部局域网中, 用户通信节点 C和 D位于 NAT设备 B后的另一个 内部局域网中, 用户通信节点 E是外网节点。
现假设通信节点 E要向通信节点 A请求数据, 由于 NAT的存在, 连接不能直接 建立, E的数据请求会被 NAT设备 A过滤, 因此通信节点 A要进行 NAT穿越。
根据本发明的方法,具体流程如图 2所示,通信节点 A首先釆用 UPnP方法添加 端口映射, 如果成功就可与外网节点 E建立连接; 该方法具体步骤包括:
( 1 )新加入 P2P流媒体系统的用户节点 A首先通过简单服务发现协议 SSDP在 内网中广播搜索 UPnP设备的消息:
void Search(char* name, const char* type);
根据 UPnP标准要求, name应为" WANIPConnection", type为" service", 表示搜 索 UPnP服务;
(2)如果搜索 UPnP服务成功,则节点 A通过简单对象访问协议 SOAP向 NAT 网关的控制 URL发送添加端口映射的请求:
InvokeCommand(char* name, char* args);
其中, name为向 UPnP设备下达的控制命令 AddPortMapping, args为 UPnP标 准要求的若干参数, 填加端口映射后用户节点 A就可与外网节点 E建立连接进行数 据交互, 从而实现 NAT穿越;
(3 )如果搜索失败, 则用户节点 A启动 STUN功能模块对 NAT进行二次穿越:
GetMapAddr(int& extIP, int& extPort, NatType& natType); 其中, extIP和 extPort为 STUN穿越获得的 NAT外部 IP和端口, natType是在 穿越过程中判断的 NAT类型。
所述(3 ) 步骤进一步包括:
1 )如果 NAT是除对称 NAT外的另外三种锥形 NAT, 今后该用户节点 A就可以 用得到的外部地址端口与外网节点 E通信, 实现 NAT穿越;
2)若 NAT是对称 NAT, 则节点 A采用端口添加样本估计法实行对 NAT穿越, 所述端口添加样本估计法, 其步骤包括- 位于对称 NAT后的节点 A向位于外网的 STUN服务器依次发起三次连接,并通 过服务器反馈得到三次连接添加的映射端口,设为 ,尸2 , P3 ,根据这三个数的变化规 律做如下处理:
2a)若 , 23为等差数列, 则猜测对称 NAT添加端口映射的方法为依次递增 等差数列的公差 , 今后位于对称 NAT后的节点 A只要在原外部端口的基础上递增 ί作为自己新的外部通信端口, 并填入数据交互的负载中, 就可与其它节点 Ε进行 通信;
2b)若 ,Ρ2,尸 3不是等差数列, 则添加的端口映射是随机的, 此时根据添加端口 样本值对端口映射的总体 ^进行估计 - 节点 Α再次向 STUN服务器发起 Λ /"— 3次连接, 与开始得到的三个映射端口共 同组成容量为 W的样本观察值, 设样本观察值都包含在 ]区间内, 将区间分成
Μ个子区间 (M< )
α = η0ι<...<ηΜ_ιΜ
设每个子区间 ( , +1]( =ο,ι,...,Μ— 1)包含 个观察值,根据贝努里大数定律 和概率密度的定义得到:
Figure imgf000009_0001
的图形就是端口映射总体 在 ]上的分布直方图 (如图 3所示), 通过分析 φΝ (χ)的图形在哪个 Δ 区间取值较大就可判断 NAT映射端口一般分布在 哪个子区间, 在该范围较小的子区间内再采用遍历的方法猜测对称 NAT下次会话添 加的端口映射, 可有效提高猜测的命中率。
现假设通信节点 A要向通信节点 C请求数据, 由于双方都在 NAT后故也不能直 接建立连接,这里采用本发明提出的中继辅助方法,利用通信节点 E作为中继辅助节 点转发二者的连接请求, 步骤包括-
1 )加入 P2P流媒体系统的外网节点 E首先向中继服务器注册, 中继服务器保留 一份包括外网 E节点的列表;
2)当内网节点 A向中继服务器注册时, 中继服务器注册节点 A的信息的, 同时 向其传送一份包括外网节点 E的列表;
3 )然后内网节点 A选择往返时延最小的节点 E,作为自己今后的辅助中继节点, 同时向其发送注册信息;
4)今后若要与其他 NAT后节点通信时 (如 C、 D), 首先査询自己中继辅助节点 E的 注册列表, 若待逋信的 NAT后节点 (C、 D)在列表中就用该辅助中继节点中继, 否则 再用中继服务器中继。。这样当有大量其它节点要建立连接时可以有效缓解 NAT穿越 中继服务器的压力, 如图 4所示。

Claims

权 利
1、一种基于 UPnP和 STUN技术相结合的 NAT穿越方法, 其步骤包括:
( 1 )加入 P2P流媒体系统的用户节点, 首先通过简单服务发现协议 SSDP在内 网中广播搜索 UPnP设备的消息:
void Search(char* name, const char* type);
根据 UPnP标准要求, name为" WANIPConnection", type为" service", 表示搜索 UPnP服务;
(2)如果搜索 UPnP服务成功, 则通过简单对象访问协议 SOAP向 NAT网关的 控制 URL发送添加端口映射的请求:
void InvokeCommand(char* name, char* args);
其中, name为向 UPnP设备下达的控制命令 AddPortMapping 9 args为 UPnP标 准要求的若干参数, 填加端口映射后用户节点就可与外网节点建立连接进行数据交 互, 从而实现 NAT穿越;
(3)如果搜索失败, 则用户节点启动 STU 功能模块对 NAT进行二次穿越: void GetMapAddr(int& extIP, int& extPort, NatType& natType);
其中, extIP和 extPort为 STUN穿越获得的 NAT外部 IP和端口, natType是在 穿越过程中判断的 NAT类型。
2、根据权利要求 1所述基于 UPnP和 STUN技术相结合的 NAT穿越方法,其特 征在于, 所述(3 )步骤进一步包括:
1 )如果 NAT是锥形 NAT, 该用户节点用得到的外部地址端口与其它节点通信, 实现 NAT穿越;
2)若 NAT是对称 NAT, 则该用户节点采用端口添加样本估计法实行对 NAT穿 越;
所述端口添加样本估计法, 其步骤包括:
位于对称 NAT后的用户节点向位于外网的 STUN服务器依次发起三次连接, 并 通过服务器反馈得到三次连接添加的映射端口,设为 , P2,尸 3 ,根据这三个数的变化 规律做如下处理:
2a)若 ,Ρ23为等差数列, 则对称 NAT添加端口映射为依次递增等差数列的 公差 , 位于对称 NAT后的用户节点在原外部端口的基础上递增 作为自己新的外 部通信端口, 并填入数据交互的负载中, 就可与其它节点进行通信;
2b)若/? , 2, 不是等差数列, 则添加的端口映射是随机的, 用户节点根据添加 端口样本值对端口映射的总体 进行估计:
用户节点再次向 STUN服务器发起 ^一 3次连接, 与开始得到的三个映射端口 共同组成容量为 W的样本观察值, 设样本观察值都包含在 区间内, 将区间分 成 Μ个子区间 (Μ<Λ
α = η0ι<...<ηΜ_ιΜ
设每个子区间 (^ ^Ki-OL^M— l)包含 ^个观察值,根据贝努里大数定律 和概率密度的定义得到:
φΝ (χ) = I ΝΑηί (Δ" = ¾ι - )
^Ο)的图形就是端口映射总体 在 上的分布直方图,通过分析^ (χ) 的图形取值较大时所在的 %区间就可判断 NAT映射端口一般分布在该子区间, 在 该范围较小的子区间内,再采用遍历的方法猜测对称 NAT下次会话添加的端口映射, 可有效提高猜测的命中率。
3、根据权利要求 1所述基于 UPnP和 STU 技术相结合的 NAT穿越方法,其特 征在于,还包括节点中继辅助方法,如果 P2P流媒体系统中通信双方都位于 NAT后, 用户节点用部分带宽充裕位于外网的普通通信节点充当辅助中继节点。;
4、根琚权利要求 3所述基于 UPnP和 STUN技术相结合的 NAT穿越方法,其特 征在于, 所述节点中继辅助方法, 其步骤包括:
1 )加入 P2P流媒体系统的外网节点首先向中继服务器注册, 中继服务器保留一 份外网节点的列表;
2) 中继服务器采用心跳机制对注册的外网节点进行探测, 并选择往返时延最小 的 M个外网节点作为中继辅助候选节点;
3) 内网用户节点向中继服务器注册, 中继服务器注册用户节点信息的同时, 向 用户节点传送一份外网节点的列表;
4)用户节点随机选择 N(N < M)个外网节点发起连接, 并选择往返时延最小的节 点作为自己的辅助中继节点, 同时向辅助中继节点发送注册信息;
5)用户节点确定自己辅助中继节点的同时, 得到在该辅助中继节点上注册的其它通 信节点信息, 用户节点与其他 NAT后节点通信时, 首先查询自己中继辅助节点的注 册列表, 若待通信节点在中继辅助节点的注册列表中, 就用该辅助中继节点中继, 否 则用中继服务器中继。
PCT/CN2009/000235 2008-04-11 2009-03-05 一种基于UPnP和STUN技术相结合的NAT穿越方法 WO2009124450A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2011503325A JP5185435B2 (ja) 2008-04-11 2009-03-05 UPnPとSTUNを組み合わせることに基づくNAT越え方法
US12/937,337 US8560607B2 (en) 2008-04-11 2009-05-03 Method based on the combination of the UPnP and STUN for NAT traversal

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200810103849.6A CN101557388B (zh) 2008-04-11 2008-04-11 一种基于UPnP和STUN技术相结合的NAT穿越方法
CN200810103849.6 2008-04-11

Publications (1)

Publication Number Publication Date
WO2009124450A1 true WO2009124450A1 (zh) 2009-10-15

Family

ID=41161526

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2009/000235 WO2009124450A1 (zh) 2008-04-11 2009-03-05 一种基于UPnP和STUN技术相结合的NAT穿越方法

Country Status (4)

Country Link
US (1) US8560607B2 (zh)
JP (1) JP5185435B2 (zh)
CN (1) CN101557388B (zh)
WO (1) WO2009124450A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105141711A (zh) * 2015-08-24 2015-12-09 北京息通网络技术有限公司 一种基于大数据分析的对称nat穿越方法及系统
CN105979022A (zh) * 2016-04-28 2016-09-28 Tcl集团股份有限公司 一种基于UPnP协议的NAT穿透方法及系统
CN106210092A (zh) * 2016-07-19 2016-12-07 天彩电子(深圳)有限公司 一种融合upnp及stun的p2p穿越方法及其系统

Families Citing this family (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9565239B2 (en) * 2009-05-29 2017-02-07 Orions Digital Systems, Inc. Selective access of multi-rate data from a server and/or peer
CN101841484B (zh) * 2010-05-12 2013-01-02 中国科学院计算技术研究所 一种在结构化p2p网络中实现nat穿越的方法和系统
CN102340520B (zh) * 2010-07-20 2014-06-18 上海未来宽带技术股份有限公司 一种p2p网络应用系统中私网检测与穿越的复合方法
CN102025769B (zh) * 2010-09-10 2013-07-17 香港城市大学深圳研究院 一种分布式互联网接入方法
KR101885133B1 (ko) 2011-02-01 2018-08-03 삼성전자주식회사 디지털 디바이스에서 어플리케이션 자동 인스톨 기능을 제공하기 위한 장치 및 방법
US8930959B2 (en) 2011-05-13 2015-01-06 Orions Digital Systems, Inc. Generating event definitions based on spatial and relational relationships
CN102571797B (zh) * 2012-01-16 2015-03-18 何建亿 一种通过UPnP改善STUN-P2P穿透率与稳定性的方法
CN103220377A (zh) * 2012-05-08 2013-07-24 西北工业大学 一种nat穿越以及带宽复用的系统和方法
US9591070B2 (en) * 2012-12-19 2017-03-07 Hive Streaming Ab Multiple requests for content download in a live streaming P2P network
CN104184755A (zh) * 2013-05-21 2014-12-03 华为终端有限公司 一种网页实时通信方法、系统及终端
CN103442224A (zh) * 2013-09-09 2013-12-11 杭州巨峰科技有限公司 一种基于nat穿透的视频监控访问策略和实现方法
CN103795819B (zh) * 2014-01-27 2017-02-01 宁波键一生物科技有限公司 P2p应用中基于nat的终端间的数据传输方法
CN105208139B (zh) * 2014-06-26 2018-08-07 浙江大华技术股份有限公司 一种终端建立连接的方法、终端和服务器
CN104660728B (zh) * 2015-02-13 2018-01-19 上海交通大学 基于智能家居控制系统的nat穿透方法
CN106331195B (zh) * 2015-06-23 2020-01-14 中兴通讯股份有限公司 数据接收、发送方法及装置
CN104994184A (zh) * 2015-06-25 2015-10-21 北京广密华安科技有限公司 一种nat穿透方法和装置
CN105072213B (zh) * 2015-08-28 2018-12-28 迈普通信技术股份有限公司 一种IPSec NAT双向穿越方法、系统及VPN网关
CN105163083B (zh) * 2015-09-10 2018-09-18 浙江宇视科技有限公司 一种视频数据的传输路径的确定方法和装置
TWI595765B (zh) * 2015-10-22 2017-08-11 財團法人工業技術研究院 穿透網路位置轉換器之方法及通訊裝置
CN105430066A (zh) * 2015-11-06 2016-03-23 浪潮软件集团有限公司 一种基于p2p技术的税控设备互联方法
CN107360275B (zh) * 2017-09-18 2021-01-22 北京奇艺世纪科技有限公司 一种对称型nat端口的预测方法及装置
CN107580082B (zh) * 2017-09-18 2021-03-26 北京奇艺世纪科技有限公司 一种对称型nat的穿透方法及装置
CN112491591B (zh) * 2020-11-10 2023-05-30 杭州萤石软件有限公司 一种通用即插即用UPnP端口映射方法及系统
US11652729B1 (en) * 2022-07-19 2023-05-16 Uab 360 It Enabling efficient communications in a mesh network

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050105543A1 (en) * 2003-11-14 2005-05-19 Toshiya Ikenaga System and method of information communication, information processing apparatus and information processing method, program and recording medium
CN1859314A (zh) * 2006-03-02 2006-11-08 华为技术有限公司 通信方法
JP2007096554A (ja) * 2005-09-28 2007-04-12 Nec Access Technica Ltd 通信システム、ブロードバンドルータ、情報処理装置及びそれらに用いるnat越え機能実現方法
CN1976356A (zh) * 2005-11-28 2007-06-06 华为技术有限公司 一种网络地址转换穿透系统、方法和用户设备

Family Cites Families (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002057917A2 (en) * 2001-01-22 2002-07-25 Sun Microsystems, Inc. Peer-to-peer network computing platform
AU2002368088B2 (en) * 2002-07-08 2007-10-18 Packetfront Sweden Ab Dynamic port configuration of network equipment
US7418486B2 (en) * 2003-06-06 2008-08-26 Microsoft Corporation Automatic discovery and configuration of external network devices
BRPI0516744A2 (pt) * 2004-06-07 2013-05-28 Sling Media Inc mÉtodos de reproduÇço de fluxo de mÍdia recebido numa rede e produto de programa de computador
US7788378B2 (en) * 2005-04-22 2010-08-31 Microsoft Corporation Apparatus and method for community relay node discovery
WO2007044656A2 (en) * 2005-10-07 2007-04-19 Neoedge Networks, Inc. Advertisement identification, selection, and distribution involving a peer-to-peer network
EP1999871A2 (en) * 2006-03-10 2008-12-10 Peerant Inc. Peer to peer inbound contact center
CN100435530C (zh) * 2006-04-30 2008-11-19 西安交通大学 一种多机服务器系统中双向负载均衡机制的实现方法
US8204034B2 (en) * 2007-01-10 2012-06-19 Motorola Solutions, Inc. Method and device for transmitting data packets
US8693392B2 (en) * 2007-02-21 2014-04-08 Avaya Canada Corp. Peer-to-peer communication system and method
US8656017B2 (en) * 2007-05-16 2014-02-18 Microsoft Corporation Peer-to-peer collaboration system with edge routing
US8631155B2 (en) * 2007-06-29 2014-01-14 Microsoft Corporation Network address translation traversals for peer-to-peer networks
TW200920030A (en) * 2007-10-18 2009-05-01 D Link Corp The method to puncture the firewall for building the linking channel between the network terminal devices
US8077602B2 (en) * 2008-02-01 2011-12-13 International Business Machines Corporation Performing dynamic request routing based on broadcast queue depths
US7962627B2 (en) * 2008-12-04 2011-06-14 Microsoft Corporation Peer-to-peer network address translator (NAT) traversal techniques

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050105543A1 (en) * 2003-11-14 2005-05-19 Toshiya Ikenaga System and method of information communication, information processing apparatus and information processing method, program and recording medium
JP2007096554A (ja) * 2005-09-28 2007-04-12 Nec Access Technica Ltd 通信システム、ブロードバンドルータ、情報処理装置及びそれらに用いるnat越え機能実現方法
CN1976356A (zh) * 2005-11-28 2007-06-06 华为技术有限公司 一种网络地址转换穿透系统、方法和用户设备
CN1859314A (zh) * 2006-03-02 2006-11-08 华为技术有限公司 通信方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
REN H. ET AL.: "Research combination of UPnP and STUN for NAT traversal.", COMPUTER ENGINEERING AND APPLICATIONS, vol. 45, no. 2, 2009, pages 99 - 101 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105141711A (zh) * 2015-08-24 2015-12-09 北京息通网络技术有限公司 一种基于大数据分析的对称nat穿越方法及系统
CN105141711B (zh) * 2015-08-24 2019-03-26 北京息通网络技术有限公司 一种基于大数据分析的对称nat穿越方法及系统
CN105979022A (zh) * 2016-04-28 2016-09-28 Tcl集团股份有限公司 一种基于UPnP协议的NAT穿透方法及系统
CN105979022B (zh) * 2016-04-28 2020-10-02 深圳市Tcl高新技术开发有限公司 一种基于UPnP协议的NAT穿透方法及系统
CN106210092A (zh) * 2016-07-19 2016-12-07 天彩电子(深圳)有限公司 一种融合upnp及stun的p2p穿越方法及其系统
CN106210092B (zh) * 2016-07-19 2019-08-06 天彩电子(深圳)有限公司 一种融合upnp及stun的p2p穿越方法及其系统

Also Published As

Publication number Publication date
CN101557388B (zh) 2012-05-23
US8560607B2 (en) 2013-10-15
US20110264739A1 (en) 2011-10-27
JP5185435B2 (ja) 2013-04-17
CN101557388A (zh) 2009-10-14
JP2011517545A (ja) 2011-06-09

Similar Documents

Publication Publication Date Title
WO2009124450A1 (zh) 一种基于UPnP和STUN技术相结合的NAT穿越方法
US8224985B2 (en) Peer-to-peer communication traversing symmetric network address translators
USRE47566E1 (en) NAT traversal for mobile network devices
CA2678714C (en) Bootstrapping in peer-to-peer networks with network address translators
EP2112788B1 (en) A method and node for p2p content sharing
US7995594B2 (en) Protocol and system for firewall and NAT traversal for TCP connections
CN103108089B (zh) 网络系统的连线建立管理方法及其相关系统
EP2239890B1 (en) Remote access method in a network comprising a nat device
CN101841484A (zh) 一种在结构化p2p网络中实现nat穿越的方法和系统
WO2012048613A1 (zh) 支持nat穿越的集中式p2p系统、nat穿越的方法
CN102025594A (zh) Nat环境下的路由动态调整方法和系统
US8601140B2 (en) Method for acquiring traversal resource, peer to peer node and peer to peer system
CN101321128A (zh) 通信设备、通信网络系统和通信方法
US20140337478A1 (en) Peer-to-peer network communications
Matuszewski et al. Mobile P2PSIP-Peer-to-Peer SIP communication in mobile communities
CN100426769C (zh) 一种建立对等直连通道的方法
CN109194778B (zh) 一种基于kcp协议的nat穿透方法
Zhang et al. A NAT traversal mechanism for peer-to-peer networks
US20090271523A1 (en) System, Method and Software for Using One Computer Network to Bypass a Portion of Another Computer Network
Duarte Jr et al. Transparent communications for applications behind NAT/firewall over any transport protocol
Muller et al. ANTS-a framework for knowledge based NAT traversal
Houngue et al. Overcoming NAT traversal issue for SIP-based communication in P2P networks
Hao et al. Network address translation traversal based on Bernoulli laws of large number in P2P streaming system①
Yang et al. SMBR: A novel NAT traversal mechanism for structured Peer-to-Peer communications
JP2005010871A (ja) 計算機通信制御方法およびシステム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 09729382

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2011503325

Country of ref document: JP

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 12937337

Country of ref document: US

122 Ep: pct application non-entry in european phase

Ref document number: 09729382

Country of ref document: EP

Kind code of ref document: A1