A method, apparatus, device, and storage medium for traversing network address translation.

By optimizing the STUN and mDNS protocols through resolution and port prediction models, rapid network address translation and automatic device discovery were achieved, solving the problem of NAT traversal failure and improving communication efficiency and stability.

CN119766772BActive Publication Date: 2026-01-06SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510261930.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-06
Publication Date
2026-01-06
Estimated Expiration
2045-03-06

AI Technical Summary

Technical Problem

Existing STUN and mDNS protocols have limitations in complex network environments, leading to NAT traversal failures and unstable communication, especially in scenarios involving cross-subnets or NAT obstruction, which increases communication latency and packet loss rate.

Method used

By parsing the request and response packets of user devices, the NAT type is identified, and port prediction is performed using a port prediction model. Combined with device discovery requests and information exchange, a stable communication link is established, and the STUN and mDNS protocols are optimized to achieve fast network address translation and automatic device discovery.

Benefits of technology

It improves the efficiency and stability of network address translation, reduces communication latency and packet loss rate, and provides a smooth communication experience, effective in home, enterprise, and mobile network environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766772B_ABST
    Figure CN119766772B_ABST
Patent Text Reader

Abstract

The application discloses a network address conversion traversal method and device, equipment and a storage medium, and relates to the field of network communication, and comprises the following steps: analyzing a user equipment request packet and a corresponding response packet to determine the information type of network address conversion information of the user equipment based on obtained data information; performing port prediction based on the information type and the network address conversion information through a port prediction model, so that the user equipment connects a target public network corresponding to a network address conversion device based on a predicted target prediction port combination; if the connection is successful, a device discovery request sent by the user equipment is broadcasted, and after a corresponding to-be-matched device is determined, the device information of the user equipment and the to-be-matched device is exchanged, so that a communication link between the user equipment and the to-be-matched device is established according to the device information. Therefore, the network address can be quickly converted and the device can be automatically discovered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network communication, and in particular to a network address translation traversal method, apparatus, device, and storage medium. Background Technology

[0002] With the rapid development of the Internet of Things (IoT), seamless connectivity and efficient communication between smart devices have become crucial for industry development. However, the existence of NAT (Network Address Translation) makes direct communication between devices complex and unstable, especially in communication scenarios involving cross-subnets or NAT. In such cases, communication between devices often needs to be forwarded through an intermediate server, which not only increases communication latency and cost but also reduces reliability and security.

[0003] Existing technologies typically address communication challenges in NAT environments using STUN (Simple Traversal of UDP Through NAT; UDP stands for User Datagram Protocol) and mDNS (Multicast DNS; DNS stands for Domain Name System) protocols. However, existing STUN and mDNS protocols still have limitations when dealing with complex network environments. The STUN protocol may not be accurate enough in detecting certain types of NAT, leading to traversal failures, while the mDNS protocol is mainly suitable for local area networks and is not effective for communication scenarios across subnets or where NAT obstacles exist. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a network address translation traversal method, apparatus, device, and storage medium, which can achieve rapid network address translation and automatic device discovery, thereby reducing communication latency and packet loss rate, and thus improving communication efficiency and stability. The specific solution is as follows:

[0005] In a first aspect, this application discloses a network address translation traversal method, applied to a network address translation device, comprising:

[0006] The request and response packets of the preset network protocol corresponding to the user equipment are parsed to determine the information type of the network address translation information corresponding to the user equipment based on the parsed data information;

[0007] The information type is input into the port prediction model in the preset traversal strategy library. The port prediction model performs port prediction based on the information type and the network address translation information to obtain the target predicted port combination corresponding to the user equipment, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target predicted port combination.

[0008] If the user equipment successfully connects to the target public network, it broadcasts the device discovery request sent by the user equipment, and after determining the device to be matched that responds to the device discovery request, it exchanges device information of the user equipment and the device to be matched.

[0009] A communication link is established between the user equipment and the device to be matched based on the device information, so as to conduct communication between the user equipment and the device to be matched based on the communication link.

[0010] Optionally, the parsing of request packets and response packets of a preset network protocol corresponding to the user equipment, to determine the information type of network address translation information corresponding to the user equipment based on the parsed data information, includes:

[0011] If a request packet of a preset network protocol is received from a user equipment, the request packet is parsed to determine the first data information corresponding to the request packet of the preset network protocol.

[0012] Determine the actual value of the first data information in the target public network corresponding to the local location, and use the actual value of the data as the second data information corresponding to the response packet of the preset network protocol;

[0013] The first data information and the second data information are compared. If the comparison result indicates that the port number corresponding to the first data information and the source address are the same as the port number corresponding to the second data information and the source address, and the second data information contains response data with different addresses, then the information type of the network address translation information corresponding to the user equipment is determined to be full cone.

