Method and apparatus for transmitting a penetration handshake packet

By obtaining the smooth round-trip time and controlling the sending time, the problem of NAT traversal failure caused by the timing difference of NAT device connectivity detection packets is solved, achieving a higher NAT traversal success rate and stable connection.

CN119276829BActive Publication Date: 2025-10-24ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411378384.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-10-24
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

Existing NAT devices have a connection tracking function, which leads to NAT penetration failure caused by differences in the timing of connectivity detection messages arriving at the egress NAT. Existing technologies have not been able to effectively solve this problem.

Method used

By receiving the target connection request sent by the platform server, the smooth round-trip time between the client and the first network address translation device, as well as the smooth round-trip time between the client and the platform server, is obtained. Based on these times, the target time for sending the penetration handshake packet is determined to ensure that the penetration handshake packet arrives at the other end's NAT at the same time, avoiding connectivity detection failure caused by timing differences.

Benefits of technology

It improves the success rate of NAT traversal, ensures a stable connection between the client and the device, and enhances communication quality and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119276829B_ABST
    Figure CN119276829B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method and device for sending a penetration handshake packet, comprising: receiving a target connection request from a platform server by a device end, wherein the target connection request carries a first smooth round trip time between a client and a first network address translation device, and a second smooth round trip time between the client and the platform server; receiving a time delay acquisition response from the platform server by the device end, wherein the time delay acquisition response carries a third smooth round trip time between the platform server and a second network address translation device; determining a target time for sending the penetration handshake packet to the client according to the first smooth round trip time and the second smooth round trip time, and the third smooth round trip time by the device end, and sending the penetration handshake packet to the client at the target time. Through the present application, the problem of NAT penetration failure caused by the time sequence difference of the connectivity detection message reaching the exit NAT of the opposite end in the related art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of communications, and in particular, to a method and device for sending a penetration handshake packet. BACKGROUND

[0002] NAT (Network Address Translation) technology is a common network technology, which is used to convert an IP address in a private network into an IP address in a public network, so as to realize sharing of a public IP address by multiple devices. However, the NAT technology makes the connection only initiated by an intranet host, and an extranet host cannot actively connect to the intranet host, which leads to the fact that hosts in different intranets cannot directly communicate with each other. The NAT penetration technology can break through this limitation, so that the devices located behind the NAT network can realize point-to-point direct communication, thereby improving network connectivity and stability.

[0003] The premise for implementing the NAT penetration technology is to identify the NAT type, because different NAT type devices will process network packets in different ways, thereby affecting the success rate of the NAT penetration. However, the existing NAT device has a connection tracking function, which will cause the NAT mapping port of the local connectivity detection packet (i.e., a kind of network packet) to jump when the peer connectivity detection packet arrives at the egress NAT before the local connectivity detection packet, thereby causing the connectivity detection to fail. When the local connectivity detection packet arrives at the egress NAT of the peer first, the same problem will occur.

[0004] At present, there is no effective solution to the above problems. SUMMARY

[0005] Embodiments of the present application provide a method and device for sending a penetration handshake packet, to at least solve the problem of NAT penetration failure caused by the time sequence difference of the connectivity detection packet arriving at the egress NAT of the peer in the related art.

[0006] According to an embodiment of the present application, a method for sending a penetration handshake packet is provided, comprising: receiving, by a device end, a target connection establishment request from a platform server, wherein the target connection establishment request carries a first smooth round-trip time between a client and a first network address translation device, and a second smooth round-trip time between the client and the platform server; receiving, by the device end, a time delay acquisition response from the platform server, wherein the time delay acquisition response carries a third smooth round-trip time between the platform server and a second network address translation device; determining, by the device end, a target time for sending a penetration handshake packet to the client according to the first smooth round-trip time and the second smooth round-trip time, and the third smooth round-trip time, and sending the penetration handshake packet to the client at the target time.

[0007] In an example embodiment, the device end determines the target time for sending the penetration handshake packet to the client according to the first and second smooth round trip times and the third smooth round trip time, including: the device end determines a waiting duration according to the first and second smooth round trip times and the third smooth round trip time; and the device end determines the target time for sending the penetration handshake packet to the platform server according to the waiting duration.

[0008] In an example embodiment, the device end determines the target time for sending the penetration handshake packet to the platform server according to the waiting duration, including: in the case that the device end sends a connection establishment response to the platform server at a first time, the device end determines the sum of the first time and the waiting duration as the target time; and the device end sends the penetration handshake packet to the client at the target time.

[0009] In an example embodiment, the device end determines a waiting duration according to the first, second and third smooth round trip times, including: the device end determines the sum of the first, second and third smooth round trip times as a total smooth round trip time; and the device end determines the ratio of the total smooth round trip time to the number two as the waiting duration.

[0010] In an example embodiment, before the device end receives a target connection request from the platform server, the method further includes: the client sends a first connection request to the platform server, wherein the first connection request carries a second smooth round trip time between the client and the platform server; the platform server obtains the first smooth round trip time according to the second smooth round trip time and a smooth round trip time between the platform server and the first network address translation device, adds the second smooth round trip time to the first connection request to obtain the target connection request, and sends the target connection request to the device end.

[0011] In an example embodiment, before the client sends a first connection request to the platform server, the method further includes: the client sends session traversal requests to N session traversal services of the platform server at a time, wherein N is an integer greater than 1, and the port numbers of the N session traversal services are different; the client receives N session responses returned by the platform server, wherein the session responses carry the external network addresses and port numbers translated by the first network address translation device; and the client determines the type of the first network address translation device according to the N port numbers or N external network addresses carried by the N session responses.

[0012] In an example embodiment, the client determines the type of the first network address translation device according to N port numbers or N external network addresses carried by the N session responses, including: in the case that the N port numbers are the same, the client determines that the type of the first network address translation device is a cone-shaped address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device; or, in the case that the N external network addresses are the same, the client determines that the type of the first network address translation device is a cone-shaped address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device.

[0013] In an example embodiment, the method further includes: in the case that the type of the first network address translation device is the cone-shaped address translation device, the client sends one of the penetration handshake packets to the device end; in the case that the type of the first network address translation device is the symmetric address translation device, the client sends M penetration handshake packets to the device end, wherein the M penetration handshake packets are divided into S groups, the target time is the time when the client sends the i-th penetration handshake packet in the S-th group to the client, the time interval between adjacent two groups of penetration handshake packets is a preset value, and M, S and i are integers.

[0014] In an example embodiment, the method further includes: in the case that the client sends the j-th session traversal request to the N session traversal services, the client obtains the average round-trip time between the platform server and the first network address translation device from the platform server, wherein j is an integer greater than or equal to 1; the client determines the weighted sum of the average round-trip time and the j-1th smoothed round-trip time as the j-th smoothed round-trip time, wherein the j-1th smoothed round-trip time is the smoothed round-trip time obtained by the device end sending the j-1th session traversal request to the platform server in the case that j is greater than 1, the j-1th smoothed round-trip time is equal to the average round-trip time in the case that j is equal to 1, and the j-th smoothed round-trip time is the smoothed round-trip time between the client and the platform server.

