Communication processing method and device, electronic equipment and readable storage medium

By using the STUN server to obtain the external information of the client when the NAT type is symmetrical, determine the NAT device type and predict the external port of the countertop client, the problem of low penetration success rate in P2P direct communication is solved, and a higher penetration success rate and stability are achieved.

CN120342995APending Publication Date: 2025-07-18NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510293154.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

When the NAT type is symmetric, the penetration success rate of P2P direct communication in the prior art is low, and it is impossible to effectively solve the problem of penetration failure caused by inconsistent with the external ports exposed by the client to the STUN server and the external ports of the counter-end client.

Method used

The target client obtains the external IP address and external port from multiple STUN servers, determines the type of NAT device, and predicts the predicted external port of the peer client based on the NAT type and external port, encapsulates the detection message for penetration.

Benefits of technology

The penetration success rate when the NAT type is symmetrical is improved, and the stability and reliability of P2P direct communication are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120342995A_ABST
    Figure CN120342995A_ABST
Patent Text Reader

Abstract

The invention discloses a communication processing method and device, electronic equipment and a readable storage medium, and the method comprises the steps: a target client obtains an external IP address of the target client from a plurality of STUN servers and an external port, exposed to each STUN server, of the target client, and determines an NAT type of target NAT equipment based on the external IP address and the external port, exposed to each STUN server, of the target client, and sending the determined message to a target opposite client through a forwarding server. And the target opposite-end client determines a predicted external port exposed to the target opposite-end client by the target client according to the received information, encapsulates the detection message, and sends the detection message to the predicted external port. And if the target client receives the detection message sent by the target opposite-end client, determining that penetration between the target client and the target opposite-end client is successful. And according to the NAT type of the target NAT device, determining the predicted external port exposed to the target opposite-end client by the target client, thereby improving the penetration success rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication technologies, and particularly relates to a communication processing method, apparatus, electronic device, and readable storage medium. Background Art

[0002] In related technologies, the P2P (Peer-to-Peer) direct connection technology requires direct communication between clients. In the absence of a NAT (Network Address Translation) device, the two communication parties only need to obtain each other's IP (Internet Protocol) address and port respectively to perform P2P direct connection communication. However, in actual applications, many clients are located behind NAT devices, making it difficult to achieve P2P direct connection. Usually, penetration technologies need to be adopted to achieve P2P direct connection communication.

[0003] Currently, as Figure 1 shown, Figure 1 FIG. 1 is a schematic architecture diagram of a device system adopting a penetration technology provided by the prior art. Client 1 is connected to NAT device 1, client 2 is connected to NAT device 2, a STUN (Session Traversal Utilities for NAT) server is respectively connected to NAT device 1 and NAT device 2, and a forwarding server is respectively connected to NAT device 1 and NAT device 2. Client 1 sends a request message to the STUN server through NAT device 1, and the STUN server returns the external port and external IP address exposed to the STUN server to client 1 through NAT device 1 in response to the received request message. Client 2 sends a request message to the STUN server through NAT device 2, and the STUN server returns the external port and external IP address exposed to the STUN server to client 2 through NAT device 2 in response to the received request message. Client 1 sends the external port and external IP address exposed to the STUN server to the forwarding server through NAT device 1, and client 2 sends the external port and external IP address exposed to the STUN server to the forwarding server through NAT device 2. Then, the forwarding server sends the external port and external IP address of client 1 exposed to the STUN server received to client 2 through NAT device 2, and sends the external port and external IP address of client 2 exposed to the STUN server received to client 1 through NAT device 1. Client 1 and client 2 send probe messages to each other based on the obtained external ports and external IP addresses of each other exposed to the STUN server to perform penetration.

[0004] However, in the case where the NAT type is symmetric, the external port exposed by the client to the STUN server may be different from the external port exposed by the client to the peer client. In this case, if the external port exposed by the client to the STUN server is used as the external port exposed by the client to the peer client for penetration, the penetration may fail, resulting in a significant reduction in the penetration success rate. Therefore, there is an urgent need for a communication processing method that can improve the penetration success rate when the NAT type is symmetric. Summary of the Invention

[0005] In view of this, the present application provides a communication processing method, apparatus, electronic device, and readable storage medium to improve the penetration success rate when the NAT type is symmetric.

[0006] In a first aspect, an embodiment of the present application provides a communication processing method, which is applied to a first device system. The first device system includes a first client and a second client that are peer clients to each other, a first NAT device and a second NAT device that are peer NAT devices to each other, multiple STUN servers, and a forwarding server; the first client is connected to the first NAT device, the second client is connected to the second NAT device, the STUN servers are respectively connected to the first NAT device and the second NAT device, and the forwarding server is respectively connected to the first NAT device and the second NAT device; the target clients include the first client and the second client, and the target NAT devices include the first NAT device and the second NAT device; the method includes:

[0007] The target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server from multiple STUN servers through the target NAT device;

[0008] The target client determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each STUN server;

[0009] The target client sends, through the target NAT device, the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server;

[0010] The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server;

[0011] The target peer client encapsulates a probe message according to the external IP address and the predicted external port of the target client;

[0012] The target peer client sends a probe message to the predicted external port through the target peer NAT device;

[0013] If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful.

[0014] In a second aspect, an embodiment of the present application provides a communication processing device, which is applied to a first device system. The first device system includes a first client and a second client that are peer clients to each other, a first NAT device and a second NAT device that are peer NAT devices to each other, multiple STUN servers, and a forwarding server; the first client is connected to the first NAT device, the second client is connected to the second NAT device, the STUN servers are respectively connected to the first NAT device and the second NAT device, and the forwarding server is respectively connected to the first NAT device and the second NAT device; the target client includes the first client and the second client, and the target NAT device includes the first NAT device and the second NAT device; the device includes:

[0015] An obtaining module, configured to obtain, by the target client through the target NAT device, the external IP address of the target client and the external ports exposed by the target client to each STUN server from multiple STUN servers;

[0016] A first determining module, configured to determine, by the target client according to the external ports exposed by the target client to each STUN server, the NAT type of the target NAT device;

