WO2022148361A1 - 建立p2p连接的方法、客户端及系统 - Google Patents
建立p2p连接的方法、客户端及系统 Download PDFInfo
- Publication number
- WO2022148361A1 WO2022148361A1 PCT/CN2022/070236 CN2022070236W WO2022148361A1 WO 2022148361 A1 WO2022148361 A1 WO 2022148361A1 CN 2022070236 W CN2022070236 W CN 2022070236W WO 2022148361 A1 WO2022148361 A1 WO 2022148361A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- client
- public network
- network address
- address
- port
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 69
- 230000004044 response Effects 0.000 claims abstract description 131
- 238000012544 monitoring process Methods 0.000 claims abstract description 21
- 238000001514 detection method Methods 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 14
- 239000000523 sample Substances 0.000 claims description 3
- 238000004080 punching Methods 0.000 abstract description 36
- 238000010586 diagram Methods 0.000 description 13
- 238000004891 communication Methods 0.000 description 10
- 238000013507 mapping Methods 0.000 description 9
- 230000008569 process Effects 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 5
- 238000013519 translation Methods 0.000 description 5
- 230000009471 action Effects 0.000 description 4
- 230000008859 change Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000001413 cellular effect Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
- 239000013589 supplement Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
- H04L61/2514—Translation of Internet protocol [IP] addresses between local and global IP addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
- H04L61/256—NAT traversal
- H04L61/2575—NAT traversal using address mapping retrieval, e.g. simple traversal of user datagram protocol through session traversal utilities for NAT [STUN]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
- H04L61/256—NAT traversal
- H04L61/2589—NAT traversal over a relay server, e.g. traversal using relay for network address translation [TURN]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
- H04L61/2517—Translation of Internet protocol [IP] addresses using port numbers
Definitions
- the embodiments of the present application relate to the field of Internet technologies, and in particular, to a method for establishing a P2P connection.
- One or more embodiments of the present application simultaneously relate to a client and a system for establishing a P2P connection, a computing device, a computer-readable storage medium, and a computer program product.
- NAT technology is a technology that converts the private network address of the internal network into the public network address of the external network.
- There is a mapping table inside the NAT device which stores the mapping relationship between the internal network and the external network. For the packets sent to the outside world, a mapping relationship between the internal network and the external network will be added to the mapping table of the NAT device. In the future, all packets sent from the external network will check the mapping table. If there is, replace the external network address of the packet with the internal network address.
- the embodiments of the present application provide a method for establishing a P2P connection.
- One or more embodiments of the present application simultaneously relate to a client and a system for establishing a P2P connection, a computing device, a computer-readable storage medium, and a computer program product to solve the technical problems existing in the prior art defect.
- a method for establishing a P2P connection is provided, applied to a first client, including:
- the response message determine at least one public network address corresponding to the internal network address of the first client
- Register at least one public network address corresponding to the intranet address of the first client with the cloud server, and monitor at least one public network address corresponding to the intranet address of the first client;
- a method for establishing a P2P connection including:
- the first client and the second client communicate with at least two auxiliary nodes respectively, and obtain response messages returned by the at least two auxiliary nodes; according to the response messages, determine at least one public network address corresponding to the respective intranet addresses ; register at least one public network address corresponding to each intranet address with the cloud server, and monitor the at least one public network address;
- the first client obtains at least one public network address corresponding to the intranet address of the second client through the cloud server, and sends a message to each of the at least one public network address corresponding to the intranet address of the second client.
- the public network address sends an access request data packet;
- the second client obtains at least one public network address corresponding to the internal network address of the first client through the cloud server in the case of monitoring its own target public network address to receive the access request data packet, and sends it to the Each of the at least one public network address corresponding to the internal network address of the first client returns a response data packet, and the target public network address is at least one public network address corresponding to the internal network address of the second client.
- the web addresses one of the web addresses;
- the first client establishes a P2P connection with the second client under the condition that the second client returns a response data packet to its own target public network address, and the target public network address is the One of at least one public network address corresponding to the internal network address of the first client.
- a client including:
- a first obtaining module configured to communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes;
- a determining module configured to determine at least one public network address corresponding to the internal network address of the first client according to the response message
- a monitoring module configured to register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client;
- the connection establishment module is configured to establish a P2P connection with the second client under the condition that the second client returns a response data packet to the target public network address, and the target public network address is the first client One of at least one public network address corresponding to the internal network address of the terminal.
- a system for establishing a P2P connection including:
- the first client and the second client are configured to communicate with at least two auxiliary nodes respectively, and obtain response messages returned by the at least two auxiliary nodes; a public network address; register at least one public network address corresponding to each intranet address with the cloud server, and monitor the at least one public network address;
- the first client is further configured to obtain at least one public network address corresponding to the intranet address of the second client through the cloud server, and send at least one public network address corresponding to the intranet address of the second client Each of the public network addresses in the address sends an access request data packet;
- the second client is further configured to obtain at least one public address corresponding to the internal network address of the first client through the cloud server in the case of monitoring that the target public address of the client receives the access request data packet. network address, returning a response data packet to each of the at least one public network address corresponding to the internal network address of the first client, and the target public network address is the internal network address of the second client One of the corresponding at least one public network address;
- the first client is further configured to establish a P2P connection with the second client in the case of monitoring that the second client returns a response data packet to the target public network address of the second client, and the target public address
- the network address is one of at least one public network address corresponding to the internal network address of the first client.
- a computing device including:
- the memory is used to store computer-executable instructions
- the processor is used to execute the computer-executable instructions to implement the following methods:
- the response message determine at least one public network address corresponding to the internal network address of the first client
- Register at least one public network address corresponding to the intranet address of the first client with the cloud server, and monitor at least one public network address corresponding to the intranet address of the first client;
- a computer-readable storage medium which stores computer-executable instructions, and when the instructions are executed by a processor, implements any of the methods for establishing a P2P connection described in the first aspect above. step.
- a computer program product that, when the computer program product is executed in a computer, causes the computer to execute any of the steps of the above-mentioned method for establishing a P2P connection.
- a first client can communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine the first client at least one public network address corresponding to the internal network address of the client, register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client address, establish a P2P connection with the second client in the case of monitoring that the second client returns a response data packet to the target public network address, and the target public network address corresponds to the internal network address of the first client one of at least one public address of .
- the first client can be used to communicate with at least two auxiliary nodes, and at least one public network address corresponding to the internal network address of the first client can be detected, so as to determine whether there are multiple external public network addresses of the first client. That is to say, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the first client, which improves the success rate of hole punching among clients corresponding to multiple public network addresses, and achieves a relatively high level of accuracy. High success rate of P2P connection.
- FIG. 1 is a flowchart of a method for establishing a P2P connection provided by an embodiment of the present application
- FIG. 2 is a schematic diagram of a conventional NAT detection provided by an embodiment of the present application.
- FIG. 3 is a schematic diagram of a public network address provided by an embodiment of the present application.
- FIG. 4 is a schematic diagram of establishing a P2P connection according to an embodiment of the present application.
- FIG. 5 is a flowchart of another method for establishing a P2P connection provided by an embodiment of the present application.
- FIG. 6 is a flowchart of another method for establishing a P2P connection provided by an embodiment of the present application
- FIG. 7 is a schematic structural diagram of a client according to an embodiment of the present application.
- FIG. 8 is a schematic structural diagram of a system for establishing a P2P connection provided by an embodiment of the present application.
- FIG. 9 is a structural block diagram of a computing device provided by an embodiment of the present application.
- IP address Internet Protocol Address, Internet Protocol Address
- IP address is a unified address format provided by IP protocol, which assigns a logical address to each network and each host on the Internet , to mask the difference in physical addresses.
- NAT Network Address Translation: Some hosts within the private network have been assigned local IP addresses (that is, private addresses only used within the private network), but want to communicate with hosts on the Internet (and When encryption is not required), the NAT method can be used. This method has at least one valid external global IP address, the public address. In this way, when all hosts using local addresses communicate with the outside world, they must convert their local addresses into public addresses on the NAT device before they can connect to the Internet.
- NAT devices can be divided into three categories, including static NAT, dynamic NAT and NAPT (Network Address Port Translation). Static NAT translation is relatively simple. Dynamic NAT means that instead of establishing a one-to-one fixed correspondence between internal addresses and global addresses, the NAT mapping relationship is dynamically established by sharing the IP addresses of the NAT address pool. NATP is the most common NAT and the most studied type of NAT in academia. NATP maps the internal network connection to a separate IP address in the external network, and adds a port number selected by the NAT device to this address. There are four types, including full cone and IP restricted cone. Type, Port Restricted Cone, and Symmetrical Type.
- IP-restricted cone NAT Once an internal host-port pair (iAddr:iPort) is mapped to (eAddr:ePort), all subsequent (iAddr:iPort) packets are translated to (eAddr:ePort); only (iAddr:iPort) ) has sent data to a specific external host hAddr, and the packet sent by the host hAddr from any port to (eAddr:ePort) will be forwarded to (iAddr:iPort).
- Port-restricted cone NAT Once an internal host-port pair (iAddr:iPort) is mapped to (eAddr:ePort), all subsequent (iAddr:iPort) packets are translated to (eAddr:ePort); only (iAddr:iPort) ) has sent data to a specific external host port pair (hAddr:hPort), and packets sent by (hAddr:hPort) to (eAddr:ePort) will be forwarded to (iAddr:iPort).
- Symmetric NAT The NAT gateway will treat the same packets as the internal host "address port pair" and the external host "address port pair” as a connection, and create a public network "address port pair” mapping on the gateway for translation. Only when the external host that receives the message sends a response message from the corresponding port pair can it be translated. Even if the internal host uses the previously used address-port pair to connect to a different external host (or port), the NAT gateway will establish a new one. mapping relationship.
- Hole punching server STUN server, User Datagram Protocol (UDP) simply traverses Network Address Translator (NAT), which allows all clients corresponding to NAT devices (such as computers behind firewalls) to communicate with VOIP outside the local area network
- the service provider implements telephone calls.
- STUN server Through the STUN server, clients can learn their public address, the type of NAT in front of them, and the Internet side port that is NATed to a specific local port. This information will be used to establish UDP communication between the client and the VOIP service provider in order to implement the call.
- a method for establishing a P2P connection is provided, and the present application also relates to a client and a system for establishing a P2P connection, a computing device, a computer-readable storage medium, and a computer program product, Detailed descriptions will be made one by one in the following examples.
- FIG. 1 shows a flowchart of a method for establishing a P2P connection according to an embodiment of the present application, which is applied to a first client and specifically includes the following steps:
- Step 102 Communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes.
- a first client can communicate with at least two auxiliary nodes to obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine at least one public network address corresponding to the internal network address of the first client, register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor the corresponding internal network address of the first client at least one public network address; in the case of listening to the second client returning a response data packet to the target public network address, establish a P2P connection with the second client, and the target public network address is the first client One of at least one public network address corresponding to the internal network address of the terminal.
- the first client can be used to communicate with at least two auxiliary nodes to detect whether there are multiple public network addresses corresponding to the internal network address of the first client.
- the public network address corresponding to the internal network address of the first client is detected, thereby improving the success rate of hole punching among clients corresponding to multiple public network addresses, and realizing the establishment of a P2P connection with a higher success rate.
- the auxiliary node may be a full cone NAT device or a public network node, so that other types of nodes can establish a connection with the auxiliary node to detect the public network address, where the public network address may include the public network IP address and public network port.
- the first client may obtain the at least two auxiliary nodes from a cloud server, the cloud server is a node scheduling server, and all nodes maintain signaling interaction with the cloud server. It should be noted that the greater the number of auxiliary nodes, the more comprehensive and accurate the detected public network address.
- the number of auxiliary nodes is not limited in this application, and can be set according to specific requirements in practical applications.
- the first client includes a terminal device waiting to establish a P2P connection and a corresponding NAT device, the terminal device interacts with the outside world through the corresponding NAT device, and the NAT device can convert the internal network address of the terminal device into an external device.
- the public network address to interact with the outside world.
- the second client that needs to establish a P2P connection with the first client can perform the same operation as the first client. That is, the second client can also communicate with the at least two auxiliary nodes, and obtain the response messages returned by the at least two auxiliary nodes, so as to determine at least one public network address corresponding to the internal network address of the second client, which is convenient for subsequent At least one public network address corresponding to the internal network address of the first client is exchanged to establish a P2P connection with the first client.
- the first client before using the auxiliary node to detect the corresponding public network address, may also perform detection by traversing the auxiliary server to obtain the NAT type of the NAT device corresponding to the first client.
- the first client communicates with at least two auxiliary nodes, and before acquiring the response messages returned by the at least two auxiliary nodes, the method further includes:
- the intranet address and the NAT type of the corresponding NAT device are stored locally.
- the traversal auxiliary server refers to the hole punching server, that is, the STUN server.
- the public network address detection of the NAT device is divided into conventional NAT detection and NAT detection with the help of auxiliary nodes.
- Conventional NAT detection refers to the communication between the first client and the traversal auxiliary server, and the current intranet and public network address pairs used for communication can be obtained ( IP_A, Port_A: IP_A', Port_A'), preliminarily determine the NAT type.
- communicating with at least two auxiliary nodes to obtain response messages returned by the at least two auxiliary nodes may be as follows:
- a response message returned by the at least two assisting nodes in response to the assisting probe request is received.
- auxiliary nodes can be used for further detection.
- the first client can randomly acquire at least two auxiliary nodes distributed in different locations from the cloud server;
- the client uses the intranet address (IP_A, Port_A) used to communicate with the punching server to communicate with the obtained auxiliary nodes.
- IP_A, Port_A intranet address
- the first client receives the response information from these auxiliary nodes, it can record the connection with these auxiliary nodes.
- Public network IP address and public network port that is, public network address).
- FIG. 2 is a schematic diagram of a conventional NAT detection provided by an embodiment of the present application.
- IP_A' Port_A'
- the client B communicates with the hole punching server through the intranet IP address and intranet port (IP_B: Port_B), and is converted into the public network IP address and public network port (IP_B': Port_B') through the corresponding NAT device B. , and register its own NAT device type and the corresponding public network IP address and public network port in the hole punching server.
- Step 104 Determine at least one public network address corresponding to the internal network address of the first client according to the response message.
- the public network address may include a public network IP address and a public network port.
- the public network address corresponding to the internal network address of the first client is roughly divided into three situations: Scenario 1, the public network IP addresses are different, and the corresponding internal network to public network addresses are different. Port mapping is certain; in case 2, when communicating with different auxiliary nodes, the port will change in a small range up and down the original position; in case 3, there are multiple public IP addresses, and the ports passing through the public IP addresses will also change.
- FIG. 3 is a schematic diagram of a public network address provided by an embodiment of the present application.
- client A communicates with auxiliary nodes D, E, F, and G respectively through an intranet address (IP_A: Port_A).
- IP_A Intranet address
- H communication according to the response messages returned by each auxiliary node, the public IP address of communication with auxiliary nodes D, E, F is IP_A1', and the public network IP address of communication with auxiliary nodes G and H is IP_A2', that is, , the NAT device A corresponding to the client A maps the intranet IP address IP_A of the client A to the public IP address IP_A1' or IP_A2' (no port restriction).
- NAT device A corresponding to client A is a port-restricted cone
- client A communicates with auxiliary nodes D, E, F, G, and H respectively through the intranet address (IP_A: Port_A), and according to the responses returned by each auxiliary node
- IP_A Port_A
- the public network IP addresses that communicate with the auxiliary nodes D, E, and F are IP_A1'
- the public network port that communicates with the auxiliary nodes D and E is Port_A1'
- the public network port that communicates with the auxiliary node F is Port_A2'
- the public network IP addresses communicating with the auxiliary nodes G and H are both IP_A2'
- the public network ports are both Port_A3'.
- the NAT device A corresponding to the client A maps the internal network address (IP_A: Port_A) of the client A to the public network address (IP_A1': Port_A1'), (IP_A1': Port_A2') or (IP_A2': Port_A3 ').
- NAT device corresponding to client B is a port-restricted cone
- client B communicates with auxiliary nodes D, E, F, G, and H respectively through the intranet address (IP_B: Port_B), and according to the response messages returned by each auxiliary node
- IP_B Port_B
- the public network IP addresses that communicate with the auxiliary nodes D, E, F, G, and H are all IP_B', but the public network port that communicates with the auxiliary nodes D, E, F, and G is Port_B1', which communicates with the auxiliary node H.
- the public network port is Port_B2', that is, the NAT device B corresponding to client B maps the internal network address (IP_B: Port_B) of client B to the public network address (IP_B'; Port_B1') or (IP_B'; Port_B2 ').
- At least one public network address corresponding to the internal network address of the first client is determined according to the response message, and the specific implementation process may be as follows:
- the NAT type of the NAT device corresponding to the first client is a port restriction cone
- the NAT type of the NAT device corresponding to the first client is a port restriction cone, it means that the first client will limit the port when interacting with the outside world through the corresponding NAT device.
- the public network IP address For the public network IP address, at least one corresponding public network port needs to be determined, and then the public network IP address and the corresponding at least one public network port are determined as a public network address, so as to obtain at least one public network address.
- the at least one public network address sends an access request data packet to establish a P2P connection.
- determining the estimated public network port corresponding to the public network IP address according to the at least one public network port a specific implementation process may be as follows:
- the first public network port and the second public network port determine the start port identifier and the end port identifier
- a public network port between the starting port identifier and the ending port identifier is determined as the estimated public network port.
- the determination of the starting port identifier and the ending port identifier according to the first public network port and the second public network port may be as follows:
- the initial port identifier is obtained by subtracting the preset threshold from the port identifier of the second public network port.
- the preset threshold may be set in advance, such as 20, 30, 40, and the like.
- auxiliary nodes due to the limited number of auxiliary nodes, it is difficult to determine all the public network ports corresponding to the public network IP address of the first client with the help of the auxiliary nodes.
- other public network ports corresponding to the public network IP address can also be predicted according to the determined at least one public network port, so as to determine the estimated public network port as the public network port corresponding to the internal network address of the first client. web address.
- the public network ports near these public network ports may also be the public network ports for subsequent hole punching operations. Therefore, according to at least one public network port returned by the auxiliary node, the starting port identification and the ending port identification can be determined, and then the continuous port between the starting port identification and the ending port identification can be determined as the corresponding public network IP address. The estimated public network port, and then determine the corresponding public network address.
- the public network IP addresses determined by the first client by means of at least two auxiliary nodes are IP_A, IP_B, and IP_C.
- IP_A assuming that the corresponding public network ports determined by the auxiliary node are ports 1121, 1123, and 1125, and the preset threshold is 20, then the starting port ID is 1101, and the ending port ID is 1145.
- 1101 ⁇ 1145 The port between IP_A and 1101 ⁇ 1145 is determined as the estimated public network port, and then the port between IP_A and 1101 ⁇ 1145 is determined as a public network address.
- the public network addresses corresponding to IP_B and IP_C can be obtained, thereby finally obtaining three public network addresses corresponding to the internal network address of the first client.
- determining at least one public network IP address corresponding to the internal network address of the first client terminal according to the response message including:
- auxiliary node For each auxiliary node in the at least two auxiliary nodes, determine the public network IP address corresponding to the response message returned by the auxiliary node;
- the first client when the first client (or the second client) receives the response information from these auxiliary nodes, it can record the public network IP addresses established with these auxiliary nodes, and then use the obtained series of public network IP addresses. The IP address is analyzed. If all public IP addresses are displayed as the same, it is the same as the result of conventional NAT detection, that is, the NAT device corresponding to the first client (or the second client) The address is mapped to a public network IP address, and the first client subsequently establishes a connection with other clients through the public network IP address.
- the corresponding NAT device maps the internal network address of the first client to multiple public network IP addresses, and at this time the corresponding multiple public network IP addresses can be recorded in the data structure of the local client. That is to say, a deduplication operation is performed on the public network IP address corresponding to the response message, and at least one public network IP address corresponding to the internal network address of the first client is determined.
- the NAT type of the NAT device corresponding to the first client is not a port-restricted cone, it means that the NAT device corresponding to the first client has no restrictions on ports, and only needs to respond to the response messages returned by at least two auxiliary nodes.
- the public network IP address is deduplicated to obtain the public network address, and there is no need to further determine the public network port.
- the first client and the second client may communicate with at least two auxiliary nodes respectively, and obtain response messages returned by the at least two auxiliary nodes, thereby determining the public IP address and public network IP address of the corresponding NAT device.
- network ports that is, public network addresses
- at least two auxiliary nodes can be used to more accurately detect multiple public network addresses and public network ports corresponding to the respective intranet addresses of the first client and the second client,
- the success rate of hole punching between clients corresponding to multiple public network addresses is improved, and a P2P connection with a higher success rate is realized.
- Step 106 Register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client.
- the address corresponding to the internal network address of the first client may be registered with the cloud server at least one public network address, and monitor at least one public network address corresponding to the internal network address of the first client.
- the cloud server is a server that manages and controls the at least two auxiliary nodes.
- the registering with the cloud server at least one public network address corresponding to the intranet address of the first client includes:
- At least one public network address corresponding to the internal network address of the first client and the NAT type of the corresponding NAT device are registered with the cloud server.
- the first client can also detect its own NAT device type by traversing the auxiliary server (ie, the hole punching server), and then register it in the cloud server for the first client.
- the second client obtains.
- the second client can perform the same operation as the first client, and also register its own NAT type on the cloud server for the first client to obtain.
- the first client and the second server can obtain each public network IP address corresponding to the intranet address, each public network port and the corresponding NAT type after performing NAT detection with the help of at least two auxiliary nodes respectively. It is registered on the cloud server in the form of data stream, and the cloud server and the opposite end exchange their respective registration information, so that the first client can obtain the public network IP address and public network port of the second client, thereby establishing a P2P connection.
- the second client that needs to establish a P2P connection with the first client may perform the same operation as the first client. That is, the second client can also perform the steps described in the above steps 102-106, thereby determining at least one public network address and NAT type corresponding to the intranet address of the second client, and registering it on the cloud server to facilitate subsequent At least one public network address corresponding to the internal network address of the first client and the NAT type are exchanged to establish a P2P connection with the first client.
- the first client and the second client respectively register at least one public network address corresponding to their respective intranet addresses with the cloud server
- the first client can access the cloud server from the cloud server. to obtain at least one public network address corresponding to the intranet address of the second client in order to establish a P2P connection with the second client, that is, after registering the at least one public network address corresponding to the intranet address of the first client with the cloud server
- Also includes:
- At least one public network address corresponding to the intranet address of the second client is obtained through the cloud server, and at least one public network address corresponding to the intranet address of the second client is obtained by the second client through the at least one public network address.
- the access request data packet may refer to a hole punching data packet.
- at least one public network address corresponding to the internal network address of the second client obtained by the first client from the cloud server is the public address determined by the second client through the method steps of steps 102 to 106 above and with the help of the auxiliary node. web address.
- the first client can send to the at least one public network address corresponding to the intranet address of the second client.
- Each of the public network addresses in the network addresses sends an access request data packet.
- the second client can monitor each of its own public network addresses. If it monitors any public network address of its own and receives the access request data packet sent by the first client, the second client can pass the cloud server. Acquire at least one public network address corresponding to the internal network address of the first client, and then return a response data packet to each of the at least one public network address corresponding to the internal network address of the first client.
- the public network address includes a public network IP address and at least one public network port, and each of the at least one public network address corresponding to the internal network address of the second client The public network address sends an access request data packet, including:
- the NAT type is a port restriction cone
- the public network IP addresses included in the public network address and the at least two public network ports are respectively formed into at least two address-port pairs;
- the access request packet is sent to each of the address-port pairs.
- the NAT device maps the intranet address of the second client to multiple public addresses; that is, the second client may establish a connection with the first client through any one of the multiple public addresses. Therefore, when the first client determines that there are multiple public network addresses corresponding to the acquired internal network address of the second client, it needs to send an access request data packet to each of the multiple public network addresses.
- each of the public addresses in the at least one public address corresponding to the acquired intranet address of the second client may also be Network address, determine the number of public network ports included in the public network address, if the public network address includes a public network port, directly include a public network IP address and a public network port in the public network address Form an address-port pair, and send an access request data packet to the address-port pair; if the public network address includes at least two public network ports, then one public network IP address included in the public network address is separated from at least two. The public network ports form at least two address-port pairs, and then the access request data packet is sent to each address-port pair.
- obtaining at least one public network address corresponding to the intranet address of the second client through the cloud server includes:
- At least one public network address corresponding to the intranet address of the second client that is returned by the cloud server in response to the request for assisting in establishing a connection is received.
- the first client can send a request for assistance in establishing a connection to the cloud server, and the request for assisting in establishing a connection can carry the identifier of the second client.
- the cloud server After receiving the request for assisting in establishing a connection, the cloud server returns the request to the first client. At least one public network address corresponding to the intranet address of the second client registered in the cloud server by the second client.
- Step 108 Establish a P2P connection with the second client under the condition that the second client returns a response data packet to the target public network address within a preset time period, and the target public network address is the first client One of at least one public network address corresponding to the internal network address of the terminal.
- the preset duration is the timeout duration, and the preset duration is within the timeout range, and the preset duration can be preset, such as 1 minute, 5 minutes, 10 minutes, and the like.
- the response data packet is a hole punching data packet returned by the second client to the first first client, and is used to establish a P2P connection.
- the second client listens to any public network address of its own and receives the access request data packet sent by the first client, the second client can obtain the information of the first client through the cloud server. at least one public network address corresponding to the internal network address, and a response data packet is returned to each of the at least one public network address corresponding to the internal network address of the first client. That is to say, the first client can monitor each public network address corresponding to its own intranet address, and if it monitors any public network address of its own and receives the response data packet returned by the second client, it means that the second client The access request data packet sent by the first client is successfully received, and the response data packet is successfully returned to the first client. At this time, the first client can establish a P2P connection with the second client.
- the first client keeps monitoring at least one public network address corresponding to its own intranet address, a lot of processing resources will be wasted.
- the public network address returns a response packet, it means that the second client fails to successfully receive the access request packet sent by the first client, or fails to return a response packet to the correct public network address of the first client, so it can A preset duration is set. If the preset duration is exceeded and the response data packet returned by the second client to any of its own public network addresses cannot be monitored, it means that the first client and the second client failed to establish a P2P connection. Stop listening.
- FIG. 4 is a schematic diagram of establishing a P2P connection provided by an embodiment of the present application.
- client A and client B each register with the cloud server at least one public network address determined with the help of an auxiliary node. , and then client A and client B exchange registration information, after that, client A sends several hole punching data packets according to the obtained at least one public network address of the opposite end; Public network address, returns several hole punching data packets, if the first client receives the hole punching data packets returned by the second client within the timeout range, it establishes a P2P connection with the second client, otherwise it is determined that the P2P connection establishment fails .
- a first client can communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine the first client at least one public network address corresponding to the internal network address of the client, register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client address, establish a P2P connection with the second client in the case of monitoring that the second client returns a response data packet to the target public network address, and the target public network address corresponds to the internal network address of the first client one of at least one public address of .
- the first client can be used to communicate with at least two auxiliary nodes, and at least one public network address corresponding to the internal network address of the first client can be detected, so as to determine whether there are multiple external public network addresses of the first client. That is to say, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the first client, which improves the success rate of hole punching among clients corresponding to multiple public network addresses, and achieves a relatively high level of accuracy. High success rate of P2P connection.
- FIG. 5 shows a flowchart of another method for establishing a P2P connection provided by an embodiment of the present application, which specifically includes the following steps:
- Step 502 the first client and the second client communicate with at least two auxiliary nodes respectively, and obtain the response messages returned by the at least two auxiliary nodes; according to the response messages, determine at least one corresponding to the respective intranet addresses Public network address; register at least one public network address corresponding to each intranet address with the cloud server, and monitor the at least one public network address.
- the first client and the second client communicate with at least two auxiliary nodes respectively, and before acquiring the response messages returned by the at least two auxiliary nodes, the method further includes:
- the first client and the second client communicate with the traversal auxiliary server respectively to obtain the respective intranet addresses and the NAT types of the respective NAT devices;
- the first client and the second client store the respective intranet addresses and the NAT type of the corresponding NAT device locally.
- the first client determines at least one public network address corresponding to its own intranet address according to the response message, and the specific implementation process may be as follows:
- the NAT type of the NAT device corresponding to the first client is a port restriction cone
- the second client determines that at least one public network address corresponding to its own intranet address is the same as the operation of the first client, as follows:
- the NAT type of the NAT device corresponding to the second client is a port restriction cone
- the first client and the second client respectively register at least one public network address corresponding to their respective intranet addresses with the cloud server, including:
- At least one public network address corresponding to the respective intranet address and the NAT type of the respective corresponding NAT device are registered with the cloud server.
- Step 504 The first client obtains at least one public network address corresponding to the intranet address of the second client through the cloud server, and sends each of the at least one public network address corresponding to the intranet address of the second client.
- the public network address sends an access request data packet.
- Step 506 In the case of monitoring that the target public network address of the second client receives the access request data packet, the second client obtains at least one public network address corresponding to the internal network address of the first client through the cloud server, and sends the data to the cloud server.
- Each of the at least one public network address corresponding to the internal network address of the first client returns a response data packet
- the target public network address is at least one public network address corresponding to the internal network address of the second client One of the public addresses.
- Step 508 The first client establishes a P2P connection with the second client after monitoring that the second client returns a response data packet to its own target public network address, and the target public network address is the target public network address.
- a first client can communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine the first client at least one public network address corresponding to the internal network address of the client, register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client address, establish a P2P connection with the second client in the case of monitoring that the second client returns a response data packet to the target public network address, and the target public network address corresponds to the internal network address of the first client one of at least one public address of .
- the first client can be used to communicate with at least two auxiliary nodes, and at least one public network address corresponding to the internal network address of the first client can be detected, so as to determine whether there are multiple external public network addresses of the first client. That is to say, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the first client, which improves the success rate of hole punching among clients corresponding to multiple public network addresses, and achieves a relatively high level of accuracy. High success rate of P2P connection.
- FIG. 6 shows a flowchart of another method for establishing a P2P connection provided by an embodiment of the present application, which specifically includes the following steps:
- the complete process of establishing a P2P connection includes a NAT detection phase and a hole punching phase, wherein the NAT detection phase includes conventional NAT detection and NAT detection with the help of at least two auxiliary nodes, and the hole punching phase includes conventional hole punching and assistance. Node punching.
- Step 602 The first client and the second client communicate with the hole punching server respectively, and obtain their respective intranet addresses, the first public address corresponding to the intranet addresses, and the NAT type of the corresponding NAT device; Register their respective first public network addresses, and exchange the peer's first public network addresses through the cloud server.
- step 602 is that the first client and the second client respectively perform conventional NAT detection through the hole punching server, that is, the conventional detection stage.
- Step 604 The first client and the second client respectively communicate with at least two auxiliary nodes through their respective intranet addresses, and obtain response messages returned by the at least two auxiliary nodes; and determine the respective auxiliary nodes according to the response messages. At least one second public network address corresponding to the intranet address.
- the first client and the second client respectively perform NAT detection by using at least two auxiliary nodes.
- Step 606 The first client and the second client respectively register at least one second public network address corresponding to their respective intranet addresses with the cloud server, and exchange at least one second public network address of the opposite end through the cloud server.
- Step 608 The first client sends a hole punching data packet to the second client through the first public network address, and in the case of monitoring that the second client returns a response data packet to the first public network address within the timeout range, A P2P connection is established with the second client.
- the first public network address is a public network address obtained through the hole punching server, that is, the first public network address is a conventionally detected public network address, so the above step 606 is a conventional hole punching operation.
- Step 610 The first client sends a hole punching data packet to each of the at least one second public address of the second client, and monitors the second client to any of its own addresses within the timeout range.
- the second public network address returns a response data packet, a P2P connection is established with the second client.
- the second public network address is a public network address obtained with the help of at least two auxiliary nodes, so the above step 610 is an operation of punching holes with the help of the auxiliary nodes.
- the method for establishing a P2P connection can further detect at least one public network address corresponding to the client's internal network address with the help of at least two auxiliary nodes on the basis of conventional detection, so as to determine whether the client's external public network address is There are more than one, that is, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the client, which improves the success rate of hole punching between clients corresponding to multiple public network addresses, and achieves a relatively high performance. High success rate of P2P connection.
- FIG. 7 shows a schematic structural diagram of a client provided by an embodiment of the present application.
- the device includes:
- a first obtaining module 702 configured to communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes;
- the determining module 704 is configured to determine, according to the response message, at least one public network address corresponding to the internal network address of the first client;
- the monitoring module 706 is configured to register with the cloud server at least one public network address corresponding to the internal network address of the first client, and monitor at least one public network address corresponding to the internal network address of the first client;
- the connection establishment module 708 is configured to establish a P2P connection with the second client when the second client returns a response data packet to the target public network address, and the target public network address is the first One of at least one public network address corresponding to the client's internal network address.
- the device further includes:
- the second acquisition module is configured to communicate with the traversal auxiliary server to acquire the intranet address and the NAT type of the corresponding NAT device;
- the storage module is configured to store the intranet address and the NAT type of the corresponding NAT device locally.
- the determining module 704 is further configured to:
- the NAT type of the NAT device corresponding to the first client is a port restriction cone
- the determining module 704 is further configured to:
- the first public network port and the second public network port determine the start port identifier and the end port identifier
- a public network port between the starting port identifier and the ending port identifier is determined as the estimated public network port.
- the determining module 704 is further configured to:
- the initial port identifier is obtained by subtracting the preset threshold from the port identifier of the second public network port.
- the registration module 706 is further configured to:
- At least one public network address corresponding to the internal network address of the first client and the NAT type of the corresponding NAT device are registered with the cloud server.
- the first obtaining module 702 is further configured to:
- a response message returned by the at least two assisting nodes in response to the assisting probe request is received.
- the determining module 704 is further configured to:
- auxiliary node For each auxiliary node in the at least two auxiliary nodes, determine the public network IP address corresponding to the response message returned by the auxiliary node;
- the device further includes:
- a third obtaining module is configured to obtain at least one public network address corresponding to the intranet address of the second client through the cloud server, and at least one public network address corresponding to the intranet address of the second client is the the public network address determined by the second client through the at least two auxiliary nodes;
- the sending module is configured to send an access request data packet to each of the at least one public network address corresponding to the internal network address of the second client.
- the public network address includes a public network IP address and at least one public network port; the sending module is further configured to:
- the NAT type is a port restriction cone
- the public network IP addresses included in the public network address and the at least two public network ports are respectively formed into at least two address-port pairs;
- the access request packet is sent to each of the address-port pairs.
- the third obtaining module is further configured to:
- At least one public network address corresponding to the intranet address of the second client that is returned by the cloud server in response to the request for assisting in establishing a connection is received.
- the client provided by the present application can communicate with at least two auxiliary nodes, and obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine at least one corresponding to the intranet address of the first client public network address, register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client, when monitoring the second client
- the terminal returns a response data packet to the target public network address, establishes a P2P connection with the second client, and the target public network address is one of at least one public network address corresponding to the internal network address of the first client .
- the first client can be used to communicate with at least two auxiliary nodes, and at least one public network address corresponding to the internal network address of the first client can be detected, so as to determine whether there are multiple external public network addresses of the first client. That is to say, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the first client, which improves the success rate of hole punching among clients corresponding to multiple public network addresses, and achieves a relatively high level of accuracy. High success rate of P2P connection.
- the above is a schematic solution of a client according to this embodiment. It should be noted that the technical solution of the client and the technical solution of the above-mentioned method for establishing a P2P connection belong to the same concept, and the details that are not described in detail in the technical solution of the client can be referred to the description of the technical solution of the above-mentioned method for establishing a P2P connection .
- FIG. 8 shows a schematic structural diagram of a system for establishing a P2P connection provided by an embodiment of the present application.
- the system includes: a first client 802 and a second client 804;
- the first client 802 and the second client 804 are configured to communicate with at least two auxiliary nodes respectively, and obtain response messages returned by the at least two auxiliary nodes; according to the response messages, determine the correspondence between the respective intranet addresses at least one public network address; register at least one public network address corresponding to each intranet address with the cloud server, and monitor the at least one public network address;
- the first client 802 is further configured to obtain at least one public network address corresponding to the intranet address of the second client through the cloud server, and send at least one public address corresponding to the intranet address of the second client.
- Each of the public network addresses in the network addresses sends an access request data packet;
- the second client 804 is further configured to obtain at least one corresponding to the intranet address of the first client through the cloud server in the case of monitoring that the target public address of the client receives the access request data packet.
- public network address returning a response data packet to each of the at least one public network address corresponding to the internal network address of the first client, and the target public network address is the internal network of the second client One of at least one public network address corresponding to the address;
- the first client 802 is further configured to establish a P2P connection with the second client in the case of monitoring that the second client returns a response data packet to the target public network address of the second client, the target
- the public network address is one of at least one public network address corresponding to the internal network address of the first client.
- first client 802 and the second client 804 are further configured to:
- first client 802 and the second client 804 are further configured to:
- At least one public network address corresponding to the respective intranet address and the NAT type of the respective corresponding NAT device are registered with the cloud server.
- the system for establishing a P2P connection can communicate with at least two auxiliary nodes to obtain response messages returned by the at least two auxiliary nodes; and then, according to the response messages, determine the intranet address of the first client
- the corresponding at least one public network address register at least one public network address corresponding to the internal network address of the first client with the cloud server, and monitor at least one public network address corresponding to the internal network address of the first client.
- the target public network address is at least one public address corresponding to the internal network address of the first client. one of the web addresses.
- the first client can be used to communicate with at least two auxiliary nodes, and at least one public network address corresponding to the internal network address of the first client can be detected, so as to determine whether there are multiple external public network addresses of the first client. That is to say, at least two auxiliary nodes can be used to more accurately detect the public network address corresponding to the internal network address of the first client, which improves the success rate of hole punching among clients corresponding to multiple public network addresses, and achieves a relatively high level of accuracy. High success rate of P2P connection.
- the above is a schematic solution of a system for establishing a P2P connection according to this embodiment. It should be noted that the technical solution of the system for establishing a P2P connection and the technical solution of the above-mentioned method for establishing a P2P connection belong to the same concept. A description of the technical solution of the method of connection.
- FIG. 9 shows a structural block diagram of a computing device 900 according to an embodiment of the present application.
- Components of the computing device 900 include, but are not limited to, memory 910 and processor 920 .
- the processor 920 is connected with the memory 910 through the bus 930, and the database 950 is used for saving data.
- Computing device 900 also includes access device 940 that enables computing device 900 to communicate via one or more networks 960 .
- networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet.
- Access device 940 may include one or more of any type of network interface (eg, network interface card (NIC)), wired or wireless, such as IEEE 802.11 wireless local area network (WLAN) wireless interface, World Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and the like.
- NIC network interface card
- the above-mentioned components of the computing device 900 and other components not shown in FIG. 9 may also be connected to each other, eg, through a bus. It should be understood that the structural block diagram of the computing device shown in FIG. 9 is only for the purpose of example, rather than limiting the scope of the present application. Those skilled in the art can add or replace other components as required.
- Computing device 900 may be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (eg, tablet computers, personal digital assistants, laptops, notebook computers, netbooks, etc.), mobile phones (eg, smart phones) ), wearable computing devices (eg, smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs.
- Computing device 900 may also be a mobile or stationary server.
- the processor 920 is configured to execute the following computer-executable instructions:
- the response message determine at least one public network address corresponding to the internal network address of the first client
- Register at least one public network address corresponding to the intranet address of the first client with the cloud server, and monitor at least one public network address corresponding to the intranet address of the first client;
- the above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned method for establishing a P2P connection belong to the same concept, and the details that are not described in detail in the technical solution of the computing device can be referred to the above-mentioned technical solution of the method for establishing a P2P connection. description of.
- An embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions, and when the instructions are executed by a processor, is used for:
- the response message determine at least one public network address corresponding to the internal network address of the first client
- Register at least one public network address corresponding to the intranet address of the first client with the cloud server, and monitor at least one public network address corresponding to the intranet address of the first client;
- the above is a schematic solution of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the above-mentioned method for establishing a P2P connection belong to the same concept, and the details that are not described in detail in the technical solution of the storage medium can be referred to the above-mentioned technical solution of the method for establishing a P2P connection. description of.
- An embodiment of the present application also provides a computer program product, which, when the computer program product is executed in a computer, causes the computer to execute any of the steps of the above-mentioned method for establishing a P2P connection.
- the computer-executable instructions include computer program code, which may be in source code form, object code form, an executable file, some intermediate form, or the like.
- the computer-readable storage medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) ), random access memory (RAM, Random Access Memory), electrical carrier signals, telecommunication signals, and software distribution media, etc.
- computer-readable Storage media exclude electrical carrier signals and telecommunications signals.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Small-Scale Networks (AREA)
Abstract
Description
Claims (19)
- 一种建立P2P连接的方法,其特征在于,应用于第一客户端,包括:与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息;根据所述应答消息,确定所述第一客户端的内网地址对应的至少一个公网地址;向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址,并监听所述第一客户端的内网地址对应的至少一个公网地址;在预设时长内监听到第二客户端向目标公网地址返回响应数据包的情况下,与所述第二客户端建立P2P连接,所述目标公网地址为所述第一客户端的内网地址对应的至少一个公网地址之一。
- 根据权利要求1所述的建立P2P连接的方法,其特征在于,所述与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息之前,还包括:与穿越辅助服务器通信,获取所述第一客户端的内网地址以及所述第一客户端对应的NAT设备的NAT类型;将所述第一客户端的内网地址以及所述第一客户端对应的NAT设备的NAT类型存储至本地。
- 根据权利要求2所述的建立P2P连接的方法,其特征在于,所述根据所述应答消息,确定所述第一客户端的内网地址对应的至少一个公网地址,包括:在所述第一客户端对应的NAT设备的NAT类型为端口限制锥形的情况下,根据所述应答消息,确定所述第一客户端的内网地址对应的至少一个公网IP地址;针对所述至少一个公网IP地址中的每个所述公网IP地址,确定所述公网IP地址对应的至少一个公网端口;根据所述至少一个公网端口,确定所述公网IP地址对应的预估公网端口;将所述预估公网端口和所述公网IP地址组合为所述公网地址。
- 根据权利要求3所述的建立P2P连接的方法,其特征在于,所述根据所述至少一个公网端口,确定所述公网IP地址对应的预估公网端口,包括:确定所述至少一个公网端口中端口标识最大的第一公网端口,以及端口标识最小的第二公网端口;根据所述第一公网端口和所述第二公网端口,确定起始端口标识和终止端 口标识;将所述起始端口标识和所述终止端口标识之间的公网端口确定为所述预估公网端口。
- 根据权利要求4所述的建立P2P连接的方法,其特征在于,所述根据所述第一公网端口和所述第二公网端口,确定起始端口标识和终止端口标识,包括:将所述第一公网端口的端口标识加上预设阈值,得到所述终止端口标识;将所述第二公网端口的端口标识减去所述预设阈值,得到所述起始端口标识。
- 根据权利要求2所述的建立P2P连接的方法,其特征在于,所述向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址,包括:向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址以及所述对应的NAT设备的NAT类型。
- 根据权利要求1所述的建立P2P连接的方法,其特征在于,所述与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息,包括:通过所述第一客户端的内网地址向所述至少两个辅助节点发送协助探测请求;接收所述至少两个辅助节点响应于所述协助探测请求返回的应答消息。
- 根据权利要求3所述的建立P2P连接的方法,其特征在于,所述根据所述应答消息,确定所述第一客户端的内网地址对应的至少一个公网IP地址,包括:针对所述至少两个辅助节点中的每个辅助节点,确定所述辅助节点返回的应答消息对应的公网IP地址;对所述应答消息对应的公网IP地址进行去重操作,确定出所述第一客户端的内网地址对应的至少一个公网IP地址。
- 根据权利要求1-8任一所述的建立P2P连接的方法,其特征在于,所述向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址之后,还包括:通过所述云服务器获取所述第二客户端的内网地址对应的至少一个公网地址,所述第二客户端的内网地址对应的至少一个公网地址为所述第二客户端通过所述至少两个辅助节点确定出的公网地址;向所述第二客户端的内网地址对应的至少一个公网地址中的每个所述公网地址发送访问请求数据包。
- 根据权利要求9所述的建立P2P连接的方法,其特征在于,所述公网地址包括一个公网IP地址和至少一个公网端口;所述向所述第二客户端的内网地址对应的至少一个公网地址中的每个所述公网地址发送访问请求数据包,包括:通过所述云服务器获取所述第二客户端对应的NAT设备的NAT类型;在所述第二客户端对应的NAT设备的NAT类型为端口限制锥形的情况下,针对所述至少一个公网地址中的每个所述公网地址,确定所述公网地址包括的公网端口的个数;在所述公网地址包括至少两个公网端口的情况下,将所述公网地址包括的公网IP地址分别和所述至少两个公网端口组成至少两个地址端口对;向每个所述地址端口对发送所述访问请求数据包。
- 根据权利要求9所述的建立P2P连接的方法,其特征在于,所述通过所述云服务器获取所述第二客户端的内网地址对应的至少一个公网地址,包括:向所述云服务器发送协助建联请求;接收所述云服务器响应于所述协助建联请求返回的所述第二客户端的内网地址对应的至少一个公网地址。
- 一种建立P2P连接的方法,其特征在于,包括:第一客户端和第二客户端分别与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息;根据所述应答消息,确定各自的内网地址对应的至少一个公网地址;向云服务器登记各自的内网地址对应的至少一个公网地址,并监听所述至少一个公网地址;所述第一客户端通过所述云服务器获取所述第二客户端的内网地址对应的至少一个公网地址,向所述第二客户端的内网地址对应的至少一个公网地址中的每个所述公网地址发送访问请求数据包;所述第二客户端在监听到自身的目标公网地址接收到访问请求数据包的情况下,通过所述云服务器获取所述第一客户端的内网地址对应的至少一个公网地址,向所述第一客户端的内网地址对应的至少一个公网地址中的每个所述公网地址返回响应数据包,所述目标公网地址为所述第二客户端的内网地址对应的至少一个公网地址之一;所述第一客户端在监听到所述第二客户端向自身的目标公网地址返回响 应数据包的情况下,与所述第二客户端建立P2P连接,所述目标公网地址为所述第一客户端的内网地址对应的至少一个公网地址之一。
- 根据权利要求12所述的建立P2P连接的方法,其特征在于,所述第一客户端和第二客户端分别与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息之前,还包括:所述第一客户端和所述第二客户端分别与穿越辅助服务器通信,获取各自内网地址以及各自对应的NAT设备的NAT类型;所述第一客户端和所述第二客户端将各自内网地址以及对应的NAT设备的NAT类型存储至本地。
- 根据权利要求10所述的建立P2P连接的方法,其特征在于,所述第一客户端和第二客户端分别向云服务器登记各自的内网地址对应的至少一个公网地址,包括:向云服务器登记各自的内网地址对应的至少一个公网地址以及各自对应的NAT设备的NAT类型。
- 一种客户端,其特征在于,包括:第一获取模块,被配置为与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息;确定模块,被配置为根据所述应答消息,确定第一客户端的内网地址对应的至少一个公网地址;监听模块,被配置为向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址,并监听所述第一客户端的内网地址对应的至少一个公网地址;建联模块,被配置为在监听到第二客户端向目标公网地址返回响应数据包的情况下,与所述第二客户端建立P2P连接,所述目标公网地址为所述第一客户端的内网地址对应的至少一个公网地址之一。
- 一种建立P2P连接的系统,其特征在于,包括:第一客户端和第二客户端,被配置为分别与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息;根据所述应答消息,确定各自的内网地址对应的至少一个公网地址;向云服务器登记各自的内网地址对应的至少一个公网地址,并监听所述至少一个公网地址;所述第一客户端,进一步被配置为通过所述云服务器获取所述第二客户端的内网地址对应的至少一个公网地址,向所述第二客户端的内网地址对应的至少一个公网地址中的每个所述公网地址发送访问请求数据包;所述第二客户端,进一步被配置为在监听到自身的目标公网地址接收到访问请求数据包的情况下,通过所述云服务器获取所述第一客户端的内网地址对应的至少一个公网地址,向所述第一客户端的内网地址对应的至少一个公网地址中的每个所述公网地址返回响应数据包,所述目标公网地址为所述第二客户端的内网地址对应的至少一个公网地址之一;所述第一客户端,进一步被配置为在监听到所述第二客户端向自身的目标公网地址返回响应数据包的情况下,与所述第二客户端建立P2P连接,所述目标公网地址为所述第一客户端的内网地址对应的至少一个公网地址之一。
- 一种计算设备,其特征在于,包括:存储器和处理器;所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令,以实现下述方法:与至少两个辅助节点通信,获取所述至少两个辅助节点返回的应答消息;根据所述应答消息,确定第一客户端的内网地址对应的至少一个公网地址;向云服务器登记所述第一客户端的内网地址对应的至少一个公网地址,并监听所述第一客户端的内网地址对应的至少一个公网地址;在监听到第二客户端向目标公网地址返回响应数据包的情况下,与所述第二客户端建立P2P连接,所述目标公网地址为所述第一客户端的内网地址对应的至少一个公网地址之一。
- 一种计算机可读存储介质,其特征在于,其存储有计算机指令,该指令被处理器执行时实现权利要求1至11任意一项所述建立P2P连接的方法的步骤。
- 一种计算机程序产品,当所述计算机程序产品在计算机中执行时,令计算机执行权利要求1至11任意一项所述建立P2P连接的方法的步骤。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/271,013 US20240064206A1 (en) | 2021-01-06 | 2022-01-05 | Method, client, and system for establishing p2p connection |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110011856.9A CN112637364B (zh) | 2021-01-06 | 2021-01-06 | 建立p2p连接的方法、客户端及系统 |
CN202110011856.9 | 2021-01-06 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022148361A1 true WO2022148361A1 (zh) | 2022-07-14 |
Family
ID=75291475
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/070236 WO2022148361A1 (zh) | 2021-01-06 | 2022-01-05 | 建立p2p连接的方法、客户端及系统 |
Country Status (3)
Country | Link |
---|---|
US (1) | US20240064206A1 (zh) |
CN (1) | CN112637364B (zh) |
WO (1) | WO2022148361A1 (zh) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116708358A (zh) * | 2022-10-31 | 2023-09-05 | 荣耀终端有限公司 | P2p穿越方法、设备及存储介质 |
CN116939003A (zh) * | 2023-09-19 | 2023-10-24 | 敏于行(北京)科技有限公司 | 跨nat的端到端网络连接建立方法及系统 |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112637364B (zh) * | 2021-01-06 | 2023-01-10 | 上海哔哩哔哩科技有限公司 | 建立p2p连接的方法、客户端及系统 |
CN115225646A (zh) * | 2021-04-21 | 2022-10-21 | 武汉斗鱼鱼乐网络科技有限公司 | 一种p2p节点推荐方法、终端、介质及计算机设备 |
CN113965630B (zh) * | 2021-10-25 | 2024-08-09 | 深圳市元征科技股份有限公司 | 一种udp连接方法、电子设备及存储介质 |
CN114390049A (zh) * | 2021-12-29 | 2022-04-22 | 中国电信股份有限公司 | 一种应用数据获取方法及装置 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040148406A1 (en) * | 2002-12-10 | 2004-07-29 | Koji Shima | Network system for establishing peer-to-peer communication |
CN101217536A (zh) * | 2007-12-28 | 2008-07-09 | 腾讯科技(深圳)有限公司 | 穿越网络地址转换设备/防火墙的方法、系统及客户端 |
CN106878474A (zh) * | 2017-04-25 | 2017-06-20 | 浙江风向标科技有限公司 | 一种p2p连接建立的方法和装置 |
CN107580081A (zh) * | 2017-09-18 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种nat穿透方法及装置 |
CN107580082A (zh) * | 2017-09-18 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种对称型nat的穿透方法及装置 |
CN112637364A (zh) * | 2021-01-06 | 2021-04-09 | 上海哔哩哔哩科技有限公司 | 建立p2p连接的方法、客户端及系统 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102231763B (zh) * | 2011-06-20 | 2014-04-09 | 北京思创银联科技股份有限公司 | 一种基于nat穿透的共享方法 |
CN103916382B (zh) * | 2013-12-25 | 2018-05-01 | 三亚中兴软件有限责任公司 | 基于sip媒体能力重协商的nat穿越方法、代理服务器和系统 |
CN106331198B (zh) * | 2015-06-29 | 2020-04-21 | 中兴通讯股份有限公司 | Nat穿透方法及装置 |
CN106713437A (zh) * | 2016-12-16 | 2017-05-24 | 江苏神州信源系统工程有限公司 | 一种用于nat网络中服务器向客户端发送消息的方法 |
-
2021
- 2021-01-06 CN CN202110011856.9A patent/CN112637364B/zh active Active
-
2022
- 2022-01-05 US US18/271,013 patent/US20240064206A1/en active Pending
- 2022-01-05 WO PCT/CN2022/070236 patent/WO2022148361A1/zh active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040148406A1 (en) * | 2002-12-10 | 2004-07-29 | Koji Shima | Network system for establishing peer-to-peer communication |
CN101217536A (zh) * | 2007-12-28 | 2008-07-09 | 腾讯科技(深圳)有限公司 | 穿越网络地址转换设备/防火墙的方法、系统及客户端 |
CN106878474A (zh) * | 2017-04-25 | 2017-06-20 | 浙江风向标科技有限公司 | 一种p2p连接建立的方法和装置 |
CN107580081A (zh) * | 2017-09-18 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种nat穿透方法及装置 |
CN107580082A (zh) * | 2017-09-18 | 2018-01-12 | 北京奇艺世纪科技有限公司 | 一种对称型nat的穿透方法及装置 |
CN112637364A (zh) * | 2021-01-06 | 2021-04-09 | 上海哔哩哔哩科技有限公司 | 建立p2p连接的方法、客户端及系统 |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116708358A (zh) * | 2022-10-31 | 2023-09-05 | 荣耀终端有限公司 | P2p穿越方法、设备及存储介质 |
CN116708358B (zh) * | 2022-10-31 | 2024-04-05 | 荣耀终端有限公司 | P2p穿越方法、设备及存储介质 |
CN116939003A (zh) * | 2023-09-19 | 2023-10-24 | 敏于行(北京)科技有限公司 | 跨nat的端到端网络连接建立方法及系统 |
CN116939003B (zh) * | 2023-09-19 | 2023-11-14 | 敏于行(北京)科技有限公司 | 跨nat的端到端网络连接建立方法及系统 |
Also Published As
Publication number | Publication date |
---|---|
CN112637364B (zh) | 2023-01-10 |
CN112637364A (zh) | 2021-04-09 |
US20240064206A1 (en) | 2024-02-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022148361A1 (zh) | 建立p2p连接的方法、客户端及系统 | |
US9143421B2 (en) | Network system capable of implementing stun with the assistance of two network devices and method thereof | |
EP2255497B1 (en) | Traversal of symmetric network address translator for multiple simultaneous connections | |
CN108900351B (zh) | 内网设备类型识别方法及装置 | |
EP3219087B1 (en) | Methods, systems, and computer readable media for facilitating the resolving of endpoint hostnames in test environments with firewalls, network address translators(nats), or clouds | |
US20100088427A1 (en) | Selective Routing of Data Transmission Between Clients | |
CN111800341B (zh) | 一种跨路由器终端通信方法及装置 | |
US20100241710A1 (en) | Method and system for videoconferencing or data transfer between clients behind different network address translators | |
CN112770408B (zh) | 一种日志的传输方法、装置、计算机设备和存储介质 | |
JP7401564B2 (ja) | 通信方法及び関連デバイス | |
CN113542244B (zh) | 微服务调用方法、装置、服务器和系统 | |
WO2023186109A1 (zh) | 节点访问方法以及数据传输系统 | |
GB2598293A (en) | Apparatus, methods, and computer programs | |
CN112073553A (zh) | 网络地址转换类型的检测方法、装置、设备及存储介质 | |
US11863630B2 (en) | Connection establishment method, server, accessed node, access node, and storage medium | |
WO2022148364A1 (zh) | 数据发送方法及装置、建立p2p连接的方法及系统 | |
CN112019641B (zh) | 数据传输方法和装置 | |
JP6605149B2 (ja) | 共有端末の検出方法及びその装置 | |
CN112804290B (zh) | 一种适用于频谱/信号分析仪的云平台接入方法 | |
GB2607362A (en) | Private cloud routing server connection mechanism for use in a private communication architecture | |
CN107317869B (zh) | 一种节点nat类型探测方法、装置以及系统 | |
CN113225224B (zh) | 网络测速的方法、系统、存储介质以及计算机设备 | |
CN114422456B (zh) | 任务处理方法以及装置 | |
EP2608488B1 (en) | Dialog establishment over a peer-to-peer architecture | |
Cardwell | Capturing Network Traffic |
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: 22736523 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 18271013 Country of ref document: US |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 21.11.2023) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22736523 Country of ref document: EP Kind code of ref document: A1 |