WO2007019809A1 - Procede et systeme d'etablissement d'un canal direct point par point - Google Patents

Procede et systeme d'etablissement d'un canal direct point par point Download PDF

Info

Publication number
WO2007019809A1
WO2007019809A1 PCT/CN2006/002111 CN2006002111W WO2007019809A1 WO 2007019809 A1 WO2007019809 A1 WO 2007019809A1 CN 2006002111 W CN2006002111 W CN 2006002111W WO 2007019809 A1 WO2007019809 A1 WO 2007019809A1
Authority
WO
WIPO (PCT)
Prior art keywords
host
data packet
receiving
nat
address information
Prior art date
Application number
PCT/CN2006/002111
Other languages
English (en)
French (fr)
Inventor
Ye Zhu
Baohe Zhang
Bo Wu
Haijun Wu
Original Assignee
Tencent Technology (Shenzhen) Company Limited
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 Tencent Technology (Shenzhen) Company Limited filed Critical Tencent Technology (Shenzhen) Company Limited
Priority to BRPI0616599-0A priority Critical patent/BRPI0616599A2/pt
Publication of WO2007019809A1 publication Critical patent/WO2007019809A1/zh

Links

Classifications

    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/164Adaptation or special uses of UDP protocol
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]

Definitions

  • the present invention relates to a connection technology for nodes in a computer network, and more particularly to a method and system for establishing a Peer to Peer (P2P) channel.
  • P2P Peer to Peer
  • this connection is a one-to-many relationship, such as As shown in Figure 1, a server can receive applications from multiple clients and provide services to multiple clients.
  • the relationship between the two is non-reciprocal; the other is P2P, as shown in Figure 2.
  • the connection in the P2P mode refers to the direct connection of every two nodes in the computer network, that is, the relationship between the two nodes is a peer-to-peer connection.
  • the server In the client/server mode, since the server needs to provide services to multiple clients, it is usually necessary to use a high-performance machine, and the cost is generally large.
  • the communication between the two parties in the P2P mode is a peer-to-peer relationship. The two provide each other with a monthly service. Therefore, the outstanding advantage of the P2P mode is that a large number of PCs with low performance can be connected to realize resource sharing and communication.
  • the method has greatly reduced the cost and gradually become a new direction of network development.
  • the main applications are file exchange, distributed computing, collaborative work, distributed search, and e-commerce.
  • NAT Network Address Translator
  • NAT is roughly classified into two types: Basic NAT, Cone NAT, and Symmetric NAT.
  • Basic NAT private IP address, private port
  • public network IP address, public network port The binding between Basic NAT (private IP address, private port) and (public network IP address, public network port), Basic NAT performs address translation for the bound port.
  • Cone NAT establishes (private IP address, private port) and (public network IP address, public network port) binding relationship, and then, for application connections from the same private IP and port number, this binding will be reused. Port, as long as there is a connection session, the bound port will remain active.
  • Cone NAT is divided into several subtypes: Full Cone NAT, Restricted Cone NAT, and Port-Restricted Cone NAT.
  • Full Cone NAT establishes a public/private port binding for a new external session, it can receive data traffic from any external endpoint on the public network through this public port.
  • Restricted Cone NAT will receive the packet of this external IP address after the internal host sends one or more packets to the IP address of an external host.
  • Port-Restricted Cone NAT receives the external IP address and port number packet after the internal host sends one or more packets to the IP address and port number of an external host. It can be seen that Restricted Cone NAT and Port-Restricted Cone NAT can effectively protect internal hosts from receiving unrequested packets.
  • Symmetric NAT does not maintain (private IP, private port number) and (public network IP, public network port number) binding relationship in all session devices. Instead, it will reassign a new public to each new session. Network port or public IP address.
  • P2P is established between two nodes located in different types of NAT.
  • a host A in the network needs to establish a P2P channel with host B, it usually needs an external server with dual IP to determine the NAT type of the network where it is located, and then submit the NAT type to the server. Similarly, the server also stores the host. The type of NAT submitted by B. Host A obtains the NAT type of the network where Host B is located from the server. If Host B is on the public network, or the NAT type of the network is Full Cone NAT, Host A adopts the active mode. As shown in Figure 3, Host A sends data directly. After the packet is sent to the host B, the host B returns the response packet to the host A to establish a P2P connection. Otherwise, the host A adopts the passive mode. As shown in FIG. 4, the host A notifies the host B to send the data packet to the host A through the server. A returns a response packet to host B to establish a P2P connection.
  • the main object of the present invention is to provide a method and system for establishing a P2P channel, which improves the success rate of P2P channel establishment.
  • a method of establishing a peer-to-peer direct channel including: After receiving the synchronization request sent by the first host, the server simultaneously sends the synchronization data packet including the address information of the other party to the first and second hosts;
  • the first and second hosts After receiving the synchronization data packet, the first and second hosts send a User Datagram Protocol UDP data packet to the other party according to the received counterpart address information.
  • the method further includes:
  • the first host and the second host log in to the server, and the server records the network identifier and address information of the first and second hosts, respectively.
  • the synchronization request sent by the first host to the server includes at least network identification and address information of the second host.
  • the method further includes:
  • the second host After receiving the synchronization data packet, the second host determines whether to establish a peer-to-peer direct connection with the first host, and if so, immediately sends a UDP data packet to the first host; otherwise, the process ends.
  • the method further includes:
  • the first host and the second host After receiving the UDP packet sent by the other party, the first host and the second host return the response packet to the other party.
  • the package includes:
  • the first host After receiving the synchronous data packet, the first host sends a UDP packet to the second host according to the received address information of the second host;
  • the second host After receiving the synchronization data packet, the second host sends a UDP data packet to the first host according to the received address information of the first host.
  • the second host After receiving the synchronization data packet, the second host sends the UDP data packet to the other party, including: after receiving the synchronization data wave packet, the second host sends the UDP data packet to the first host according to the received address information of the first host;
  • the first host After receiving the synchronization data packet, the first host sends a UDP data packet to the second host according to the received address information of the second host.
  • the second host is located in the Restricted Cone NAT or the Port-Restricted Cone NAT. After receiving the synchronization data packet, the first and second hosts send the UDP data packet to the other party, including:
  • the first host After receiving the synchronous data packet, the first host sends a UDP packet to the second host according to the received address information of the second host;
  • the second host After receiving the synchronization data packet, the second host sends a UDP data packet to the first host according to the received address information of the first host.
  • the package includes:
  • the second host After receiving the synchronous data packet, the second host sends a UDP packet to the first host according to the received address information of the first host;
  • the first host After receiving the synchronization data packet, the first host sends a UDP data packet to the second host according to the received address information of the second host.
  • the address information includes at least a public network internet protocol IP address and a port number.
  • the address information further includes a private network IP address and a port number.
  • a system for establishing a peer-to-peer direct connection channel includes a server, a first host, and a second host; After receiving the synchronization request sent by the first host, the server simultaneously sends the synchronization data packet including the address information of the other party to the first and second hosts;
  • the first and second hosts After receiving the synchronization data packet, the first and second hosts send a User Datagram Protocol UDP data packet to the other party according to the received counterpart address information.
  • a method of establishing a peer-to-peer direct connection channel comprising:
  • the first host obtains address information of the second host from the server and network address converter NAT information of the network where the second host is located;
  • the first host directly sends the UDP data packet to the second host according to the obtained second host address information
  • the first host further determines the NAT information of the network in which it is located;
  • the first host If the first host is located in the public network or is in the fully symmetric Full Cone NAT jurisdiction, the first host notifies the second host to send the UDP data packet to the first host A through the server;
  • the first host sends a synchronization request to the server, and after receiving the synchronization request, the server simultaneously sends the synchronization data packet including the address information of the other party to the first and second hosts;
  • the first and second hosts After receiving the synchronization data packet, the first and second hosts send a User Datagram Protocol UDP data packet to the other party according to the received counterpart address information.
  • two hosts simultaneously send UDP data packets to each other, and when receiving the data packet sent by the other party, since the data packet has been sent to the other party, the NAT will receive
  • the arriving packet is regarded as a valid data packet
  • the P2P channel can be successfully established between the two hosts.
  • the NAT of the network where the host is located is both Restricted Cone NAT or Port-Restricted Cone NAT, The problem of the inability to successfully establish a P2P tunnel due to the rejection of unsolicited packets by these two NATs.
  • the P2P connection can be successfully established. Thereby greatly improving the success rate of P2P connection establishment.
  • Figure 1 is a schematic diagram of a host in a network connected in a client/server manner.
  • Figure 2 is a schematic diagram of a host connected in a network in a P2P manner.
  • FIG. 3 is a schematic diagram of a prior art method for establishing a P2P channel in an active manner.
  • FIG. 4 is a schematic diagram of a prior art method for establishing a P2P channel in a passive manner.
  • Figure 5 is a schematic diagram of the present invention for establishing a P2P channel in a synchronous manner.
  • Figure 6 is a flow chart of the present invention for establishing a P2P channel in a synchronous manner. Mode for carrying out the invention
  • the present invention provides a method for establishing a P2P channel in a synchronous manner.
  • Host A wishes to establish a P2P connection with Host B, it first sends a synchronization request packet to the server, and the server receives it. After the data packet is synchronously requested, the synchronous data packet including the network information of both parties is simultaneously sent to the host A and the host B. After the host A and the host B respectively receive the synchronization data packet, the user datagram protocol (UDP) data packet is immediately sent to the other party. After receiving the UDP packet sent by the other party, the UDP response packet is returned to the other party.
  • UDP user datagram protocol
  • Figure 6 is a flow chart of the present invention for establishing a P2P channel in a synchronous manner. As can be seen from Figure 6, The process specifically includes the following steps:
  • Step 601 Host A and Host B log in to the server respectively.
  • the server records the public IP address and public network port number, private network IP address, private network port number, and network identifier of Host A and Host B.
  • Step 602 When the host A wants to establish a P2P connection between the host and the host B, the host sends a synchronization request packet to the server, where the synchronization packet includes at least the private network IP address and port number of the host A, and the public network IP of the host A.
  • Step 603 After receiving the synchronization request data packet sent by host A, the server simultaneously sends synchronization data packets to host A and host B, and the synchronization data packet sent to host A includes at least The public network IP address and port number of host B, the private network IP address and port number of host B, and the synchronization data packet sent to host B contains at least the public network IP address and port number of host A and the private network IP address of host B. And port number, and then perform steps 604 and 606, respectively;
  • Step 604 After receiving the synchronization data packet sent by the server, the host A immediately sends a UDP data packet to the host B according to the IP address and port number of the public network and the private network of the host B.
  • Step 605 Host A receives the host. After the UDP packet sent by B, since host A has sent a UDP packet to host B, the NAT of the network where host B is located accepts the packet, host A returns a response packet to host B, and then exits the process.
  • Step 606 After receiving the synchronization data packet sent by the server, the host B determines whether to establish a P2P connection with the host A. If yes, step 607 is performed; otherwise, the P2P channel establishment fails;
  • Step 607 Host B immediately sends a UDP data packet to host A according to the IP address and port number of the public network and private network of host A.
  • Step 608 After receiving the UDP data packet sent by the host A, the host B sends a UDP data packet to the host A, so the NAT of the network where the host A is located also accepts the data packet, and the host B returns to the host A. A response packet. Thereby, the establishment process of the P2P channel between the host ⁇ and the host B is completed.
  • the method for establishing the P2P channel in the synchronous manner can successfully establish the P2P channel.
  • step 604 For the case where host A is located within the jurisdiction of Restricted Cone NAT, Port-Restricted Cone NAT, or Symmetric NAT, and the host is located within the jurisdiction of the public network or Full Cone NAT, as long as step 604 has been performed before step 608, host A is Before receiving the UDP packet sent by host B, it has sent UDP packet to host B to ensure that the P2P channel can be successfully established.
  • host A can be controlled to send a UDP packet to host B first, and then host B goes to Host A sends a UDP packet.
  • step 607 For the case where host A is located within the jurisdiction of the public network or Full Cone NAT, and host B is located within the jurisdiction of Restricted Cone NAT, Port-Restricted Cone NAT, or Symmetric NAT, as long as step 607 has been performed before step 605, that is, host B is The UDP packet has been sent to Host A before receiving the UDP packet sent by Host A, which ensures that the P2P channel can be successfully established.
  • the host B in order to ensure that the host B has sent the UDP packet to the host B before receiving the UDP packet sent by the host A, the host B can be controlled to send the UDP packet to the host A first, and then the host A sends the packet again. Host B sends a UDP packet.
  • host A can be controlled to send UDP packets to host B first, and then host B Then, the host A sends a UDP packet; or, the host B can first send a UDP packet to the host A, and then the host A sends the UDP packet to the host B.
  • Some systems use the Port-Restricted Cone NAT method to map the IP address and port number in the case of the detected Symmetric NAT.
  • the Symmetric mapping method such as iptables, is used, and the two parties can establish a P2P connection. .
  • establishing a P2P connection by using the synchronization mode of the present invention can at least solve the problem that the P2P channel cannot be established when the two hosts cannot be established within the jurisdiction of the Restricted Cone NAT or the Port-Restricted Cone NAT in the prior art, as long as it is ensured.
  • the host of the two parties has already sent the data packet to the other party when receiving the data packet of the other party.
  • the host A sends the UDP data packet to the host B.
  • the time is greater than the time when the server sends the synchronization packet to the host B. In reality, this condition is easily satisfied. Therefore, the present invention can successfully establish a P2P connection in many cases, thereby improving the success rate of the P2P connection establishment.
  • the present invention further includes a solution combining the foregoing scheme for simultaneously transmitting a data packet with a scheme for establishing a P2P channel in the prior art, which is specifically as follows:
  • Host A obtains the address information of host B and the NAT type of the network where host B is located. If host B is on the public network or the NAT type of the network is Full Cone NAT, host A adopts the active mode, as shown in Figure 3. The host A directly sends a data packet to the host B according to the address information of the host B, and the host B returns the response data packet to the host A, thereby Establish a P2P connection;
  • host A further determines whether it is within the jurisdiction of the public network or Full Cone NAT;
  • host A If host A is located within the jurisdiction of the public network or Full Cone NAT, host A adopts the passive mode. As shown in FIG. 4, host A notifies host B to send a data packet to host A through the server, and host A returns a response packet to Host B, thereby establishing a P2P connection;
  • the foregoing method for simultaneously transmitting the data packet is adopted, that is, the host A sends a synchronization request to the server, and the server simultaneously sends the host A and the host B at least the address information of the other party.
  • the server After synchronizing the data packet, after receiving the synchronization data packet, Host A and Host B send the data packet to the other party.