[0017] A first sending module, configured to send, by the target client through the target NAT device, the external ports exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server;

[0018] A second determining module, configured to determine, by the target peer client according to the NAT type of the target NAT device and the external ports exposed by the target client to each STUN server, the predicted external port exposed by the target client to the target peer client;

[0019] An encapsulating module, configured to encapsulate a probe message by the target peer client according to the external IP address and the predicted external port of the target client;

[0020] A second sending module, configured to send, by the target peer client through the target peer NAT device, the probe message to the predicted external port;

[0021] A third determining module, configured to determine that the penetration between the target client and the target peer client is successful if the target client receives the probe message sent by the target peer client.

[0022] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0023] a processor; and

[0024] a memory for storing a data processing program. After the electronic device is powered on and runs the program through the processor, it executes the method as in the first aspect.

[0025] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a data processing program, which is run by a processor to execute the method as in the first aspect.

[0026] For the communication processing method provided by the present application, the target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server from multiple STUN servers through the target NAT device. According to the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device is determined, and the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client are sent to the target peer client through a forwarding server. The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, and encapsulates a probe message according to the external IP address and the predicted external port of the target client, and sends the probe message to the predicted external port through the target peer NAT device. If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful. Compared with directly using the external ports respectively exposed by the target client to each STUN server as the external ports exposed by the target client to the target peer client, determining the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device improves the penetration success rate. Description of the Drawings

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0028] Figure 1 It is a schematic diagram of an architecture of a device system adopted for implementing penetration technology provided by the prior art;

[0029] Figure 2A flowchart example of the communication processing method provided by the embodiments of the present application;

[0030] Figure 3 A schematic structural diagram of the first device system provided by the embodiments of the present application;

[0031] Figure 4-1 The first schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0032] Figure 4-2 The second schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0033] Figure 4-3 The third schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0034] Figure 5 The fourth schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0035] Figure 6 The fifth schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0036] Figure 7 The sixth schematic diagram of the target peer client sending a probe message to the target client provided by the embodiments of the present application;

[0037] Figure 8 A schematic structural diagram of the second device system provided by the embodiments of the present application;

[0038] Figure 9 A schematic structural diagram of the communication processing apparatus provided by the embodiments of the present application;

[0039] Figure 10 A schematic block diagram of the electronic device for implementing the communication processing method provided by the embodiments of the present application. Detailed implementation manners

[0040] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.

[0041] It should be noted that in the claims, the description, and the drawings of the present application, terms such as "first", "second", "third", etc. are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising", "having", and their variants are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0042] It should be understood that in the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "Including A, B, and / or C" means including any one, any two, or all three of A, B, and C.

[0043] It should be understood that in the embodiments of the present application, "B corresponding to A", "B corresponding to A relatively", "A corresponding to B relatively", or "B corresponding to A relatively" means that B is associated with A, and B can be determined according to A. Determining B according to A does not mean determining B only according to A, but B can also be determined according to A and / or other information.

[0044] Based on the problems existing in the above related technologies, the embodiments of the present application provide a communication processing method, device, electronic device, and readable storage medium.

[0045] Before elaborating on the embodiments of the present application in detail, the related concepts of the present application will be further introduced first.

[0046] NAT: It is a technology used to modify the IP address of a data packet when it passes through a router or firewall. NAT runs on a router or firewall, enabling multiple devices to share a common external IP address to connect to the Internet while using private internal IP addresses for communication within a local area network.

[0047] Depending on its implementation method and application scenarios, NAT technology can be divided into several types. The following are several common NAT types and their differences:

[0048] Full Cone NAT: In this type of NAT device, once an internal IP address and an internal port are mapped to an external IP address and an external port, any external device can send data to the internal IP address and internal port by sending data to the external IP address and external port. That is, as long as the public network mapping information of the internal device is known, any external device can initiate a connection request.

[0049] Restricted Cone NAT: Similar to Full Cone NAT, but with an additional restriction: only when the internal device has previously attempted to send data to a specific external IP address can that external IP address send data back to the internal device through NAT. Even if the above conditions are met, the external device can only send data to the internal device from the external port where it previously received data.

[0050] Port Restricted Cone: It not only requires that the external IP address of the external device must be one that the internal host has previously attempted to contact, but also that the external port used by the external device must be the external port used in previous communications.

[0051] Symmetric NAT: For each external connection request, NAT creates a new mapping, and this mapping is only valid for that specific destination address and port. If the internal device attempts to communicate with a different external device, different external ports may be allocated, and even different external IP addresses may be used. Depending on whether a certain pattern or rule is followed, Symmetric NAT can be further divided into "regular" and "irregular". Here, "regular" and "irregular" refer to whether there is a pattern in the allocation of different external ports.

[0052] NAT Device: A hardware or software tool that performs network address translation, mainly used to modify the source or destination IP address of a data packet when it passes through a router or firewall. This allows an internal network to use private IP addresses and communicate with an external network through one or more public IP addresses.

[0053] STUN: A network protocol used to help a client discover its external IP address and external port when connected to a NAT device and determine the type of NAT. The STUN protocol defines a set of methods that enable a client to communicate with a STUN server to obtain this information, thus helping to establish a direct P2P connection. This is particularly important for applications that need to establish a direct connection, such as VoIP (Voice over Internet Protocol), instant messaging, and online gaming scenarios.

[0054] P2P: It is a distributed network architecture in which each node (i.e., peer) can act as both a client and a server, directly communicating and sharing resources with other nodes without going through a forwarding server. The P2P direct connection technology features decentralization and distribution, and is widely applied in various scenarios. Some application scenarios of the P2P direct connection technology are briefly listed below:

[0055] File sharing: The P2P technology was first applied to file sharing, such as P2P file sharing protocols like BitTorrent, eDonkey, and Gnutella. Users can download and upload files through the P2P network, dispersing the pressure on the server and increasing the download speed.

[0056] Instant messaging: The P2P technology is also widely used in instant messaging applications, such as communication applications like Skype and WhatsApp. Users can make voice and video calls and send messages through the P2P network, reducing the dependence on the central server.

