Connection establishment method and device, storage medium and electronic equipment
By establishing a relay connection during NAT penetration and determining whether to establish a point-to-point connection based on the network address conversion type, using idle devices for address exchange, the problem of excessive resource consumption during NAT penetration is solved, and the connection success rate and user experience are improved.
Patent Information
- Application Number
- CN202510069349.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2045-01-16
AI Technical Summary
The resource consumption during NAT penetration is too large, resulting in a high impact on code streaming and equipment resource overhead.
The relay connection between the terminal device and the target device is established, and the point-to-point connection is determined based on the network address conversion type, and the address exchange is performed using idle devices to realize P2P connection.
It improves the connection success rate, reduces resource consumption, optimizes penetration problems in symmetric NAT environments, and ensures business continuity and user experience fluency.
Smart Images

Figure CN119520587A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a connection establishment method and device, a storage medium, and an electronic device. Background Art
[0002] With the rapid development of the Internet, NAT (Network Address Translation) technology has become one of the key technologies to solve the problem of IPv4 address shortage. NAT technology allows mapping and conversion between private IP addresses (such as IP addresses used within a local area network) and public IP addresses (used for Internet communication). This allows multiple devices to share a public IP address, effectively alleviating the shortage of IPv4 address resources. However, NAT technology allows connections to be initiated only by intranet hosts, and external hosts cannot actively connect to intranet hosts, which results in hosts in different intranets being unable to communicate directly. NAT penetration technology can break through this limitation, allowing devices behind the NAT network to achieve P2P (Peer-to-Peer) communication, thereby improving network stability, reducing transmission latency and reducing platform traffic costs.
[0003] The success rate of NAT penetration technology varies greatly depending on the NAT type of the network where the dual-end devices are located. The difficulty of penetration increases step by step, such as cone vs cone, cone vs symmetric, or symmetric vs cone, symmetric vs symmetric. In addition, the more difficult NAT penetration process also consumes a lot of device resources, which will affect the normal business of the device itself. How to avoid the impact of resource consumption on bitstream transmission during NAT penetration is an urgent problem to be solved.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a connection establishment method and apparatus, a storage medium, and an electronic device to at least solve the technical problem that resource consumption during NAT penetration has too great an impact on code stream transmission and that device resource overhead is high.
[0006] According to one aspect of an embodiment of the present application, a connection establishment method is provided, comprising: receiving a data request message sent by a terminal device, wherein the data request message is used to request data of a target device, and the terminal device and the target device belong to different local area networks; in response to the data request message, establishing a relay connection between the terminal device and the target device, and obtaining network address translation types corresponding to the terminal device and the target device, wherein the network address translation type indicates a behavior mode of a device processing a data packet; based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, establishing a relay connection between the terminal device and the target device; and a point-to-point connection between the terminal device and the target device, and interrupting the relay connection, wherein, when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is realized by exchanging addresses between the target device and the first idle device, the first idle device and the target device belong to the same local area network, and when the terminal device and the target device are both symmetric, the point-to-point connection is realized by exchanging addresses between the target device, the first idle device and the second idle device, the second idle device and the target device belong to different local area networks, and the network address conversion type of the second idle device is the asymmetric type.
[0007] According to another aspect of an embodiment of the present application, a connection establishment device is also provided, including: a receiving module, used to receive a data request message sent by a terminal device, wherein the data request message is used to request to obtain data of a target device, and the terminal device and the target device belong to different local area networks; an acquisition module, used to establish a relay connection between the terminal device and the target device in response to the data request message, and obtain the network address translation type corresponding to the terminal device and the target device, wherein the network address translation type represents the behavior mode of a device processing a data packet; a processing module, used to determine whether the network address translation types corresponding to the terminal device and the target device are both correct. A point-to-point connection is established between the terminal device and the target device, and the relay connection is interrupted, wherein, when at least one of the terminal device and the target device is of an asymmetric type, the point-to-point connection is realized by exchanging addresses between the target device and a first idle device, and the first idle device and the target device belong to the same local area network, and when the terminal device and the target device are both of the symmetric type, the point-to-point connection is realized by exchanging addresses between the target device, the first idle device and the second idle device, and the second idle device and the target device belong to different local area networks, and the network address conversion type of the second idle device is the asymmetric type.
[0008] In an exemplary embodiment, the device is used to establish a point-to-point connection between the terminal device and the target device, and interrupt the relay connection based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric in the following manner: when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is established based on the first idle device, and the relay connection is interrupted; when the terminal device and the target device are both symmetric, the point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted.
[0009] In an exemplary embodiment, the device is used to establish the point-to-point connection based on the first idle device and interrupt the relay connection when at least one of the terminal device and the target device is not of the symmetrical type in the following manner: when at least one of the terminal device and the target device is not of the symmetrical type, receive a first point-to-point connection request sent by the terminal device; in response to the first point-to-point connection request, obtain the device operating status of each device in a first group of devices, wherein the first group of devices and the target device belong to the same local area network; determine a first group of idle devices from the first group of devices based on the device operating status; send the first point-to-point connection request to the first group of idle devices; and determine the device in the first group of idle devices that responds to the first point-to-point connection request as the The first idle device establishes a first penetration connection between the first idle device and the terminal device; in the case where the first penetration connection is successfully established, sending a first address exchange request to the target device and the first idle device respectively, wherein the first address exchange request is used to request the target device and the first idle device to exchange address information with each other; in the case where the target device and the first idle device complete the exchange of address information, receiving a login request sent by the target device and the first idle device to complete the login of the target device and the first idle device, switching the relay connection to a point-to-point connection between the target device and the first idle device, and interrupting the relay connection, wherein the point-to-point connection is automatically established when the target device and the first idle device complete the login.
[0010] In an exemplary embodiment, the apparatus is used to establish the point-to-point connection based on the first idle device and the second idle device and interrupt the relay connection when the terminal device and the target device are both of the symmetrical type in the following manner: when the terminal device and the target device are both of the symmetrical type, determine whether the second idle device exists; when the second idle device exists, establish the point-to-point connection based on the first idle device and the second idle device and interrupt the relay connection.
[0011] In an exemplary embodiment, the device is used to determine whether the second idle device exists when the terminal device and the target device are both of the symmetric type in the following manner: when the terminal device and the target device are both of the symmetric type, receive a second point-to-point connection request sent by the terminal device; in response to the second point-to-point connection request, obtain the device operation status of the second group of devices, wherein the second group of devices and the target device belong to different local area networks, and the network address translation type corresponding to the second group of idle devices is the asymmetric type; determine a second group of idle devices from the second group of devices based on the device operation status; send a point-to-point cascade request to the second group of idle devices; determine the device in the second group of idle devices that responds to the point-to-point cascade request as the second idle device, and establish a second penetration connection between the second idle device and the terminal device.
[0012] In an exemplary embodiment, the device is used to establish the point-to-point connection based on the first idle device and the second idle device and interrupt the relay connection in the following manner when the second idle device exists: when the second idle device exists, receive a third point-to-point connection request sent by the second idle device; in response to the third point-to-point connection request, obtain the device operation status of each device in the first group of devices, wherein the first group of devices and the target device belong to the same local area network; determine a first group of idle devices from the first group of devices based on the device operation status; send the third point-to-point connection request to the first group of idle devices; determine the device in the first group of idle devices that responds to the third point-to-point connection request as the first idle device, and establish a third penetration connection between the first idle device and the second idle device. ; When both the second penetration connection and the third penetration connection are successfully established, send a second address exchange request to the target device and the second idle device respectively, wherein the second address exchange request is used to request the target device and the first idle device to exchange address information with each other through the second idle device; when the second idle device sends the second address exchange request to the first idle device and the target device and the first idle device complete the exchange of address information, receive the login request sent by the target device and the first idle device to complete the login of the target device and the first idle device, switch the relay connection to a point-to-point connection between the target device and the first idle device, and interrupt the relay connection, wherein when the target device and the first idle device complete the login, the point-to-point connection is automatically established.
[0013] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned connection establishment method when running.
[0014] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above connection establishment method.
[0015] According to another aspect of an embodiment of the present application, there is further provided an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the connection establishment method through the computer program.
[0016] In the embodiment of the present application, by adopting the method of establishing a relay connection between the terminal device and the target device and obtaining the network address translation type, by judging whether the network address translation types corresponding to the two devices are both symmetric, and establishing a point-to-point connection strategy based on this judgment result, the purpose of efficiently establishing a P2P connection in different network environments is achieved, thereby achieving the technical effect of improving the connection success rate and reducing resource consumption. Specifically, when at least one of the terminal device and the target device is asymmetric, the address is exchanged between the target device and the first idle device in the same local area network to achieve P2P connection; if both are symmetric, a second idle device in a different local area network is introduced, and its network address translation type is asymmetric. The address is exchanged by cascading multiple devices, which optimizes the penetration problem in the symmetric NAT environment, ensures the continuity of the business and the smoothness of the user experience, and thus solves the technical problem that the resource consumption in the NAT penetration process has too much impact on the code stream transmission and the device resource overhead is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a schematic diagram of an application environment of an optional connection establishment method according to an embodiment of the present application;
[0019] Figure 2 is a flowchart of an optional connection establishment method according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of an application environment of an optional connection establishment method according to an embodiment of the present application;
[0021] Figure 4 This is a schematic diagram of a non-bisymmetric NAT scenario of an optional connection establishment method according to an embodiment of the present application;
[0022] Figure 5 It is a schematic diagram of a dual symmetric NAT scenario of an optional connection establishment method according to an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of the main steps of an optional connection establishment method according to an embodiment of the present application;
[0024] Figure 7 is a schematic structural diagram of an optional connection establishment device according to an embodiment of the present application;
[0025] Figure 8is a structural schematic diagram of an optional connection establishment product according to an embodiment of the present application;
[0026] Fig. 9 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, 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 "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to one aspect of an embodiment of the present application, a connection establishment method is provided. Optionally, in this embodiment, the connection establishment method can be applied to Figure 1 In the hardware environment composed of the server 101 and the terminal device 103 shown in FIG. Figure 1As shown, the server 101 is connected to the terminal device 103 via a network, and can be used to provide services for the terminal device or the application installed on the terminal device. The application 107 can be a video application, an instant messaging application, a browser application, an educational application, a game application, etc. A database 105 may be set up on the server or independently of the server to provide data storage services for the server 101, for example, a game data storage server. The above-mentioned network may include, but is not limited to, a wired network and a wireless network, wherein the wired network includes, a local area network, a metropolitan area network and a wide area network; the wireless network includes, Bluetooth, WIFI and other networks that implement wireless communication; the terminal device 103 may be a terminal configured with an application, and may include, but is not limited to, at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a mixed reality (MR) terminal and other computer devices; the above-mentioned server may be a single server, a server cluster consisting of multiple servers, or a cloud server.
[0030] Combination Figure 1 As shown, the above connection establishment method can be executed by an electronic device, which can be a terminal device or a server. The above connection establishment method can be implemented by the terminal device or the server respectively, or by the terminal device and the server together.
[0031] The above is only an example and is not specifically limited in this embodiment.
[0032] Optionally, as an optional implementation, as Figure 2 As shown, the above connection establishment method includes:
[0033] S202, receiving a data request message sent by a terminal device, wherein the data request message is used to request to obtain data of a target device, and the terminal device and the target device belong to different local area networks;
[0034] S204, in response to the data request message, establishing a relay connection between the terminal device and the target device, and obtaining network address translation types corresponding to the terminal device and the target device, wherein the network address translation type indicates a behavior mode of the device processing a data packet;
[0035] S206, based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, establish a point-to-point connection between the terminal device and the target device, and interrupt the relay connection, wherein, when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is achieved by exchanging addresses between the target device and the first idle device, and the first idle device and the target device belong to the same local area network; when the terminal device and the target device are both symmetric, the point-to-point connection is achieved by exchanging addresses between the target device, the first idle device and the second idle device, and the second idle device and the target device belong to different local area networks, and the network address translation type of the second idle device is asymmetric.
[0036] Optionally, in the embodiment of the present application, the receiving terminal device may include but is not limited to a user-operated smart device that can send and receive data through a network. This includes but is not limited to a smart phone, a tablet computer, a laptop or a desktop computer. For example, a user may use his smart phone to request to connect to a smart camera at home through an application, and the camera is the target device.
[0037] In the embodiment of the present application, the above data request message may include but is not limited to a signal or information packet sent by a terminal device, the purpose of which is to request to obtain specific data from a target device. This includes but is not limited to video stream requests, file download requests, or status information queries. For example, when a user wants to view the real-time video of a smart camera, the smart phone will send a data request message to the camera to request video stream data.
[0038] It should be noted that data request messages are not limited to textual forms, but can also include multimedia data, such as video, audio, or images. For example, a data request message can be a user's request to obtain a real-time video stream from a smart camera, or a request to obtain a temperature sensor reading from a home automation system, or a request to obtain heart rate data from a health monitoring device. These requests can span different application scenarios and device types, and this application does not limit this.
[0039] Optionally, in an embodiment of the present application, the above-mentioned relay connection may include but is not limited to a network connection method that allows two devices that cannot communicate directly to exchange data through an intermediary server or node. This includes but is not limited to a virtual connection established through a cloud platform relay server. For example, when a P2P connection cannot be established directly between a terminal device and a target device, data can be forwarded through a cloud platform relay server to achieve communication.
[0040] It should be further explained that the establishment of relay connections is not limited to cloud platform relay servers, but can also be achieved through other intermediary devices or services. For example, the relay connection can be established through a proxy server in the enterprise's internal network, or through a relay point provided by a specific network optimization service. These intermediary services can be hardware devices or software services. Their role is to facilitate data transmission under different network environments and conditions, and this application does not limit this.
[0041] Optionally, in the embodiment of the present application, the above network address translation type may include but is not limited to the rules and behavior patterns that describe how the NAT device processes and converts the data packets flowing through it. This includes but is not limited to types such as cone NAT and symmetric NAT. For example, symmetric NAT will dynamically allocate different external network IP and port for each session, while cone NAT uses the same external network IP and port for all sessions of the intranet device.
[0042] It should be pointed out that the network address translation type is not limited to symmetric and asymmetric types, but can also include other NAT types such as full cone, restricted cone, port restricted cone, etc. These types describe how the NAT device processes and converts data packets flowing through it. Different NAT types have different processing rules and behavior patterns for data packets, which will affect the establishment and maintenance of P2P connections. For example, the full cone NAT is open to all external connections initiated to specific ports on the intranet, while the restricted cone NAT is only open to connections to specific IPs. These different NAT types have a direct impact on the establishment and maintenance of P2P connections, and this application does not limit this.
[0043] Optionally, in an embodiment of the present application, the above-mentioned point-to-point connection may include but is not limited to a direct communication path between two devices without passing through any intermediary server or node. This includes but is not limited to a direct connection established through the ICE (Interactive Connectivity Establishment) framework. For example, once the terminal device and the target device are able to determine each other's external network IP and port, they can perform a series of tests and exchange information through the ICE framework, and finally establish a direct P2P connection.
[0044] Optionally, in the embodiment of the present application, the first idle device may include but is not limited to a device in an idle state in the same local area network, which can help establish a P2P connection between the terminal device and the target device. This includes but is not limited to other smart devices in the same home network. For example, if the target device is a smart camera, and a smart light bulb in the same local area network is in an idle state, the smart light bulb can serve as the first idle device to assist in establishing a P2P connection.
[0045] Optionally, in the embodiment of the present application, the second idle device may include but is not limited to a device in an idle state in a different local area network, whose network address translation type is asymmetric, and which participates in the establishment of the P2P connection. This includes but is not limited to devices located in different network environments. For example, if the terminal device and the target device are both behind a symmetric NAT, another device located in an asymmetric NAT network (such as a printer in an office) may be needed to assist in completing the address exchange and the establishment of the P2P connection.
[0046] For example, take the smart home monitoring system as an example, where the user requests to obtain the real-time video stream of the smart camera (target device) at home through a smart phone (terminal device). The following is the specific implementation process:
[0047] S1: The user sends a data request message to the smart camera via a smartphone, which contains instructions for requesting a real-time video stream.
[0048] S2: After receiving the data request message, the smart camera responds to the request by establishing a relay connection with the smartphone through the cloud platform (relay server) and starts transmitting real-time video stream data.
[0049] S3: At the same time, the cloud platform obtains the network address translation type corresponding to the smartphone and the smart camera. Assume that the NAT type of the smartphone is symmetric and the NAT type of the smart camera is cone.
[0050] S4: Based on the information of the network address translation type, since the smart camera is an asymmetric NAT, the cloud platform decides to use the device cascade auxiliary penetration solution. The cloud platform queries whether there is an idle device in the same LAN that can be used as the first idle device, and finds that the smart light bulb (the first idle device) is in an idle state.
[0051] S5: The smart camera exchanges addresses with the smartphone through the smart bulb (the first idle device) to establish a point-to-point connection. The smart bulb sends a request to the cloud platform STUN server to obtain its external network IP and port after the egress NAT, and sends this information to the smartphone.
[0052] S6: The smartphone and the smart bulb start the ICE interaction process based on the external network IP and port behind the NAT of both parties to perform NAT penetration.
[0053] S7: After NAT penetration is successful, the smartphone suspends the relay transmission link through the cloud platform and sends an address exchange request to the smart camera, carrying the device serial number of the smart bulb and the port number bound to the local network socket.
[0054] S8: The smart camera and the smart light bulb complete the address exchange process and update the ARP table entry, so that the smart camera can send data directly to the smartphone.
[0055] S9: The smart camera creates a new network socket and binds the port number corresponding to the local network socket of the smart bulb, sends a request to restore the real-time video stream service to the smartphone, and completes the link switching from the cloud platform relay to the P2P transmission.
[0056] Through the above process, efficient P2P connection establishment is achieved in different NAT environments. In the asymmetric NAT scenario, by introducing idle devices (smart light bulbs) in the same LAN as relays, the resource occupation of the target device (smart camera) is reduced, and the success rate of P2P connection is improved. In the symmetric NAT scenario, by adding asymmetric NAT devices (such as office printers) in different LANs as the second idle device, multi-to-multi cascade penetration is achieved, avoiding the time-consuming and resource-intensive problems of dual symmetric NAT penetration. This solution not only improves connection efficiency and reduces latency, but also reduces platform traffic costs and improves user experience.
[0057] Through the embodiment of the present application, by adopting the method of establishing a relay connection between the terminal device and the target device and obtaining the network address translation type, by judging whether the network address translation types corresponding to the two devices are both symmetric, and establishing a point-to-point connection strategy based on this judgment result, the purpose of efficiently establishing a P2P connection in different network environments is achieved, thereby achieving the technical effect of improving the connection success rate and reducing resource consumption. Specifically, when at least one of the terminal device and the target device is asymmetric, the address is exchanged between the target device and the first idle device in the same local area network to achieve P2P connection; if both are symmetric, a second idle device in a different local area network is introduced, and its network address translation type is asymmetric. The address is exchanged by cascading multiple devices, which optimizes the penetration problem in the symmetric NAT environment, ensures the continuity of the business and the smoothness of the user experience, and thus solves the technical problem that the resource consumption in the NAT penetration process has too much impact on the code stream transmission and the device resource overhead is high.
[0058] As an optional solution, based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, a point-to-point connection is established between the terminal device and the target device, and the relay connection is interrupted, including:
[0059] In the case where at least one of the terminal device and the target device is asymmetric, establishing a point-to-point connection based on the first idle device and interrupting the relay connection;
[0060] In the case that both the terminal device and the target device are symmetrical, a point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted.
[0061] Optionally, in an embodiment of the present application, symmetric NAT is a type of network address translation that dynamically assigns a different address and port to each external port connection passing through NAT. In this mode, the NAT device maintains a dynamic translation table that records the mapping relationship between internal private addresses and external public network addresses. Whenever a new connection request arrives, the NAT device searches the translation table. If no match is found, a new entry is created and an unused external port is randomly selected to establish a connection. The characteristic of symmetric NAT is that for each new external connection request, even the same external address and port from the same internal device may be assigned a different external address and port. This means that devices in a symmetric NAT environment cannot accept all connections from any external source through only one external address and port, which poses a challenge to P2P communication.
[0062] Optionally, in an embodiment of the present application, asymmetric NAT is another type of network address translation, which allows traffic from the same internal address and port to be mapped to the same external address and port, but for return traffic, as long as the source address and port match the mapping recorded on the NAT device, it can be forwarded to the correct internal device even if the destination address and port are different. Asymmetric NAT is commonly used in P2P applications because it allows an internal device to use a fixed external address and port to accept connections from any external source. This type of NAT is more friendly to P2P communication because it does not need to allocate a new external port for each new connection request like symmetric NAT, thereby simplifying the process of establishing a P2P connection.
[0063] Exemplarily, take remote monitoring and data backup as an example, where a user wants to remotely access a NAS storage device (target device) in a home network through a smartphone (terminal device) to back up photos and videos.
[0064] S1: The user sends a data request message to the NAS storage device via a smartphone, requesting to back up the photos and videos in the smartphone.
[0065] S2: The NAS storage device responds to the data request message, establishes a relay connection with the smartphone through the cloud platform relay server, and starts transmitting data.
[0066] S3: The cloud platform obtains the network address translation type of the smartphone and the NAS storage device. Assume that the NAT type of the smartphone is asymmetric and the NAT type of the NAS storage device is symmetric.
[0067] S4: Based on the information of the network address translation type, the cloud platform decides to establish a point-to-point connection based on the first idle device (the smart router in the home network). The smart router sends a request to the cloud platform STUN server to obtain its external network IP and port after the egress NAT.
[0068] S5: The smart router (first idle device) exchanges addresses with the smartphone and establishes a point-to-point connection. The smart router creates a new network socket and obtains its own NATed external IP and port from the cloud platform STUN server. It then constructs a P2P connection establishment response and carries its own device serial number, network NAT type, NATed external IP and port, and the port number bound to the local network socket, and forwards it to the smartphone through the cloud platform signaling server.
[0069] S6: The smartphone and the smart router start the ICE interaction process based on the external network IP and port after NAT of both parties to perform NAT penetration.
[0070] S7: After NAT penetration is successful, the smartphone suspends the relay transmission link through the cloud platform, and sends an address exchange request to the NAS storage device and the smart router through the relay transmission link and the P2P transmission link respectively, carrying the device serial numbers of both devices.
[0071] S8: The NAS storage device and the smart router complete the address exchange process and update the ARP table entry, so that the NAS storage device can send data directly to the smart phone.
[0072] S9: The NAS storage device creates a new network socket and binds the port number corresponding to the local network socket of the smart router, sends a data backup recovery service request to the smart phone, completes the link switching from the cloud platform relay to the P2P transmission, and interrupts the relay connection.
[0073] Through the above process, efficient P2P connection establishment in different NAT environments is achieved. In the case where at least one device is an asymmetric NAT, with the assistance of the first idle device (smart router), a point-to-point connection is successfully established and the relay connection is interrupted, reducing the dependence on cloud platform resources, reducing data transmission costs, and improving data transmission efficiency. In a symmetric NAT environment, by introducing the first idle device and the second idle device (for example, the second idle device can be a printer in the user's office or a smart TV in another home network), multi-to-multi cascade penetration is achieved, avoiding the problem of long time and high resource consumption of dual symmetric NAT penetration. This solution not only improves connection efficiency and reduces latency, but also reduces platform traffic costs and improves user experience. By optimizing the NAT penetration process, the continuity and stability of data backup are ensured, while the utilization of network resources is improved.
[0074] As an optional solution, when at least one of the terminal device and the target device is not symmetrical, a point-to-point connection is established based on a first idle device, and a relay connection is interrupted, including: when at least one of the terminal device and the target device is not symmetrical, a first point-to-point connection establishment request sent by the terminal device is received; in response to the first point-to-point connection establishment request, a device operating status of each device in a first group of devices is obtained, wherein the first group of devices and the target device belong to the same local area network; based on the device operating status, a first group of idle devices is determined from the first group of devices; a first point-to-point connection establishment request is sent to the first group of idle devices; and the device that responds to the first point-to-point connection establishment request in the first group of idle devices is determined as the first idle device. an idle device, establishing a first penetration connection between the first idle device and the terminal device; in the case where the first penetration connection is successfully established, sending a first address exchange request to the target device and the first idle device respectively, wherein the first address exchange request is used to request the target device and the first idle device to exchange address information with each other; in the case where the target device and the first idle device complete the exchange of address information, receiving a login request sent by the target device and the first idle device to complete the login of the target device and the first idle device, switching the relay connection to a point-to-point connection between the target device and the first idle device, and interrupting the relay connection, wherein, in the case where the target device and the first idle device complete the login, a point-to-point connection is automatically established.
[0075] Optionally, in an embodiment of the present application, the above-mentioned first point-to-point connection request may include but is not limited to a network request sent by a terminal device in order to establish direct communication with a target device, and this request contains necessary network parameters and authentication information so that the target device or other devices in the same local area network can respond and establish a connection. Including but not limited to a data packet containing a port number, an IP address, and specific protocol requirements. For example, when a smartphone needs to establish a connection with a smart camera in a home network, it sends a connection request containing its public IP address and port number so that the smart camera or other devices in the same local area network can respond.
[0076] Optionally, in an embodiment of the present application, the first group of devices may include but is not limited to all smart devices in the same local area network as the target device, which can assist in establishing a point-to-point connection. This includes but is not limited to smart sockets, smart light bulbs, smart thermostats, etc. For example, if the target device is a NAS server in a home, then the first group of devices may include smart TVs, smart speakers, and other smart home devices in the same home network.
[0077] Optionally, in the embodiment of the present application, the above-mentioned device operation status may include but is not limited to parameters describing whether the device is currently able to participate in network operations, such as whether it is idle, whether it is busy, network connection quality, etc. Including but not limited to the device's CPU usage, memory usage, current network bandwidth usage, etc. For example, in a smart home network, a smart socket may be displayed as busy because it is controlling an appliance in use, while a smart light bulb may be displayed as idle because it is not currently turned on.
[0078] Optionally, in an embodiment of the present application, the first group of idle devices may include but is not limited to devices in the first group of devices that are not currently performing tasks or that can extract resources to assist in establishing a point-to-point connection. Including but not limited to a smart refrigerator that has just completed an update operation or a smart speaker that is not currently playing music. For example, if a smart refrigerator in a home network has just completed a software update and is idle, it can be selected as one of the first group of idle devices to assist in establishing a point-to-point connection.
[0079] Optionally, in an embodiment of the present application, the first penetration connection may include but is not limited to a network connection for NAT penetration established between the terminal device and the first idle device. This connection allows the two devices to exchange necessary information in order to communicate directly bypassing the NAT device. Including but not limited to a connection established through the STUN protocol or other NAT penetration technologies. For example, a first penetration connection may be established between a smartphone and a smart refrigerator, allowing them to exchange external network IP addresses and port numbers, thereby achieving NAT penetration.
[0080] Optionally, in an embodiment of the present application, the first address exchange request may include but is not limited to a request sent by the terminal device to the target device and the first idle device, with the purpose of allowing the two devices to exchange their network address information with each other so as to directly establish a connection. Including but not limited to a data packet containing a device serial number, IP address and port number. For example, a smartphone may send a request to a smart camera and a smart refrigerator, asking them to exchange their internal IP addresses so that the smartphone can directly establish a connection with the smart camera.
[0081] Optionally, in an embodiment of the present application, the above login request may include but is not limited to a request sent by the target device and the first idle device to the network system to confirm that they are ready and can start direct communication. This request may contain the device's authentication information and network parameters. Including but not limited to a data packet containing the device MAC address and a login token. For example, in a smart home system, after the address information is exchanged, the smart camera and the smart refrigerator will send a login request to the cloud platform to confirm that they are ready for point-to-point communication.
[0082] It should be noted that the first point-to-point connection request between the terminal device and the target device may include a variety of network parameters and authentication information, which is not limited to the basic IP address and port number, but may also include encryption keys, protocol types, data transmission formats, etc. For example, the request may contain parameters of the SSL / TLS encryption protocol to ensure the security of the connection, or specify the use of the MQTT protocol for communication between IoT devices. This application does not limit this.
[0083] Among them, in response to the first point-to-point connection request, when obtaining the device operating status of each device in the first group of devices, the parameters of the device operating status can be very diverse, including CPU load, memory usage, network bandwidth occupancy, device temperature, battery power, etc. These parameters can help the system more accurately evaluate the availability and performance of the device, so as to select the best device to assist in establishing the point-to-point connection. For example, a device may not be selected as the first idle device because of low battery power, even if it currently has no other tasks. This application is not limited to this.
[0084] In addition, when determining the first group of idle devices from the first group of devices based on the device operating status, the system may consider various attributes and historical behaviors of the devices, such as the reliability record of the devices, the previous connection success rate, the priority settings of the devices by the user, etc. For example, if a device often fails in past connection attempts, the system may give priority to other devices even if their current operating status is not optimal. This application does not limit this.
[0085] On the other hand, when sending the first point-to-point connection establishment request to the first group of idle devices, the request may include multiple types of network protocols and data formats to adapt to the needs of different devices and network environments. For example, the request may be sent in JSON format or include data in XML format to adapt to the parsing capabilities of different devices. This application does not limit this.
[0086] On the other hand, when the device that responds to the first point-to-point connection request in the first group of idle devices is determined as the first idle device, the system may evaluate and select the best device based on multiple dimensions such as response speed, connection quality, and historical connection stability. For example, even if multiple devices respond to the request, the system may select the device with the shortest response time and the strongest signal as the first idle device. This application does not limit this.
[0087] Furthermore, when the first penetration connection is successfully established, the first address exchange request sent to the target device and the first idle device respectively may include multiple types of address information, including IPv4 address, IPv6 address, MAC address, etc., and possible network interface identifiers. For example, the request may require the devices to exchange their addresses on different network interfaces, or addresses used under different network protocols. This application does not limit this.
[0088] Then, when the target device and the first idle device complete the exchange of address information, when receiving login requests sent by the target device and the first idle device, these requests may include a variety of identity authentication and authorization information, such as user name and password, digital certificate, one-time password (OTP), etc. This information is used to ensure that only authorized devices can establish a point-to-point connection. For example, the system may require the device to provide a login request based on two-factor authentication to enhance security. This application does not limit this.
[0089] Finally, when the relay connection is switched to a point-to-point connection between the target device and the first idle device and the relay connection is interrupted, this process may involve a variety of network optimization and fault recovery mechanisms to ensure the stability of the connection and the integrity of the data. For example, the system may monitor the network quality during the switching process and automatically restore to the relay connection when a problem is detected, or automatically switch back to a more economical connection mode after the data transmission is completed. This application is not limited to this.
[0090] For example, take a remote office scenario as an example, where an employee (terminal device) needs to obtain important documents from a file server (target device) on the company's intranet. The following is the specific implementation process:
[0091] S1: The employee's laptop (terminal device) sends the first point-to-point connection request to the file server (target device) on the company's intranet, requesting to obtain a specific document.
[0092] S2: The file server responds to the first point-to-point connection request and queries the device operation status of the first group of devices (such as printers, scanners, and other computers) in the same intranet, including CPU load, memory usage, network bandwidth occupancy, etc.
[0093] S3: Based on the device operation status, the file server determines a first group of idle devices, for example, finds an idle printer (the first idle device).
[0094] S4: The file server sends a first point-to-point connection request to the idle printer, requesting assistance in establishing a penetration connection with the employee's laptop.
[0095] S5: The printer responds to the first point-to-point connection establishment request and establishes a first penetration connection with the employee's laptop, for example, obtaining the external network IP and port after NAT through the STUN protocol, and starting the ICE interaction process.
[0096] S6: Once the first penetration connection is successfully established, the file server sends a first address exchange request to the printer and the employee's laptop respectively, requesting both parties to exchange address information, such as IP addresses and port numbers.
[0097] S7: The printer and the employee's laptop complete the exchange of address information, for example, by sending ARP requests and responses to confirm each other's LAN addresses.
[0098] S8: The file server receives the login requests from the printer and the employee's laptop, completes the login of both parties, and prepares to switch the connection. For example, the file server may require both parties to provide digital certificates or passwords to verify their identities.
[0099] S9: The file server switches the relay connection to a point-to-point connection between the printer and the employee's laptop and disconnects the previous relay connection. For example, the file server may send a control signal to instruct the two parties to communicate directly.
[0100] Through the above process, efficient P2P connection establishment in an asymmetric NAT environment is achieved. When at least one of the terminal device and the target device is not symmetric, with the assistance of the first idle device (printer), a point-to-point connection is successfully established and the relay connection is interrupted, reducing the dependence on the company's intranet resources, reducing data transmission costs, and improving data transmission efficiency. This method not only improves the stability and security of the connection, but also allows flexible resource allocation and connection management in a complex network environment, ensuring the fast and secure transmission of important documents. In addition, by automatically switching connections and interrupting relay connections, the system is able to save bandwidth, reduce latency, improve user experience, and save network operating costs for the company.
[0101] As an optional solution, when the terminal device and the target device are both symmetrical, a point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted, including: when the terminal device and the target device are both symmetrical, determining whether there is a second idle device; when there is a second idle device, establishing a point-to-point connection based on the first idle device and the second idle device, and interrupting the relay connection.
[0102] Optionally, in an embodiment of the present application, when both the terminal device and the target device are symmetrical, the process of determining whether there is a second idle device may involve considerations of multiple dimensions, including the network location of the device, the network address translation type, and the functionality of the device. For example, the second idle device may be located in a local area network different from the target device, and its NAT type may be asymmetric, and such a device can assist in establishing a more stable point-to-point connection. In addition, the selection of the second idle device may also be based on its processing power, available resources, and historical connection success rate. For example, a device with higher processing power and lower battery consumption may be more favored as the second idle device. This application is not limited to this.
[0103] It should be noted that, in the presence of a second idle device, the process of establishing a point-to-point connection based on the first idle device and the second idle device may include a variety of technical solutions and parameter configurations. For example, this connection may be implemented through different communication protocols, such as TCP, UDP, or application layer-specific protocols. The establishment of a connection may need to consider the security of data transmission, so it may involve the use of encryption technologies such as SSL / TLS. In addition, the stability and efficiency of the connection may be affected by network conditions, so it may be necessary to dynamically adjust the transmission rate or retransmission strategy. For example, if the network conditions are poor, the system may choose to use a more robust transmission protocol or increase the confirmation mechanism of the data packet. This application is not limited to this.
[0104] In addition, in the process of interrupting the relay connection after establishing a point-to-point connection, a variety of network management and optimization technologies may be involved. For example, the interruption of the relay connection may need to ensure the integrity and consistency of data transmission, so data synchronization or status confirmation may be performed before the interruption. In addition, the interruption of the relay connection may be based on real-time monitoring and analysis of network traffic to ensure that it is performed when the network load is low to reduce the impact on network performance. For example, the system may automatically interrupt the relay connection when a low network traffic is detected, or during non-peak hours specified by the user. This application is not limited to this.
[0105] As an optional scheme, when the terminal device and the target device are both symmetrical, determining whether there is a second idle device includes: when the terminal device and the target device are both symmetrical, receiving a second point-to-point connection request sent by the terminal device; in response to the second point-to-point connection request, obtaining the device operation status of the second group of devices, wherein the second group of devices and the target device belong to different local area networks, and the network address translation type corresponding to the second group of idle devices is asymmetric; determining a second group of idle devices from the second group of devices based on the device operation status; sending a point-to-point cascade request to the second group of idle devices; determining the device in the second group of idle devices that responds to the point-to-point cascade request as the second idle device, and establishing a second penetration connection between the second idle device and the terminal device.
[0106] Optionally, in an embodiment of the present application, the above-mentioned second point-to-point connection request may include but is not limited to a network request sent by a terminal device to establish direct communication with a target device. This request may contain specific protocol identifiers, port information, encryption parameters, etc. to ensure compatibility and security with the target device. Including but not limited to a data packet containing the public IP address, port number and encryption protocol type (such as TLS / SSL) of the terminal device. For example, when a terminal device needs to establish a secure point-to-point connection with a target device, it may send a connection request containing its public IP address and port number, and specify the use of the TLS protocol to encrypt communication. This application is not limited to this.
[0107] It should be noted that, when both the terminal device and the target device are symmetrical, the second point-to-point connection request sent by the receiving terminal device may involve a variety of network parameters and authentication information. These parameters and information include not only the basic IP address and port number, but also encryption keys, protocol types, data transmission formats, etc. For example, the request may include parameters of the SSL / TLS encryption protocol to ensure the security of the connection, or specify the use of the MQTT protocol for communication between IoT devices. In addition, the request may also include QoS (Quality of Service) requirements to ensure the priority and efficiency of data transmission. This application does not limit this.
[0108] Optionally, in an embodiment of the present application, the second group of devices may include, but is not limited to, a series of devices located in different local area networks from the target device, and these devices may have different network address translation types, including asymmetric NAT. These devices may be any type of network device, such as a router, a switch, a smart home device, etc. For example, if the target device is a server in a company's intranet, the second group of devices may include a smart TV, a game console, or other network communication-supporting device in an employee's home network. This application is not limited to this.
[0109] Among them, in response to the second point-to-point connection request, when obtaining the device operating status of the second group of devices, the parameters of the device operating status can be very diverse, including CPU load, memory usage, network bandwidth occupancy, device temperature, battery power, etc. These parameters can help the system more accurately evaluate the availability and performance of the device, so as to select the best device to assist in establishing a point-to-point connection. For example, a device may not be selected as a second group of idle devices because of low battery power, even if it currently has no other tasks. In addition, the acquisition of device operating status may be implemented through different monitoring tools and protocols, such as SNMP (Simple Network Management Protocol) or a custom device API. This application is not limited to this.
[0110] Optionally, in an embodiment of the present application, the second group of idle devices may include but is not limited to devices in the second group of devices that are not currently performing tasks or that can extract resources to assist in establishing a point-to-point connection. The selection of these devices may be based on factors such as their network performance, processing power, and available bandwidth. For example, if there is a smart TV and a game console in the second group of devices, and the game console is not currently running any games, it may be selected as the second group of idle devices to assist in establishing a point-to-point connection. This application is not limited to this.
[0111] Among them, when determining the second group of idle devices from the second group of devices based on the device operating status, the system may consider various attributes and historical behaviors of the devices, such as the reliability record of the devices, the previous connection success rate, the user's priority setting for the devices, etc. For example, if a device often fails in past connection attempts, the system may give priority to other devices even if their current operating status is not optimal. In addition, the system may select devices based on the energy consumption and environmental impact of the devices to achieve the goal of green energy saving. This application is not limited to this.
[0112] Optionally, in an embodiment of the present application, the above-mentioned point-to-point cascade request may include but is not limited to a request sent by the terminal device to the second group of idle devices, the purpose of which is to allow these devices to assist in establishing a penetration connection with the target device. This request may include network parameters of the target device, protocol details of the penetration connection, etc. For example, the terminal device may send a cascade request including the public IP address, port number, and expected penetration protocol (such as STUN or TURN) of the target device. This application is not limited to this.
[0113] When a point-to-point cascade request is sent to the second group of idle devices, the request may include multiple types of network protocols and data formats to meet the needs of different devices and network environments. For example, the request may be sent in JSON format or include data in XML format to meet the parsing capabilities of different devices. In addition, the request may also include requirements for specific network service quality, such as low latency or high throughput, to meet the needs of specific applications. This application is not limited to this.
[0114] Optionally, in an embodiment of the present application, the second penetration connection may include but is not limited to a network connection for NAT penetration established between the terminal device and the second idle device. This connection allows the two devices to exchange necessary information in order to bypass the NAT device and communicate directly. Including but not limited to a connection established by the STUN protocol or other NAT penetration technologies. For example, a second penetration connection may be established between the terminal device and the game console, so that they can exchange external network IP addresses and port numbers, thereby achieving NAT penetration. This application is not limited to this.
[0115] Among them, when the device in the second group of idle devices that responds to the point-to-point cascade request is determined as the second idle device, and a second penetration connection is established between the second idle device and the terminal device, the establishment of this connection may involve multiple security and encryption measures to protect the security and privacy of data transmission. For example, the connection may use VPN (virtual private network) technology to encrypt all transmitted data, or use IPSec (Internet Protocol Security) to ensure the integrity and confidentiality of the data. In addition, the establishment of the connection may also include the optimization of the network path to reduce delays and improve data transmission efficiency. This application is not limited to this.
[0116] For example, take the security monitoring system as an example, where the remote security monitoring center (terminal device) needs to establish a connection with the surveillance camera (target device) in the company building to transmit video data in real time. The following is the specific implementation process:
[0117] S1: The remote security monitoring center (terminal device) sends a second point-to-point connection request to the surveillance camera (target device) in the company building, requesting to establish a real-time video data transmission connection.
[0118] S2: The surveillance camera responds to the second point-to-point connection request and queries the device operation status of the second group of devices (such as security devices of other branches) in different local area networks outside the building, including CPU load, memory usage, network bandwidth occupancy, etc.
[0119] S3: Based on the operating status of the devices, the surveillance camera determines which devices in the second group of devices are in an idle state and the corresponding network address translation type is asymmetric, for example, a security router of a branch office.
[0120] S4: The surveillance camera sends a point-to-point cascade request to the branch office's security router (the second group of idle devices), requesting assistance in establishing a penetration connection with the remote security monitoring center.
[0121] S5: The branch security router responds to the point-to-point cascade request and establishes a second penetration connection with the remote security monitoring center. For example, the external network IP and port after NAT are obtained through the STUN protocol, and the ICE interaction process is started.
[0122] S6: Once the second penetration connection is successfully established, the surveillance camera sends a first address exchange request to the security router of the branch office, requesting to exchange address information, such as IP address and port number.
[0123] S7: After the security router of the branch office completes the exchange of address information, the surveillance camera receives the login request sent by the security router of the branch office, completes the login, and prepares to switch the relay connection to a point-to-point connection.
[0124] S8: The surveillance camera switches the relay connection to a point-to-point connection with the branch office's security router and disconnects the previous relay connection. For example, the surveillance camera may send a control signal to instruct the two parties to communicate directly.
[0125] Through the above process, efficient P2P connection establishment in a symmetric NAT environment is achieved. When both the terminal device and the target device are symmetric, with the assistance of the branch's security router (the second idle device), a point-to-point connection is successfully established and the relay connection is interrupted, reducing the reliance on the company's intranet resources, reducing data transmission costs, and improving data transmission efficiency. This method not only improves the stability and security of the connection, but also allows flexible resource allocation and connection management in a complex network environment, ensuring the fast and secure transmission of important video data. In addition, by automatically switching connections and interrupting relay connections, the system is able to save bandwidth, reduce latency, improve user experience, and save network operating costs for the company. By optimizing the NAT penetration process, the continuity and stability of the security monitoring system are ensured, while improving the utilization of network resources.
[0126] As an optional solution, in the case where a second idle device exists, a point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted, including: in the case where the second idle device exists, a third point-to-point connection establishment request sent by the second idle device is received; in response to the third point-to-point connection establishment request, a device operation status of each device in the first group of devices is obtained, wherein the first group of devices and the target device belong to the same local area network; based on the device operation status, a first group of idle devices is determined from the first group of devices; a third point-to-point connection establishment request is sent to the first group of idle devices; a device in the first group of idle devices that responds to the third point-to-point connection establishment request is determined as a first idle device, and a third penetration connection is established between the first idle device and the second idle device; When the second penetration connection and the third penetration connection are both successfully established, a second address exchange request is sent to the target device and the second idle device respectively, wherein the second address exchange request is used to request the target device and the first idle device to exchange address information with each other through the second idle device; when the second idle device sends the second address exchange request to the first idle device, and the target device and the first idle device complete the exchange of address information, a login request sent by the target device and the first idle device is received to complete the login of the target device and the first idle device, the relay connection is switched to a point-to-point connection between the target device and the first idle device, and the relay connection is interrupted, wherein, when the target device and the first idle device complete the login, a point-to-point connection is automatically established.
[0127] Optionally, in an embodiment of the present application, the above-mentioned third point-to-point connection request may include but is not limited to a network request sent by the second idle device in order to establish direct communication with a device in the first group of devices. This request may contain specific protocol identifiers, port information, encryption parameters, etc. to ensure compatibility and security with the devices in the first group of devices. Including but not limited to a data packet containing the public IP address, port number and encryption protocol type (such as TLS / SSL) of the second idle device. For example, when the second idle device needs to establish a secure point-to-point connection with the smart router in the first group of devices, it may send a connection request containing its public IP address and port number, and specify the use of the TLS protocol to encrypt communication. This application is not limited to this.
[0128] Optionally, in an embodiment of the present application, the third penetration connection may include but is not limited to a network connection for NAT penetration established between the first idle device and the second idle device. This connection allows the two devices to exchange necessary information in order to bypass the NAT device and communicate directly. Including but not limited to connections established through the STUN protocol or other NAT penetration technologies. For example, a third penetration connection may be established between the first idle device (smart router) and the second idle device (security router of the branch office), so that they can exchange external network IP addresses and port numbers, thereby achieving NAT penetration. This application is not limited to this.
[0129] Optionally, in an embodiment of the present application, the second address exchange request may include but is not limited to a request for the target device and the first idle device to exchange address information with each other through the second idle device. This request may include network parameters of the target device and the first idle device, protocol details of the penetration connection, etc. For example, the target device may send an address exchange request including its public IP address, port number, and the penetration protocol (such as STUN or TURN) to be used. This application does not limit this.
[0130] For example, suppose a large enterprise needs to establish a secure remote access connection between its headquarters (where the target device is located) and branch offices to ensure that remote workers can securely access the company's internal network resources. The following is the specific implementation process:
[0131] S1: The VPN server of the branch office (the second idle device) sends a third point-to-point connection request to the firewall of the company headquarters (the target device), requesting to establish a VPN connection.
[0132] S2: The firewall at the company headquarters responds to the third point-to-point connection request and queries the device operation status of the first group of devices (such as routers, switches, and other servers) in the same LAN, including CPU load, memory usage, network bandwidth occupancy, etc.
[0133] S3: Based on the device operation status, the firewall determines an idle device in the first group of devices, for example, discovers an idle internal router (the first group of idle devices).
[0134] S4: The firewall sends a third point-to-point connection request to the idle internal router, requesting assistance in establishing a penetration connection with the branch office VPN server.
[0135] S5: The internal router responds to the third point-to-point connection request and establishes a third penetration connection with the branch office VPN server. For example, the external network IP and port after NAT are obtained through the STUN protocol, and the ICE interaction process is started.
[0136] S6: Once the second penetration connection (the connection between the branch VPN server and the corporate headquarters firewall) and the third penetration connection (the connection between the internal router and the branch VPN server) are successfully established, the firewall sends a second address exchange request to the internal router and the branch VPN server respectively, requesting the two parties to exchange address information, such as IP addresses and port numbers.
[0137] S7: The branch office VPN server sends a second address exchange request to the internal router, and the firewall and the internal router complete the address information exchange, for example, by sending ARP requests and responses to confirm each other's LAN addresses.
[0138] S8: The firewall receives the login requests from the internal router and the branch office VPN server, completes the login of both parties, and prepares to switch the relay connection to a point-to-point connection.
[0139] S9: The firewall switches the relay connection to a point-to-point connection with the internal router and disconnects the previous relay connection. For example, the firewall may send a control signal to instruct the two parties to communicate directly.
[0140] Through the above process, efficient P2P connection establishment in a symmetric NAT environment is achieved. In the presence of a second idle device, with the assistance of the internal router (the first idle device), a point-to-point connection is successfully established and the relay connection is interrupted, reducing the dependence on the company's intranet resources, reducing data transmission costs, and improving data transmission efficiency. This method not only improves the stability and security of the connection, but also allows flexible resource allocation and connection management in a complex network environment, ensuring the continuity and stability of remote access. In addition, by automatically switching connections and interrupting relay connections, the system can save bandwidth, reduce latency, improve user experience, and save network operating costs for the company. By optimizing the NAT penetration process, the continuity and stability of the remote access system are ensured, while improving the utilization of network resources.
[0141] The following is a further explanation of this application with reference to specific examples:
[0142] Figure 3 is a schematic diagram of an application environment of an optional connection establishment method according to an embodiment of the present application, such as Figure 3 As shown, a P2P connection establishment method and system, including:
[0143] Cloud platform (STUN server, application server, signaling server and relay server):
[0144] 1) Responsible for maintaining the device group information under the user terminal account;
[0145] 2) Responsible for relay transmission between terminal equipment and target equipment;
[0146] 3) Responsible for signaling transmission between terminal devices and target devices and device groups;
[0147] Terminal equipment: Access the target equipment through application software to perform routine services such as remote configuration, alarm notification, real-time preview and video playback;
[0148] Target devices:
[0149] 1) Receive business access requests from terminal device application software and execute corresponding business processing logic;
[0150] 2) Receive the link switching request sent by the platform relay server and execute the switching process from the relay transmission link to the P2P transmission link;
[0151] Device group: In the same LAN, each device node identifies other device nodes around it through its own device discovery function, and forms device group information and reports it to the platform application server.
[0152] In the same network, different device nodes identify other device nodes around them through their own device discovery function. The device discovery broadcast message carries its own device serial number and the assigned local IP address. The following device group information is formed on each device node:
[0153]
[0154] Table 1
[0155] 2) The platform STUN server deploys multiple STUN (Session Traversal Utilities for NAT) services, each of which is bound to a different port number. Each device sends a STUN request to multiple STUN services on the platform to obtain its external IP and port after passing through the egress NAT. If the external port numbers returned by multiple STUN services are the same, the NAT type of the network where the device is located can be determined to be cone-shaped. Otherwise, the network NAT type is considered to be symmetric.
[0156] 3) Each device sends a login request to the platform application server and reports the network NAT type and corresponding device group information. The platform application server receives the network NAT type and device group information reported by each device node under the same user account, forming the following example content in Table 2:
[0157]
[0158] Table 2
[0159] Because the penetration success rate is low and the penetration time is long in the symmetric VS symmetric NAT scenario, and too many device resources are occupied, the present application scheme adds a device group cascade auxiliary penetration scenario (symmetric VS symmetric) according to the different network NAT types of different device groups during the NAT penetration process.
[0160] In an exemplary embodiment, Figure 4 is a schematic diagram of a non-bisymmetric NAT scenario of an optional connection establishment method according to an embodiment of the present application, such as Figure 4 As shown in the figure, in the non-bisymmetric NAT scenario, the target device P2P connection process includes but is not limited to the following:
[0161] S1, the user terminal device sends a request to start the real-time preview service to the target device C of network 1 through the platform application server;
[0162] S2, the platform relay server establishes a relay transmission link between the terminal device and the target device C. Based on the platform relay transmission link, the terminal device and the target device C start the execution process of the real-time preview service. At the same time, the platform application server marks the device operation status of device C as busy.
[0163] S3: When the real-time preview service starts, the terminal device sends a P2P connection establishment request to the platform application server with the target device C, carrying the NAT type of the terminal device side network and the external network IP and port after NAT (obtained based on the STUN service). The platform application server obtains the running status information of each node device in the device group where device C is located, and forwards the P2P connection establishment request to the device node in the idle state through the signaling server;
[0164] S4, after receiving the P2P connection establishment request, the idle device node in the same device group creates a new network socket and obtains its own external IP and port after NAT from the platform STUN server, then builds a P2P connection establishment response and carries its own device serial number, network NAT type, external IP and port after NAT, and the port number bound to the local network socket, and forwards it to the terminal device through the platform signaling server. Subsequently, the terminal device and the idle node of the device group start the NAT penetration ICE (Interactive Connectivity Establishment) interaction process based on the NAT types of both parties and the external IP and port after NAT;
[0165] S5, when one of the idle device nodes successfully penetrates the NAT, the terminal device stops the NAT penetration process with other device nodes, suspends the real-time preview service with the target device on the relay transmission link, and sends an address exchange request to the target device C and the successfully penetrated device A through the relay transmission link and the P2P transmission link respectively, carrying the device serial numbers of both devices, wherein the request sent to the target device C also carries the port number bound to the local network socket of device A, and the external network IP and port of the successfully penetrated terminal device;
[0166] S6, device A and device C match the corresponding device group information based on the other device serial number, obtain the other local IP address, and then start negotiation and perform the address exchange process at the same time. Device A and device C bind each other's local IP address respectively, and send Free ARP to other routing nodes in the current network to update the ARP table entries cached by other routing nodes (i.e., the mapping relationship between IP address and MAC address);
[0167] S7, after both parties complete the address exchange process, they resend a login request to the platform application server with the updated device group information. Then device C creates a new network socket and binds the port number corresponding to the local network socket of device A, and sends a request to restore the real-time preview service to the external network IP and port that the terminal device successfully penetrates, thereby completing the link switching process between the terminal device and the target device.
[0168] In another exemplary embodiment, Figure 5 FIG. 1 is a schematic diagram of a dual symmetric NAT scenario of an optional connection establishment method according to an embodiment of the present application, such as Figure 5 As shown in the figure, in the dual symmetric NAT scenario, the target device P2P connection process includes but is not limited to the following:
[0169] When the platform application server identifies that the NAT types of the terminal device and the target device network are both symmetric, it checks whether there is an asymmetric network node under the user account. If there is, it executes the target device P2P connection process in the dual symmetric NAT scenario. If not, it stops the NAT penetration process to avoid the impact of complex penetration scenarios on the performance of user terminal devices. In addition, the difference between the dual symmetric NAT scenario and the non-dual symmetric NAT scenario is that the device cascade penetration step is added in the NAT penetration process, so this process only describes the differences in the NAT penetration process.
[0170] S1, the terminal device sends a P2P connection request to the platform application server with the target device C in network 1, carrying the external network IP and port of the terminal device after NAT. The platform application server obtains the running status information of the asymmetric network node (network 2) under the user account, and sends a P2P cascade request to the device node in the idle state through the signaling server, carrying the device serial number of the target device C and the external network IP and port of the terminal device after NAT;
[0171] S2, after receiving the P2P cascade request, the idle device node of the asymmetric network creates a new network socket and obtains its own NATed external IP and port from the platform STUN server, then constructs a P2P cascade response and carries its own NATed external IP and port, and forwards it to the terminal device through the platform signaling server;
[0172] S3: The terminal device and the idle device node of the asymmetric network start the ICE interaction process of NAT penetration based on the external network IP and port after NAT of both parties. In addition, because the terminal device receives the P2P cascade response message forwarded by the platform, it needs to wait for the other end to notify the penetration result. It is impossible to directly mark the end of the NAT penetration process based on the success of ICE of a single device.
[0173] S4, each idle device node in the asymmetric network sends a P2P connection establishment request with the target device C to the platform application server, carrying the external network IP and port of the device after NAT. The platform application server obtains the operation status information of each node device in the device group where device C is located, and forwards the P2P connection establishment request to the idle device node through the signaling server;
[0174] S5, after receiving the P2P connection request, the idle device node under the target device group creates a new network socket and obtains its own external IP and port after NAT from the platform STUN server, then builds a P2P connection response and carries its own device serial number, external IP and port after NAT, and the port number bound to the local network socket, and forwards it to the requesting device in the asymmetric network through the platform signaling server. Subsequently, the requesting device in the asymmetric network and the idle device node under the target device group start the NAT penetration ICE interaction process based on the external IP and port after NAT of both parties;
[0175] S6, when the terminal device and the idle device nodes under the target device group complete the NAT penetration process with the same idle device (relay device) in the asymmetric network, they both stop the NAT penetration process with other idle devices in their device groups, where device A is the NAT penetration successful device under the target device group, and device D is the NAT penetration successful device in the asymmetric network;
[0176] S7, device D sends a P2P cascade completion notification to the terminal device, and carries its own external network IP and port of successful penetration, the device serial number of device A, and the port number bound to the local network socket of device A;
[0177] S8, the terminal device suspends the real-time preview service with the target device on the relay transmission link, and sends an address exchange request to the target device C and the successfully penetrated device D through the relay transmission link and the P2P transmission link respectively, wherein the device D forwards the address exchange request to the device A, and the exchange request carries the device serial numbers of the devices A and C, wherein the request sent to the target device C also carries the port number bound to the local network socket of the device A, and the external network IP and port of the successfully penetrated device D;
[0178] S9: The subsequent address exchange process is the same as that in the non-double-symmetric NAT scenario.
[0179] In yet another exemplary embodiment, Figure 6 is a schematic diagram of the main steps of an optional connection establishment method according to an embodiment of the present application, such as Figure 6 As shown, the following steps are included:
[0180] S1, start;
[0181] S2, the terminal device establishes a relay transmission link with the target device;
[0182] S3, the terminal device initiates a P2P connection establishment with the target device;
[0183] S4, determining the NAT type of the terminal device and the target device;
[0184] S5, in the case of symmetric VS cone / cone VS symmetric / cone VS cone, execute the P2P connection establishment process of non-bisymmetric NAT scenario;
[0185] S6, in the case of symmetric VS symmetric, determining whether there is an asymmetric network node device group under the user account;
[0186] S7, if the result of S6 is yes, execute the P2P connection establishment process of the dual symmetric NAT scenario;
[0187] S8, after the execution of the non-double-symmetric NAT scenario P2P connection establishment process or the execution of the double-symmetric NAT scenario P2P connection establishment process is completed, the address switching process is executed;
[0188] S9, when the judgment result of S6 is no or after S8 is completed, ends.
[0189] Through the embodiment of the present application, the terminal device establishes a relay transmission link with the target device, and simultaneously initiates a NAT penetration process with the idle devices in the device group. On the premise of not occupying the hardware resources and network resources of the target device, and without affecting the continuity and stability of the service transmission of the target device, a P2P connection between the terminal device and the target device is established through a one-to-many NAT penetration method between the terminal device and the idle devices in the device group and an address switching process after successful penetration, thereby improving the penetration success rate between the terminal device network and the target device network, and after the NAT penetration is successful, the relay transmission link is seamlessly switched to the P2P transmission link through the address switching process. On the premise of ensuring the continuity and stability of the service transmission of the target device, a P2P connection between the terminal device and the target device is established.
[0190] On the other hand, by judging the network NAT type of the terminal device and the target device, the P2P connection process in different NAT scenarios is executed according to different NAT type combinations. In the dual symmetric NAT scenario, many-to-many cascade penetration is achieved by adding cone network nodes during the interaction between two symmetric network nodes, thereby avoiding the problems of long NAT penetration time and large consumption of device hardware resources and network resources in dual symmetric networks.
[0191] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0192] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0193] According to another aspect of the embodiment of the present application, a connection establishment device for implementing the above connection establishment method is also provided. Figure 7 As shown, the device comprises:
[0194] The receiving module 702 is used to receive a data request message sent by a terminal device, wherein the data request message is used to request to obtain data of a target device, and the terminal device and the target device belong to different local area networks;
[0195] an acquisition module 704, configured to establish a relay connection between the terminal device and the target device in response to the data request message, and acquire a network address translation type corresponding to the terminal device and the target device, wherein the network address translation type indicates a behavior mode of a device processing a data packet;
[0196] Processing module 706 is used to establish a point-to-point connection between the terminal device and the target device and interrupt the relay connection based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, wherein, when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is achieved by exchanging addresses between the target device and a first idle device, and the first idle device and the target device belong to the same local area network. When the terminal device and the target device are both symmetric, the point-to-point connection is achieved by exchanging addresses between the target device, the first idle device and the second idle device, and the second idle device and the target device belong to different local area networks, and the network address translation type of the second idle device is asymmetric.
[0197] As an optional scheme, the above-mentioned device is used to establish a point-to-point connection between the terminal device and the target device, and interrupt the relay connection based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric in the following manner: when at least one of the terminal device and the target device is asymmetric, a point-to-point connection is established based on the first idle device, and the relay connection is interrupted; when the terminal device and the target device are both symmetric, a point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted.
[0198] As an optional solution, the above-mentioned device is used to establish a point-to-point connection based on a first idle device and interrupt the relay connection in the following manner when at least one of the terminal device and the target device is not symmetrical: when at least one of the terminal device and the target device is not symmetrical, receive a first point-to-point connection request sent by the terminal device; in response to the first point-to-point connection request, obtain the device operating status of each device in the first group of devices, wherein the first group of devices and the target device belong to the same local area network; determine a first group of idle devices from the first group of devices based on the device operating status; send a first point-to-point connection request to the first group of idle devices; determine the devices in the first group of idle devices that respond to the first point-to-point connection request For a first idle device, a first penetration connection is established between the first idle device and a terminal device; when the first penetration connection is successfully established, a first address exchange request is sent to the target device and the first idle device respectively, wherein the first address exchange request is used to request the target device and the first idle device to exchange address information with each other; when the target device and the first idle device complete the exchange of address information, a login request is received from the target device and the first idle device to complete the login of the target device and the first idle device, the relay connection is switched to a point-to-point connection between the target device and the first idle device, and the relay connection is interrupted, wherein when the target device and the first idle device complete the login, a point-to-point connection is automatically established.
[0199] As an optional solution, the above-mentioned device is used to establish a point-to-point connection based on the first idle device and the second idle device and interrupt the relay connection in the following manner when the terminal device and the target device are both symmetrical: when the terminal device and the target device are both symmetrical, determine whether there is a second idle device; when there is a second idle device, establish a point-to-point connection based on the first idle device and the second idle device, and interrupt the relay connection.
[0200] As an optional scheme, the above-mentioned device is used to determine whether there is a second idle device when the terminal device and the target device are both symmetrical in the following manner: when the terminal device and the target device are both symmetrical, receive a second point-to-point connection request sent by the terminal device; in response to the second point-to-point connection request, obtain the device operation status of the second group of devices, wherein the second group of devices and the target device belong to different local area networks, and the network address translation type corresponding to the second group of idle devices is asymmetric; determine the second group of idle devices from the second group of devices based on the device operation status; send a point-to-point cascade request to the second group of idle devices; determine the device in the second group of idle devices that responds to the point-to-point cascade request as the second idle device, and establish a second penetration connection between the second idle device and the terminal device.
[0201] As an optional solution, the above-mentioned device is used to establish a point-to-point connection based on the first idle device and the second idle device and interrupt the relay connection in the following manner when the second idle device exists: when the second idle device exists, receive a third point-to-point connection establishment request sent by the second idle device; in response to the third point-to-point connection establishment request, obtain the device operation status of each device in the first group of devices, wherein the first group of devices and the target device belong to the same local area network; determine the first group of idle devices from the first group of devices based on the device operation status; send a third point-to-point connection establishment request to the first group of idle devices; determine the device in the first group of idle devices that responds to the third point-to-point connection establishment request as the first idle device, and establish the third point-to-point connection between the first idle device and the second idle device. Penetration connection; when the second penetration connection and the third penetration connection are successfully established, sending a second address exchange request to the target device and the second idle device respectively, wherein the second address exchange request is used to request the target device and the first idle device to exchange address information with each other through the second idle device; when the second idle device sends the second address exchange request to the first idle device, and the target device and the first idle device complete the exchange of address information, receiving the login request sent by the target device and the first idle device to complete the login of the target device and the first idle device, switching the relay connection to a point-to-point connection between the target device and the first idle device, and interrupting the relay connection, wherein when the target device and the first idle device complete the login, a point-to-point connection is automatically established.
[0202] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0203] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0204] According to one aspect of the present application, a computer program product is provided. The computer program product includes a computer program.
[0205] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0206] Figure 8 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0207] It should be noted that Figure 8 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0208] like Figure 8 As shown, the computer system 800 includes a central processing unit 801 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 802 (ROM) or the program loaded from the storage part 808 to the random access memory 803 (RAM). Various programs and data required for system operation are also stored in the random access memory 803. The central processing unit 801, the read-only memory 802 and the random access memory 803 are connected to each other through a bus 804. The input / output interface 805 (Input / Output interface, i.e., I / O interface) is also connected to the bus 804.
[0209] The following components are connected to the input / output interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0210] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processor 801, various functions defined in the system of the present application are executed.
[0211] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processor 801, various functions provided by the embodiment of the present application are performed.
[0212] According to another aspect of the embodiment of the present application, an electronic device for implementing the above connection establishment method is also provided. The electronic device may be Figure 1 The terminal device or server shown in the figure. This embodiment is described by taking the electronic device as a terminal device as an example. Fig. 9 As shown, the electronic device includes a memory 902 and a processor 904, wherein the memory 902 stores a computer program, and the processor 904 is configured to execute the steps of at least one of the above method embodiments through the computer program.
[0213] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0214] Optionally, in this embodiment, the above-mentioned processor can be configured to execute the methods in each embodiment of the present application through a computer program.
[0215] Alternatively, a person skilled in the art may understand that: Fig. 9 The structure shown is for illustration only. Fig. 9 The structure of the electronic device is not limited. Fig. 9 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig. 9 Different configurations shown.
[0216] Among them, the memory 902 can be used to store software programs and modules, such as the program instructions / modules corresponding to the connection establishment method and device in the embodiments of the present application. The processor 904 executes various functional applications and data processing by running the software programs and modules stored in the memory 902, that is, realizing the above-mentioned connection establishment method. The memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 902 may further include a memory remotely located relative to the processor 904, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 902 can be specifically, but not limited to, used for information such as device information. As an example, such as Fig. 9As shown, the memory 902 may include but is not limited to the receiving module 702, the acquiring module 704 and the processing module 706 in the connection establishment device. In addition, it may also include but is not limited to other module units in the connection establishment device, which will not be repeated in this example.
[0217] Optionally, the transmission device 906 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 906 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 906 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0218] In addition, the electronic device further includes: a display 908 for displaying the data transmitted by the target device; and a connection bus 910 for connecting various module components in the electronic device.
[0219] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. The nodes may form a peer-to-peer network, and any form of computing device, such as a server, terminal or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0220] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the connection establishment method provided in various optional implementations of the above-mentioned connection establishment aspects.
[0221] Optionally, in this embodiment, the above-mentioned computer-readable storage medium can be configured to store data for executing the methods in various embodiments of the present application.
[0222] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0223] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0224] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for one or more electronic devices to execute all or part of the steps of the methods described in each embodiment of the present application.
[0225] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0226] In the several embodiments provided in the present application, it should be understood that the disclosed application can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0227] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0228] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0229] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A connection establishment method, characterized in that: include: Receiving a data request message sent by a terminal device, wherein the data request message is used to request to obtain data of a target device, and the terminal device and the target device belong to different local area networks; In response to the data request message, establish a relay connection between the terminal device and the target device, and obtain network address translation types corresponding to the terminal device and the target device, wherein the network address translation type indicates a behavior mode of a device processing a data packet; Based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, a point-to-point connection is established between the terminal device and the target device, and the relay connection is interrupted, wherein, when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is realized by exchanging addresses between the target device and a first idle device, and the first idle device and the target device belong to the same local area network, and when the terminal device and the target device are both symmetric, the point-to-point connection is realized by exchanging addresses between the target device, the first idle device and the second idle device, and the second idle device and the target device belong to different local area networks, and the network address translation type of the second idle device is asymmetric.
2. The method according to claim 1, characterized in that The step of establishing a point-to-point connection between the terminal device and the target device based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, and interrupting the relay connection, comprises: In the case where at least one of the terminal device and the target device is of the asymmetric type, establishing the point-to-point connection based on the first idle device, and interrupting the relay connection; In the case that both the terminal device and the target device are of the symmetric type, the point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is interrupted.
3. The method according to claim 2, characterized in that The step of establishing the point-to-point connection based on the first idle device and interrupting the relay connection when at least one of the terminal device and the target device is not of the symmetric type includes: In a case where at least one of the terminal device and the target device is not of the symmetric type, receiving a first point-to-point connection establishment request sent by the terminal device; In response to the first point-to-point connection establishment request, obtaining a device operation status of each device in a first group of devices, wherein the first group of devices and the target device belong to the same local area network; Determining a first group of idle devices from the first group of devices based on the device operating status; Sending the first point-to-point connection establishment request to the first group of idle devices; Determine a device in the first group of idle devices that responds to the first point-to-point connection establishment request as the first idle device, and establish a first penetration connection between the first idle device and the terminal device; When the first penetration connection is successfully established, sending a first address exchange request to the target device and the first idle device respectively, wherein the first address exchange request is used to request the target device and the first idle device to exchange address information with each other; When the target device and the first idle device complete the exchange of address information, a login request sent by the target device and the first idle device is received to complete the login of the target device and the first idle device, the relay connection is switched to a point-to-point connection between the target device and the first idle device, and the relay connection is interrupted, wherein the point-to-point connection is automatically established when the target device and the first idle device complete the login.
4. The method according to claim 2, characterized in that: In the case where both the terminal device and the target device are of the symmetric type, establishing the point-to-point connection based on the first idle device and the second idle device, and interrupting the relay connection, comprises: In the case that the terminal device and the target device are both of the symmetric type, determining whether there is a second idle device; In the case where the second idle device exists, the point-to-point connection is established based on the first idle device and the second idle device, and the relay connection is terminated.
5. The method according to claim 4, characterized in that When both the terminal device and the target device are of the symmetric type, determining whether the second idle device exists includes: In a case where both the terminal device and the target device are of the symmetric type, receiving a second point-to-point connection establishment request sent by the terminal device; In response to the second point-to-point connection establishment request, obtaining the device operation status of the second group of devices, wherein the second group of devices and the target device belong to different local area networks, and the network address translation type corresponding to the second group of idle devices is the asymmetric type; Determining a second group of idle devices from the second group of devices based on the device operating status; Sending a point-to-point cascade request to the second group of idle devices; A device in the second group of idle devices that responds to the point-to-point cascade request is determined as the second idle device, and a second penetration connection is established between the second idle device and the terminal device.
6. The method according to claim 5, characterized in that The step of establishing the point-to-point connection based on the first idle device and the second idle device and interrupting the relay connection in the presence of the second idle device includes: In the case where the second idle device exists, receiving a third point-to-point connection establishment request sent by the second idle device; In response to the third point-to-point connection establishment request, obtaining a device operation status of each device in a first group of devices, wherein the first group of devices and the target device belong to the same local area network; Determining a first group of idle devices from the first group of devices based on the device operating status; Sending the third point-to-point connection establishment request to the first group of idle devices; Determine a device in the first group of idle devices that responds to the third point-to-point connection establishment request as the first idle device, and establish a third penetration connection between the first idle device and the second idle device; When both the second penetration connection and the third penetration connection are successfully established, sending a second address exchange request to the target device and the second idle device respectively, wherein the second address exchange request is used to request the target device and the first idle device to exchange address information with each other through the second idle device; When the second idle device sends the second address exchange request to the first idle device and the target device and the first idle device complete the address information exchange, receive the login request sent by the target device and the first idle device to complete the login of the target device and the first idle device, switch the relay connection to a point-to-point connection between the target device and the first idle device, and interrupt the relay connection, wherein the point-to-point connection is automatically established when the target device and the first idle device complete the login.
7. A connection establishment device, characterized in that: include: A receiving module, used for receiving a data request message sent by a terminal device, wherein the data request message is used for requesting to obtain data of a target device, and the terminal device and the target device belong to different local area networks; an acquisition module, configured to establish a relay connection between the terminal device and the target device in response to the data request message, and acquire network address translation types corresponding to the terminal device and the target device, wherein the network address translation type indicates a behavior mode of a device processing a data packet; A processing module, used to establish a point-to-point connection between the terminal device and the target device, and interrupt the relay connection based on whether the network address translation types corresponding to the terminal device and the target device are both symmetric, wherein, when at least one of the terminal device and the target device is asymmetric, the point-to-point connection is achieved by exchanging addresses between the target device and a first idle device, and the first idle device and the target device belong to the same local area network; when the terminal device and the target device are both symmetric, the point-to-point connection is achieved by exchanging addresses between the target device, the first idle device and the second idle device, and the second idle device and the target device belong to different local area networks, and the network address translation type of the second idle device is asymmetric.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein the computer program can be executed by an electronic device to perform the method described in any one of claims 1 to 6.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.
Citation Information
Patent Citations
UDT-based system and method for realizing network address translator traversal
CN101895590A
Network crossing method, device and system
CN103391334A
VoIP voice monitoring method and VoIP voice monitoring system based on symmetric NAT
CN105100086A
Method and equipment for determining NAT (Network Address Translation) traversal strategy
CN118056391A
Cited By
Audio and video data point-to-point real-time transmission method and system and readable storage medium
CN121585365A
Audio transmission control method based on cross-network address translation and related device
CN122247924A