Landscapes

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

Description

一种建立对等直连通道的方法和系统
技术领域
本发明涉及计算机网络中节点的连接技术, 特别是涉及一种建立对 等连接(P2P, Peer to Peer )通道的方法和系统。 发明背景
在网络中, 两个节点之间的连接方式一般有两种: 一种是客户端 / 服务器方式的连接, 客户端申请服务, 服务器提供服务, 通常这种连接 方式是一对多的关系, 如图 1所示, 一个服务器可以接收来自多个客户 端的申请,并向多个客户端提供服务, 两者之间的关系是非对等的关系; 另一种是 P2P方式, 如图 2所示, P2P方式的连接是指在计算机网络中 的每两个节点直接连接, 即每两个节点之间是对等连接的关系。
在客户端 /服务器的方式下, 由于服务器需要向多个客户端提供服 务, 所以, 通常需要使用高性能的机器, 成本一般比较大。 P2P方式的 通讯双方是对等的关系, 两者互相为对方提供月艮务, 所以, P2P方式的 突出优势在于可以将众多性能不高的 PC连接起来, 以实现资源共享和 通讯, 这种连接方式大大降低了成本, 逐渐成为网络发展的新方向。 目 前主要的应用有文件交换、 分布式计算、 协同工作、 分布式搜索和电子 商务等。
虽然 P2P方式有如上所述的优势, 但是其发展受到一定限制, 这是 因为, 为了防范网络病毒的攻击, 越来越多的计算机都位于网络地址转 换器(Network Address Translator, NAT )的保护之内。 NAT是在内部网 络和公共网络之间起检查和转发作用的设备,通常集成在路由器上 , NAT 可能会修改内网中主机的 IP地址和端口信息,所以它限制了网络上任意 两台计算机之间的直接通讯,只有符合一定规则的通讯才被允许,所以, 如何突破 NAT的限制是实现 P2P的重要内容。
NAT大致分为两种类型:基本 NAT( Basic NAT )、非对称 NAT( Cone NAT )和对称 NAT ( Symmetric NAT )。
Basic NAT建立(私有 IP地址, 私有端口)和(公网 IP地址, 公网 端口)之间的绑定关系, Basic NAT为绑定的端口执行地址翻译。
Cone NAT建立(私有 IP地址, 私有端口)和(公网 IP地址, 公网 端口)之间的绑定关系, 然后, 对于来自同一私有 IP和端口号的应用连 接, 将重复使用这个绑定的端口, 只要有一个连接会话, 这个绑定端口 就会保持激活状态。
Cone NAT又分为几种子类型: 完全非对称 NAT ( Full Cone NAT ), 受限非对称 NAT ( Restricted Cone NAT ) 和端口受限非对称 NAT ( Port-Restricted Cone NAT )。 Full Cone NAT在给一个新的外部会话建 立了一个公网 /私有的端口绑定后,就可以通过这个公共端口从公网上的 任何外部端点接收数据通讯了。 Restricted Cone NAT在内部主机发送了 一个或多个数据包给一个外部主机的 IP地址后, 才会接收这个外部 IP 地址的数据包。 Port-Restricted Cone NAT在内部主机发送了一个或多个 数据包给一个外部主机的 IP地址和端口号后, 才会接收这个外部 IP地 址和端口号的数据包。可见, Restricted Cone NAT和 Port-Restricted Cone NAT可有效保护内部主机不接收未被请求的数据包。
Symmetric NAT在所有会话器件不会保持(私有 IP, 私有端口号) 和(公网 IP, 公网端口号)的绑定关系不变, 相反, 它会为每个新会话 重新分配一个新的公网端口或公网 IP地址。
由于当前 NAT的种类繁多, 并且不同种类的 NAT各有其自身规定 的通讯方式, 所以, 在位于不同种类 NAT 中的两个节点之间建立 P2P 通道的时候, 首先需要获得双方节点的 NAT的类型, 然后根据 NAT的 类型采用不同的通讯方式建立 P2P通道。
下面介绍现有技术建立 P2P通道的方法。
首先, 当网络中某主机 A需要与主机 B建立 P2P通道时,通常需要 一台具有双 IP的外部服务器确定自身所在网络的 NAT类型,然后将 NAT 类型提交给服务器, 同样, 服务器也保存有主机 B提交的 NAT类型。 主机 A从服务器获取主机 B所在网络的 NAT类型, 如果主机 B位于公 网, 或其所在网络的 NAT类型为 Full Cone NAT, 则主机 A采用主动方 式, 如图 3所示, 主机 A直接发送数据包至主机 B, 主机 B返回应答数 据包至主机 A, 从而建立 P2P连接; 否则, 主机 A采用被动方式, 如图 4所示, 主机 A通过服务器通知主机 B先发送数据包给主机 A, 主机 A 返回应答数据包至主机 B, 从而建立 P2P连接。
对于上述采取被动方式的情况, 如果主机 A位于公网, 或其所在网 络的 NAT类型为 Full Cone NAT, P2P连接可以成功建立。 但是, 如果 主机 A所在网络的 NAT类型为 Restricted Cone NAT、 Port-Restricted Cone NAT和 Symmetric NAT, 由于这些类型的 NAT将拒绝不请自来的数据 包,甚至会将某 'IP地址和端口号在一段时间之内发来的数据包认作攻击 包而全部丢弃,造成 P2P连接的建立失败。由此可见,现有技术建立 P2P 通道的成功率低。 发明内容
本发明的主要目的在于提供一种建立 P2P通道的方法和系统, 提高 P2P通道建立的成功率。
本发明的目的是通过如下技术方案实现的:
—种建立对等直连通道的方法, 包括: 服务器在接收到第一主机发来的同步请求后, 同时向第一和第二主 机发送至少包含对方地址信息的同步数据包;
第一和第二主机在接收到同步数据包后, 根据接收到的对方地址信 息, 向对方发送用户数据报协议 UDP数据包。
该方法进一步包括:
在第一主机向服务器发送同步请求之前, 第一主机和第二主机登录 服务器, 服务器分别记录第一和第二主机的网络标识和地址信息。
所述第一主机向服务器发送的同步请求至少包括第二主机的网络标 识和地址信息。
该方法进一步包括:
第二主机在接收到同步数据包后, 判断是否建立与第一主机的对等 直连通道, 如果是, 则立即向第一主机发送 UDP数据包; 否则, 结束 本流程。
该方法进一步包括:
第一和第二主机在接收到对方发来的 UDP数据包后,向对方返回应 答数据包。
如果第一主机位于 Restricted Cone NAT、 Port-Restricted Cone NAT 或 Symmetric NAT, 第二主机位于公网或 Full Cone NAT, 所述第一和第 二主机在接收到同步数据包后, 向对方发送 UDP数据包包括:
接收到同步数据波包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包;
接收到同步数据包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包。
如果第一主机位于公网或 Full Cone NAT, 第二主机位于 Restricted Cone NAT、 Port-Restricted Cone NAT或 Symmetric NAT, 所述第一和第 二主机在接收到同步数据包后, 向对方发送 UDP数据包包括: 接收到同步数据波包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包;
接收到同步数据包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包。
如果第一主机位于 Restricted Cone NAT 或 Port-Restricted Cone
NAT, 第二主机位于 Restricted Cone NAT或 Port-Restricted Cone NAT, 所述第一和第二主机在接收到同步数据包后, 向对方发送 UDP数据包 包括:
接收到同步数据波包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包;
接收到同步数据包后 , 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包。
如果第一主机位于 Restricted Cone NAT 或 Port-Restricted Cone NAT , 第二主机位于 Restricted Cone NAT或 Port-Restricted Cone NAT , 所述第一和第二主机在接收到同步数据包后, 向对方发送 UDP数据包 包括:
接收到同步数据波包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包;
接收到同步数据包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包。
所述地址信息至少包含公网网际协议 IP地址和端口号。
所述地址信息进一步包括私网 IP地址和端口号。
一种建立对等直连通道的系统包括服务器、 第一主机和第二主机; 其中 服务器接收到第一主机发来的同步请求后, 同时向第一和第二主机 发送至少包含对方地址信息的同步数据包;
第一和第二主机在接收到同步数据包后, 根据接收到的对方地址信 息, 向对方发送用户数据报协议 UDP数据包。
一种建立对等直连通道的方法, 包括:
第一主机从服务器上获取第二主机的地址信息以及第二主机所在网 络的网絡地址转换器 NAT信息;
如果第二主机位于公网或其处于完全对称 Full Cone NAT管辖内, 第一主机根据获取的第二主机地址信息, 直接发送 UDP数据包至第二 主机;
如果第二主机不位于公网且不处于 Full Cone NAT管辖内, 第一主 机进一步判断其自身所在网络的 NAT信息;
如果第一主机位于公网或其处于完全对称 Full Cone NAT管辖内, 第一主机通过服务器通知第二主机发送 UDP数据包给第一主机 A;
如果第一主机不位于公网且不处于 Full Cone NAT的管辖内, 执行 如下步骤:
第一主机向服务器发送同步请求, 服务器在接收到该同步请求后, 同时向第一和第二主机发送至少包含对方地址信息的同步数据包;
第一和第二主机在接收到同步数据包后, 根据接收到的对方地址信 息, 向对方发送用户数据报协议 UDP数据包。
从上述技术方案可以看出, 在本发明的方法中, 两个主机同时向对 方发送 UDP数据包, 那么在接收到对方发来的数据包时, 由于已经向 对方发送了数据包, NAT将接收到的数据包认作有效的数据包, 则两个 主机之间能够成功建立 P2P通道。解决了现有技术中双方主机所在网络 的 NAT均为 Restricted Cone NAT或 Port-Restricted Cone NAT的情况下, 由于这两种 NAT拒绝不请自来的数据包所造成的无法成功建立 P2P通 道的问题。而且,在其中一方主机所在网络的 NAT为变端口的 Symmetric NAT, 另一方主机所在网络的 NAT为 Restricted Cone NAT的情况下也 可成功建立 P2P连接。 从而大大提高了 P2P连接建立的成功率。 附图简要说明
图 1是网络中的主机以客户端 /服务器方式连接的示意图。
图 2是网络中的主机以 P2P方式连接的示意图。
图 3是现有技术的采用主动方式建立 P2P通道的示意图。
图 4是现有技术的采用被动方式建立 P2P通道的示意图。
图 5是本发明的采用同步方式建立 P2P通道的示意图。
图 6是本发明的采用同步方式建立 P2P通道的流程图。 实施本发明的方式
为了使本发明的目的、 技术方案及优点更加清楚明白 , 以下结合附 图及实施例, 对本发明进行进一步详细说明。 应当理解, 此处所描述的 具体实施例仅仅用以解释本发明, 并不用于限定本发明。
本发明提供了一种采用同步方式建立 P2P通道的方法,如图 5所示, 当主机 A希望建立与主机 B之间的 P2P连接时, 首先向服务器发送同 步请求数据包, 服务器在接收到到同步请求数据包后, 同时向主机 A和 主机 B发送包含双方网络信息的同步数据包, 在主机 A和主机 B分别 接收到同步数据包后, 立即向对方发送用户数据报协议 ( UDP )数据包, 并在接收到对方发来的 UDP数据包后, 分别向对方返回 UDP应答数据 包。
图 6是本发明的采用同步方式建立 P2P通道的流程图。从图 6可见, 该流程具体包括如下步骤:
步骤 601 : 主机 A和主机 B分别登录服务器, 服务器记录主机 A和 主机 B的公网 IP地址和公网端口号、 私网 IP地址和私网端口号、 网络 标识;
步骤 602: 当主机 A希望建立其与主机 B之间的 P2P连接时, 向服 务器发送同步请求数据包, 该同步数据包至少包含主机 A的私网 IP地 址和端口号、 主机 A的公网 IP地址和端口号、 主机 B的网络标识; 步骤 603: 服务器接收到主机 A发来的同步请求数据包后, 同时向 主机 A和主机 B发送同步数据包 , 发给主机 A的同步数据包至少包含 主机 B的公网 IP地址和端口号、 主机 B的私网 IP地址和端口号, 发给 主机 B的同步数据包至少包含主机 A的公网 IP地址和端口号、 主机 B 的私网 IP地址和端口号 , 然后分别执行步骤 604和 606;
步骤 604: 主机 A在接收到服务器发来的同步数据包后, 根据主机 B的公网及私网的 IP地址和端口号立即向主机 B发送 UDP数据包; 步驟 605: 主机 A在接收到主机 B发来的 UDP数据包后, 由于主 机 A已经发送了一个 UDP数据包至主机 B ,因此主机 B所在网络的 NAT 接受该数据包,主机 A向主机 B返回一个应答数据包,然后退出本流程; 步骤 606: 主机 B在接收到服务器发来的同步数据包后, 判断是否 与主机 A建立 P2P连接, 如果是, 则执行步骤 607, 否则结束, P2P通 道建立失败;
步骤 607:主机 B根据主机 A的公网及私网的 IP地址和端口号立即 向主机 A发送 UDP数据包;
步骤 608: 主机 B在接收到主机 A发来的 UDP数据包后, 由于其 已经发送了一个 UDP数据包至主机 A, 因此主机 A所在网络的 NAT也 接受该数据包, 主机 B向主机 A返回一个应答数据包。 从而, 完成了主机 Α和主机 B之间的 P2P通道的建立过程。
下面对于上述技术方案的效果进行分析。
对于主机 A和主机 B位于公网或 Full Cone NAT管辖内的情况, 本 发明的采用同步方式建立 P2P通道的方法可以成功建立 P2P通道。
对于主机 A位于 Restricted Cone NAT、 Port-Restricted Cone NAT或 Symmetric NAT的管辖内, 主机 Β位于公网或 Full Cone NAT的管辖内 的情况, 只要在步骤 608之前已经执行了步骤 604, 即主机 A在接收到 主机 B发来的 UDP数据包之前已经向主机 B发:^了 UDP数据包,即可 保证 P2P通道能够成功建立。在实际应用中, 为了保证主机 A在接收到 主机 B发来的 UDP数据包之前就已经向主机 B发送了 UDP数据包,可 以控制主机 A先向主机 B发送 UDP数据包,然后主机 B再向主机 A发 送 UDP数据包。
对于主机 A位于公网或 Full Cone NAT 的管辖内, 主机 B位于 Restricted Cone NAT、 Port-Restricted Cone NAT或 Symmetric NAT的管 辖内的情况, 只要在步骤 605之前已经执行了步骤 607, 即主机 B在接 收到主机 A发来的 UDP数据包之前已经向主机 A发送了 UDP数据包, 即可保证 P2P通道能够成功建立。在实际应用中, 为了保证主机 B在接 收到主机 A发来的 UDP数据包之前就已经向主机 B发送了 UDP数据包, 可以控制主机 B先向主机 A发送 UDP数据包, 然后主机 A再向主机 B 发送 UDP数据包。
对于主机 A位于 Restricted Cone NAT或 Port-Restricted Cone NAT的 管辖内,主机 B位于 Restricted Cone NAT或 Port-Restricted Cone NAT的 管辖内的情况, 只要在步骤 605之前已经执行了步骤 607,'或者在步骤 608之前已经执行了步骤 604, 即可保证 P2P通道能够成功建立。 在实 际应用中, 可以控制主机 A先向主机 B发送 UDP数据包, 然后主机 B 再向主机 A发送 UDP数据包; 或者, 可以控制主机 B先向主机 A发送 UDP数据包, 然后主机 A再向主机 B发送 UDP数据包。
对于主机 A和主机 B中任一方位于 Symmetric NAT的管辖内,在以 下两种情况下亦可以成功建立连接:
其一, 如果一方位于变端口的 Symmetric NAT的管辖内, 另一方位 于 Restricted NAT的管辖内, 由于 Symmetric NAT不改变发出数据包的 源公网 IP地址, 因此对方的 Restricted NAT可接受该数据包, 从而双方 可以建立 P2P连接;
其二, 有的系统对于检测出的 Symmetric NAT , 优先按按 Port-Restricted Cone NAT的方式来映射 IP地址和端口号,冲突时才使用 Symmetric的映射方式, 例如 iptables , 这时双方可以建立 P2P连接。
从以上分析可以看出, 采用本发明的同步方式建立 P2P连接至少可 以解决现有技术中无法建立双方主机位于 Restricted Cone NAT 或 Port-Restricted Cone NAT的管辖内时无法建立 P2P通道的问题, 只要确 保双方主机在接收到对方的数据包时已经向对方发送过数据包即可, 如 图 5所示, 只要确保服务器发送同步数据包至主机 A的时间加上主机 A 发送 UDP数据包到主机 B的时间大于服务器发送同步数据包至主机 B 的时间, 在现实情况下, 这个条件很容易满足, 因此本发明能够在较多 情况下成功建立 P2P连接, 从而提高了 P2P连接建立的成功率。
另外, 本发明还包括将上述同时发送数据包的方案与现有技术建立 P2P通道的方案相结合的方案, 具体如下:
主机 A从服务器获取主机 B的地址信息以及主机 B所在网络的 NAT 类型,如果主机 B位于公网,或其所在网络的 NAT类型为 Full Cone NAT, 则主机 A采用主动方式, 即如图 3所示, 主机 A根据主机 B的地址信 息, 直接发送数据包至主机 B, 主机 B返回应答数据包至主机 A, 从而 建立 P2P连接;
如果主机 B不位于公网或 Full Cone NAT的管辖之内, 则主机 A进 一步判断自身是否位于公网或 Full Cone NAT的管辖内;
如果主机 A位于公网或 Full Cone NAT的管辖内, 则主机 A采用被 动方式, 即如图 4所示,主机 A通过服务器通知主机 B先发送数据包给 主机 A, 主机 A返回应答数据包至主机 B, 从而建立 P2P连接;
如果主机 A不位于公网或 Full Cone NAT的管辖内, 则采用前述的 同时发送数据包的方案, 即主机 A向服务器发送同步请求, 服务器同时 向主机 A和主机 B发送至少包含对方地址信息的同步数据包,接收到同 步数据包后, 主机 A和主机 B向对方发送数据包。
以上所述仅为本发明的较佳实施例而已, 并不用以限制本发明, 凡 在本发明的精神和原则之内所作的任何修改、 等同替换和改进等, 均应 包含在本发明的保护范围之内。