[0057] NAT traversal technology: It refers to a method of establishing direct communication between two devices located behind different NAT devices. Common NAT traversal technologies include UDP (User Datagram Protocol) hole punching.

[0058] The communication processing method provided by the embodiments of this application can be applied to application scenarios such as VoIP (Voice over Internet Protocol), video conferencing, online games, file sharing and transmission, Internet of Things device management, and instant messaging tools, and can also be applied to other application scenarios according to actual needs. This application does not limit this.

[0059] The technical solution of this application will be described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments involved in the following description are used to explain the technical solution of this application and are not used as a limitation for actual use.

[0060] To solve the problems existing in the related technologies, the embodiments of this application provide a communication processing method, as Figure 2 shown, Figure 2 is a flowchart of an example of the communication processing method provided by the embodiments of this application. It should be noted that the steps shown can be executed in a logical order different from that shown in the method flowchart. The method may include the following steps S201 to step S207.

[0061] The communication processing method provided by the embodiments of this application is applied in the first device system, as Figure 3 shown, Figure 3A schematic architecture diagram of the first device system provided by an embodiment of the present application. The first device system 300 includes a first client 301 and a second client 302 that are peer clients to each other, a first NAT device 303 and a second NAT device 304 that are peer NAT devices to each other, multiple STUN servers 305, and a forwarding server 306. The first client 301 is connected to the first NAT device 303, the second client 302 is connected to the second NAT device 304, the STUN servers 305 are respectively connected to the first NAT device 303 and the second NAT device 304, and the forwarding server 306 is respectively connected to the first NAT device 303 and the second NAT device 304.

[0062] Step S201: The target client obtains the external IP address of the target client and the external ports exposed by the target client to each STUN server from multiple STUN servers through the target NAT device.

[0063] It should be noted that the target client includes the first client 301 and the second client 302, and the target NAT device includes the first NAT device 303 and the second NAT device 304. Each NAT device can be connected to at least one client. That is, the number of the first client 301 and the second client 302 is at least one.

[0064] Any two clients connected behind different NAT devices are peer clients to each other, and the NAT devices they are connected to are peer NAT devices to each other. As Figure 3 shown, the first client 301 and the second client 302 are peer clients to each other, and the first NAT device 303 and the second NAT device 304 are peer NAT devices to each other.

[0065] It should be noted that the NAT device can be a device such as a router, a firewall, and a mobile network management device. The client can be a personal computer, a smart phone, a tablet computer, an Internet of Things device, a server, etc. The present application does not limit the NAT type of the NAT device and the client.

[0066] It should be noted that the STUN server can be a public STUN server or a STUN server built by the user according to actual needs.

[0067] In an alternative embodiment, as Figure 3As shown, the number of STUN servers is 3. As shown in Table 1, the 3 STUN servers are STUN Server 1, STUN Server 2, and STUN Server 3. The IP address and port of STUN Server 1 are 220.181.38.1 and 3478, the IP address and port of STUN Server 2 are 220.181.38.2 and 3478, and the IP address and port of STUN Server 3 are 220.181.38.3 and 3478. It should be noted that the IP addresses of different STUN servers are different, and the ports of different STUN servers can be the same or different.

[0068] STUN Server IP Address Port STUN Server 1 220.181.38.1 3478 STUN Server 2 220.181.38.2 3478 STUN Server 3 220.181.38.3 3478

[0069] Table 1

[0070] It should be noted that the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server are assigned by the target NAT device for the target client.

[0071] In an alternative embodiment, as shown in Table 2, the external IP address of the target client can be 67.105.12.10, and the external ports exposed by the target client to STUN Server 1, STUN Server 2, and STUN Server 3 can all be 31256.

[0072]

[0073] Table 2

[0074] In an alternative embodiment, as shown in Table 3, the external IP address of the target client can be 67.105.12.10, the external port exposed by the target client to STUN Server 1 can be 49153, the external port exposed by the target client to STUN Server 2 can be 49154, and the external port exposed by the target client to STUN Server 3 can be 49155.

[0075]

[0076] Table 3

[0077] In an alternative embodiment, as shown in Table 4, the external IP address of the target client can be 67.105.12.10, the external port exposed by the target client to STUN Server 1 can be 31256, the external port exposed by the target client to STUN Server 2 can be 61347, and the external port exposed by the target client to STUN Server 3 can be 10034.

[0078]

[0079] Table 4

[0080] In an alternative embodiment, as Figure 3 shown, the first client 301 obtains the external IP address of the first client 301 and the external ports to which the first client 301 is respectively exposed to each STUN server 305 through the first NAT device 303 from multiple STUN servers 305. The second client 302 obtains the external IP address of the second client 302 and the external ports to which the second client 302 is respectively exposed to each STUN server 305 through the second NAT device 304 from multiple STUN servers 305.

[0081] In an alternative embodiment, the target client obtains the external IP address of the target client and the external ports to which the target client is respectively exposed to each STUN server from multiple STUN servers through the target NAT device, including the following steps:

[0082] The target client respectively sends request messages to multiple STUN servers through the target NAT device according to the obtained IP addresses and ports of the multiple STUN servers. Each STUN server returns the external port and external IP address to which the target client is exposed to the corresponding STUN server to the target client through the target NAT device in response to the received request message.

[0083] It should be noted that considering that multiple clients may use the same NAT device for external communication, that is, a NAT device may need to process the request messages of multiple clients, so the NAT device will allocate external ports to different clients. Therefore, if the interval duration between the request messages sent by the target client is too long, other target clients will perform external communication through the target NAT device during this interval duration. At this time, the target NAT device will allocate external ports to other target clients, resulting in the target client being difficult to accurately judge the NAT type according to the external port and external IP address to which the target client is exposed to the corresponding STUN server returned by the STUN server. Therefore, the target client needs to send request messages to multiple STUN servers through the target NAT device at an interval duration less than the preset duration.

[0084] In an alternative embodiment, a socket can be created on the target client, and the source port is bound to the socket, and the socket bound with the source port is denoted as udp_src. The target client uses udp_src to send request messages to multiple STUN servers through the target NAT device.