[0014] If the second data information contains only response data with the same address, then the information type of the network address translation information corresponding to the user equipment is determined to be restricted cone.

[0015] Optionally, the step of inputting the information type into a port prediction model in a preset traversal strategy library, and using the port prediction model to perform port prediction based on the information type and the network address translation information to obtain a target predicted port combination corresponding to the user equipment, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target predicted port combination, further includes:

[0016] Collect interaction data between each user device and the preset network protocol; the interaction data includes data in the request and response packets corresponding to each user device and the connection success rate corresponding to each user device.

[0017] The interaction data is preprocessed, and features are extracted from the preprocessed interaction data to obtain the feature data corresponding to the preprocessed interaction data.

[0018] The pre-trained model is trained using the feature data to obtain a port prediction model, and the port prediction model is integrated into a preset traversal strategy library.

[0019] Optionally, the step of inputting the information type into a port prediction model in a preset traversal strategy library, and using the port prediction model to perform port prediction based on the information type and the network address translation information to obtain a target predicted port combination corresponding to the user equipment, includes:

[0020] Initialize the preset traversal strategy library and input the information type into the port prediction model in the preset traversal strategy library. The port prediction model matches the corresponding target network address translation traversal strategy in the preset traversal strategy library based on the information type, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target network address translation traversal strategy.

[0021] If the user equipment fails to connect to the target public network corresponding to the network address translation device based on the target network address translation traversal strategy, then the port prediction model performs port prediction based on the information type and the network address translation information to obtain the target predicted port combination corresponding to the user equipment.

[0022] Optionally, broadcasting the device discovery request sent by the user equipment, and after determining the device to be matched that responds to the device discovery request, exchanging device information of the user equipment and the device to be matched, includes:

[0023] Broadcast the device discovery request sent by the user equipment, and filter and sort the received response messages to determine the target response message that corresponds to the device discovery request among the response messages;

[0024] The device to be matched corresponding to the target response message is determined, and the first device information corresponding to the user equipment and the second device information corresponding to the device to be matched are obtained respectively.

[0025] The first device information and the second device information are encrypted using a preset encryption algorithm to obtain first encrypted device information corresponding to the first device information and second encrypted device information corresponding to the second device information.

[0026] The first encrypted device information is sent to the device to be matched, and the second encrypted device information is sent to the user equipment.

[0027] Optionally, establishing a communication link between the user equipment and the device to be matched based on the device information includes:

[0028] Configure the Internet communication protocol stack between the user equipment and the device to be matched, so as to establish a communication link between the user equipment and the device to be matched based on the network address and port number in the device information through the Internet communication protocol stack.

[0029] Optionally, the network address translation traversal method further includes:

[0030] Real-time monitoring of communication metrics of the user equipment and the device to be matched communicating through the communication link;

[0031] If the communication indicators indicate that there is data packet loss, a data retransmission request is sent from the data receiver in the user equipment and the matching device to the data sender in order to retransmit the data.

[0032] If the communication metrics indicate that the communication traffic of the communication link reaches a preset traffic threshold, then the backup communication link between the user equipment and the device to be matched is activated for load balancing.

[0033] Secondly, this application discloses a network address translation traversal device, applied to a network address translation device, comprising:

[0034] The information type determination module is used to parse the request packets and response packets of the preset network protocol corresponding to the user equipment, so as to determine the information type of the network address translation information corresponding to the user equipment based on the parsed data information;

[0035] The local area network connection module is used to input the information type into the port prediction model in the preset traversal strategy library, so that the port prediction model performs port prediction based on the information type and the network address translation information to obtain the target predicted port combination corresponding to the user equipment, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target predicted port combination.

[0036] The information exchange module is used to broadcast a device discovery request sent by the user equipment if the user equipment successfully connects to the target public network, and exchange device information of the user equipment and the device to be matched after determining the device to be matched that responds to the device discovery request.

[0037] A communication link establishment module is used to establish a communication link between the user equipment and the device to be matched based on the device information, so as to conduct communication between the user equipment and the device to be matched based on the communication link.

[0038] Thirdly, this application discloses an electronic device, including:

[0039] Memory, used to store computer programs;

[0040] A processor is used to execute the computer program to implement the network address translation traversal method as described above.

[0041] Fourthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the network address translation traversal method as described above.

[0042] In this application, request packets and response packets of a preset network protocol corresponding to a user equipment (UE) can be parsed to determine the information type of network address translation (NAT) information corresponding to the UE based on the parsed data. The information type is input into a port prediction model in a preset traversal strategy library to perform port prediction based on the information type and the NAT information, thereby obtaining a target predicted port combination corresponding to the UE. This allows the UE to connect to the target public network corresponding to the NAT device based on the target predicted port combination. If the UE successfully connects to the target public network, a device discovery request sent by the UE is broadcast. After identifying a device to be matched that responds to the device discovery request, device information of the UE and the device to be matched is exchanged. A communication link is established between the UE and the device to be matched based on the device information, and communication between the UE and the device to be matched is performed based on the communication link.

