Client point-to-point connection method and device, equipment, storage medium and product
By sending intranet connection information to the hole-punching server and performing port collisions in complex network scenarios, the problem of low success rate of client point-to-point connections is solved, and more efficient and reliable data transmission is achieved.
Patent Information
- Application Number
- CN202510231120.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-05-30
AI Technical Summary
In complex network scenarios, the ports between clients change, resulting in a low success rate of point-to-point connections.
By sending intranet connection information to the hole-punching server, an initial point-to-point connection is established, and when the connection fails, a port collision is performed according to the client's network address translation type to establish a backup point-to-point connection.
It effectively improves the success rate of client point-to-point connections in complex network scenarios, improves the efficiency and reliability of data transmission, and reduces data transmission delay.
Smart Images

Figure CN120075277A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a client peer-to-peer connection method, apparatus, device, storage medium, and product. Background Art
[0002] In the complex network scenario of global cross-border communication, although the traditional client-server (C2S) mode has its advantages in audio and video transmission, it faces many challenges in dealing with large-scale user concurrency, cross-regional network transmission, and network bandwidth fluctuations. The complex network scenario may include different network types (such as public network, private network, VPN, etc.), different network protocols (such as TCP, UDP), different NAT (Network Address Translation Protocol) types (such as symmetric type, port-restricted cone type, restricted cone type, etc.), and a dynamically changing network environment (such as network congestion, packet loss, blocking, etc.).
[0003] The peer-to-peer (P2P) technology, as a distributed network architecture, allows each node in the network to directly communicate and share resources with other nodes without relying on a central server, thereby reducing the load on the server, improving the efficiency and reliability of data transmission, and reducing the transmission delay. However, in a complex network scenario, the ports between two clients are variable, resulting in frequent connection creation failures for peer-to-peer connections, and the success rate of peer-to-peer connections is relatively low. Summary of the Invention
[0004] The embodiments of the present application provide a client peer-to-peer connection method, apparatus, device, storage medium, and product to solve the technical problem in the related art that the ports between clients are variable in a complex network scenario and the success rate of peer-to-peer connections is relatively low, which can effectively improve the success rate of peer-to-peer connections, enhance the efficiency and reliability of data transmission, and reduce the data transmission delay.
[0005] In a first aspect, the embodiments of the present application provide a client peer-to-peer connection method applied to a first client, including:
[0006] When successfully connected to the hole punching server, sending first internal network connection information to the hole punching server for the hole punching server to record first hole punching information according to the first internal network connection information, where the first hole punching information includes a first call identifier of the first client, first internal network connection information, and first public network connection information;
[0007] In the case of receiving the second punching information of the second client sent by the punching server, establish a first peer-to-peer connection with the second client according to the second punching information, where the second punching information includes the second call identifier, the second private network connection information, and the second public network connection information of the second client, the second call identifier is the same as the first call identifier, and when the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients;
[0008] In the case where the establishment of the first peer-to-peer connection fails, determine the first network address translation type of the first client and the second network address translation type corresponding to the second client. In the case where the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, perform a port collision with the second client and establish a second peer-to-peer connection with the second client through the port where the collision is successful.
[0009] In a second aspect, an embodiment of the present application provides a client peer-to-peer connection device applied to a first client, including an information sending module, a first connection module, and a second connection module, where:
[0010] The information sending module is configured to send first private network connection information to the punching server in the case of successfully connecting to the punching server, for the punching server to record first punching information according to the first private network connection information, and the first punching information includes the first call identifier, the first private network connection information, and the first public network connection information of the first client;
[0011] The first connection module is configured to establish a first peer-to-peer connection with the second client according to the second punching information in the case of receiving the second punching information of the second client sent by the punching server, where the second punching information includes the second call identifier, the second private network connection information, and the second public network connection information of the second client, the second call identifier is the same as the first call identifier, and when the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients;
[0012] The second connection module is configured to determine a first network address translation type of the first client and a second network address translation type corresponding to the second client when a first peer-to-peer connection establishment fails. When the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, perform a port collision with the second client, and establish a second peer-to-peer connection with the second client through the port with a successful collision.
[0013] In a third aspect, an embodiment of the present application provides a client peer-to-peer connection device, including: a memory and one or more processors;
[0014] The memory is used to store one or more programs;
[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the client peer-to-peer connection method as described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a non-volatile storage medium storing computer-executable instructions, where the computer-executable instructions are used to execute the client peer-to-peer connection method as described in the first aspect when executed by a computer processor.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program. The computer program is stored in a computer-readable storage medium, and at least one processor of the device reads and executes the computer program from the computer-readable storage medium, so that the device executes the client peer-to-peer connection method as described in the first aspect.
[0018] In the embodiment of the present application, by sending first intranet connection information to a punching server, when receiving second punching information of a second client sent by the punching server, a first peer-to-peer connection is established with the second client according to the second punching information. Among them, when the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients. When the first peer-to-peer connection establishment fails, and the first network address translation type of the first client and the second network address translation type corresponding to the second client are a combination of symmetric network address translation and port-restricted network address translation, perform a port collision with the second client, and establish a second peer-to-peer connection with the second client through the port with a successful collision. By adopting multiple punching methods to establish peer-to-peer connections, the success rate of client peer-to-peer connections in complex network scenarios can be effectively improved, the data transmission efficiency and reliability can be enhanced, and the data transmission delay can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flowchart of a client peer-to-peer connection method provided by an embodiment of the present application;
[0020] Figure 2 It is a flowchart of another client peer-to-peer connection method provided by an embodiment of the present application;
[0021] Figure 3 It is a schematic diagram of a network address translation type determination process provided by an embodiment of the present application;
[0022] Figure 4 It is a schematic structural diagram of a client peer-to-peer connection device provided by an embodiment of the present application;
[0023] Figure 5 It is a schematic structural diagram of a client peer-to-peer connection device provided by an embodiment of the present application. Detailed implementation manners
[0024] In order to make the purpose, technical solutions and advantages of the present application clearer, the following further describes the specific embodiments of the present application in detail with reference to the accompanying drawings. It can be understood that the specific embodiments described herein are only used to explain the present application, rather than limiting the present application. Additionally, it should be noted that for the sake of convenience of description, only parts related to the present application are shown in the drawings rather than all the content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the operations can be rearranged. When the operations are completed, the above process can be terminated, but there may also be additional steps not included in the drawings. The above process can correspond to methods, functions, procedures, subroutines, subprograms, and the like.
[0025] The client peer-to-peer connection method provided by the present application can be applied to data transmission based on P2P technology in complex network scenarios, such as audio and video VoIP (Voice over Internet Protocol) transmission based on P2P technology. The aim is to establish peer-to-peer connections by adopting multiple hole punching methods, which can effectively improve the success rate of client peer-to-peer connections in complex network scenarios, enhance the data transmission efficiency and reliability, and reduce the data transmission delay.
[0026] In the complex network scenario of global communication, the existing client peer-to-peer connection solutions are generally based on the traditional client-server mode. When providing data transmission services such as audio and video, the client-server mode needs to face challenges such as global deployment of servers, high server traffic costs, and complex server management costs. However, in the actual network scenario, the ports between different clients are variable, and the peer-to-peer connection often fails to create a connection, resulting in a low success rate of the peer-to-peer connection. Based on this, a client peer-to-peer connection method according to an embodiment of the present application is provided to solve the technical problem of the low success rate of the existing peer-to-peer connection.
[0027] Figure 1 The flowchart of a client peer-to-peer connection method provided by an embodiment of the present application is given. This client peer-to-peer connection method can be applied to the first client. The client peer-to-peer connection method provided by an embodiment of the present application can be executed by a client peer-to-peer connection device, and this client peer-to-peer connection device can be implemented in a hardware and / or software manner and integrated in a client peer-to-peer connection device.
[0028] The following describes the execution of the client peer-to-peer connection method by the client peer-to-peer connection device as an example.
[0029] Refer to Figure 1 , the client peer-to-peer connection method includes:
[0030] S110: In the case of successfully connecting to the hole punching server, send the first intranet connection information to the hole punching server for the hole punching server to record the first hole punching information according to the first intranet connection information. The first hole punching information includes the first call identifier of the first client, the first intranet connection information, and the first public network connection information.
[0031] In one embodiment, multiple hole punching servers can be deployed in the client peer-to-peer connection application scenario. For example, private peer-to-peer hole punching servers (P2P hole punching servers) with public IPv4 addresses are deployed globally, and the hole punching servers are configured to use the hole punching protocol provided by the present application to provide the peer-to-peer hole punching function to achieve efficient peer-to-peer connection of the client in a complex network scenario. Optionally, after deploying the hole punching server, the service address information of the hole punching server can be recorded in the signaling server or other preset storage locations. Among them, the address information provided by the present application can include the IP address and port. For example, the service address information can include the IP address and port of the hole punching server (such as the IPv4 public network address and port of the hole punching server).
[0032] The first client and the second client provided in this application can be understood as clients that need to establish a peer-to-peer connection, such as two terminals in a call. Among them, the second client can also execute the client peer-to-peer connection method provided in this application (in this case, the current second client and the first client respectively act as the first client and the second client to execute the client peer-to-peer connection method). Before establishing a peer-to-peer connection, the first client and the second client can be connected through a signaling server. When a peer-to-peer connection is required, the first client and the second client can obtain the service address information of the punching server, the unique call identifier (conv_id), and the client identifier (is_initiator) from the signaling server, and connect to the punching server based on the obtained service address information. Optionally, the signaling server can send a list of service address information of the punching server to the first client and the second client, and the first client and the second client can determine one or more service address information of the punching server for connection from the list of service address information.
[0033] Exemplarily, when the first client successfully connects to the hole punching server, it sends the first private network connection information to the hole punching server for the hole punching server to record the first hole punching information (peer_info) according to the first private network connection information. The first hole punching information includes the first call identifier of the first client (i.e., the unique call identifier for the first client to make a call), the first private network connection information, and the first public network connection information (the egress public network IPv4 address global_ip and the client public network IPv4 port global_port of the first client seen by the hole punching server). Among them, when the second client successfully connects to the hole punching server, it sends the second private network connection information to the hole punching server for the hole punching server to record the second hole punching information according to the second private network connection information. The second hole punching information includes the second call identifier of the second client (i.e., the unique call identifier for the second client to make a call), the second private network connection information, and the second public network connection information (the egress public network IPv4 address global_ip and the client public network IPv4 port global_port of the second client seen by the hole punching server). Optionally, the first private network connection information provided in this application may include the first call identifier corresponding to the first client, the first client identifier, and the first local address information (such as the IPv4 address local_ip and the port local_port), the first public network connection information may include the first IPv6 public network address information (such as the IPv6 address global_ip and the port global_port), the second private network connection information may include the second call identifier corresponding to the second client, the second client identifier, and the second local address information (such as the IPv4 address local_ip and the port local_port), and the second public network connection information may include the second IPv6 public network address information (such as the IPv6 address global_ip and the port global_port). For example, both client sides of the call create IPv4 udp sockets (udp_socket) to connect to the hole punching server at the same time, and notify the hole punching server of information such as the local address information (the IPv4 address local_ip and the port local_port (the internal network IP and port seen by the client behind the NAT device)) configured or bound to the socket, the unique call identifier (conv_id), and the client identifier (is_initiator). At the same time, the hole punching server can observe the egress public network address information of the connected client.
[0034] S120: When receiving the second hole punching information of the second client sent by the hole punching server, establish a first peer-to-peer connection with the second client according to the second hole punching information, where the second hole punching information includes the second call identifier of the second client, the second private network connection information, and the second public network connection information, the second call identifier is the same as the first call identifier, and when the hole punching server receives the same call identifier of two different clients, it sends the hole punching information corresponding to the other client to the two clients.
[0035] In one embodiment, when the hole punching server detects the first hole punching information and the second hole punching information corresponding to the same call from different clients (for example, the first call identifier and the second call identifier are the same, and the corresponding first client identifier and second client identifier are different), it sends the second hole punching information to the first client and the first hole punching information to the second client.
[0036] Exemplarily, when the first client receives the second hole punching information of the second client sent by the hole punching server, it establishes a first peer-to-peer connection with the second client according to the second hole punching information. When the first peer-to-peer connection is successfully established, data transmission can be performed between the first client and the second client based on the peer-to-peer connection. Correspondingly, when the second client receives the first hole punching information of the first client sent by the hole punching server, it establishes a peer-to-peer connection with the first client according to the first hole punching information. Both the first client and the second client attempt to establish peer-to-peer connections for the private network and the public network. If both paths are successful, data transmission is performed through the peer-to-peer connection channel that is successfully established first.
[0037] S130: When the first peer-to-peer connection fails to be established, determine the first network address translation type of the first client and the second network address translation type corresponding to the second client. When the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, perform a port collision with the second client and establish a second peer-to-peer connection with the second client through the port with successful collision.
[0038] Exemplarily, when the establishment of the first peer-to-peer connection fails, the first network address translation type (NAT type) of the first client and the second network address translation type corresponding to the second client can be determined. Among them, the first network address translation type of the first client can be determined by the local address information and the public network address information of itself determined by querying the punching servers when connecting to multiple punching servers. Similarly, the second network address translation type of the second client can be determined by the local address information and the public network address information of itself determined by querying the punching servers when connecting to multiple punching servers. Optionally, the second network address translation type of the second client is uploaded to the punching server, that is, both clients in the call report their own network address translation types to the punching server, and after the punching server determines that the conditions are met (for example, the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation), it notifies the two clients to perform port collision.
[0039] In one embodiment, when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, the first client can perform port collision with the second client, and when the port collision is successful, establish a second peer-to-peer connection with the second client through the successfully collided port. When the second peer-to-peer connection is successfully established, data transmission can be performed between the first client and the second client based on the peer-to-peer connection.
[0040] Optionally, the first client and the second client can perform port collision by sending information of random ports between the first client and the second client. When the port for successful mutual information sending is detected, it is considered that the port collision is successful. For example, the first client randomly creates multiple ports, and the first client sends probe packets from the random multiple ports to the second client. The second client sends probe packets from a fixed port to the random multiple ports of the first client. It can also be that the second client randomly creates multiple ports, and the second client sends probe packets from the random multiple ports to the fixed port of the first client. The first client sends probe packets from a fixed port to the multiple random ports of the second client. When there is a port where the first client and the second client successfully send probe packets to each other, it is considered that the port collision is successful.
[0041] Among them, the first network address translation type and the second network address translation type being a combination of symmetric network address translation and port-restricted network address translation can be that the first network address translation type is symmetric network address translation and the second network address translation type is port-restricted network address translation, or the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation.
[0042] As described above, by sending the first intranet connection information to the punching server, when receiving the second punching information of the second client sent by the punching server, a first peer-to-peer connection is established with the second client according to the second punching information. Among them, when the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients. When the establishment of the first peer-to-peer connection fails, and the first network address translation type of the first client and the second network address translation type corresponding to the second client are a combination of symmetric network address translation and port-restricted network address translation, a port collision is performed with the second client, and a second peer-to-peer connection is established with the second client through the successfully collided port. By using multiple punching methods to establish peer-to-peer connections, the success rate of peer-to-peer connections between clients in complex network scenarios can be effectively improved, the data transmission efficiency and reliability can be enhanced, and the data transmission delay can be reduced.
[0043] Based on the above embodiments, Figure 2 A flowchart of another client peer-to-peer connection method provided by the embodiment of the present application is given. This client peer-to-peer connection method is a specific implementation of the above client peer-to-peer connection method. Refer to Figure 2 , this client peer-to-peer connection method includes:
[0044] S210: When successfully connected to the punching server, send the first intranet connection information to the punching server for the punching server to record the first punching information according to the first intranet connection information. The first punching information includes the first call identifier of the first client, the first intranet connection information, and the first public network connection information.
[0045] S220: When receiving the second punching information of the second client sent by the punching server, establish a first peer-to-peer connection with the second client according to the second punching information. Among them, the second punching information includes the second call identifier of the second client, the second intranet connection information, and the second public network connection information. The second call identifier is the same as the first call identifier. When the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients.
[0046] In a possible embodiment, the client peer-to-peer connection method provided by the present application establishing a first peer-to-peer connection with the second client according to the second punching information may include: sending preset connection information to the second client according to the second intranet connection information and the second public network connection information in the second punching information. When the second client receives the preset connection information, it returns a preset response message; when receiving the preset response message sent by the second client, it is determined that the first peer-to-peer connection with the second client is successfully established.
[0047] Exemplarily, when the first client receives the second hole punching information of the second client sent by the hole punching server, it determines the second address information in the second hole punching information, and sends preset connection information (C2P message) to the second client according to the second address information. When the second client receives the preset connection information, it records the source address information (source ip:port) corresponding to the preset connection information, and returns a preset response message (C2P_ACK message) to the first client. Among them, when the source address information corresponding to the preset connection information is inconsistent with the first local address information recorded in the first hole punching information of the first client, a preset response message is sent to the source address information and the first local address information.
[0048] In one embodiment, when the second client receives the first hole punching information of the first client sent by the hole punching server, it can determine the first address information in the first hole punching information, and send preset connection information to the first client according to the first address information. When the first client receives the preset connection information, it returns a preset response message to the source address of the received preset connection information. If the source address of the received preset connection information is inconsistent with the second address information of the second client, the source address information corresponding to the preset connection information is recorded, and this source address is used as a possible peer address to attempt to establish a peer-to-peer connection.
[0049] For example, after the client (including the first client and the second client) receives the hole punching information of the other party, it multiplexes the udp socket udp_socket used to communicate with the hole punching server and starts to attempt to establish a P2P connection with the other client. The attempt process can be: sending the agreed C2P message to the peer address peer_addr obtained from the hole punching information (initially, there are generally two peer addresses, which are the local network address local_ip:local_port and the public network address global_ip:global_port of the other party). When the other client receives the C2P message, it records the source ip:port and returns the agreed C2P_ACK message. If the source ip:port is inconsistent with the peer address sent in the peer_info, this address is also used as a possible peer address peer_addr to attempt to establish a P2P connection. After the client receives the peer C2P_ACK message returned by a certain peer_addr that has been attempted, it means that the P2P connection with this peer_addr has been successfully established, and subsequent data transmission (such as audio and video VoIP transmission) can be based on the P2P connection. In this application, by sending preset connection information to the second client and determining whether the first peer-to-peer connection is successfully established according to whether the preset response message sent by the second client is received, the peer-to-peer connection with the second client is accurately established, improving the data transmission efficiency and reliability.
[0050] S230: When the establishment of the first peer-to-peer connection fails, determine the first network address translation type of the first client and the second network address translation type corresponding to the second client.
[0051] In a possible embodiment, as Figure 3 shown in the schematic diagram of a network address translation type determination process provided, the client peer-to-peer connection method provided by this application to determine the first network address translation type of the first client includes:
[0052] S231: Connect to multiple hole punching servers and query public network address information from the multiple hole punching servers.
[0053] S232: Determine the first network address translation type of the first client according to the local address information and the multiple public network address information.
[0054] Exemplarily, when the establishment of the first peer-to-peer connection fails, the first client and the second client can respectively create an ipv4 socket (udp ipv4 socket), bind the ipv4 socket to a random local port, and determine the local address information. Among them, the ipv4 socket can reuse the socket in the hole punching process. The first client and the second client respectively use the corresponding ipv4 sockets to connect to multiple hole punching servers (a preset number of hole punching servers). The multiple hole punching servers connected by the first client and the second client can be the same or different. The address information corresponding to the multiple hole punching servers can be determined from the service address information list provided by the signaling server.
[0055] After the first client and the second client connect to the hole punching server, they query the public network address information (public network ipv4 ip and port) corresponding to the client observed by the connected hole punching server from the hole punching server. After querying the public network address information from multiple hole punching servers, the first client and the second client can respectively determine the network address translation type based on the relationship between the local address information and the public network address information under different network address translation types, and the public network address information corresponding to different hole punching servers. This application accurately determines the network address translation type by querying the public network address information from multiple hole punching servers and according to the local address information and the multiple public network address information, and can accurately determine whether port collision can occur between the first client and the second client, improving the success rate of client peer-to-peer connection in complex network scenarios.
[0056] Optionally, the method for determining the second network address translation type of the second client may refer to the first network address translation type of the first client, which will not be elaborated in this application. In one embodiment, the client peer-to-peer connection method provided in this application determines the first network address translation type of the first client according to the local address information and multiple public network address information, which may include: when the local address information is inconsistent with the multiple public network address information, and the IP addresses in the multiple public network address information are the same but the ports are different, determining that the first network address translation type of the first client is symmetric network address translation; when the local address information is inconsistent with the multiple public network address information, and the IP addresses in the multiple public network address information are the same and the ports are the same, requesting one of the hole punching servers to send a preset message to the first client using another port, and when the preset message is not received, determining that the first network address translation type of the first client is port-restricted network address translation.
[0057] Exemplarily, after querying the public network address information from multiple hole punching servers, it is determined whether the local address information is consistent with the multiple public network address information. If the local address information is consistent with the multiple public network address information (that is, the queried public network ipv4 ip and port are the same as the local ipv4 ip and port), it indicates that the first client is not behind the NAT device, and the first network address translation type of the first client is non-network address translation (NON_NAT).
[0058] In one embodiment, when the local address information is inconsistent with the multiple public network address information, it is further determined whether the multiple public network address information is consistent. If the local address information is inconsistent with the multiple public network address information, and the multiple public network address information is inconsistent (both the IP address and port in the public network address information are different), it indicates that there may be multiple public network ip exits in the first client network, which does not belong to the common NAT type, and the first network address translation type of the first client is undetermined network address translation type (UNDETERMINED_NAT).
[0059] In one embodiment, when the local address information is inconsistent with the multiple public network address information, and the IP addresses in the multiple public network address information are the same but the ports are different, it indicates that the first client is behind the symmetric NAT device, and it can be determined that the first network address translation type of the first client is symmetric network address translation (SYMMETRIC_NAT).
[0060] When the local address information is inconsistent with multiple public network address information, and the IP addresses and ports in the multiple public network address information are the same, it indicates that the first client may be behind a cone-shaped NAT device, and it can be further determined which type of cone-shaped NAT device it is behind. Based on this, when the local address information is inconsistent with multiple public network address information, and the IP addresses are the same and the ports are the same in the multiple public network address information, the first client can request one of the hole punching servers to send a preset message to the first client using other ports. If the first client can receive the preset message, it indicates that the first client is behind a full cone-shaped NAT device or a restricted cone-shaped NAT, and the first network address translation type of the first client can be determined as the full cone network address translation (FULL_CONE_NAT) corresponding to the full cone-shaped NAT or the restricted cone network address translation (RESTRICTED_CONE_NAT) corresponding to the restricted cone-shaped NAT. If the first client does not receive the preset message (for example, does not receive the preset message after a preset time), the first network address translation type of the first client can be determined as the port restricted cone network address translation (PORT_RESTRICTED_CONE_NAT). This application accurately determines the first network address translation type of the first client according to the comparison of the local address information and the IP addresses and ports in the multiple public network address information, which helps to accurately determine whether port collision can be performed between the first client and the second client, and improves the success rate of peer-to-peer connection of clients in complex network scenarios.
[0061] S240: In the case where the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port restricted cone network address translation, perform port collision with the second client, and establish a second peer-to-peer connection with the second client through the successfully collided port.
[0062] In a possible embodiment, the client peer-to-peer connection method provided in this application performs port collision with the second client in the case where the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port restricted cone network address translation, including:
[0063] S241: In the case where the first network address translation type is symmetric network address translation and the second network address translation type is port restricted cone network address translation, create a first preset number of first IPv4 sockets.
[0064] S242: Through each first IPv4 socket, send a first detection message to the port corresponding to the second address information in the second hole punching information, where the second client sends a second detection message to a second preset number of random ports corresponding to the first client according to the first address information in the first hole punching information.
[0065] S243: Determine that the port collision is successful when the second probe information sent by the second client is received.
[0066] Exemplarily, when the first network address translation type is symmetric network address translation and the second network address translation type is port-restricted network address translation, the first client can create a first preset number of first IPv4 sockets, randomly bind ports to each of the first IPv4 sockets, and send first probe information to the ports corresponding to the second address information in the second hole punching information through each of the first IPv4 sockets. Among them, the second client sends second probe information to a second preset number of random ports corresponding to the first client according to the first address information in the first hole punching information. When the first client receives the second probe information sent by the second client, it can determine that the port collision is successful, and when the second client receives the first probe information sent by the first client, the second client can determine that the port collision is successful. Among them, the port that receives the probe information is the port where the collision is successful. Among them, the second client also performs port collision with the first client based on the above method. When the port collision of one of the clients is successful, it can be determined that the port collision between the two clients is successful.
[0067] In a possible embodiment, the client peer-to-peer connection method provided by this application performs port collision with the second client when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, including:
[0068] S244: When the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation, send first probe information to a fourth preset number of random ports corresponding to the second client according to the second address information in the second hole punching information, where the second client sends second probe information to the ports corresponding to the first address information in the first hole punching information by creating a third preset number of second IPv4 sockets.
[0069] S245: Determine that the port collision is successful when the second probe information sent by the second client is received.
[0070] Exemplarily, when the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation, the second client will create a third preset number of second IPv4 sockets and randomly bind ports to each second IPv4 socket, and send second probe information to the port corresponding to the first address information in the first hole punching information (i.e., the port of the first client) through each second IPv4 socket. The first client can send first probe information to the fourth preset number of random ports corresponding to the second client according to the second address information in the second hole punching information. When receiving the second probe information sent by the second client, it can be determined that the port collision is successful, and when the second client receives the first probe information sent by the first client, the second client can determine that the port collision is successful, where the port receiving the probe information is the port where the collision is successful. Among them, the second client also performs port collision with the first client based on the above method. When the port collision of one of the clients is successful, it can be determined that the port collision between the two clients is successful. The first preset number, the second preset number, the third preset number, and the fourth preset number provided in this application can be the same or different.
[0071] This application can use a hole punching method based on port collision in the scenario of hole punching between symmetric network address translation and port-restricted network address translation, and obtain a higher hole punching success rate with fewer port collision times. Assume that hole punching is attempted between client A and client B. The public network address queried by client A in the hole punching server is ip_a:port_a, and the public network address queried by client B in the hole punching server is ip_b:port_b. And client A detects that its network address translation type is symmetric network address translation, and client B is port-restricted network address translation.
[0072] It needs to be explained that in the conventional peer-to-peer hole punching scheme, client A attempts to connect to the address ip_b:port_b, and client B attempts to connect to the address ip_a:port_a. Since the exit port of client A is random (from 1 to 65535), there is only a 1 / 65535 probability of using port port_a. At this time, the hole punching success rate from client B to client A is 1 / 65535. If client B attempts port prediction and collision with N random ports {port_a1, port_a2... port_an}, the hole punching success rate is only N / 65535. At this time, if client A creates M IPv4 sockets udp socket and randomly binds ports at the same time and then attempts to perform hole punching to the address ip_b:port_b of client B, then the hole punching success rate at this time is:
[0073]
[0074] Assume that both N and M are 200, and the hole punching success rate is:
[0075]
[0076] It can be seen that in the scenario of hole punching between symmetric network address translation and port-restricted network address translation, if client B collides with 200 random ports of the public IP address ip_a of client A, and at the same time client A applies for 200 IPv4 sockets udp socket to try to punch holes to the address ip_b:port_b of client B, there is a hole punching success rate of about 45%. Similarly, when both ends simultaneously try to collide 300 and 400 ports, the hole punching success rates are about 75% and 91% respectively. According to the characteristics of symmetric NAT, using the principle of birthday collision algorithm, only by having both client sides try a certain number of port collisions (the number of times is much less than the number of ports that symmetric NAT may randomly select), can a relatively high success rate of P2P hole punching be achieved, and only a small amount of computing resources are required to significantly improve this hole punching success rate.
[0077] In the conventional solution, the server path connected by the client and the P2P path may share a UDP socket, which means that the implementation of the P2P path also depends on the network protocol type of the server path. However, considering the complex network scenarios of global cross-border and cross-regional communications, different users may be in different network scenarios, and the peer-to-peer connection methods in the related technologies may cause P2P communication obstacles due to differences in network types and protocols. This application can make the establishment of P2P communication more flexible, be able to adapt to various network conditions, and achieve the decoupling of the peer-to-peer connection path. Among them, the number of ports that different clients try respectively can be configured by themselves, and the number of ports that different clients try respectively can be the same or different. For example, client A applies for 200 sockets, and client B collides with 300 random ports of client A.
[0078] When the first network address translation type is symmetric network address translation and the second network address translation type is port-restricted network address translation, this application collides ports by creating a first preset number of first IPv4 sockets with the second client, and when the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation, it collides ports by sending a first detection message to a fourth preset number of random ports corresponding to the second client, which can effectively improve the port collision success rate and improve the second peer-to-peer connection efficiency.
[0079] In a possible embodiment, the client peer-to-peer connection method provided by this solution establishes a second peer-to-peer connection with a second client through the port with successful collision, which may include: sending preset connection information to the second client through the port with successful collision, and the second client returns preset response information when receiving the preset connection information; when receiving the preset response information sent by the second client, it is determined that the second peer-to-peer connection with the second client is successfully established.
[0080] Exemplarily, when the port collision is successful, the first client sends preset connection information to the second client through the port with successful collision. When the second client receives the preset connection information sent by the first client, it may send preset response information to the first client based on the source address information corresponding to the preset connection information. When the first client receives the preset response information, it may determine that the second peer-to-peer connection with the second client is successfully established. This application sends preset connection information to the second client through the port with successful collision, and determines whether the first peer-to-peer connection is successfully established according to whether the preset response information sent by the second client is received, accurately establishing a peer-to-peer connection with the second client, and improving the data transmission efficiency and reliability.
[0081] S250: When the first client is in an IPv6 environment, create an IPv6 socket and obtain the first IPv6 public network address information corresponding to the IPv6 socket, and send the first IPv6 public network address information to the hole punching server for the hole punching server to record the first IPv6 public network address information. When the hole punching server receives the same call identifier of two different clients and has recorded the IPv6 public network address information corresponding to the two different clients, it sends the IPv6 public network address information corresponding to the other client to the two clients.
[0082] S260: When receiving the second IPv6 public network address information of the second client sent by the hole punching server, establish a third peer-to-peer connection based on IPv6 with the second client. When the second peer-to-peer connection fails to be established, perform data transmission based on the peer-to-peer channel corresponding to the third peer-to-peer connection.
[0083] Exemplarily, the first client can detect whether it is in an IPv6 environment. When the first client is in an IPv6 environment, it can create an IPv6 socket and obtain the first IPv6 public network address information corresponding to the IPv6 socket. After successfully connecting to the hole punching server, it sends the first IPv6 public network address information to the hole punching server for the hole punching server to record the first IPv6 public network address information. The hole punching server provided in this application is further configured to send the IPv6 public network address information corresponding to the other client to the two clients when receiving the same call identifier of two different clients and both record the IPv6 public network address information corresponding to the two different clients.
[0084] Optionally, the client uploading the public network address information to the hole punching server and establishing the third peer-to-peer connection based on the public network address information can be carried out separately from the uploading of the internal network connection information and the establishment of the first and second peer-to-peer connections. Among them, the interaction based on the IPv6 public network address information can be completed in the same process as the above interaction steps based on the IPv4 internal network and public network address information, which can reduce the number of interactions between the client and the hole punching server. For example, if a client has an IPv6 address, then the message sent by the client to the hole punching server at the beginning includes the IPv4 internal network address, the public IPv6 address, and the call unique identifier.
[0085] When the first client receives the second IPv6 public network address information of the second client sent by the hole punching server, it can establish a third peer-to-peer connection based on IPv6 with the second client according to the second IPv6 public network address information of the second client recorded. When the establishment of the second peer-to-peer connection fails, data transmission can be carried out based on the peer-to-peer channel corresponding to the third peer-to-peer connection. When the establishment of the first or second peer-to-peer connection is successful and the establishment of the third peer-to-peer connection is successful, data transmission can be carried out based on the peer-to-peer channel corresponding to the first or second peer-to-peer connection, or data transmission can also be carried out based on the peer-to-peer channel corresponding to the third peer-to-peer connection.
[0086] It should be explained that in the IPv4+IPv6 dual-stack environment, due to the huge capacity of IPv6 addresses, most operators providing the dual-stack environment offer public IPv6 addresses. Since the addresses provided by IPv6 in the dual-stack environment are all public addresses without being translated by NAT devices, the network address translation types of clients in the IPv6 environment all belong to non-network address translation (NON_NAT), and there is no need to perform the process of punching holes in NAT devices. After the client locally creates an IPv6 socket (ipv6udp socket), the socket ip and port seen locally are the public ip and port of the actual IPv6 egress address. Therefore, for the establishment of the third peer-to-peer connection of the client under the public IPv6 protocol, as long as the IPv6 ip and port information bound at both ends is synchronized to the peer, the establishment of the third peer-to-peer connection can be completed. For example, during the process of punching holes based on IPv4, when there is an IPv6 environment on the client side, an additional IPv6 socket IPv6 udp socket can be created. After obtaining the IPv6 public address global_ipv6_ip and port global_ipv6_port, the ip and port information of IPv6 is additionally synchronized to the punching hole server, and the punching hole message peer_info sent by the punching hole server to the client additionally records the information of the IPv6 public address global_ipv6_ip and port global_ipv6_port. After the punching hole server collects the punching hole messages peer_info of both parties, if it is found that both parties have an IPv6 environment and report the IPv6 public address, the global_ipv6_ip and global_ipv6_port can be sent to the peer client together in the peer_info; otherwise, only the punching hole information related to IPv4 is sent in the peer_info. While starting to attempt punching holes in the IPv4 protocol, if the public IPv6 address global_ipv6_ip and global_ipv6_port of the peer are received in the peer_info, an attempt is also made to establish a public IPv6 P2P channel with the other party at the same time.
[0087] As described above, by sending the first intranet connection information to the punching server, when receiving the second punching information of the second client sent by the punching server, a first peer-to-peer connection is established with the second client according to the second punching information. Among them, when the punching server receives the same call identifier of two different clients, it sends the punching information corresponding to the other client to the two clients. When the establishment of the first peer-to-peer connection fails and the first network address translation type of the first client and the second network address translation type corresponding to the second client are a combination of symmetric network address translation and port-restricted network address translation, a port collision is performed with the second client, and a second peer-to-peer connection is established with the second client through the port where the collision is successful. By adopting multiple punching methods to establish peer-to-peer connections, the success rate of peer-to-peer connections between clients in complex network scenarios can be effectively improved, the data transmission efficiency and reliability can be enhanced, and the data transmission delay can be reduced. At the same time, the public IPv6 address of the client is used for IPv6 punching. Taking advantage of the rich IPV6 address resources, the public IPv6 punching can work in a dual-stack environment, ensuring that in a network with both IPv4 and IPv6, P2P punching can be carried out simultaneously and serve as complementary channels to greatly improve the success rate of peer-to-peer communication.
[0088] Figure 4 It is a schematic structural diagram of a client peer-to-peer connection device provided by an embodiment of the present application. This client peer-to-peer connection device can be applied to the first client. Refer to Figure 4 In this regard, this client peer-to-peer connection device includes an information sending module 41, a first connection module 42, and a second connection module 43.
[0089] Among them, the information sending module 41 is configured to send first intranet connection information to the hole punching server when successfully connecting to the hole punching server, so that the hole punching server records first hole punching information according to the first intranet connection information. The first hole punching information includes the first call identifier of the first client, the first intranet connection information, and the first public network connection information. The first connection module 42 is configured to establish a first peer-to-peer connection with the second client according to the second hole punching information when receiving the second hole punching information of the second client sent by the hole punching server. Among them, the second hole punching information includes the second call identifier of the second client, the second intranet connection information, and the second public network connection information. The second call identifier is the same as the first call identifier. When the hole punching server receives the same call identifier of two different clients, it sends the hole punching information corresponding to the other client to the two clients. The second connection module 43 is configured to determine the first network address translation type of the first client and the second network address translation type corresponding to the second client when the first peer-to-peer connection fails. When the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, perform port collision with the second client and establish a second peer-to-peer connection with the second client through the successfully collided port.
[0090] As described above, by sending the first intranet connection information to the hole punching server and establishing a first peer-to-peer connection with the second client according to the second hole punching information of the second client sent by the hole punching server. Among them, when the hole punching server receives the same call identifier of two different clients, it sends the hole punching information corresponding to the other client to the two clients. When the first peer-to-peer connection fails and the first network address translation type of the first client and the second network address translation type corresponding to the second client are a combination of symmetric network address translation and port-restricted network address translation, perform port collision with the second client and establish a second peer-to-peer connection with the second client through the successfully collided port. By using multiple hole punching methods to establish peer-to-peer connections, the success rate of peer-to-peer connections between clients in complex network scenarios can be effectively improved, the data transmission efficiency and reliability can be enhanced, and the data transmission delay can be reduced.
[0091] In a possible embodiment, the first connection module 42 establishing a first peer-to-peer connection with the second client according to the second hole punching information is configured to:
[0092] Send preset connection information to the second client according to the second intranet connection information and the second public network connection information in the second hole punching information. When the second client receives the preset connection information, it returns a preset response message.
[0093] In the case of receiving the preset response information sent by the second client, it is determined that the first peer-to-peer connection with the second client is successfully established.
[0094] In a possible embodiment, the second connection module 43 determines the first network address translation type of the first client and is configured as follows:
[0095] Connect to multiple hole punching servers and query public network address information from multiple hole punching servers;
[0096] Determine the first network address translation type of the first client according to the local address information and the multiple public network address information.
[0097] In a possible embodiment, the second connection module 43 determines the first network address translation type of the first client according to the local address information and the multiple public network address information and is configured as follows:
[0098] In the case where the local address information is inconsistent with the multiple public network address information, and the IP addresses in the multiple public network address information are the same and the ports are different, it is determined that the first network address translation type of the first client is symmetric network address translation;
[0099] In the case where the local address information is inconsistent with the multiple public network address information, and the IP addresses in the multiple public network address information are the same and the ports are the same, request one of the hole punching servers to send a preset message to the first client using other ports. In the case where the preset message is not received, it is determined that the first network address translation type of the first client is port-restricted network address translation.
[0100] In a possible embodiment, when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, the second connection module 43 performs port collision with the second client and is configured as follows:
[0101] In the case where the first network address translation type is symmetric network address translation and the second network address translation type is port-restricted network address translation, create a first preset number of first IPv4 sockets;
[0102] Through each first IPv4 socket, send first probe information to the port corresponding to the second address information in the second hole punching information, where the second client sends second probe information to a second preset number of random ports corresponding to the first client according to the first address information in the first hole punching information;
[0103] In the case of receiving the second probe information sent by the second client, it is determined that the port collision is successful.
[0104] In a possible embodiment, when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port-restricted network address translation, the second connection module 43 performs port collision with the second client, and is configured as follows:
[0105] When the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation, the first detection information is sent to the fourth preset number of random ports corresponding to the second client according to the second address information in the second hole punching information. The second client sends the second detection information to the port corresponding to the first address information in the first hole punching information through the third preset number of second IPv4 sockets;
[0106] When the second detection information sent by the second client is received, it is determined that the port collision is successful.
[0107] In a possible embodiment, the second connection module 43 establishes a second peer-to-peer connection with the second client through the port with successful collision, and is configured as follows:
[0108] The preset connection information is sent to the second client through the port with successful collision. When the second client receives the preset connection information, it returns the preset response information;
[0109] When the preset response information sent by the second client is received, it is determined that the second peer-to-peer connection with the second client is successfully established.
[0110] In a possible embodiment, the client peer-to-peer connection device further includes a third connection module, and the third connection module is configured as follows:
[0111] When the first client is in an IPv6 environment, an IPv6 socket is created and the first IPv6 public network address information corresponding to the IPv6 socket is obtained, and the first IPv6 public network address information is sent to the hole punching server for the hole punching server to record the first IPv6 public network address information. When the hole punching server receives the same call identifier of two different clients and has recorded the IPv6 public network address information corresponding to the two different clients, the IPv6 public network address information corresponding to the other client is sent to the two clients;
[0112] When the second IPv6 public network address information of the second client sent by the hole punching server is received, a third peer-to-peer connection based on IPv6 is established with the second client;
[0113] When the second peer-to-peer connection fails to be established, data transmission is performed through the peer-to-peer channel corresponding to the third peer-to-peer connection.
[0114] It should be noted that in the above embodiments of the client peer-to-peer connection device, the included units and modules are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of mutual distinction and do not limit the protection scope of the embodiments of the present application.
[0115] The embodiments of the present application also provide a client peer-to-peer connection device, and this client peer-to-peer connection device can integrate the client peer-to-peer connection device provided by the embodiments of the present application. Figure 5 It is a schematic structural diagram of a client peer-to-peer connection device provided by the embodiments of the present application. Refer to Figure 5 , this client peer-to-peer connection device includes: an input device 53, an output device 54, a memory 52, and one or more processors 51; the memory 52 is used to store one or more programs; when the one or more programs are executed by the one or more processors 51, the one or more processors 51 implement the client peer-to-peer connection method provided in the above embodiments. The above-provided client peer-to-peer connection device, equipment, and computer can be used to execute the client peer-to-peer connection method provided in any of the above embodiments, and have the corresponding functions and beneficial effects.
[0116] The embodiments of the present application also provide a non-volatile storage medium storing computer-executable instructions, and the computer-executable instructions are used to execute the client peer-to-peer connection method provided in the above embodiments when executed by a computer processor. Of course, for the non-volatile storage medium storing computer-executable instructions provided by the embodiments of the present application, its computer-executable instructions are not limited to the client peer-to-peer connection method provided above, and can also execute the relevant operations in the client peer-to-peer connection method provided in any embodiment of the present application. The client peer-to-peer connection device, equipment, and storage medium provided in the above embodiments can execute the client peer-to-peer connection method provided in any embodiment of the present application. For the technical details not described in detail in the above embodiments, reference can be made to the client peer-to-peer connection method provided in any embodiment of the present application.
[0117] Based on the above embodiments, the embodiments of the present application also provide a computer program product. Essentially, or the part that contributes to the prior art, or all or part of this technical solution of the present application can be embodied in the form of a software product. This computer program product is stored in a storage medium and includes several instructions to enable a computer device, a mobile terminal, or a processor therein to execute all or part of the steps of the client peer-to-peer connection method provided in each embodiment of the present application.
Claims
1. A client point-to-point connection method, applied to a first client, characterized in that: include: In the case of successfully connecting to the hole punching server, sending first intranet connection information to the hole punching server, so that the hole punching server records first hole punching information according to the first intranet connection information, where the first hole punching information includes a first call identifier of the first client, the first intranet connection information, and the first public network connection information; In the case of receiving the second hole punching information of the second client sent by the hole punching server, establishing a first point-to-point connection with the second client according to the second hole punching information, wherein the second hole punching information includes a second call identifier of the second client, second intranet connection information and second public network connection information, the second call identifier is the same as the first call identifier, and the hole punching server sends the hole punching information corresponding to the other client to the two clients when receiving the same call identifier of two different clients; In the event that establishment of the first point-to-point connection fails, a first network address translation type of the first client and a second network address translation type corresponding to the second client are determined; in the event that the first network address translation type and the second network address translation type are a combination of a symmetric network address translation and a port-restricted network address translation, a port collision is performed with the second client, and a second point-to-point connection is established with the second client through the port where the collision succeeds.
2. The client point-to-point connection method according to claim 1, characterized in that: The establishing a first point-to-point connection with the second client according to the second hole punching information includes: Sending preset connection information to the second client according to the second intranet connection information and the second public network connection information in the second hole punching information, and the second client returning preset response information when receiving the preset connection information; When the preset response information sent by the second client is received, it is determined that the first point-to-point connection with the second client is successfully established.
3. The client point-to-point connection method according to claim 1, characterized in that: The determining the first network address translation type of the first client includes: Connecting to multiple hole punching servers, and querying the public network address information from the multiple hole punching servers; A first network address translation type of the first client is determined according to the local address information and the plurality of public network address information.
4. The client point-to-point connection method according to claim 3, characterized in that: The determining the first network address translation type of the first client according to the local address information and the plurality of public network address information includes: When the local address information and the plurality of public network address information are inconsistent, and the IP addresses in the plurality of public network address information are consistent but the ports are inconsistent, determining that the first network address translation type of the first client is symmetric network address translation; When the local address information and the multiple public network address information are inconsistent, and the IP addresses and ports in the multiple public network address information are consistent, request one of the hole punching servers to use other ports to send a preset message to the first client. If the preset message is not received, determine that the first network address translation type of the first client is port-restricted network address translation.
5. The client point-to-point connection method according to claim 1, characterized in that: The performing port collision with the second client when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port restricted network address translation comprises: In a case where the first network address translation type is symmetric network address translation and the second network address translation type is port-restricted network address translation, creating a first preset number of first IPv4 sockets; Sending first detection information to a port corresponding to the second address information in the second hole punching information through each of the first IPv4 sockets, wherein the second client sends second detection information to a second preset number of random ports corresponding to the first client according to the first address information in the first hole punching information; When the second detection information sent by the second client is received, it is determined that the port collision is successful.
6. The client point-to-point connection method according to claim 1, characterized in that: The performing port collision with the second client when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port restricted network address translation comprises: In the case where the first network address translation type is port-restricted network address translation and the second network address translation type is symmetric network address translation, first detection information is sent to a fourth preset number of random ports corresponding to the second client according to the second address information in the second hole punching information, wherein the second client sends the second detection information to the port corresponding to the first address information in the first hole punching information through a third preset number of second IPv4 sockets; When the second detection information sent by the second client is received, it is determined that the port collision is successful.
7. The client point-to-point connection method according to claim 1, characterized in that: The establishing of a second point-to-point connection with the second client through the port that successfully collided includes: Sending preset connection information to the second client through the port where the collision succeeds, and the second client returning preset response information when receiving the preset connection information; When the preset response information sent by the second client is received, it is determined that the second point-to-point connection with the second client is successfully established.
8. The client point-to-point connection method according to claim 1, characterized in that: Also includes: When the first client is in an IPv6 environment, create an IPv6 socket and obtain first IPv6 public network address information corresponding to the IPv6 socket, and send the first IPv6 public network address information to the hole punching server, so that the hole punching server records the first IPv6 public network address information. When the hole punching server receives the same call identifier from two different clients and both record the IPv6 public network address information corresponding to two different clients, it sends the IPv6 public network address information corresponding to the other client to the two clients; Upon receiving the second IPv6 public network address information of the second client sent by the hole punching server, establishing a third IPv6-based point-to-point connection with the second client; In the event that establishment of the second point-to-point connection fails, data transmission is performed based on a point-to-point channel corresponding to the third point-to-point connection.
9. A client point-to-point connection device, applied to a first client, characterized in that: It includes an information sending module, a first connection module and a second connection module, wherein: The information sending module is configured to send first intranet connection information to the hole punching server when the hole punching server is successfully connected, so that the hole punching server records first hole punching information according to the first intranet connection information, wherein the first hole punching information includes a first call identifier of the first client, the first intranet connection information and the first public network connection information; The first connection module is configured to establish a first point-to-point connection with the second client according to the second hole punching information when receiving the second hole punching information of the second client sent by the hole punching server, wherein the second hole punching information includes a second call identifier of the second client, second intranet connection information and second public network connection information, the second call identifier is the same as the first call identifier, and the hole punching server sends the hole punching information corresponding to the other client to the two clients when receiving the same call identifier of two different clients; The second connection module is configured to, when the first point-to-point connection fails to be established, determine the first network address translation type of the first client and the second network address translation type corresponding to the second client, and when the first network address translation type and the second network address translation type are a combination of symmetric network address translation and port restricted network address translation, perform port collision with the second client, and establish a second point-to-point connection with the second client through the port where the collision succeeds.
10. A client point-to-point connection device, characterized in that: include: memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the client point-to-point connection method as described in any one of claims 1-8.
11. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions are used to execute the client point-to-point connection method as described in any one of claims 1-8 when executed by a computer processor.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the client point-to-point connection method according to any one of claims 1 to 8 is implemented.