[0085] In this step, the external IP address of the target client and the external ports that the target client exposes to each STUN server are obtained, so that the NAT type of the target NAT device can be determined based on the above-obtained information subsequently, and then the predicted external port that the target client exposes to the target peer client can be determined based on different NAT types, so as to perform penetration based on the predicted external port.

[0086] Step S202: The target client determines the NAT type of the target NAT device according to the external ports that the target client exposes to each STUN server.

[0087] In an optional embodiment, as shown in Table 2, if the external ports that the target client exposes to each STUN server are all the same port, for example, the port is 31256, then it is determined that the NAT type of the target NAT device is port-restricted cone type. As shown in Table 3, if the port numbers of the external ports that the target client exposes to each STUN server have a preset rule, for example, the ports are 49153, 49154, and 49155 respectively, obviously, the port increases by 1 each time, then it is determined that the NAT type of the target NAT device is regularly symmetric type. It should be noted that the preset rule is to increase by a constant. As shown in Table 4, if the port numbers of the external ports that the target client exposes to each STUN server are random values, for example, the ports are 31256, 61347, and 10034 respectively, then it is determined that the NAT type of the target NAT device is irregularly symmetric type.

[0088] In an optional embodiment, the NAT type of the first NAT device is determined according to the external ports that the first client exposes to each STUN server. The NAT type of the second NAT device is determined according to the external ports that the second client exposes to each STUN server.

[0089] In this step, determining the NAT type is for subsequently determining the predicted external port that the target client exposes to the target peer client based on the determined NAT type, so as to perform penetration based on the predicted external port.

[0090] It should be noted that the NAT type also includes full cone type and restricted cone type. In the case where the NAT type of the NAT device is full cone type and restricted cone type, the existing technology is used to determine the external port that the target client exposes to the target peer client, so as to perform penetration based on the external port. Therefore, the embodiments of the present application do not describe these two NAT types in detail.

[0091] Step S203: The target client sends, through the target NAT device, the external ports to which the target client is exposed to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server.

[0092] In an alternative embodiment, the target client sends, through the target NAT device, the external ports to which the target client is exposed to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server, including the following steps:

[0093] In an alternative embodiment, the target client sends to the forwarding server the external ports and the external IP address to which the target client is exposed to the STUN server through the target NAT device. Then, the forwarding server sends the received external ports and the external IP address to which the target client is exposed to the STUN server to the target peer client through the target peer NAT device.

[0094] In an alternative embodiment, as Figure 3 shown, the external ports to which the first client 301 is exposed to each STUN server 305, the NAT type of the first NAT device 303, and the external IP address of the first client 301 are sent to the second client 302 through the forwarding server 306. The external ports to which the second client 302 is exposed to each STUN server 305, the NAT type of the second NAT device 304, and the external IP address of the second client 302 are sent to the first client 301 through the forwarding server 306.

[0095] Specifically, the first client 301 sends to the forwarding server 306 the external ports to which the first client 301 is exposed to the STUN server 305 and the external IP address of the first client 301 through the first NAT device 303. The second client 302 sends to the forwarding server 306 the external ports to which the second client 302 is exposed to the STUN server 305 and the external IP address of the second client 302 through the second NAT device 304. Then, the forwarding server 306 sends the received external ports to which the first client 301 is exposed to the STUN server 305 and the external IP address of the first client 301 to the second client 302 through the second NAT device 304, and sends the received external ports to which the second client 302 is exposed to the STUN server 305 and the external IP address of the second client 302 to the first client 301 through the first NAT device 303.

[0096] Step S204: The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports exposed by the target client to each STUN server respectively.

[0097] When the NAT type of the target NAT device is a restricted cone type, the external ports exposed by the target client to each STUN server are the same. It is easy to conclude that the external port exposed by the target client to the target peer client is the external port exposed by the target client to the STUN server. Therefore, in this case, the external port exposed by the target client to the STUN server can be directly determined as the predicted external port exposed by the target client to the target peer client.

[0098] When the NAT type of the target NAT device is a symmetric type, the external ports exposed by the target client to each STUN server are different. It is easy to understand that the external ports exposed by the target client to different target peer clients are different. Therefore, it is necessary to predict the external port exposed by the target client to the target peer client according to the external ports exposed by the target client to each STUN server respectively.

[0099] It should be noted that the external IP address of the target client and the external port exposed by the target client to the target peer client are assigned by the target NAT device for the target client. It is easy to understand that the external port exposed by the target client to the target peer client is on the target NAT device. Considering that there may be multiple target clients connected to the target NAT device, multiple target clients may simultaneously require the target NAT device to assign external ports for them. Therefore, multiple predicted external ports exposed by the target client to the target peer client can be determined, thereby increasing the possibility that the external port exposed by the target client to the target peer client is included in the multiple predicted external ports, and thus improving the penetration success rate.

[0100] In an alternative embodiment, when the NAT type of the target NAT device is a symmetric type, the target peer client determines multiple predicted external ports exposed by the target client to the target peer client according to the external ports exposed by the target client to each STUN server respectively.

[0101] Considering that the NAT type is further divided into regular symmetric type and irregular symmetric type. In the case where the NAT type is regular symmetric, the external port assigned by the target NAT device to the target client follows a certain pattern. In the case where the NAT type is irregular symmetric, the target NAT device randomly assigns external ports to the target client without any pattern. Therefore, for these two different cases, different methods are adopted to determine multiple predicted external ports exposed by the target client to the target peer client.

[0102] In an alternative embodiment, in the case where the NAT type is regular symmetric, the target peer client predicts N predicted external ports based on the external ports exposed by the target client to each STUN server respectively and a preset increment, where N is an integer greater than 0. For example, N can be 4, 8, or 10.

[0103] In an alternative embodiment, predicting N predicted external ports based on the external ports exposed by the target client to each STUN server respectively and a preset increment includes: the target peer client adds the external port exposed by the target client to the last STUN server to 1 to N times the preset increment respectively to obtain N predicted external ports.