[0043] Therefore, the method of this application can parse user equipment request packets and corresponding response packets to determine the information type of network address translation (NAT) information of the user equipment based on the obtained data information. A port prediction model is used to predict ports based on the information type and NAT information, enabling the user equipment to connect to the target public network corresponding to the NAT device based on the predicted target port combination. If the connection is successful, a device discovery request sent by the user equipment is broadcast. After identifying the corresponding matching device, device information of the user equipment and the matching device is exchanged to establish a communication link between the user equipment and the matching device. This enables rapid NAT translation and automatic device discovery, reducing communication latency and packet loss rate, thereby improving communication efficiency and stability. It provides users with a smooth communication experience in home networks, enterprise networks, and mobile network environments. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0045] Figure 1 This is a flowchart of a network address translation traversal method disclosed in this application;

[0046] Figure 2 This application discloses a specific network address translation traversal method flowchart;

[0047] Figure 3 This is a schematic diagram of the architecture of a network address translation traversal method disclosed in this application;

[0048] Figure 4 This is a schematic diagram of a network address translation traversal device disclosed in this application;

[0049] Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0050] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0051] In existing technologies, STUN and mDNS protocols are commonly used to solve communication problems in NAT environments. However, the existing STUN and mDNS protocols still have certain limitations when dealing with complex network environments. The STUN protocol may not be accurate enough in detecting certain types of NAT, leading to traversal failures. The mDNS protocol is mainly suitable for local area networks, and its effect is not good for communication scenarios across subnets or where there is NAT obstruction.

[0052] To overcome the aforementioned technical problems, this application discloses a network address translation traversal method, apparatus, device, and storage medium, which can integrate and optimize the STUN protocol and mDNS protocol, and realize fast network address translation and automatic device discovery based on the port prediction mechanism, so as to reduce communication latency and packet loss rate, thereby improving communication efficiency and stability.

[0053] See Figure 1 As shown, this embodiment of the invention discloses a network address translation traversal method, applied to a network address translation device, including:

[0054] Step S11: Parse the request packet and response packet of the preset network protocol corresponding to the user equipment, so as to determine the information type of the network address translation information corresponding to the user equipment based on the parsed data information.

[0055] In this embodiment, it is necessary to parse the user equipment's request packet and corresponding response packet to determine the information type of the user equipment's network address translation information based on the parsed data. Specifically, during NAT traversal, it is necessary to identify the NAT type. The core of intelligent NAT type identification lies in utilizing the characteristics of the STUN protocol. By sending a request packet of a specific format to the public network and analyzing the NAT type information in the returned response packet, accurate identification of the NAT type can be achieved. Therefore, the user equipment can send a request packet with a preset network protocol, where the preset network protocol is the STUN protocol, to the NAT device using a NAT type detection algorithm. If the NAT device receives the STUN request packet sent by the user equipment, it can parse the request packet using the NAT type detection algorithm to determine the first data information corresponding to the STUN request packet. It should be noted that the STUN request packet contains a set of specific fields. These fields may be modified or retained when passing through the NAT device, and the response packet contains the actual values ​​of these fields on the public network. Therefore, it is necessary to determine the actual data value of the first data information in the target public network corresponding to the local NAT device and use the actual data value as the second data information corresponding to the STUN response packet. It should be further explained that the NAT type detection algorithm is deployed on every device that needs to interact, and it is capable of sending STUN request packets, receiving and analyzing response packets, and determining the NAT type based on the response content.

[0056] Furthermore, the NAT type of the user device can be determined by analyzing the differences between the response packet and the request packet. Therefore, the first data information and the second data information can be compared. If the comparison results indicate that the port number and source address corresponding to the first data information and the port number and source address corresponding to the second data information are the same, and the second data information contains response data from different addresses (i.e., responses from different IP addresses can be received), then the NAT type is full cone. On the other hand, if the second data information only contains response data from the same address (i.e., responses from the same IP address and port can only be received), then the NAT type is likely limited cone. In this way, the method of this application can quickly identify the NAT type of the device, thereby improving the efficiency of network address translation traversal, and thus improving the efficiency of NAT traversal.

[0057] Step S12: Input the information type into the port prediction model in the preset traversal strategy library, so that the port prediction model can perform port prediction based on the information type and the network address translation information to obtain the target predicted port combination corresponding to the user equipment, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target predicted port combination.