[0015] In an example embodiment, after the client determines the jth smooth round trip time as the weighted sum of the average round trip time and the (j-1)th smooth round trip time, the method further comprises: the client determining a jth biased round trip time according to the average round trip time and the jth smooth round trip time, wherein the jth biased round trip time is a biased round trip time between the client and the platform server.

[0016] In an example embodiment, the method further comprises: the device end sending a connection response to the client after a preset time length after receiving the target connection request, and the client sending a penetration handshake packet to the device end upon receiving the connection response; and the first network address translation device and the second network address translation device successfully penetrating in a case where the client receives the penetration handshake packet sent by the device end and a target condition is met.

[0017] In an example embodiment, the method further comprises: the device end determining a target sum as a sum of a first biased round trip time between the client and the first network address translation device, a second biased round trip time between the client and the platform server, and a third biased round trip time between the second network address translation device and the platform server; the device end determining a target difference as a difference between a fourth smooth round trip time between the first network address translation device and the second network address translation device and a fourth biased round trip time between the first network address translation device and the second network address translation device; and the target condition comprising that the target sum is less than the target difference.

[0018] According to another embodiment of the present application, a device for sending a penetration handshake packet is provided, comprising: a first receiving module configured to receive a target connection request from a platform server, wherein the target connection request carries a first smooth round trip time between a client and a first network address translation device, and a second smooth round trip time between the client and the platform server; a second receiving module configured to receive a time delay acquisition response from the platform server, wherein the time delay acquisition response carries a third smooth round trip time between the platform server and a second network address translation device; and a determining module configured to determine a target time for sending a penetration handshake packet to the client according to the first smooth round trip time and the second smooth round trip time, and the third smooth round trip time, and send the penetration handshake packet to the client at the target time.

[0019] According to yet another embodiment of the present application, a computer readable storage medium is provided, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the method described in any of the above embodiments.

[0020] According to still another embodiment of the present application, there is also provided an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the method embodiments described above.

[0021] According to still another embodiment of the present application, there is also provided a computer program product comprising computer instructions which, when executed by a processor, implement the steps of the method described in any of the above.

[0022] According to the present application, since the first smooth round trip time between the client and the first network address translation device and the second smooth round trip time between the client and the platform server are obtained by receiving the target connection request sent by the platform server, the third smooth round trip time between the platform server and the second network address translation device is obtained by receiving the time delay obtaining response sent by the platform server, and the target time is determined according to the first smooth round trip time, the second smooth round trip time and the third smooth round trip time, the device end is instructed to send the penetration handshake packet to the client at the target time, so that the penetration handshake packet sent by the client and the device end reaches the opposite end egress NAT at the same time, the situation that the NAT penetration fails due to the time sequence difference of the connectivity detection packet (i.e. the penetration handshake packet) reaching the opposite end egress NAT, so that the NAT mapping port of the local connectivity detection packet changes, is avoided, the stable connection between the client and the device end is facilitated, the communication quality and stability between the client and the device end are ensured, and the user experience is improved. Therefore, the problem of the NAT penetration failure caused by the time sequence difference of the connectivity detection packet reaching the opposite end egress NAT in the related art can be solved, and the success rate of the NAT penetration is improved. BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 is a full cone NAT structure diagram according to an embodiment of the present application;

[0024] Figure 2 is a restricted cone NAT structure diagram according to an embodiment of the present application;

[0025] Figure 3 is a port restricted cone NAT structure diagram according to an embodiment of the present application;

[0026] Figure 4 is a symmetric NAT structure diagram according to an embodiment of the present application;

[0027] Figure 5 is a hardware structure diagram of a mobile terminal of a method for sending a penetration handshake packet according to an embodiment of the present application;

[0028] Figure 6is a flow chart of a method for sending a penetration handshake packet according to an embodiment of the present application;

[0029] Figure 7 is a flow chart of a NAT penetration according to an embodiment of the present application;

[0030] Figure 8 is a timing chart of a NAT penetration according to an embodiment of the present application;

[0031] Figure 9 is a data flow diagram of a penetration process according to an embodiment of the present application;

[0032] Figure 10 is a timing chart of a NAT type identification process according to an embodiment of the present application;

[0033] Figure 11 is a system structure diagram according to an embodiment of the present application;

[0034] Figure 12 is a timing chart of a terminal information exchange process according to an embodiment of the present application;

[0035] Figure 13 is an example one of a timing control time axis when DN2 is greater than CN1 according to an embodiment of the present application;

[0036] Figure 14 is an example one of a timing control time axis when DN2 is less than CN1 according to an embodiment of the present application;

[0037] Figure 15 is an example two of a timing control time axis when DN2 is greater than CN1 according to an embodiment of the present application;

[0038] Figure 16 is an example two of a timing control time axis when DN2 is less than CN1 according to an embodiment of the present application;

[0039] Figure 17 is a structure block diagram of an apparatus for sending a penetration handshake packet according to an embodiment of the present application. DETAILED DESCRIPTION

[0040] A prerequisite for a NAT (Network Address Translation) penetration technology is to identify a NAT type, because different NAT type devices will process network packets in different ways, thereby affecting the success rate of the NAT penetration. Currently, the main NAT types are as follows:

[0041] Full Cone NAT: such as Figure 1As shown, all requests from the same private IP address and port (IP1:Port1) are mapped to the same public IP address and port (IP:Port), and any external host (Public-PC2, Public-PC3) can send messages to the internal host (Private-PC1) by sending messages to the mapped public IP address and port.

[0042] Restricted Cone NAT: As shown, all requests from the same private IP address and port (IP1:Port1) are mapped to the same public IP and port (IP:Port). Unlike the full cone, an external host (Public-PC2) can send messages to the internal host (Private-PC1) only if the internal host (Private-PC1) has previously sent a message to the external host (Public-PC2). Otherwise, an external host (Public-PC3) cannot send messages to the internal host (Private-PC1). Figure 2

[0043] Port Restricted Cone NAT: As shown, similar to the restricted cone, but it includes the port number, that is, an external host (Public-PC2 IP2:Port2) wants to send messages to the internal host (Private-PC1 IP1:Port1), must be this internal host (Private-PC1 IP1:Port1) has previously sent a message to this IP address and port (IP2:Port2). Figure 3

[0044] Symmetric: As shown, all requests from the same private IP address and port (IP1:Port1) to a specific destination IP address and port are mapped to the same IP address and port. If the same host (Private-PC1) sends messages using the same source address and port number (IP1:Port1), but to different destinations (Public-PC2, Public-PC4), NAT will use different mappings. In addition, only the external host that receives the data can send messages back to the internal host. Figure 4