[0104] In an alternative embodiment, as shown in Table 3, the external port exposed by the target client to STUN server 1 can be 49153, the external port exposed by the target client to STUN server 2 can be 49154, and the external port exposed by the target client to STUN server 3 can be 49155. The preset increment is 1. Assuming N is 4, the four predicted external ports are 49156, 49157, 49158, and 49159 respectively.

[0105] In an alternative embodiment, in the case where the NAT type is irregular symmetric, the target peer client randomly determines M predicted external ports from the ports after the external ports exposed by the target client to each STUN server respectively, where M is an integer greater than 0.

[0106] In an alternative embodiment, as shown in Table 4, the external port exposed by the target client to STUN server 1 can be 31256, the external port exposed by the target client to STUN server 2 can be 61347, and the external port exposed by the target client to STUN server 3 can be 10034. Assuming M is 6, the four predicted external ports can be 42587, 59723, 45892, and 23214 respectively.

[0107] In this step, the larger the value of M is set, the greater the probability that the predicted external ports exposed by the target client to the target peer client include the external ports exposed by the target client to the target peer client. That is, the penetration success rate is higher.

[0108] In an alternative embodiment, as Figure 3 shown, the first client 301 determines the predicted external ports exposed by the second client 302 to the first client 301 according to the NAT type of the second NAT device 304 and the external ports exposed by the second client 302 to each STUN server 305. The second client 302 determines the predicted external ports exposed by the first client 301 to the second client 302 according to the NAT type of the first NAT device 303 and the external ports exposed by the first client 301 to each STUN server 305.

[0109] In this step, according to the NAT type of the target NAT device and the external ports exposed by the target client to each STUN server, the predicted external ports exposed by the target client to the target peer client are determined, so that penetration can be performed based on the predicted external ports subsequently.

[0110] Step S205: The target peer client encapsulates a probe message according to the external IP address and the predicted external ports of the target client.

[0111] It should be noted that the probe message is used to determine whether the penetration between the target client and the target peer client is successful. Among them, the probe message is a UDP packet. Encapsulating the probe message with the external IP address and the predicted external ports of the target client is to be able to send the probe message to the predicted external ports exposed by the target client to the target peer client subsequently, and after the target client receives the probe message, determine whether the penetration between the target client and the target peer client is successful according to the encapsulated external IP address of the target client.

[0112] In an alternative embodiment, as Figure 3 shown, the first client 301 encapsulates a probe message according to the external IP address of the second client 302 and the predicted external ports exposed by the second client 302 to the first client 301, and the second client 302 encapsulates a probe message according to the IP address of the first client 301 and the predicted external ports exposed by the first client 301 to the second client 302.

[0113] Step S206: The target peer client sends the probe message to the predicted external ports through the target peer NAT device.

[0114] When the NAT type of the target NAT device is symmetric, in an optional embodiment, the target peer client sends a probe message to the predicted external port through the target peer NAT device, including:

[0115] The target peer client sends the probe message to each predicted external port through the target peer NAT device.

[0116] Considering that before the target peer client sends the probe message to the predicted external port, it also needs to obtain the NAT type of the target NAT device and the external ports exposed by the target client to each STUN server, and determine the predicted external port exposed by the target client to the target peer client based on this information. During this period, the target NAT device will allocate external ports to other target clients. Therefore, when the target peer client sends the probe message to the predicted external port, it can send the probe message to the last predicted external port among multiple predicted external ports.

[0117] In an optional embodiment, the target peer client sends a probe message to the predicted external port through the target peer NAT device, including:

[0118] The target peer client sends the probe message to the last predicted external port through the target peer NAT device.

[0119] In an optional embodiment, as Figure 3 shown, the first client 301 sends the probe message to the predicted external port exposed by the second client 302 to the first client 301 through the first NAT device 303; the second client 302 sends the probe message to the predicted external port exposed by the first client 301 to the second client 302 through the second NAT device 304.

[0120] In an optional embodiment, when the NAT type of the first NAT device is port-restricted cone type and the NAT type of the second NAT device is regular symmetric type, as Figure 4-1 shown, the first client sends the probe message to ports 49156, 49157, 49158, and 49159 of the second NAT device through the first NAT device, where ports 49153, 49154, and 49155 are the external ports exposed by the second client to the STUN server respectively. As Figure 4-2 shown, the second client sends the probe message to port 31256 through the second NAT device. Among them, Figure 4-2 is a schematic diagram of the second NAT device allocating only one external port to the second client. In addition, as Figure 4-3 shown, the second NAT device can also allocate multiple external ports to the second client.

[0121] In an alternative embodiment, multiple sockets bound to source ports can be created on the target client. Each time a socket bound to a source port is created, the target NAT device will allocate one more external port exposed to the target peer client for the target client.

[0122] In an alternative embodiment, the first client uses the same created socket bound to a source port to send probe messages to ports 49156, 49157, 49158, and 49159 of the second NAT device through the first NAT device. The second client can use multiple created sockets bound to source ports to send probe messages to port 31256 through the second NAT device.

[0123] In this embodiment, the first client uses the same created socket bound to a source port to send probe messages to different external ports, so that the first NAT device records these external ports, so as to subsequently allow the first NAT device to receive replies to these external ports. Creating multiple sockets bound to source ports on the second client is to let the second NAT device allocate external ports for each source port, so that the first client can successfully penetrate after predicting these allocated external ports.

[0124] In an alternative embodiment, when the NAT type of the first NAT device is port-restricted cone type and the NAT type of the second NAT device is irregular symmetric type, as Figure 5 shown, the first client sends probe messages to ports 42587, 59723, 45892, and 23214 of the second NAT device through the first NAT device. Among them, ports 31256, 61347, and 10034 are the external ports exposed by the second client to the STUN server respectively. As Figure 4-2 shown, the second client sends probe messages to port 31256 through the second NAT device. In addition, as Figure 4-3 shown, the second NAT device can also allocate multiple external ports for the second client.

[0125] In an alternative embodiment, the first client uses the same created socket bound to a source port to send probe messages to ports 42587, 59723, 45892, and 23214 of the second NAT device through the first NAT device. The second client can use multiple created sockets bound to source ports to send probe messages to port 31256 through the second NAT device.