[0058] In this embodiment, port prediction is performed using a port prediction model from a preset traversal strategy library, based on the analyzed information type, i.e., the NAT type. Before port prediction, if the pre-trained model is not trained as a port prediction model, it needs to be trained and integrated into the preset traversal strategy library. Specifically, this requires collecting a large amount of STUN protocol interaction data, which can be collected from interaction data between various user devices and preset network protocols. This data can come from actual NAT traversal scenarios, including successful and failed connection attempts. The interaction data is then preprocessed, including removing duplicate data, handling missing values, and formatting data to ensure data quality. Feature extraction is then performed on the preprocessed interaction data to obtain corresponding feature data, such as NAT type, source port number, target port number, and connection success rate. Finally, the pre-trained model is trained using the feature data to obtain the port prediction model, which is then integrated into the preset traversal strategy library. It should be noted that when training a pre-trained model, machine learning algorithms such as decision trees and neural networks can be used for model training. The extracted feature data can be used to train the model, and the model performance can be evaluated through methods such as cross-validation to ensure that the model has good generalization ability and prediction accuracy.

[0059] Furthermore, when performing port prediction, it is necessary to initialize a preset traversal strategy library and input the analyzed information types into the port prediction model in the preset traversal strategy library. After receiving the information type, the port prediction model can match the corresponding traditional NAT traversal strategy in the preset traversal strategy library according to the information type, such as STUN traversal strategy and TURN (Traversal Using Relay NAT) traversal strategy, as the target network address translation traversal strategy. The target device can then connect to the target public network corresponding to the network address translation device according to the determined target network address translation traversal strategy. If the connection fails to be successful according to the matched traversal strategy, the port prediction model needs to perform port prediction based on the information type and network address translation information. It should be noted that when performing port prediction, possible port combinations can be predicted based on the current NAT type, source port number, and other information, so that the user device can connect to the target public network corresponding to the network address translation device based on the target predicted port combination.

[0060] Step S13: If the user equipment successfully connects to the target public network, it broadcasts the device discovery request sent by the user equipment, and after determining the device to be matched that responds to the device discovery request, it exchanges device information of the user equipment and the device to be matched.

[0061] In this embodiment, if the user equipment successfully connects to the public network, device matching can be performed by broadcasting device discovery requests sent by the user equipment. Specifically, the device discovery request can be broadcast within the local area network via multicast UDP (User Datagram Protocol) packets according to the mDNS protocol. mDNS sends multicast messages at fixed time intervals and listens for responses from other devices. However, to avoid traditional mDNS ignoring network fluctuations and causing network congestion and message conflicts, the sending interval can be automatically adjusted according to network load to improve the efficiency of device discovery. Furthermore, since multiple devices may respond, the received response messages need to be filtered and sorted to determine the target response message corresponding to the device discovery request. Specifically, the received multicast messages need to be prioritized and quickly filtered, processing only messages related to the user equipment. Additionally, the caching mechanism can be optimized to store discovered device information in a local cache and retrieve it quickly when needed, reducing unnecessary network requests and response delays. It should be noted that if network instability or temporary device unavailability occurs, automatic retry via broadcast, timeout detection, and error code parsing can be performed, thereby improving the efficiency and reliability of device discovery in this application.

[0062] Furthermore, if the target response message is identified, the matching device corresponding to the target response message needs to be determined. The first device information corresponding to the user device and the second device information corresponding to the matching device are then obtained. The first encrypted device information is then sent to the matching device, and the second encrypted device information is sent to the user device. It should be noted that when transmitting device information, a new transmission must be performed according to the defined standard device information format. In this embodiment, the standard device information format is as follows: basic information such as IP address, port number, device type, and service name, as well as advanced information such as possible security authentication and encryption keys. Furthermore, encryption technology is required to ensure the security and integrity of the information when exchanging device information. Strong encryption algorithms, such as AES (Advanced Encryption Standard), can be used for data encryption. Different layers of data can be encrypted, such as TLS (Transport Layer Security) and SSL (Secure Socket Layer), to protect the information during transmission. Digital signatures or hash verification techniques are used to verify the integrity of the information.

[0063] Next, a secure key management system needs to be established to ensure the security of key generation, distribution, storage, and destruction processes. A key exchange protocol, such as the Diffie-Hellman (DH) key exchange algorithm, should be used to securely negotiate session keys. The two devices establishing the communication link can use HMAC (Hash-based Message Authentication Code) or similar mechanisms to verify data integrity. Before sending data, the sender hashes the data using a shared key and appends the hash value to the data. After receiving the data, the receiver recalculates the hash value using the same key and algorithm and compares it with the received hash value to verify data integrity. For scenarios requiring verification of data source authenticity, digital signature technology can be used. The sender signs the data digest using their private key and sends the signature along with the data to the receiver. The receiver uses the corresponding public key to verify the validity of the signature, thus confirming that the data indeed originated from a trusted sender. This effectively guarantees the security and integrity of data during communication.

[0064] Step S14: Establish a communication link between the user equipment and the device to be matched based on the device information, so as to conduct communication between the user equipment and the device to be matched based on the communication link.