Claims

权利要求书
1、 一种建立对等直连通道的方法, 其特征在于, 包括:
服务器在接收到第一主机发来的同步请求后, 同时向第一和第二主 机发送至少包含对方地址信息的同步数据包;
第一和第二主机在接收到同步数据包后, 根据接收到的对方地址信 息, 向对方发送用户数据报协议 UDP数据包。
2、 根据权利要求 1所述的方法, 其特征在于, 进一步包括: 在第一主机向服务器发送同步请求之前, 第一主机和第二主机登录 服务器, 服务器分别记录第一和第二主机的网络标识和地址信息。
3、根据权利要求 1所述的方法, 其特征在于, 所述第一主机向服务 器发送的同步请求至少包括第二主机的网络标识和地址信息。
4、 根据权利要求 1所述的方法, 其特征在于, 进一步包括: 第二主机在接收到同步数据包后, 判断是否建立与第一主机的对等 直连通道, 如果是, 则立即向第一主机发送 UDP数据包; 否则, 结束 本流程。
5、 根据权利要求 1所述的方法, 其特征在于, 进一步包括: 第一和第二主机在接收到对方发来的 UDP数据包后,向对方返回应 答数据包。
6、 居权利要求 1 所述的方法, 其特征在于, 如果第一主机位于 受限的非对称网络地址转换器 Restricted Cone NAT, 端口受限的非对称 网络地址转换器 Port-Restricted Cone NAT 或对称网络地址转换器 Symmetric NAT, 第二主机位于公网或完全非对称网络地址转换器 Full Cone NAT, 所述第一和第二主机在接收到同步数据包后, 向对方发送 UDP数据包包括: 接收到同步数据波包后 , 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包;
接收到同步数据包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包。
7、 才艮据权利要求 1 所述的方法, 其特征在于, 如果第一主机位于 公网或 Full Cone NAT的管辖内, 第二主机位于 Restricted Cone NAT、 Port-Restricted Cone NAT或 Symmetric NAT的管辖内, 所述第一和第二 主机在接收到同步数据包后 , 向对方发送 UDP数据包包括:
接收到同步数据波包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包;
接收到同步数据包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包。
8、 才 据权利要求 1 所述的方法, 其特征在于, 如果第一主机位于 Restricted Cone NAT 或 Port-Restricted Cone NAT , 第二主机位于 Restricted Cone NAT或 Port-Restricted Cone NAT, 所述第一和第二主机 在接收到同步数据包后, 向对方发送 UDP数据包包括:
接收到同步数据波包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包;
接收到同步数据包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包。
9、 才艮据权利要求 1 所述的方法, 其特征在于, 如果第一主机位于 Restricted Cone NAT 或 Port-Restricted Cone NAT , 第二主机位于 Restricted Cone NAT或 Port-Restricted Cone NAT, 所述第一和第二主机 在接收到同步数据包后, 向对方发送 UDP数据包包括:
接收到同步数据波包后, 第二主机根据接收到的第一主机的地址信 息, 向第一主机发送 UDP数据包;
接收到同步数据包后, 第一主机根据接收到的第二主机的地址信 息, 向第二主机发送 UDP数据包。
10、 根据权利要求 1至 9中任一项所述的方法, 其特征在于, 所述 地址信息至少包含公网网际协议 IP地址和端口号。
11、 根据权利要求 10所述的方法, 其特征在于, 所述地址信息进 一步包括私网 IP地址和端口号。
12、 一种建立对等直连通道的系统, 其特征在于, 包括服务器、 第 一主机和第二主机; 其中
服务器在接收到第一主机发来的同步请求后, 同时向第一和第二主 机发送至少包含对方地址信息的同步数据包;
第一和第二主机接收到同步数据包后, 根据接收到的对方地址信 息 , 向对方发送用户数据报协议 UDP数据包。
13、 一种建立对等直连通道的方法, 其特征在于, 包括:
第一主机从服务器上获取第二主机的地址信息以及第二主机所在网 络的网络地址转换器 NAT信息;
如果第二主机位于公网或其处于完全对称 Full Cone NAT管辖内, 第一主机根据获取的第二主机地址信息,直接发送用户数据报协议 UDP 数据包至第二主机;
如果第二主机不位于公网且不处于 Full Cone NAT管辖内, 第一主 机进一步判断其自身所在网络的 NAT信息;
如果第一主机位于公网或其处于完全对称 Full Cone NAT管辖内, 第一主机通过服务器通知第二主机发送 UDP数据包给第一主机 A; 如果第一主机不位于公网且不处于 Full Cone NAT的管辖内, 执行 如下步骤:
第一主机向服务器发送同步请求, 服务器在接收到该同步请求后, 同时向第一和第二主机发送至少包含对方地址信息的同步数据包; 第一和第二主机在接收到同步数据包后, 根据接收到的对方地址信 息, 向对方发送用户数据报协议 UDP数据包。
PCT/CN2006/002111 2005-08-18 2006-08-18 Procede et systeme d'etablissement d'un canal direct point par point WO2007019809A1 (fr)