[0045] ​​​Most operators provide optical modem Internet access services that are cone NAT, while fiber-to-the-home, 4G / 5G networks, public WIFI, etc. are all symmetric NAT for security reasons. The difficulty of penetrating different NAT types varies. From difficult to easy, they are: symmetric vs. symmetric, symmetric vs. cone or cone vs. symmetric, cone vs. cone. When one or both sides are cone NAT networks, port guessing is easier to hit and the penetration success rate is high. However, existing NAT devices have a connection tracking (Conntrack) function, which ensures that the five-tuple information of the uplink and downlink of the NAT device does not conflict. This will cause the NAT mapping port of the local connectivity detection message to jump when the connectivity detection message of the other end arrives at the egress NAT before the local end, resulting in the failure of the connectivity detection. When the connectivity detection message of the local end arrives at the egress NAT of the other end first, the same problem will occur. Therefore, how to avoid the NAT penetration failure caused by the timing difference of the connectivity detection message arriving at the egress NAT is an urgent problem to be solved.

[0046] In summary, the present invention proposes a method and device for sending a penetration handshake packet, which ensures that the dual-end penetration handshake packets arrive at the other end's egress NAT at the same time through dynamic packet sending timing control on the device side, thereby avoiding NAT penetration failure caused by the timing difference of the handshake packets arriving at the egress NAT.

[0047] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with embodiments.

[0048] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0049] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 5 FIG is a hardware structure diagram of a mobile terminal for a method of sending a penetration handshake packet according to an embodiment of the present invention. Figure 5 As shown, the mobile terminal may include one or more ( Figure 5 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 5 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 5 More or fewer components than shown, or withFigure 5 different configurations.

[0050] The memory 104 can be used to store computer programs, such as software programs of application software and modules, such as the computer program corresponding to the method of transmitting a penetration handshake packet in the embodiments of the present application. The processor 102 can execute various functional applications and data processing, i.e., implement the above method, by running the computer programs stored in the memory 104. The memory 104 can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include memories remotely arranged with respect to the processor 102, which can be connected to the mobile terminal through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0051] The transmission device 106 is configured to receive or transmit data via a network. The above network can include, for example, a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (NIC), which can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is configured to communicate with the Internet in a wireless manner.

[0052] In the embodiments of the present application, a method for running on the above mobile terminal is provided, Figure 6 is a flowchart of the method of transmitting a penetration handshake packet according to the embodiments of the present application, as shown in the figure, the flow includes the following steps: Figure 6

[0053] In step S602, the device end receives a target connection request from a platform server, wherein the target connection request carries a first smooth round-trip time between a client and a first network address translation device, and a second smooth round-trip time between the client and the platform server.

[0054] ​The platform server can be a specially built server program for relaying data traffic and providing some service interfaces and protocols to help different devices establish connections, etc. The platform server includes STUN (Session Traversal Utilities for NAT) services, signaling relay services, latency acquisition services, etc. The STUN services are mainly used to obtain the external IP address and port of the terminal (client or device) in the NAT environment to establish a Peer-to-Peer (P2P) connection. The signaling relay services are mainly used to relay signaling between two clients to establish communication when the two clients cannot directly communicate. The latency acquisition services are mainly used to obtain the latency information between external IP addresses or the latency information between IP locations based on operators and network monitoring service providers, so as to help the client or device to calculate the delay between the client or device and the server in real time to optimize the efficiency and quality of data transmission.

[0055] The device and the client can be any terminal, such as a mobile phone, a computer, a tablet, etc. They are mainly used to obtain the external IP and port after NAT from the STUN services deployed on the platform server, identify the type of the nearest NAT to the platform server, calculate the smooth round-trip time and the deviation round-trip time between the platform server and the client or device in real time, and exchange the NAT type, latency information (i.e. round-trip time), and external IP and port of the client and the device based on the signaling relay services.

[0056] The first network address translation device NAT1 can be the NAT device nearest to the platform server between the client and the platform server, i.e. the NAT device nearest to the platform server connected to the client. The NAT device is mainly responsible for data transmission conversion and management between the private network and the public network (i.e. external network), including IP address conversion, protocol port conversion, and management of the network address translation table, etc.

[0057] The target connection request can be a P2P connection request, which carries the first smooth round-trip time RTT CN1 between the client and the NAT1, and the second smooth round-trip time RTT CP between the client and the platform server. The first smooth round-trip time RTT CN1 is calculated in real time according to the second smooth round-trip time RTT CP and the smooth round-trip time RTT N1P between the NAT1 and the platform server obtained by the platform server. The second smooth round-trip time RTT CPThe first smooth round-trip time is obtained in real time according to the request message timestamp and the response message timestamp in the NAT type identification process. The device end receives a target connection request from a signaling relay service of the platform server.

[0058] Optionally, before the device end receives the target connection request from the platform server, the method further comprises: the client sends a first connection request to the platform server, wherein the first connection request carries a second smooth round-trip time between the client and the platform server; the platform server obtains the first smooth round-trip time according to the second smooth round-trip time and a smooth round-trip time between the platform server and the first network address translation device, adds the second smooth round-trip time to the first connection request to obtain the target connection request, and sends the target connection request to the device end.

[0059] The first connection request can be a P2P connection request, and the client sends the first connection request to a signaling relay service of the platform server, wherein the first connection request carries a second smooth round-trip time RTT CP between the client and the platform server. CP After the signaling relay service of the platform server receives the first connection request, the second smooth round-trip time RTT CP is stored, and a client delay acquisition request carrying the second smooth round-trip time RTT CP between the client and the platform server is sent to a delay acquisition service of the platform server. N1P At this time, the delay acquisition service of the platform server receives the client delay acquisition request, obtains a first smooth round-trip time RTT CN1 between the client and a first network address translation device (NAT1) according to the second smooth round-trip time RTT CN1 and a smooth round-trip time RTT CN1 between the platform server and the first network address translation device (NAT1), and sends a client delay acquisition response carrying the first smooth round-trip time RTT CP to the signaling relay service of the platform server. CN1 After that, the signaling relay service of the platform server sends a target connection request carrying the first smooth round-trip time RTT CP and the second smooth round-trip time RTT N1P to the device end.

[0060] Optionally, the first smooth round-trip time can be obtained by the following formula:

[0061] RTT CN1 = RTT CP - RTT N1P

[0062] Among them, RTT CN1 is the first smoothed round trip time, RTT CP is the second smoothed round trip time, RTT N1P It is the smoothed round trip time between the platform server and NAT1. The smoothed round trip time can be obtained by directly matching the client's external network IP address through the server's delay acquisition service.

[0063] Step S604: The device receives a latency acquisition response from the platform server, wherein the latency acquisition response carries a third smoothed round-trip time between the platform server and the second network address translation device;

[0064] The above-mentioned second network address translation device NAT2 can be the NAT device closest to the platform server between the device end and the platform server, that is, the NAT device closest to the platform server connected to the device end. The NAT device is mainly responsible for data transmission conversion and management between the private network and the public network (that is, the external network), including IP address conversion, protocol port conversion and network address translation table management.