[0065] In this embodiment, a communication link needs to be established between the user device and the device to be matched based on the device information. Specifically, an Internet communication protocol stack needs to be configured between the user device and the device to be matched, and a TCP / IP protocol stack needs to be configured to use the correct IP address and port number. This allows the communication link between the user device and the device to be matched to be established based on the network address and port number in the device information via the Internet communication protocol stack. It should be noted that, to ensure the active status of the communication link, a heartbeat mechanism can be introduced to periodically check the activity status of the communication link. Furthermore, if a communication link failure occurs, a notification is generated to inform the user and relevant maintenance personnel to restore the communication link.

[0066] Therefore, the method of this application can parse user equipment request packets and corresponding response packets to determine the information type of network address translation (NAT) information of the user equipment based on the obtained data information. A port prediction model is used to predict ports based on the information type and NAT information, enabling the user equipment to connect to the target public network corresponding to the NAT device based on the predicted target port combination. If the connection is successful, a device discovery request sent by the user equipment is broadcast. After identifying the corresponding matching device, device information of the user equipment and the matching device is exchanged to establish a communication link between the user equipment and the matching device. This enables rapid NAT translation and automatic device discovery, reducing communication latency and packet loss rate, thereby improving communication efficiency and stability. It provides users with a smooth communication experience in home networks, enterprise networks, and mobile network environments.

[0067] See Figure 2 As shown, this embodiment of the invention discloses a network address translation traversal method, applied to a network address translation device, including:

[0068] Step S21: Monitor in real time the communication indicators of user equipment and the device to be matched communicating through the communication link.

[0069] In this embodiment, if it is necessary to monitor communication between devices, key indicators during network communication, such as packet loss rate, latency, and bandwidth utilization, can be monitored in real time. Thresholds can be set, and anomaly alarms can be triggered when indicators exceed the thresholds. Furthermore, it is necessary to collect and analyze log information during network communication to identify potential abnormal patterns and root causes. Specifically, a baseline of normal network communication behavior needs to be established by analyzing historical log data. This baseline includes key indicators such as communication frequency, packet size, and communication protocols. Then, network communication logs are monitored in real time and compared with the baseline to determine which indicators are abnormal and to analyze the malicious behavior patterns and abnormal activities corresponding to these abnormal indicators. In-depth analysis of detected abnormal behaviors can be performed to determine their nature and scope of impact, identify the source and target of the abnormal behaviors, and trace attack paths. Finally, based on the anomaly analysis results, the root cause of the problem can be located, such as configuration errors or malware infection, and the execution process and results of response measures can be recorded to provide a reference for subsequent security decisions.

[0070] Step S22: If the communication indicator indicates that there is data packet loss, a data retransmission request is sent from the data receiver in the user equipment and the matching device to the data sender to retransmit the data.

[0071] In this embodiment, if packet loss occurs due to network congestion or equipment failure, an automatic retransmission mechanism is employed to ensure complete data transmission. When the receiver detects data loss, it sends a retransmission request to the sender, which then retransmits the lost data packets according to the request. It should be noted that retransmission waiting time can be dynamically calculated based on network latency using algorithms such as exponential backoff, prioritizing the retransmission of critical data, such as keyframes in video. Non-critical data can be temporarily abandoned for retransmission and will be retransmitted when network conditions improve.

[0072] Step S23: If the communication index indicates that the communication traffic of the communication link reaches a preset traffic threshold, then the backup communication link between the user equipment and the device to be matched is activated for load balancing.

[0073] In this embodiment, if the current communication link reaches a preset traffic threshold, it indicates that the current network load is high. A backup link can be activated for inter-device network communication, and load balancing technology can be used to distribute communication traffic across multiple nodes or links to improve communication stability and efficiency. This effectively ensures the stability of inter-device communication.

[0074] In this embodiment, communication metrics between the user equipment and the device to be matched via the communication link can be monitored in real time. If the communication metrics indicate data packet loss, a data retransmission request is sent from the data receiver in both the user equipment and the device to be matched to the data sender to re-transmit the data. If the communication metrics indicate that the communication traffic of the communication link reaches a preset traffic threshold, a backup communication link between the user equipment and the device to be matched is activated for load balancing. This effectively detects abnormal communication between devices, retransmits data when abnormalities occur, and activates a backup link for load balancing when necessary, thereby significantly improving the stability of communication between devices.

[0075] As a preferred embodiment, such as Figure 3 As shown, a modular design approach can be adopted, dividing the various functional modules of the technical solution into independent components or services. Each module is responsible for specific functions or business logic and interacts and collaborates with other modules through standardized interfaces. Specifically, interface standardization can be implemented to ensure smooth data exchange and communication between different modules or services. Furthermore, a plug-in extension mechanism is supported, allowing developers or users to develop new plug-ins or modules according to actual needs and integrate the newly developed modules into the technical solution.