[0126] In an alternative embodiment, when the NAT type of the first NAT device is regularly symmetric and the NAT type of the second NAT device is regularly symmetric, as Figure 4-1 shown, the first client sends a probe message to ports 49156, 49157, 49158, and 49159 of the second NAT device through the first NAT device. Among them, ports 49153, 49154, and 49155 are the external ports respectively exposed by the second client to the STUN server. As Figure 6 shown, the second client sends a probe message to ports 6006, 6008, 6010, and 6012 of the first NAT device through the second NAT device. Among them, ports 6000, 6002, and 6004 are the external ports respectively exposed by the second client to the STUN server.

[0127] In an alternative embodiment, the first client can send a probe message to ports 49156, 49157, 49158, and 49159 of the second NAT device through the first NAT device by using multiple created sockets bound to source ports, and the second client can send a probe message to ports 6006, 6008, 6010, and 6012 of the first NAT device through the second NAT device by using multiple created sockets bound to source ports.

[0128] In another alternative embodiment, as Figure 7 shown, when the NAT type of the first NAT device is regularly symmetric and the NAT type of the second NAT device is regularly symmetric, the first client sends a probe message to port 49159 of the second NAT device through the first NAT device, and the second client sends a probe message to port 6012 of the first NAT device through the second NAT device.

[0129] In this embodiment, by sending the probe message to the last predicted external port of the NAT device, while improving the penetration success rate, resources are saved.

[0130] In an alternative embodiment, when the NAT type of the first NAT device is regularly symmetric and the NAT type of the second NAT device is irregularly symmetric, as Figure 5 shown, the first client sends a probe message to ports 42587, 59723, 45892, and 23214 of the second NAT device through the first NAT device. Among them, ports 31256, 61347, and 10034 are the external ports respectively exposed by the second client to the STUN server. As Figure 6As shown in the figure, the second client sends probe messages to ports 6006, 6008, 6010, and 6012 of the first NAT device through the second NAT device, where ports 6000, 6002, and 6004 are the external ports exposed by the second client to the STUN server respectively.

[0131] In an alternative embodiment, the first client can use multiple created sockets bound to active ports to send probe messages to ports 42587, 59723, 45892, and 23214 of the second NAT device through the first NAT device, and the second client can use multiple created sockets bound to active ports to send probe messages to ports 6006, 6008, 6010, and 6012 of the first NAT device through the first NAT device.

[0132] In an alternative embodiment, assuming that the external port of the first client exposed to the second client has been successfully determined, the first client can use the same created socket bound to an active port to send probe messages to ports 42587, 59723, 45892, and 23214 of the second NAT device through the first NAT device, and the second client can use multiple created sockets bound to active ports to send probe messages to the external port of the first NAT device through the first NAT device.

[0133] Step S207: If the target client receives a probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful.

[0134] In an alternative embodiment, if the target client receives a probe message sent by the target peer client and it is determined that the penetration between the target client and the target peer client is successful, it includes:

[0135] In the case where the NAT type of the target NAT device is symmetric, if the target client receives a probe message sent by the target peer client through one of the predicted external ports, it is determined that the penetration between the target client and the target peer client is successful.

[0136] In an alternative embodiment, as Figure 3 shown, if the target client receives a probe message sent by the target peer client and it is determined that the penetration between the target client and the target peer client is successful, it includes:

[0137] If the first client 301 receives the probe message sent by the second client 302 and the second client 302 receives the probe message sent by the first client 301, it is determined that the penetration between the first client 301 and the second client 302 is successful.

[0138] In the embodiment of the present application, the target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server from multiple STUN servers through the target NAT device, determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each STUN server, and sends the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server. The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, encapsulates the probe message according to the external IP address and the predicted external port of the target client, and sends the probe message to the predicted external port through the target peer NAT device. If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful. Compared with directly using the external ports respectively exposed by the target client to each STUN server as the external ports exposed by the target client to the target peer client, determining the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device improves the penetration success rate.

[0139] In an alternative embodiment, when the NAT type of the first NAT device is the port-restricted cone type and the NAT type of the second NAT device is the irregular symmetric type, the penetration success probability is calculated according to the Birthday paradox algorithm.

[0140] The specific formula is:

[0141]

[0142] Among them, C is the combination operation symbol in mathematics, the value of c is 65535, representing the total number of ports of the target NAT device; b is the number of external ports allocated by the target NAT device for the target client and exposed to the target peer client, a is 65535 - M, M is the number of predicted external ports exposed by the target client to the target peer client, and P(M) is the penetration success rate when the number of predicted external ports exposed by the target client to the target peer client is M.

[0143] In an alternative embodiment, when the NAT type of the first NAT device is regularly symmetric and the NAT type of the second NAT device is irregularly symmetric, assuming that the second client successfully predicts the external port exposed by the first client to the second client, the penetration success probability can be calculated according to the following formula:

[0144] The specific formula is:

[0145] P(M) = 1 - (1 - 1 / 65535)^M;

[0146] where M is the number of predicted external ports exposed by the target client to the target peer client, and P(M) is the penetration success rate when the number of predicted external ports exposed by the target client to the target peer client is M.

[0147] When M = 45425, P(M) ≈ 50%. It can be seen that in this case, the number of attempts required for successful penetration will be very large, but as long as there is enough time, penetration can still be successful using this method.

[0148] In an alternative embodiment, the present application embodiment also provides a communication method between a target client and a target peer client, which is applied to the second device system. As Figure 8 shown, Figure 8 This is a schematic architecture diagram of the second device system provided by the present application embodiment. The second device system 800 includes a first client 301 and a second client 302 that are peer clients to each other, a first NAT device 303, a second NAT device 304, and a forwarding server 306 that are peer NAT devices to each other. The first client 301 is connected to the first NAT device 303, the second client 302 is connected to the second NAT device 304, and the forwarding server 306 is connected to the first NAT device 303 and the second NAT device 304 respectively.

[0149] In an alternative embodiment, the communication method between the target client and the target peer client includes:

[0150] The target client sends a communication message to the target peer client through the target NAT device and the target peer NAT device based on the external port exposed by the target peer client to the target client.

[0151] In an alternative embodiment, the communication method between the target client and the target peer client includes:

[0152] The target peer client sends a communication message to the target client through the target peer NAT device and the target NAT device based on the external port exposed by the target client to the target peer client, so as to achieve point-to-point communication between the first client 301 and the second client 302.

[0153] In an alternative embodiment, as Figure 8 shown, the first client 301 sends a communication message to the client 302 through the first NAT device 303 and the second NAT device 304 based on the external port exposed by the second client 302 to the first client 301. The second client 302 sends a communication message to the first client 301 through the second NAT device 304 and the first NAT device 303 based on the external port exposed by the first client 301 to the second client 302, so as to implement peer-to-peer communication between the first client 301 and the second client 302.

[0154] Corresponding to the method for processing data provided by the embodiments of the present application, the embodiments of the present application further provide a communication processing device 900, as Figure 9 shown, the device includes:

[0155] An obtaining module 901, configured to obtain, by the target client through the target NAT device, the external IP address of the target client and the external ports respectively exposed by the target client to each of the multiple STUN servers;

[0156] A first determining module 902, configured to determine, by the target client according to the external ports respectively exposed by the target client to each of the STUN servers, the NAT type of the target NAT device;

[0157] A first sending module 903, configured to send, by the target client through the target NAT device, the external ports respectively exposed by the target client to each of the STUN servers, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through a forwarding server;

[0158] A second determining module 904, configured to determine, by the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each of the STUN servers, the predicted external port exposed by the target client to the target peer client;

[0159] An encapsulating module 905, configured to encapsulate a probe message by the target peer client according to the external IP address and the predicted external port of the target client;

[0160] A second sending module 906, configured to send, by the target peer client through the target peer NAT device, the probe message to the predicted external port;

[0161] A third determining module 907, configured to determine that the penetration between the target client and the target peer client is successful if the target client receives the probe message sent by the target peer client.

[0162] Corresponding to a communication processing method provided by an embodiment of the present application, an embodiment of the present application further provides an electronic device for implementing the communication processing method. As Figure 10 shown, the electronic device includes: a processor 1001; and a memory 1002 for storing a program of the communication processing method. After the device is powered on and the program of the communication processing method runs through the processor, the following steps are executed:

[0163] The target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server from multiple STUN servers through the target NAT device;

[0164] The target client determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each STUN server;

[0165] The target client sends the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server through the target NAT device;

[0166] The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server;

[0167] The target peer client encapsulates a probe message according to the external IP address and the predicted external port of the target client;

[0168] The target peer client sends the probe message to the predicted external port through the target peer NAT device;

[0169] If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful.

[0170] In an embodiment of the present application, the target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server through the target NAT device, determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each STUN server, and sends the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server. The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, encapsulates a probe message according to the external IP address and the predicted external port of the target client, and sends the probe message to the predicted external port through the target peer NAT device. If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful. Compared with directly using the external ports respectively exposed by the target client to each STUN server as the external ports exposed by the target client to the target peer client, determining the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device improves the penetration success rate.

[0171] Corresponding to the communication processing method provided in the embodiment of the present application, the embodiment of the present application further provides a computer-readable storage medium, storing a program of the communication processing method, which is run by a processor to execute the following steps:

[0172] The target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server through the target NAT device;

[0173] The target client determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each STUN server;

[0174] The target client sends the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the target NAT device and the forwarding server;

[0175] The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server;

[0176] The target peer client encapsulates a probe message according to the external IP address and the predicted external port of the target client;

[0177] The target peer client sends a detection message to the predicted external port through the target peer NAT device;

[0178] If the target client receives the detection message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful.

[0179] In the embodiment of the present application, the target client obtains the external IP address of the target client and the external ports respectively exposed by the target client to each STUN server from multiple STUN servers through the target NAT device. According to the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device is determined, and the external ports respectively exposed by the target client to each STUN server, the NAT type of the target NAT device, and the external IP address of the target client are sent to the target peer client through the forwarding server. The target peer client determines the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, and encapsulates a detection message according to the external IP address and the predicted external port of the target client, and sends the detection message to the predicted external port through the target peer NAT device. If the target client receives the detection message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful. Compared with directly using the external ports respectively exposed by the target client to each STUN server as the external ports exposed by the target client to the target peer client, determining the predicted external port exposed by the target client to the target peer client according to the NAT type of the target NAT device improves the penetration success rate.

[0180] It should be noted that for the detailed description of the communication processing device, electronic device and readable storage medium provided in the embodiment of the present application, reference can be made to the relevant description of the embodiment of the communication processing method provided in the embodiment of the present application, which will not be elaborated here.

[0181] Although the present application is disclosed above with preferred embodiments, it is not used to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be defined by the scope of the claims of the present application.

[0182] In a typical configuration, an electronic device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.

[0183] The memory may include non - permanent memory in the form of computer - readable media, such as random access memory (RAM) and / or non - volatile memory, such as read - only memory (ROM) or flash RAM. The memory is an example of computer - readable media.