[0065] The above delay acquisition response can be a delay acquisition response of the device end used by the delay acquisition service of the platform server to feedback the round-trip time between the platform server and NAT, for example, to feedback the third smoothed round-trip time RTT between the platform server and NAT2. N2P The delay acquisition response carries the third smoothed round trip time RTT between the device and NAT2 N2P , where the third smoothed round trip time RTT N2P The latency acquisition service of the platform server periodically obtains the data from the operator and network monitoring service provider. The device receives the latency acquisition service from the platform server and uses it to feedback the third smoothed round trip time (RTT) between the platform server and NAT2. N2P It should be noted that when obtaining the third smoothed round-trip time, based on the capabilities of the operator and network monitoring service provider, priority is given to obtaining the real-time smoothed round-trip time between external IP addresses. If this is not supported, the real-time smoothed round-trip time between IP addresses is obtained through the geographic location information corresponding to the IP address.

[0066] Step S606: The device determines a target time for sending a penetration handshake packet to the client based on the first smooth round-trip time, the second smooth round-trip time, and the third smooth round-trip time, and sends the penetration handshake packet to the client at the target time.

[0067] The above-mentioned penetration handshake packet can be a special packet for establishing a communication connection, mainly used for penetrating NAT1 and NAT2. The handshake packet contains some specific information so that the NAT penetration service can identify and process the communication request, thereby realizing normal communication between the client and the server. When performing NAT penetration, the communication between the client or device and the platform server can be limited due to the presence of NAT devices. Therefore, in the case of NAT1 and NAT2 penetration, the client and the device are allowed to directly interact with information.

[0068] The above-mentioned target time can be the time when the device sends the penetration handshake packet. The penetration handshake packet sent by the device at the target time can arrive at the opposite end exit NAT (i.e. the NAT closest to the platform server) at the same time as the penetration handshake packet sent by the client. The device determines the target time for sending the penetration handshake packet to the client according to the first, second and third smooth round-trip times, and sends the penetration handshake packet to the client at the target time, thereby ensuring that the penetration handshake packets sent by the client and the device arrive at the opposite end exit NAT at the same time, avoiding the situation that the NAT mapping port of the local connectivity detection packet (i.e. the penetration handshake packet) changes due to the difference in time sequence, resulting in NAT penetration failure, improving the success rate of NAT penetration, and being conducive to stable connection between the client and the device, ensuring the communication quality and stability between the client and the device, and improving user experience.

[0069] Specifically, the device determines the waiting time according to the first and second smooth round-trip times and the third smooth round-trip time. The device determines the target time for sending the penetration handshake packet to the client according to the waiting time.

[0070] The above-mentioned waiting time can be the time period required between sending the P2P connection establishment response by the device and sending the penetration handshake packet. By waiting for the time period, the target time for sending the penetration handshake packet by the device to the client can be determined, thereby ensuring that the penetration handshake packets sent by the client and the device arrive at the opposite end exit NAT at the same time.

[0071] Optionally, the device determines the target time for sending the penetration handshake packet to the platform server according to the waiting time, including: in the case that the device sends the connection establishment response to the signaling transit service of the platform server at the first time, the sum of the first time and the waiting time is determined as the target time; and the device sends the penetration handshake packet to the client at the target time.

[0072] Optionally, the execution subject of the above steps can be a background processor, or other devices with similar processing capabilities, and can also be a machine integrated with at least an image acquisition device and a data processing device, wherein the image acquisition device can include a camera and other graphic acquisition modules, and the data processing device can include a computer, a mobile phone and other terminals, but is not limited thereto.

[0073] Through the above steps, by receiving the target connection request sent by the signaling relay service of the platform server, the first smooth round trip time between the client and the first network address translation device, and the second smooth round trip time between the client and the platform server are obtained, by receiving the time delay acquisition response sent by the time delay acquisition service of the platform server, the third smooth round trip time between the device end and the second network address translation device is obtained, so as to determine the target time according to the first smooth round trip time, the second smooth round trip time and the third smooth round trip time, so as to instruct the device end to send the penetration handshake packet to the client at the target time, which ensures that the penetration handshake packets sent by the client and the device end reach the opposite end NAT at the same time, avoids the situation that the NAT penetration fails due to the time sequence difference of the connectivity detection packet (i.e. the penetration handshake packet) reaching the end NAT, so that the NAT mapping port of the local connectivity detection packet changes, thereby causing the NAT penetration to fail, which is beneficial to the stable connection between the client and the device end, ensures the communication quality and stability between the client and the device end, and improves the user experience. The problem of NAT penetration failure caused by the time sequence difference of the connectivity detection packet reaching the opposite end NAT in the related art is solved, and the success rate of NAT penetration is improved.

[0074] As an optional implementation, Figure 7 is a NAT penetration flowchart according to an embodiment of the application, as Figure 7 shown, the main flow includes:

[0075] Client: after sending the P2P connection request, the P2P connection response is acquired, and the penetration handshake packet is sent;

[0076] Device end: after receiving the P2P connection request, the time delay information (i.e. the third smooth round trip time) is acquired from the time delay acquisition service of the platform server, and the time sequence control TC value (i.e. the waiting time) is calculated, then the P2P connection response is sent, and the penetration handshake packet is sent after waiting for the TC time.

[0077] Wherein, the specific NAT penetration time sequence diagram is as Figure 8 shown:

[0078] S801, the client sends a P2P connection request to the platform server, and the signaling relay service of the platform server receives the P2P connection request sent by the client, and then forwards the P2P connection request to the device end;

[0079] S802, the device end receives the P2P connection request forwarded by the signaling transfer service of the platform server, and sends a P2P connection response to the platform server after calculating a waiting TC duration, and waits for the TC duration;

[0080] S803, the signaling transfer service of the platform server receives the P2P connection response sent by the device end, and forwards the P2P connection response to the client end;

[0081] S804, the client end receives the P2P connection response forwarded by the signaling transfer service of the platform server, and sends a penetration handshake packet to the device end;

[0082] S805, the device end sends a penetration handshake packet to the client end after waiting for the TC duration.

[0083] Thus, the penetration handshake packets sent by the client end and the device end reach the opposite end egress NAT at the same time, avoiding the situation that the NAT penetration fails due to the time sequence difference, which causes the NAT mapping port of the local connectivity detection packet (i.e., the penetration handshake packet) to jump, thereby causing the NAT penetration to fail.

[0084] As an optional implementation, the device end determines the waiting duration according to the first smooth round trip time and the second smooth round trip time, and the third smooth round trip time, including: the device end determines the sum of the first smooth round trip time, the second smooth round trip time and the third smooth round trip time as a smooth round trip time total; and the device end determines the ratio of the smooth round trip time total to the value two as the waiting duration.

[0085] Optionally, Figure 9 is a penetration process data flow diagram according to an embodiment of the application, as Figure 9 shown, the penetration process mainly includes the following data flows:

[0086] C->N1 (CN1): client penetration handshake packet data flow;

[0087] D->N2 (DN2): device end penetration handshake packet data flow;

[0088] N1<->N2 (N1N2 / N2N1): bidirectional penetration handshake packet data flow;