[0076] It should be noted that, such as Figure 3 As shown, the modules in this application are described as follows: The high-efficiency and stable communication module improves communication efficiency and stability by optimizing STUN and mDNS protocols, reducing communication latency and packet loss rate, and ensuring smooth and reliable data transmission; the security and privacy protection module ensures data transmission security and user privacy protection by employing encryption technology and verification mechanisms to ensure data security and integrity during transmission, preventing data leakage and tampering; the widely compatible expansion module supports various network devices, operating systems, and communication protocols, and adopts a modular design approach to ensure the solution can easily integrate into various network environments and adapt to future technological and market changes; the low-cost and easy-to-deploy module reduces deployment costs and improves usability by simplifying deployment processes, reducing hardware and software requirements, and providing detailed technical documentation and user guides to help users get started quickly and reduce overall costs; the IoT development promotion module enables the interconnection of various smart devices based on the NAT traversal method in this application, thereby promoting innovation and development in areas such as smart homes and smart cities.

[0077] In this way, by strictly adhering to standards and specifications, adopting a multi-platform support strategy, establishing a comprehensive testing system, and providing detailed technical documentation and user guides, we can ensure the broad compatibility of the technical solution with existing equipment and protocols. At the same time, through modular design, interface standardization, plug-in mechanisms, and performance optimization and expansion, we have built a flexible, open, and easily expandable technical architecture, laying a solid foundation for future technology upgrades and functional expansion.

[0078] See Figure 4 As shown, this embodiment of the invention discloses a network address translation traversal method, applied to a network address translation device, including:

[0079] The information type determination module 11 is used to parse the request packet and response packet of the preset network protocol corresponding to the user equipment, so as to determine the information type of the network address translation information corresponding to the user equipment based on the parsed data information;

[0080] The local area network connection module 12 is used to input the information type into the port prediction model in the preset traversal strategy library, so that the port prediction model performs port prediction based on the information type and the network address translation information to obtain the target predicted port combination corresponding to the user equipment, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target predicted port combination.

[0081] The information exchange module 13 is used to broadcast a device discovery request sent by the user equipment if the user equipment successfully connects to the target public network, and exchange device information of the user equipment and the device to be matched after determining the device to be matched that responds to the device discovery request.

[0082] The communication link establishment module 14 is used to establish a communication link between the user equipment and the device to be matched based on the device information, so as to conduct communication between the user equipment and the device to be matched based on the communication link.

[0083] In this application, request packets and response packets of a preset network protocol corresponding to a user equipment (UE) can be parsed to determine the information type of network address translation (NAT) information corresponding to the UE based on the parsed data. The information type is input into a port prediction model in a preset traversal strategy library to perform port prediction based on the information type and the NAT information, thereby obtaining a target predicted port combination corresponding to the UE. This allows the UE to connect to the target public network corresponding to the NAT device based on the target predicted port combination. If the UE successfully connects to the target public network, a device discovery request sent by the UE is broadcast. After identifying a device to be matched that responds to the device discovery request, device information of the UE and the device to be matched is exchanged. A communication link is established between the UE and the device to be matched based on the device information, and communication between the UE and the device to be matched is performed based on the communication link. Therefore, the method of this application can parse user equipment request packets and corresponding response packets to determine the information type of network address translation (NAT) information of the user equipment based on the obtained data information. A port prediction model is used to predict ports based on the information type and NAT information, enabling the user equipment to connect to the target public network corresponding to the NAT device based on the predicted target port combination. If the connection is successful, a device discovery request sent by the user equipment is broadcast. After identifying the corresponding matching device, device information of the user equipment and the matching device is exchanged to establish a communication link between the user equipment and the matching device. This enables rapid NAT translation and automatic device discovery, reducing communication latency and packet loss rate, thereby improving communication efficiency and stability. It provides users with a smooth communication experience in home networks, enterprise networks, and mobile network environments.

[0084] In some embodiments, the information type determination module 11 may specifically include:

[0085] The request parsing unit is configured to parse the request packet of the preset network protocol sent by the user equipment to determine the first data information corresponding to the request packet of the preset network protocol if the request packet of the preset network protocol is received.

[0086] An information determination unit is used to determine the actual value of the first data information in the target public network corresponding to the local location, and to use the actual value of the data as the second data information corresponding to the response packet of a preset network protocol;

[0087] The first data type determination unit is used to compare the first data information and the second data information. If the comparison result indicates that the port number corresponding to the first data information is consistent with the source address and the port number corresponding to the second data information is consistent with the source address, and the second data information contains response data with different addresses, then the information type of the network address translation information corresponding to the user equipment is determined to be full cone.