[0184] 1. Computer - readable media includes both permanent and non - permanent, removable and non - removable media that can store information by any method or technology. The information can be computer - readable operations, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase - change memory (PRAM), static random - access memory (SRAM), dynamic random - access memory (DRAM), other types of random - access memory (RAM), read - only memory (ROM), electrically erasable programmable read - only memory (EEPROM), flash memory or other memory technologies, compact disc read - only memory (CD - ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non - transitory medium that can be used to store information accessible by a computing device. As defined herein, computer - readable media does not include transitory media such as modulated data signals and carrier waves.

[0185] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer - usable storage media (including but not limited to disk memory, CD - ROM, optical memory, etc.) that contain computer - usable program code.

[0186] Although the present application is disclosed above with preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be determined by the scope defined in the claims of the present application.

Claims

1. A communication processing method, characterized in that, Applied to a first device system, the first device system includes a first client and a second client that are peer clients to each other, a first NAT device and a second NAT device that are peer NAT devices to each other, a plurality of STUN servers, and a forwarding server; the first client is connected to the first NAT device, the second client is connected to the second NAT device, the STUN servers are respectively connected to the first NAT device and the second NAT device, and the forwarding server is respectively connected to the first NAT device and the second NAT device; The target client includes the first client and the second client, and the target NAT device includes the first NAT device and the second NAT device; the method includes: The target client obtains, through the target NAT device, the external IP address of the target client and the external ports respectively exposed by the target client to each of the STUN servers from the plurality of STUN servers; The target client determines the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each of the STUN servers; The target client sends, through the target NAT device, the external ports respectively exposed by the target client to each of the STUN servers, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server; The target peer client determines the predicted external ports exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each of the STUN servers; The target peer client encapsulates a probe message according to the external IP address of the target client and the predicted external ports; The target peer client sends the probe message to the predicted external ports through the target peer NAT device; If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful.

2. The method according to claim 1, characterized in that The target peer client determines the predicted external ports exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each of the STUN servers, including: When the NAT type of the target NAT device is symmetric, the target peer client determines a plurality of predicted external ports exposed by the target client to the target peer client according to the external ports respectively exposed by the target client to each of the STUN servers; If the target client receives the probe message sent by the target peer client, it is determined that the penetration between the target client and the target peer client is successful, including: If the target client receives a probing message sent by the target peer client through one of the predicted external ports, it is determined that the penetration between the target client and the target peer client is successful.

3. The method according to claim 2, characterized in that, The target peer client determines multiple predicted external ports exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, including: When the NAT type of the target NAT device is regular symmetric type, the target peer client predicts N predicted external ports according to the external ports respectively exposed by the target client to each STUN server and a preset increment, where N is an integer greater than 0.

4. The method according to claim 3, wherein The predicting N predicted external ports according to the external ports respectively exposed by the target client to each STUN server and a preset increment includes: The target peer client adds the external ports exposed by the target client to the last STUN server to 1 to N times of the preset increment respectively to obtain the N predicted external ports.

5. The method according to claim 2, characterized in that, The target peer client sends the probing message to the predicted external ports through the target peer NAT device, including: The target peer client sends the probing message to each of the predicted external ports through the target peer NAT device.

6. The method according to claim 2, wherein The target peer client sends the probing message to the predicted external ports through the target peer NAT device, including: The target peer client sends the probing message to the last predicted external port through the target peer NAT device.

7. The method according to claim 2, wherein The target peer client determines multiple predicted external ports exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, including: When the NAT type of the target NAT device is irregular symmetric type, the target peer client randomly determines M predicted external ports from the ports after the external ports respectively exposed by the target client to each STUN server, where M is an integer greater than 0.

8. The method according to claim 1, wherein The target peer client determines the predicted external ports exposed by the target client to the target peer client according to the NAT type of the target NAT device and the external ports respectively exposed by the target client to each STUN server, including: When the NAT type of the target NAT device is port-restricted cone type, the target peer client determines the external port exposed by the target client to the STUN server as the predicted external port exposed by the target client to the target peer client.

9. The method according to claim 8, wherein When the NAT type of the target NAT device is port-restricted cone type, the external ports exposed by the target client to each STUN server are the same.

10. The method according to claim 1, wherein If the target client receives the probe message sent by the target peer client, determining that penetration is successful between the target client and the target peer client includes: If the first client receives the probe message sent by the second client and the second client receives the probe message sent by the first client, determining that penetration is successful between the first client and the second client.

11. The method according to claim 1, characterized in that, The method further includes: The target client records the port included in the probe message as the external port exposed by the target client to the target peer client; The target peer client records the port included in the probe message as the external port exposed by the target peer client to the target client.

12. The method according to claim 11, wherein The communication method between the target client and the target peer client includes: The target client sends a communication message to the target peer client through the target NAT device and the target peer NAT device based on the external port exposed by the target peer client to the target client.

13. The method according to claim 11, wherein The communication method between the target client and the target peer client includes: The target peer client sends a communication message to the target client through the target peer NAT device and the target NAT device based on the external port exposed by the target client to the target peer client.

14. A communication processing device, characterized in that, Applied to a first device system, the first device system includes a first client and a second client that are peer clients to each other, a first NAT device and a second NAT device that are peer NAT devices to each other, multiple STUN servers, and a forwarding server; the first client is connected to the first NAT device, the second client is connected to the second NAT device, the STUN servers are respectively connected to the first NAT device and the second NAT device, and the forwarding server is respectively connected to the first NAT device and the second NAT device; The target client includes the first client and the second client, and the target NAT device includes the first NAT device and the second NAT device; the device includes: An acquisition module, configured to enable the target client to obtain the external IP address of the target client and the external ports respectively exposed by the target client to each of the STUN servers from the multiple STUN servers through the target NAT device; A first determination module, configured to enable the target client to determine the NAT type of the target NAT device according to the external ports respectively exposed by the target client to each of the STUN servers; A first sending module, configured to enable the target client to send, through the target NAT device, the external ports respectively exposed by the target client to each of the STUN servers, the NAT type of the target NAT device, and the external IP address of the target client to the target peer client through the forwarding server; A second determination module, configured to determine, by the target peer client, a predicted external port that the target client exposes to the target peer client according to the NAT type of the target NAT device and the external ports that the target client exposes to each of the STUN servers; An encapsulation module, configured to encapsulate a probe message by the target peer client according to the external IP address of the target client and the predicted external port; A second sending module, configured to send the probe message to the predicted external port by the target peer client through the target peer NAT device; A third determination module, configured to determine that the penetration between the target client and the target peer client is successful if the target client receives the probe message sent by the target peer client.

15. An electronic device, characterized in that, Comprising: A processor; And A memory, configured to store a data processing program, where after the electronic device is powered on and runs the program through the processor, the method according to any one of claims 1 to 13 is executed.

16. A computer-readable storage medium, characterized in that, A data processing program is stored, and the program is run by a processor to execute the method according to any one of claims 1 to 13.