[0089] ((D->N2)`+N2->P+P->N1+N1->C) (DP+CP): device end P2P connection response data flow;

[0090] Due to the different sending time of the device end and the client end, the NAT penetration fails due to the time difference of the penetration handshake packet reaching the opposite end of the NAT, and the time consumption of D->P+C->P+C->N1+N1->N2 needs to be equal to D->N2+N2->N1, that is, RTT DP +RTT CP +RTT CN1 +RTT N1N2 =RTT DN2 +RTT N2N1 Due to RTT N1N2 =RTT N2N1 , so only RTT DP +RTT CP +RTT CN1 =RTT DN2 Therefore, the timing control T (that is, the total sum of the smooth round trip time) needs to be introduced to control the device end to send the penetration handshake packet, so that RTT DP +RTT CP +RTT CN1 =RTT DN2 +T. At the same time, due to RTT DP =RTT DN2 +RTT N2P , only RTT N2P +RTT CP +RTT CN1 =T. The waiting time can be obtained by the following formula:

[0091]

[0092] Wherein, TC is the waiting time, RTT N2P is the third smooth round trip time, RTT CP is the second smooth round trip time, and RTT CN1 is the first smooth round trip time.

[0093] As an optional implementation, before the client sends a first connection request to the platform server, the method further comprises: the client sends a session traversal request to N session traversal services of the platform server at a time, wherein N is an integer greater than 1, and the port numbers of the N session traversal services are different; the client receives N session responses returned by the platform server, wherein the session responses carry the external network address and the port number converted by the first network address translation device; and the client determines the type of the first network address translation device according to the N port numbers or the N external network addresses carried by the N session responses.

[0094] The session traversal service can be a STUN service deployed by the platform server to determine the type of NAT; alternatively, in the case that the N port numbers are the same, the client determines that the type of the first network address translation device is a cone address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device; or, in the case that the N external network addresses are the same, the client determines that the type of the first network address translation device is a cone address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device.

[0095] Figure 10 is a timing diagram of a NAT type identification process according to an embodiment of the present application, as shown in Figure 10 The platform server is deployed with N STUN services, each of which is bound to a different port number, and the specific type identification process is as follows:

[0096] S1001, the client initiates STUN requests to the N STUN services of the platform in turn at regular intervals, and obtains the external network IP and port returned by the STUN services after the STUN requests pass through the egress NAT;

[0097] S1002, according to the external network IP and port returned by each of the N STUN services, if the external network port numbers returned by multiple STUN services are the same, it is determined that the type of the egress NAT of the client is a cone, otherwise it is determined that the type of the egress NAT of the client is a symmetric; or, if the external network IP returned by multiple STUN services is the same, it is determined that the type of the egress NAT of the client is a cone, otherwise it is determined that the type of the egress NAT of the client is a symmetric.

[0098] As an optional implementation, the method further comprises: in the case that the type of the first network address translation device is the cone address translation device, the client sends a penetration handshake packet to the device end; in the case that the type of the first network address translation device is the symmetric address translation device, the client sends M penetration handshake packets to the device end, wherein the M penetration handshake packets are divided into S groups, in the case that the client sends the i th penetration handshake packet in the S th group to realize the penetration of the first network address translation device and the second network address translation device, the target time is the time when the client sends the penetration handshake packet to the client for the first time, the time interval between adjacent two groups of penetration handshake packets is a preset value, and M, S and i are integers.

[0099] The first network address translation device NAT1 can be a cone type or a symmetric type. In the cone type, requests from the same private IP address and port are mapped to the same public IP address and port. In the symmetric type, requests from the same private IP address and port can be mapped to different public IP addresses and ports.

[0100] When the first network address translation device is a cone type, the client only needs to send one penetration handshake packet to the device end. When the first network address translation device is a symmetric type, the client needs to send M penetration handshake packets to the device end, i.e., as many penetration handshake packets as possible, so as to cover as many public IP addresses of NAT1 as possible and improve the success rate of NAT penetration.

[0101] As an optional implementation, the method further includes: when the client sends a jth session traversal request to the N session traversal services, the client obtains an average round-trip delay between the platform server and the first network address translation device from the platform server, where j is an integer greater than or equal to 1; and the client determines a weighted sum of the average round-trip delay and a (j-1)th smoothed round-trip time as a jth smoothed round-trip time, where the (j-1)th smoothed round-trip time is a smoothed round-trip time obtained by the device end sending a (j-1)th session traversal request to the platform server when j is greater than 1, the (j-1)th smoothed round-trip time is equal to the average round-trip delay when j is equal to 1, and the jth smoothed round-trip time is a smoothed round-trip time between the client and the platform server.

[0102] The second smoothed round-trip time can be calculated in real time based on the timestamps of a request message (i.e., a session request) and a response message (i.e., a session response) in the timing NAT type identification process. The second smoothed round-trip time can be obtained by the following formula:

[0103]

[0104] where RTT CP is the second smoothed round-trip time, RTT j-1 is the (j-1)th smoothed round-trip time, RTT j is the average round-trip delay, and a is a preset weight, 0 < a < 1.

[0105] As an optional implementation, after the client determines the weighted sum of the average round-trip time and the j-1th smoothed round-trip time as the jth smoothed round-trip time, the method further comprises: the client determines the jth deviation round-trip time according to the average round-trip time and the jth smoothed round-trip time, wherein the jth deviation round-trip time is the deviation round-trip time between the client and the platform server.

[0106] The jth deviation round-trip time can be obtained through the following announcement:

[0107]

[0108] Wherein, ΔRTT CP is the jth deviation round-trip time, RTT j is the average round-trip time, ΔRTT j-1 is the j-1th deviation round-trip time, RTT CP is the jth smoothed round-trip time, and β is a preset weight, 0 < β < 1.

[0109] As an optional implementation, the method further comprises: after the device end receives the connection establishment request, the device end sends a connection establishment response to the client, and the client sends a penetration handshake packet to the device end when receiving the connection establishment response; in the case that the client receives the penetration handshake packet sent by the device end and meets a target condition, the first network address translation device and the second network address translation device successfully penetrate.

[0110] The preset time length can be a time length in which the device end obtains a smoothed round-trip time between the device end and the second network address translation device (NAT2); within the preset time length, the device end sends a 100Tring temporary response to the client through the signaling relay service of the platform server, wherein the 100Tring temporary response is used to indicate that the P2P connection establishment request sent by the client is being processed, and the device end creates a new connection to initiate a time delay acquisition request to the time delay acquisition service of the platform server, so as to obtain the smoothed round-trip time between the device end and NAT2 by receiving the time delay acquisition response returned by the time delay acquisition service of the platform server, and then send a connection establishment response to the client.

[0111] The target condition can be a time condition between the time when the client receives the penetration handshake packet sent by the device end and the time when the device end receives the penetration handshake packet sent by the client. Only in the case that the client receives the penetration handshake packet sent by the device end and meets the corresponding time condition, the first network address translation device and the second network address translation device can successfully penetrate.

[0112] As an optional implementation, the method further comprises: determining, by the device side, a sum of a first biased round-trip time between the client and the first network address translation device, a second biased round-trip time between the client and the platform server, and a third biased round-trip time between the second network address translation device and the platform server as a target sum; determining, by the device side, a difference between a fourth smoothed round-trip time between the first network address translation device and the second network address translation device and a fourth biased round-trip time between the first network address translation device and the second network address translation device as a target difference; and the target condition comprises that the target sum is less than the target difference.

[0113] Specifically, the target condition can be represented by the following formula:

[0114] ΔRTT CP +ΔRTT N2P +ΔRTT CN1 <RTT N1N2 -ΔRTT N1N2

[0115] wherein ΔRTT CP is the second biased round-trip time, ΔRTT N2P is the third biased round-trip time, ΔRTT CN1 is the first biased round-trip time, RTT N1N2 is the fourth smoothed round-trip time, and ΔRTT N1N2 is the fourth biased round-trip time.

[0116] As an optional implementation, Figure 11 is a system structure diagram according to an embodiment of the present application, as shown in Figure 11 The system mainly comprises:

[0117] a platform server, which comprises a STUN service, a signaling relay service, and a time delay acquisition service,

[0118] is responsible for signaling relay between the client and the device side;

[0119] is responsible for acquisition of the public network IP and port of the client and the device side after NAT;

[0120] acquires time delay information between public network IPs based on an operator and a network monitoring service provider;

[0121] acquires time delay information between IP home locations based on an operator and a network monitoring service provider;

[0122] a NAT device, which is responsible for data transmission conversion and management between a private network and a public network, including IP address conversion, protocol port conversion, and management of a network address translation table;

[0123] Terminal (client / device side) :

[0124] Real-time acquisition of NATed external IP and port from STUN service, and identification of NAT type of local-side egress NAT;

[0125] Real-time measurement of weighted average round-trip time (smooth round-trip time) and RTT deviation weighted average (deviation round-trip time) between the platform;

[0126] Exchange of NAT type, delay information, and external IP and port between the client and the device side based on the signaling relay service.

[0127] As an optional implementation, Figure 12 is a terminal information exchange flow timing diagram according to an embodiment of the application, as Figure 12 described, the specific process is as follows:

[0128] S1201, the client sends a P2P (Peer-to-Peer) connection request to the signaling relay service, wherein the connection request carries the local (client side) NAT type, smooth RTT (second smooth round-trip time between the client and the platform server) and deviation RTT (second deviation round-trip time between the client and the platform server), and fills in the local NAT type, smooth RTT and deviation RTT;

[0129] S1202, the signaling relay service identifies the source IP and source port information in the client network message, and fills them into the request field (P2P connection request) protocol field as the external IP and port data of the client side, and sends a delay acquisition request to the delay acquisition service, wherein the delay acquisition request carries the external IP, smooth RTT and deviation RTT of the client;

[0130] S1203, the delay acquisition service queries the platform server to the client egress NAT (NAT1) based on the external IP of the client to acquire the smooth RTT (smooth round-trip time) and deviation RTT (deviation round-trip time), and calculates the smooth RTT (first smooth round-trip time between the client and the first network address translation device) and deviation RTT (first deviation round-trip time between the client and the first network address translation device) between the client and the egress NAT;

[0131] S1204, the delay acquisition service sends a delay acquisition response to the signaling relay service, wherein the delay acquisition response carries the smooth RTT and deviation RTT between the client and the egress NAT;

[0132] S1205, the signaling relay service receives the delay acquisition response, fills the smooth RTT and the deviation RTT between the client and the egress NAT into the P2P connection request protocol field, and forwards the P2P connection request to the device end;

[0133] S1206, the device end caches the client-side NAT type, the smooth RTT and the deviation RTT, the external network IP and the port, and the smooth RTT and the deviation RTT between the client and the egress NAT, and sends a 100 Trying temporary response to the signaling relay service, which is forwarded to the client, indicating that the P2P connection request processing is in progress.

[0134] S1207, the device end creates a new connection to initiate a delay acquisition request to the delay acquisition service, wherein the delay acquisition request carries the smooth RTT (smooth round-trip time between the device end and the platform server) and the deviation RTT (deviation round-trip time between the device end and the platform server) on the local side (device end side).

[0135] S1208, the delay acquisition service queries the platform server to obtain the smooth RTT (third smooth round-trip time) and the deviation RTT (third deviation round-trip time) between the egress NAT (NAT2) and the device end based on the external network IP address of the device end, and calculates the smooth RTT (smooth round-trip time) and the deviation RTT (deviation round-trip time) between the device end and the egress NAT.

[0136] S1209, the delay acquisition service sends a delay acquisition response to the device end, wherein the delay acquisition response carries the smooth RTT, the deviation RTT, the external network IP and the port between the device end and the egress NAT.

[0137] S1210, the device end caches the external network IP and the port of the device end and the smooth RTT and the deviation RTT between the device end and the egress NAT.

[0138] S1211, the device end sends a P2P connection response to the signaling relay service, wherein the P2P connection response carries and fills the NAT type on the local side (device end side), the external network IP and the port, and the signaling relay service forwards the P2P connection response to the client.

[0139] S1212, the client caches the device end-side NAT type, the external network IP and the port.

[0140] It should be noted that in the above process, the signaling relay service matches the request and the response based on the unique session ID in the P2P connection request and the connection response. Meanwhile, in order to avoid the large deviation RTT between the terminal NAT device and the platform server, a CDN (Content Delivery Network) can be introduced to send the requested content to the server node closest to the terminal.

[0141] As an optional embodiment, in the double-cone NAT scenario, the terminal (client or device) sends the penetration handshake packet to the opposite public IP and port. When the handshake packet of one side reaches the exit NAT of the other side before the handshake packet of the other side, the NAT penetration success rate is high. Therefore, the device side needs to send the penetration handshake packet to the public IP and port of the client after replying to the P2P connection response and waiting for the TC duration. The client side can send the penetration handshake packet to the public IP and port of the device after receiving the P2P connection response. The whole penetration process timing control is performed by the device side. Alternatively, Figure 13 is a timing control time axis example one according to the embodiment of the present application when DN2 is greater than CN1. Figure 14 is a timing control time axis example one according to the embodiment of the present application when DN2 is less than CN1, wherein C represents the client, D represents the device, N1 represents NAT1, and N2 represents NAT2.

[0142] As an optional embodiment, in the scenario of one symmetric NAT and one cone NAT, the symmetric side sends the handshake packet to the cone side. Since the target IP address changes, the exit NAT of the symmetric side reassigns a new NAT port, resulting in that the cone side sends the packet to the old NAT port and is rejected by the NAT device. Therefore, the birthday attack algorithm needs to be used for this NAT scenario. The essence is to realize the penetration process through the principle of random collision.

[0143] The specific operation is as follows:

[0144] Step 1. The terminal of the symmetric side sends the handshake packet to the public IP and port of the terminal of the cone side through multiple newly created sockets. These data packets are mapped into different public ports when exiting the NAT.

[0145] Step 2. The terminal of the cone side randomly sends the penetration handshake packet to different public ports of the opposite terminal to see whether one target port hits the public port mapped by the symmetric side. If it hits, the connection can be successfully established.

[0146] The penetration success rate calculation formula is as follows:

[0147]

[0148] Wherein, 64511 is the upper limit of the port 65535 minus the system default occupation 1024; Y is the number of times of guessing the public port of the cone side (Y handshake packets); X is the number of mapped ports of the symmetric side (X handshake packets); for example, when Y=2400 and X=200, the penetration success probability is 99.94%.

[0149] Alternatively, Figure 15 is a timing control time axis example two according to the embodiment of the present application when DN2 is greater than CN1.Figure 16 is a timing control timeline example two when DN2 is less than CN1 according to the embodiment of the application, wherein C represents a client, D represents a device, N1 represents NAT1, and N2 represents NAT2.

[0150] It should be noted that in actual use, to ensure successful penetration in this scenario, the X handshake packets of the symmetrical terminal and the Y handshake packets of the tapered terminal should all arrive at the local egress NAT before the other party. However, because too many packets will cause a large time difference between the first packet and the last packet, if this time difference is greater than the time consumed between the two egress NATs, some data packets will arrive at the opposite egress NAT in advance, so X and Y need to be split into multiple groups of x and y, and the number of packets sent by each group of x and y is controlled to avoid time deviation caused by packet transmission time. The sending interval of each group of x and y can be a fixed value, which is agreed by the client and the device in advance, and the remaining groups of handshake packets are sent at fixed intervals after the first group of penetration handshake packets are sent. The specific penetration success rate calculation formula is as follows:

[0151]

[0152] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the method described in each embodiment of the present application.

[0153] In this embodiment, an apparatus for sending penetration handshake packets is also provided, which is used to implement the above embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.

[0154] Figure 17 is a structure block diagram of the apparatus for sending penetration handshake packets according to the embodiment of the application, as Figure 17The apparatus includes: a first receiving module 1702, configured to receive a target connection request from a platform server, wherein the target connection request carries a first smooth round trip time between a client and a first network address translation device, and a second smooth round trip time between the client and the platform server; a second receiving module 1704, configured to receive a time delay obtaining response from the platform server, wherein the time delay obtaining response carries a third smooth round trip time between the platform server and a second network address translation device; a determining module 1706, configured to determine a target time for sending a penetration handshake packet to the client according to the first and second smooth round trip times and the third smooth round trip time, and send the penetration handshake packet to the client at the target time.

[0155] In an example embodiment, the apparatus is further configured to determine a waiting duration according to the first and second smooth round trip times and the third smooth round trip time; and determine the target time for sending the penetration handshake packet to the platform server according to the waiting duration.

[0156] In an example embodiment, the apparatus is further configured to, in a case that a connection response is sent to the platform server at a first time, determine the target time as a sum of the first time and the waiting duration; and send the penetration handshake packet to the client at the target time.

[0157] In an example embodiment, the apparatus is further configured to determine a sum of the first, second, and third smooth round trip times as a total smooth round trip time; and determine a ratio of the total smooth round trip time to the value two as the waiting duration.

[0158] In an example embodiment, before receiving the target connection request from the platform server, the client is further configured to send a first connection request to the platform server, wherein the first connection request carries a second smooth round trip time between the client and the platform server; the platform server obtains the first smooth round trip time according to the second smooth round trip time and a smooth round trip time between the platform server and the first network address translation device, adds the second smooth round trip time to the first connection request to obtain the target connection request, and sends the target connection request to the device.

[0159] In an example embodiment, the client is further configured to send a session traversal request to N session traversal services of the platform server at a timing, where N is an integer greater than 1, and the port numbers of the N session traversal services are different; receive N session responses returned by the platform server, where the session responses carry the external network address and port number converted by the first network address translation device; and determine the type of the first network address translation device according to the N port numbers or the N external network addresses carried by the N session responses.

[0160] In an example embodiment, the client is further configured to, in the case that the N port numbers are the same, determine that the type of the first network address translation device is a cone-shaped address translation device; otherwise, determine that the type of the first network address translation device is a symmetric address translation device; or, in the case that the N external network addresses are the same, determine that the type of the first network address translation device is a cone-shaped address translation device; otherwise, determine that the type of the first network address translation device is a symmetric address translation device.

[0161] In an example embodiment, the client is further configured to, in the case that the type of the first network address translation device is the cone-shaped address translation device, send one of the penetration handshake packets to the device end; and in the case that the type of the first network address translation device is the symmetric address translation device, send M penetration handshake packets to the device end, where the M penetration handshake packets are divided into S groups, the target time is the time when the client sends the i-th penetration handshake packet in the S-th group to the client, the time interval between adjacent two groups of penetration handshake packets is a preset value, and M, S and i are integers.

[0162] In an example embodiment, the client is further configured to, in the case that the client sends a session traversal request to the j-th session traversal service, obtain an average round-trip time between the platform server and the first network address translation device from the platform server, where j is an integer greater than or equal to 1; determine a weighted sum of the average round-trip time and a (j-1)-th smoothed round-trip time as a j-th smoothed round-trip time, where the (j-1)-th smoothed round-trip time is the smoothed round-trip time obtained by the device end when the device end sends a session traversal request to the (j-1)-th session traversal service in the case that j is greater than 1, the (j-1)-th smoothed round-trip time is equal to the average round-trip time in the case that j is equal to 1, and the j-th smoothed round-trip time is the smoothed round-trip time between the client and the platform server.

[0163] In an example embodiment, the client is further configured to determine a jth deviation round trip time between the client and the platform server according to the average round trip time and the jth smoothed round trip time, wherein the jth deviation round trip time is a deviation round trip time between the client and the platform server.

[0164] In an example embodiment, the apparatus is further configured to send a connection response to the client after a preset time period from receiving the target connection request, and the client sends a penetration handshake packet to the device end upon receiving the connection response; and the first network address translation device and the second network address translation device successfully penetrate when the client receives the penetration handshake packet sent by the device end and a target condition is met.

[0165] In an example embodiment, the apparatus is further configured to determine a target sum of a first deviation round trip time between the client and the first network address translation device, a second deviation round trip time between the client and the platform server, and a third deviation round trip time between the second network address translation device and the platform server; determine a target difference of a fourth smoothed round trip time between the first network address translation device and the second network address translation device and a fourth deviation round trip time between the first network address translation device and the second network address translation device; and the target condition comprises that the target sum is less than the target difference.

[0166] It should be noted that the above modules can be implemented by software or hardware, and for the latter, the following implementation manners can be used, but are not limited thereto: the above modules are located in the same processor; or the above modules are located in different processors in any combination.

[0167] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement the steps of the method in any of the above embodiments.

[0168] In an example embodiment, the above computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.

[0169] Embodiments of the present application also provide an electronic device, which comprises a memory storing a computer program and a processor configured to run the computer program to perform the steps in any of the above method embodiments.

[0170] In one example embodiment, the electronic device described above can further include a transmission device connected to the processor, and an input / output device connected to the processor.

[0171] Embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method described in the various embodiments of the present application.

[0172] The specific examples in the present embodiment can refer to the examples described in the above embodiments and exemplary implementation manners, which will not be described herein again.

[0173] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be realized by general computing devices, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices, which can be realized by program codes executable by the computing devices, so that they can be stored in storage devices and executed by the computing devices, and in some cases, the steps shown or described can be executed in different order, or they can be manufactured into individual integrated circuit modules, or multiple modules or steps among them can be manufactured into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.

[0174] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method of sending a punch-through handshake packet, characterized by, The method comprises the following steps: The device end receives a target connection request from a platform server, wherein the target connection request carries a first smooth round-trip time between a client and a first network address translation device and a second smooth round-trip time between the client and the platform server; The device end receives a time delay acquisition response from the platform server, wherein the time delay acquisition response carries a third smooth round-trip time between the platform server and a second network address translation device; The device end determines a target time for sending a penetration handshake packet to the client according to the first smooth round-trip time, the second smooth round-trip time and the third smooth round-trip time, and sends the penetration handshake packet to the client at the target time.

2. The method of claim 1, wherein, The device end determines a target time for sending a penetration handshake packet to the client according to the first smooth round-trip time, the second smooth round-trip time and the third smooth round-trip time, comprising: The device end determines a waiting time according to the first smooth round-trip time, the second smooth round-trip time and the third smooth round-trip time; The device end determines the target time for sending the penetration handshake packet to the platform server according to the waiting time.

3. The method of claim 2, wherein, The device end determines the target time for sending the penetration handshake packet to the platform server according to the waiting time, comprising: If the device end sends a connection response to the platform server at a first time, the device end determines the sum of the first time and the waiting time as the target time; The device end sends the penetration handshake packet to the client at the target time.

4. The method of claim 2, wherein, The device end determines a waiting time according to the first smooth round-trip time, the second smooth round-trip time and the third smooth round-trip time, comprising: The device end determines the sum of the first smooth round-trip time, the second smooth round-trip time and the third smooth round-trip time as a smooth round-trip time sum; The device end determines the ratio of the smooth round-trip time sum to the value two as the waiting time.

5. The method of claim 1, wherein, Before the device end receives a target connection request from a platform server, the method further comprises: The client sends a first connection request to the platform server, wherein the first connection request carries a second smooth round-trip time between the client and the platform server; The platform server obtains a first smooth round-trip time according to the second smooth round-trip time and a smooth round-trip time between the platform server and the first network address translation device, adds the second smooth round-trip time to the first connection request to obtain the target connection request, and sends the target connection request to the device end; The platform server adds the second smooth round-trip time to the first connection request to obtain the target connection request, and sends the target connection request to the device end.

6. The method of claim 5, wherein, Before the client sends a first connection request to the platform server, the method further comprises: The client sends a session traversal request to N session traversal services of the platform server at a time, wherein N is an integer greater than 1, and the port numbers of the N session traversal services are different; The client receives N session responses returned by the platform server, wherein the session responses carry the external network address and port number converted by the first network address translation device; The client determines the type of the first network address translation device according to the N port numbers or N external network addresses carried by the N session responses.

7. The method of claim 6, wherein, The client determines the type of the first network address translation device according to the N port numbers or N external network addresses carried by the N session responses, comprising: In the case that the N port numbers are the same, the client determines that the type of the first network address translation device is a cone-shaped address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device; or, In the case that the N external network addresses are the same, the client determines that the type of the first network address translation device is a cone-shaped address translation device; otherwise, the client determines that the type of the first network address translation device is a symmetric address translation device.

8. The method of claim 7, wherein, The method further comprises: In the case that the type of the first network address translation device is the cone-shaped address translation device, the client sends one penetration handshake packet to the device end; In the case that the type of the first network address translation device is the symmetric address translation device, the client sends M penetration handshake packets to the device end, wherein the M penetration handshake packets are divided into S groups, the target time is the time when the client sends the i-th penetration handshake packet in the S-th group to the client, the time interval between adjacent two groups of penetration handshake packets is a preset value, and M, S and i are integers.

9. The method of claim 6, wherein, The method further comprises: In the case that the client sends a j-th session traversal request to the N session traversal services, the client obtains an average round-trip delay between the platform server and the first network address translation device from the platform server, wherein j is an integer greater than or equal to 1; The client determines a weighted sum of the average round-trip delay and a j-1-th smoothed round-trip time as a j-th smoothed round-trip time, wherein the j-1-th smoothed round-trip time is a smoothed round-trip time obtained by the device end sending a j-1-th session traversal request to the platform server in the case that j is greater than 1, the j-1-th smoothed round-trip time is equal to the average round-trip delay in the case that j is equal to 1, and the j-th smoothed round-trip time is a smoothed round-trip time between the client and the platform server.

10. The method of claim 9, wherein, After the client determines the weighted sum of the average round-trip delay and the j-1-th smoothed round-trip time as the j-th smoothed round-trip time, the method further comprises: The client determines a j-th deviation round-trip time according to the average round-trip delay and the j-th smoothed round-trip time, wherein the j-th deviation round-trip time is a deviation round-trip time between the client and the platform server.

11. The method of claim 1, wherein, The method further comprises: The device sends a connection establishment response to the client within a preset time after receiving the target connection establishment request, and the client sends a transparent handshake packet to the device when receiving the connection establishment response; When the client receives the penetration handshake packet sent by the device and the target condition is met, the first network address translation device and the second network address translation device are successfully penetrated.

12. The method of claim 11, wherein, The method further comprises: The device determines, as a target sum, a sum of a first offset round-trip time between the client and the first network address translation device, a second offset round-trip time between the client and the platform server, and a third offset round-trip time between the second network address translation device and the platform server; The device determines, as a target difference, a difference between a fourth smoothed round trip time between the first network address translation device and the second network address translation device and a fourth deviated round trip time between the first network address translation device and the second network address translation device; The target condition includes: the target sum is less than the target difference.

13. An apparatus for transmitting a pass-through handshake packet, the apparatus comprising: include: A first receiving module is configured to receive a target connection establishment request from a platform server, wherein the target connection establishment request carries a first smoothed round-trip time between the client and the first network address translation device, and a second smoothed round-trip time between the client and the platform server; a second receiving module, configured to receive a latency acquisition response from the platform server, wherein the latency acquisition response carries a third smoothed round-trip time between the platform server and the second network address translation device; The determination module is configured to determine a target time for sending a penetration handshake packet to the client based on the first smooth round-trip time, the second smooth round-trip time, and the third smooth round-trip time, and send the penetration handshake packet to the client at the target time.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method according to any one of claims 1 to 12 when executed by a processor. 15.An electronic device comprising a memory and a processor, the electronic device characterized by, A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 12.

16. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Method for AP configuration management and wireless terminal access control by cloud-side platform

    CN107483558A

  • Scheduling method and scheduling end for FogCDN scene

    CN110278254A