[0088] The second data type determination unit is used to determine that the information type of the network address translation information corresponding to the user equipment is restricted cone if the second data information only contains response data with the same address.

[0089] In some embodiments, the network address translation traversal device may further include:

[0090] A data collection unit is used to collect interaction data between each user device and the preset network protocol; the interaction data includes data in the request and response packets corresponding to each user device and the connection success rate corresponding to each user device.

[0091] A data preprocessing unit is used to preprocess the interactive data and extract features from the preprocessed interactive data to obtain feature data corresponding to the preprocessed interactive data.

[0092] The model integration unit is used to train the pre-trained model using the feature data to obtain the port prediction model, and to integrate the port prediction model into the preset traversal strategy library.

[0093] In some embodiments, the local area network connection module 12 may specifically include:

[0094] The strategy matching unit is used to initialize a preset traversal strategy library and input the information type into the port prediction model in the preset traversal strategy library, so as to match the corresponding target network address translation traversal strategy in the preset traversal strategy library based on the information type by the port prediction model, so that the user equipment can connect to the target public network corresponding to the network address translation device based on the target network address translation traversal strategy.

[0095] The port prediction unit is used to predict the target predicted port combination corresponding to the user equipment if the user equipment fails to connect to the target public network corresponding to the network address translation device based on the target network address translation traversal strategy. This is done by using the port prediction model based on the information type and the network address translation information.

[0096] In some embodiments, the information exchange module 13 may specifically include:

[0097] A request broadcasting unit is used to broadcast a device discovery request sent by the user equipment, and to filter and sort a number of received response messages to determine the target response message that corresponds to the device discovery request among the number of response messages;

[0098] The device information acquisition unit is used to determine the device to be matched corresponding to the target response message, and to acquire the first device information corresponding to the user device and the second device information corresponding to the device to be matched, respectively.

[0099] The information encryption unit is used to encrypt the first device information and the second device information respectively using a preset encryption algorithm to obtain first encrypted device information corresponding to the first device information and second encrypted device information corresponding to the second device information.

[0100] The device information sending unit is used to send the first encrypted device information to the device to be matched, and to send the second encrypted device information to the user equipment.

[0101] In some embodiments, the communication link establishment module 14 may specifically include:

[0102] A communication establishment unit is configured to configure the Internet communication protocol stack between the user equipment and the device to be matched, so as to establish a communication link between the user equipment and the device to be matched based on the network address and port number in the device information through the Internet communication protocol stack.

[0103] In some embodiments, the network address translation traversal device may further include:

[0104] A communication monitoring unit is used to monitor in real time the communication indicators of the user equipment and the device to be matched communicating through the communication link;

[0105] The data retransmission unit is used to send a data retransmission request to the data sender through the data receiver in the user equipment and the matching device if the communication indicator indicates that there is data packet loss, so as to re-transmit the data.

[0106] The backup link activation unit is used to enable the backup communication link between the user equipment and the device to be matched for load balancing if the communication index indicates that the communication traffic of the communication link reaches a preset traffic threshold.

[0107] Furthermore, embodiments of this application also disclose an electronic device, Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0108] Figure 5 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the network address translation traversal method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0109] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0110] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon can include an operating system 221, computer programs 222, etc., and the storage method can be temporary storage or permanent storage.

[0111] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the network address translation traversal method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.

[0112] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned network address translation traversal method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0113] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0114] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0115] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0116] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0117] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A network address translation traversal method, characterized by, The application is applied to a network address translation device, comprising: parsing a request packet and a response packet of a preset network protocol corresponding to a user equipment to determine an information type of network address translation information corresponding to the user equipment based on data information obtained by parsing; inputting the information type into a port prediction model in a preset traversal strategy library to perform port prediction based on the information type and the network address translation information by the port prediction model to obtain a target predicted port combination corresponding to the user equipment, so that the user equipment connects a target public network corresponding to the network address translation device based on the target predicted port combination; if the user equipment successfully connects the target public network, broadcasting a device discovery request sent by the user equipment, and exchanging device information of the user equipment and a to-be-matched device after determining the to-be-matched device responding to the device discovery request; establishing a communication link between the user equipment and the to-be-matched device according to the device information to perform communication between the user equipment and the to-be-matched device based on the communication link.

2. The network address translation traversal method of claim 1, wherein, The parsing of the request packet and the response packet of the preset network protocol corresponding to the user equipment to determine the information type of the network address translation information corresponding to the user equipment based on the data information obtained by parsing comprises: if a request packet of a preset network protocol sent by a user equipment is received, parsing the request packet to determine first data information corresponding to the request packet of the preset network protocol; determining a data actual value of the first data information in a target public network corresponding to the user equipment locally, and taking the data actual value as second data information corresponding to a response packet of the preset network protocol; comparing the first data information and the second data information, if a comparison result obtained indicates that a port number corresponding to the first data information and a source address are consistent with a port number corresponding to the second data information and a source address, and the second data information contains response data of different addresses, it is determined that the information type of the network address translation information corresponding to the user equipment is full-cone; if the second data information only contains response data of the same address, it is determined that the information type of the network address translation information corresponding to the user equipment is limited-cone.