Priority Applications (1)

Application Number Priority Date Filing Date Title
BRPI0616599-0A BRPI0616599A2 (pt) 2005-08-18 2006-08-18 método e sistema para estabelecer uma conexão ponto a ponto

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200510092810.5A CN1917512B (zh) 2005-08-18 2005-08-18 一种建立对等直连通道的方法
CN200510092810.5 2005-08-18

Publications (1)

Publication Number Publication Date
WO2007019809A1 true WO2007019809A1 (fr) 2007-02-22

Family

ID=37738407

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2006/002111 WO2007019809A1 (fr) 2005-08-18 2006-08-18 Procede et systeme d'etablissement d'un canal direct point par point

Country Status (4)

Country Link
CN (1) CN1917512B (zh)
BR (1) BRPI0616599A2 (zh)
RU (1) RU2373654C1 (zh)
WO (1) WO2007019809A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112468610A (zh) * 2020-11-17 2021-03-09 杭州安恒信息安全技术有限公司 数据传输方法、监控节点、监控服务器及监控网络系统
CN112804285A (zh) * 2020-11-08 2021-05-14 北京明瑞之光科技有限公司 一种景观照明系统及其文件传输方法

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8060626B2 (en) * 2008-09-22 2011-11-15 Sony Computer Entertainment America Llc. Method for host selection based on discovered NAT type
CN101217536B (zh) * 2007-12-28 2011-11-09 腾讯科技(深圳)有限公司 穿越网络地址转换设备/防火墙的方法、系统及客户端
CN101980508B (zh) * 2010-11-01 2013-05-15 深圳市鼎盛威电子有限公司 网络监控系统上的网络自适应运行模式
CN103516795B (zh) * 2013-09-26 2015-06-10 传线网络科技(上海)有限公司 分布式网络连通性改善方法以及使用该方法的分布式网络
CN104660722A (zh) * 2013-11-21 2015-05-27 倚强科技股份有限公司 网络连线方法及其网络系统
CN110661860B (zh) * 2019-09-18 2021-08-20 华为技术有限公司 一种建立通话的方法及通话设备
CN111506013A (zh) * 2020-04-08 2020-08-07 上海汉枫电子科技有限公司 一种基于虚拟串口的plc设备远程数据通信实现方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1493140A (zh) * 2001-02-20 2004-04-28 �������繫˾ 允许数据传输穿越防火墙的方法和设备
JP2004180003A (ja) * 2002-11-27 2004-06-24 Kitt Peak:Kk 通信ネットワークシステムおよび通信の接続方法
US20040139228A1 (en) * 2003-01-15 2004-07-15 Yutaka Takeda Peer-to-peer (P2P) connection despite network address translators (NATs) at both ends

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1166124C (zh) * 2002-09-16 2004-09-08 联想(北京)有限公司 家庭网络中实现动态组网时的设备对等连接方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1493140A (zh) * 2001-02-20 2004-04-28 �������繫˾ 允许数据传输穿越防火墙的方法和设备
JP2004180003A (ja) * 2002-11-27 2004-06-24 Kitt Peak:Kk 通信ネットワークシステムおよび通信の接続方法
US20040139228A1 (en) * 2003-01-15 2004-07-15 Yutaka Takeda Peer-to-peer (P2P) connection despite network address translators (NATs) at both ends

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112804285A (zh) * 2020-11-08 2021-05-14 北京明瑞之光科技有限公司 一种景观照明系统及其文件传输方法
CN112804285B (zh) * 2020-11-08 2023-08-04 北京明瑞之光科技有限公司 一种景观照明系统及其文件传输方法
CN112468610A (zh) * 2020-11-17 2021-03-09 杭州安恒信息安全技术有限公司 数据传输方法、监控节点、监控服务器及监控网络系统
CN112468610B (zh) * 2020-11-17 2023-06-06 杭州安恒信息安全技术有限公司 数据传输方法、监控节点、监控服务器及监控网络系统

Also Published As

Publication number Publication date
CN1917512A (zh) 2007-02-21
CN1917512B (zh) 2010-09-29
RU2373654C1 (ru) 2009-11-20
BRPI0616599A2 (pt) 2011-06-28

Similar Documents

Publication Publication Date Title
CN114866521B (zh) 会议服务器
CN112911027B (zh) 用于建立媒体会话的方法和装置
EP2112788B1 (en) A method and node for p2p content sharing
US7227864B2 (en) Methods and systems for establishing communications through firewalls and network address translators
US8868757B1 (en) Two-way web service router gateway
US7366894B1 (en) Method and apparatus for dynamically securing voice and other delay-sensitive network traffic
WO2007019809A1 (fr) Procede et systeme d'etablissement d'un canal direct point par point
EP3225014B1 (en) Source ip address transparency systems and methods
US11425216B2 (en) Virtual private network (VPN) whose traffic is intelligently routed
WO2003021931A1 (fr) Procede et appareil d'egalisation de la charge d'un serveur de transmission multimedia en continu
WO2010127610A1 (zh) 一种虚拟专用网节点信息的处理方法、设备及系统
WO2016210202A1 (en) Media relay server
WO2010063242A1 (zh) 时钟同步的方法、设备以及网络系统
US20140123267A1 (en) Method and system for tcp turn operation behind a restrictive firewall
US20140337478A1 (en) Peer-to-peer network communications
US20120300776A1 (en) Method for creating virtual link, communication network element, and ethernet network system
CA2884382C (en) Method and system for tcp turn operation behind a restrictive firewall
US11716222B2 (en) Communications bridge
WO2023116165A1 (zh) 网络负载均衡方法、装置、电子设备、介质和程序产品
WO2011044810A1 (zh) 实现多方通信的方法、装置及系统
KR100660123B1 (ko) Nat 통과를 위한 브이.피.엔 서버 시스템 및 브이.피.엔클라이언트 단말기
Komu et al. Basic host identity protocol (HIP) extensions for traversal of network address translators
KR101996588B1 (ko) Arp 프로토콜을 지원하는 분리망 연계장치 및 그 제어방법
CN117439815B (zh) 一种基于反向透明桥接的内网穿透系统及方法
US20240171641A1 (en) Data service management of proxy devices

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application
WWE Wipo information: entry into national phase

Ref document number: 783/CHENP/2008

Country of ref document: IN

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2008109140

Country of ref document: RU

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSANT TO RULE 112(1) EPC OF 26-06-2008

122 Ep: pct application non-entry in european phase

Ref document number: 06775429

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: PI0616599

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20080218