3. The network address translation traversal method of claim 1, wherein, Before the inputting of the information type into the port prediction model in the preset traversal strategy library to perform port prediction based on the information type and the network address translation information by the port prediction model to obtain the target predicted port combination corresponding to the user equipment, so that the user equipment connects the target public network corresponding to the network address translation device based on the target predicted port combination, further comprising: collecting interaction data corresponding to the preset network protocol of each user equipment; the interaction data comprises data in a request packet and a response packet corresponding to each user data and a connection success rate corresponding to the each user equipment; preprocessing the interaction data, and performing feature extraction on the obtained preprocessed interaction data to obtain feature data corresponding to the preprocessed interaction data; The pre-training model is trained by the feature data to obtain a port prediction model, and the port prediction model is integrated into a preset traversal strategy library.

4. The network address translation traversal method of claim 1, wherein, The information type is input into a port prediction model in the preset traversal strategy library, and the port prediction model is used to perform port prediction based on the information type and the network address translation information to obtain a target predicted port combination corresponding to the user equipment. The preset traversal strategy library is initialized, and the information type is input into the port prediction model in the preset traversal strategy library, so that the port prediction model is used to match a corresponding target network address translation traversal strategy in the preset traversal strategy library based on the information type, so that the user equipment connects a target public network corresponding to the network address translation equipment based on the target network address translation traversal strategy. If the user equipment fails to connect the target public network corresponding to the network address translation equipment based on the target network address translation traversal strategy, the port prediction model is used to perform port prediction based on the information type and the network address translation information to obtain a target predicted port combination corresponding to the user equipment.

5. The network address translation traversal method of claim 1, wherein, The device discovery request sent by the user equipment is broadcasted, and after determining a to-be-matched device responding to the device discovery request, device information of the user equipment and the to-be-matched device is exchanged, including: The device discovery request sent by the user equipment is broadcasted, and a plurality of response messages received are filtered and sorted to determine a target response message corresponding to the device discovery request in the plurality of response messages; A to-be-matched device corresponding to the target response message is determined, and first device information corresponding to the user equipment and second device information corresponding to the to-be-matched device are obtained respectively; The first device information and the second device information are respectively encrypted by a preset encryption algorithm to obtain first encrypted device information corresponding to the first device information and second encrypted device information corresponding to the second device information; The first encrypted device information is sent to the to-be-matched device, and the second encrypted device information is sent to the user equipment.

6. The network address translation traversal method of claim 1, wherein, The communication link between the user equipment and the to-be-matched device is established according to the device information, including: An Internet communication protocol stack between the user equipment and the to-be-matched device is configured to establish a communication link between the user equipment and the to-be-matched device based on a network address and a port number in the device information through the Internet communication protocol stack.

7. The network address translation traversal method according to any of claims 1 to 6, characterized in that, Further comprising: Real-time monitoring of a communication indicator of communication between the user equipment and the to-be-matched device through the communication link; If the communication indicator indicates that there is data packet loss, a data retransmission request is sent by a data receiving side data sender in the user equipment and the to-be-matched device to retransmit data; If the communication indicator indicates that the communication traffic of the communication link reaches a preset traffic threshold, a standby communication link between the user equipment and the to-be-matched device is enabled for load balancing.

8. A network address translation traversal apparatus, characterized by: Applied to a network address translation device, comprising: An information type determination module configured to parse a request packet and a response packet of a preset network protocol corresponding to a user device, and determine an information type of network address translation information corresponding to the user device based on data information obtained by the parsing; A local area network connection module configured to input the information type into a port prediction model in a preset traversal strategy library, and perform port prediction based on the information type and the network address translation information by the port prediction model to obtain a target predicted port combination corresponding to the user device, so that the user device connects a target public network corresponding to the network address translation device based on the target predicted port combination; An information exchange module configured to broadcast a device discovery request sent by the user device if the user device successfully connects the target public network, and exchange device information of the user device and a to-be-matched device after determining the to-be-matched device responding to the device discovery request; A communication link establishment module configured to establish a communication link between the user device and the to-be-matched device according to the device information, and perform communication between the user device and the to-be-matched device based on the communication link.

9. An electronic device, comprising: Comprising: A memory configured to save a computer program; A processor configured to execute the computer program to implement the network address translation traversal method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer program is saved, wherein the computer program is executed by a processor to implement the network address translation traversal method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Symmetrical NAT traversal method and system based on big data analysis

    CN105141711A

  • Method and apparatus for implementing network communication through NAT

    CN1863157A