Network address translation type detection method, system and electronic device

By adopting a two-tier service architecture of STUN server and load balancer server, efficient parallelization of NAT type detection is achieved, which solves the problems of complex interaction and low efficiency in existing technologies and improves the success rate of point-to-point communication in IoT video applications.

CN115766654BActive Publication Date: 2026-04-28ALIBABA CLOUD COMPUTING CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA CLOUD COMPUTING CO LTD
Filing Date
2022-11-02
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, NAT type detection methods involve complex interaction processes and are inefficient, making it difficult to meet the needs of point-to-point communication in IoT video application scenarios.

Method used

A two-tier service architecture consisting of a STUN server and a load balancer is adopted. The load balancer maps multiple public network address information, and the client sends NAT type detection request messages in parallel. The STUN server returns multiple response messages to determine the NAT type.

Benefits of technology

It simplifies the interaction process between STUN servers and clients, improves the efficiency of NAT type detection, reduces cloud platform resource overhead and costs, and increases the success rate of peer-to-peer communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115766654B_ABST
    Figure CN115766654B_ABST
Patent Text Reader

Abstract

The application provides a network address conversion type detection method, system and electronic equipment, relates to the field of cloud computing, and the method comprises the following steps: a STUN server returns reply messages corresponding to a plurality of NAT type detection request messages in response to the plurality of NAT type detection request messages sent in parallel by a client for a plurality of public network address information, so that the client determines the NAT type according to the plurality of reply messages, wherein the local port is determined by mapping the plurality of public network address information through a load balancing server. In the embodiment, the demand of the client for sending the NAT type detection request message in parallel is met through the two-level service architecture of the STUN server and the load balancing server, the interaction process of the STUN server and the client is simplified, and the NAT type detection efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and in particular to a method, system and electronic device for detecting network address translation type. Background Technology

[0002] In IoT video application scenarios, by detecting the Network Address Translation (NAT) type of terminal devices and applications, hole punching strategies can be designed based on the NAT type of the peer to improve the success rate of peer-to-peer communication, reduce the cloud forwarding traffic of video live streaming applications, and effectively reduce cloud platform resource consumption and costs.

[0003] Currently, NAT type detection methods involve complex interaction processes and have low efficiency. Summary of the Invention

[0004] This application provides a network address translation type detection method, system, and electronic device to simplify the NAT type detection process and improve NAT type detection efficiency.

[0005] In a first aspect, embodiments of this application provide a network address translation type detection method, which is applied to a STUN server and includes:

[0006] In response to multiple NAT type detection request messages sent in parallel by the client for multiple public IP address information, the system returns reply messages corresponding to the multiple NAT type detection request messages using the local ports corresponding to the multiple public IP address information, so that the client can determine the NAT type based on the multiple reply messages; wherein, the local port is determined by the load balancer mapping the multiple public IP address information.

[0007] Secondly, embodiments of this application provide a network address translation type detection method, which is applied to a client and includes:

[0008] The system sends multiple NAT type detection request messages in parallel to the STUN server for multiple public IP address information; it receives reply messages from the STUN server corresponding to the multiple NAT type detection request messages using the local ports corresponding to the multiple public IP address information; it determines the NAT type based on the multiple reply messages; the multiple local ports are determined by the STUN server through the mapping of multiple public IP address information by the load balancer server.

[0009] Thirdly, embodiments of this application provide a network address translation type detection system, which includes the STUN server, load balancing server, and client as described in any of the above methods.

[0010] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the methods described above when executing the computer program.

[0011] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any of the preceding claims.

[0012] Compared with the prior art, this application has the following advantages:

[0013] This application provides a method, system, and electronic device for Network Address Translation (NAT) type detection. In response to multiple NAT type detection request messages sent in parallel by a client for multiple public IP addresses, the STUN server returns reply messages corresponding to the respective local ports of the multiple public IP addresses. The client determines the NAT type based on the multiple reply messages; the local ports are determined by a load balancer mapping the multiple public IP addresses. This embodiment utilizes a two-tier service architecture of the STUN server and the load balancer to meet the client's requirement for sending NAT type detection request messages in parallel, simplifying the interaction between the STUN server and the client and improving the efficiency of NAT type detection.

[0014] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application, it can be implemented according to the contents of the specification. In order to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description

[0015] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments according to this application and should not be construed as limiting the scope of this application.

[0016] Figure 1 A schematic diagram illustrating a scenario for the network address translation type detection method provided in this application;

[0017] Figure 2 This is a flowchart of a network address translation type detection method according to an embodiment of this application;

[0018] Figure 3 This is a flowchart of a network address translation type detection method according to another embodiment of this application;

[0019] Figure 4 An interactive diagram of a network address translation type detection method provided in an embodiment of this application;

[0020] Figure 5 This is a structural block diagram of a network address translation type detection device according to an embodiment of this application;

[0021] Figure 6 This is a structural block diagram of a network address translation type detection device according to another embodiment of this application; and

[0022] Figure 7 This is a block diagram of an electronic device used to implement embodiments of this application. Detailed Implementation

[0023] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the concept or scope of this application. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0024] To facilitate understanding of the technical solutions of the embodiments of this application, the relevant technologies of the embodiments of this application are described below. The following relevant technologies are optional solutions and can be combined with the technical solutions of the embodiments of this application in any way, and all of them fall within the protection scope of the embodiments of this application.

[0025] The technical terms used in the embodiments of this application are explained below:

[0026] STUN: Session Traversal Utilities for NAT. STUN is a network protocol designed to solve the problem of User Datagram Protocol (UDP) traversing NAT. The STUN protocol is primarily used for obtaining public IP addresses and ports for peer-to-peer applications and for detecting network NAT types.

[0027] Full Cone NAT: The characteristic of Full Cone NAT is that all requests originating from the same internal IP address and port are mapped to the same external IP address and port. Any external host can send packets to the internal host through this mapped external IP address.

[0028] IP Restricted Cone NAT: Also known as Restricted Cone NAT, IP Restricted Cone NAT is characterized by all requests from the same internal IP address and port being mapped to the same external IP address and port. However, unlike Full Cone NAT, an external host can send packets to an internal host through this mapped external address provided that the internal host has previously sent packets to the external host's IP address.

[0029] Port-restricted cone NAT: Port-restricted cone NAT is similar to IP-restricted cone NAT, but it restricts access to ports. Specifically, an external host can only send a data packet to an internal host on a certain port if the internal host has previously sent a data packet to that port on the external host.

[0030] Symmetric NAT: The characteristic of symmetric NAT is that all requests originating from the same internal IP address and port to a specific destination IP address and port are mapped to the same external IP address and port. However, if the request is sent to a different destination IP address and port, it will be mapped to a different set of external IP addresses and ports. An external host can send packets to an internal host through a certain port only if that internal host has previously sent packets to that port on the external host.

[0031] The primary purpose of NAT technology was to address the resource depletion issue of Internet Protocol version 4 (IPv4) and the security requirements for communication between local area networks (LANs) and the public internet for enterprises, organizations, and individuals. NAT maps Internet Protocol (IP) addresses and ports for LAN applications accessing the public internet, enabling interconnection within protocol rules. However, it imposes numerous security restrictions, preventing unrestricted communication between any two applications on the internet.

[0032] In many applications, communication between two endpoints needs to bypass NAT, such as point-to-point video transmission in the Internet of Things (IoT). Clients can obtain the public IP address and port mapped on the NAT by interacting with a STUN server located on the public network, thus providing a necessary prerequisite for many applications. In one related technology, the STUN protocol document describes a method for a client to identify its network NAT type by interacting with two public STUN servers through a series of sequential test requests. This method is complex and requires sophisticated client-side code implementation, making it an inefficient solution.

[0033] Another related technology uses a serial pipeline approach for NAT type detection. This requires strict adherence to the steps and execution sequence; otherwise, the accuracy of the detection results will be affected. This pipeline approach is highly complex in terms of program design and the overall detection time is very long. In practical applications, it may be necessary to perform four tests serially to determine whether it is an IP-restricted cone NAT or a port-restricted cone NAT.

[0034] Another related technology utilizes two sets of STUN servers to support parallel client requests. This approach requires two sets of STUN servers with different processing logics and also needs to handle internal forwarding, resulting in a complex service architecture.

[0035] To address the above issues, this embodiment provides a method for detecting network address translation types. Figure 1 This is a schematic diagram illustrating an application scenario for implementing the method of the embodiments of this application. For example... Figure 1 As shown, in this embodiment, a STUN server (such as...) is included. Figure 1 The STUN service shown) and load balancer (such as Figure 1The diagram shows a two-tier service architecture (SLB1, SLB2, and SLB3) for load balancing services. The STUN server belongs to an Internet Data Center (IDC) server room. Based on this two-tier architecture, the STUN server and load balancer provide three public IP addresses (IP1, IP2, and IP3), each listening on two ports (A and B). Six possible IP and port combinations (IP1:A, IP1:B, IP2:A, IP2:B, IP3:A, IP4:B) are supported to support parallel client requests. The STUN service also listens on six UDP ports (a, b, c, d, e, and f). The load balancer exposes three public IP addresses (IP1, IP2, and IP3) and two ports (A and B). The load balancer maps port A of public IP1 to port a of the STUN server, and port B to port b of the STUN server; it maps port A of public IP2 to port c of the STUN server, and port B to port d of the STUN server; and it maps port A of public IP3 to port e of the STUN server, and port B to port f of the STUN server. In this service architecture, the services provided by the three public IPs are consistent, and each IP can act as the primary service provider for NAT detection, with the other two IPs serving as backup services. Each backend STUN server can independently handle NAT type detection requests routed from the load balancer. The STUN servers can be flexibly horizontally scaled to meet availability requirements under massive concurrency. The NAT type detection method and high-availability server architecture provided in this application greatly simplify the interaction process between the client and the STUN server, and the detection of network NAT types is fast, efficient, and reliable.

[0036] This application provides a method for detecting network address translation type, such as... Figure 2 The diagram shown is a flowchart of a network address translation type detection method according to an embodiment of this application. The method is applied to a STUN server and includes:

[0037] Step S201: In response to the client sending multiple NAT type detection request messages in parallel for multiple public IP address information, return multiple NAT type detection results using the local ports corresponding to the multiple public IP address information.

[0038] The request message corresponds to a reply message, allowing the client to determine the NAT type based on multiple reply messages; the local port is determined by a load balancer mapping multiple public IP address information.

[0039] The NAT type detection request message can be a UDP request, or multiple messages sent in parallel for multiple public IP address information. After receiving the UDP request from the client, the STUN server responds according to the protocol, returning multiple reply messages to the client using the local ports corresponding to the multiple public IP address information. The client determines the NAT type based on whether it receives a reply message and the content of the reply message. Based on the NAT type, a hole-punching strategy is determined for port prediction to improve the success rate of point-to-point communication.

[0040] The local port can be an internal port of the STUN server, mapped to a public network port by the load balancer using routing policies. Multiple mapping relationships between public network addresses and local ports need to be pre-configured. Upon receiving a NAT type detection request message, the load balancer determines the corresponding local ports of the STUN server for each public network address based on the mapping relationship and forwards the message to that local port.

[0041] NAT types can include any of the following: Full Cone NAT, IP-restricted Cone NAT, Port-restricted Cone NAT, and Symmetric NAT.

[0042] The Network Address Translation (NAT) type detection method provided in this application involves a STUN server responding to multiple NAT type detection request messages sent in parallel by a client for multiple public IP address information. The STUN server returns response messages corresponding to the local ports corresponding to the multiple public IP address information, respectively. The client determines the NAT type based on the multiple response messages; the local ports are determined by a load balancer mapping the multiple public IP address information. This embodiment utilizes a two-tier service architecture of a STUN server and a load balancer to meet the client's requirement for sending NAT type detection request messages in parallel, simplifying the interaction process between the STUN server and the client, and improving the efficiency of NAT type detection.

[0043] In one implementation, the public IP address information includes a public Internet Protocol (IP) address and a public port; multiple NAT type detection request messages include at least one of the following:

[0044] The first request message includes a first type STUN binding request message sent to the first public port of the first public IP address. The change request attribute of the first type STUN binding request message does not set the flag bit for changing IP or changing port.

[0045] The second request message includes a first type STUN binding request message sent to the second public port of the second public IP address.

[0046] The third request message includes a second type STUN binding request message sent to the first public port of the first public IP address. The second type STUN binding request message sets the change request attribute to the IP change flag and the port change flag.

[0047] The fourth request message includes a Type 3 STUN binding request message sent to the first public port of the first public IP address. The Type 3 STUN binding request message sets the change request attribute to the flag for changing the port.

[0048] In one example, the first type of STUN Binding Request message is a test request (Test Case 1): The client sends a STUN Binding Request packet to the STUN server. The CHANGE-REQUEST attribute of this request does not have the flags set for changing the Internet Protocol (IP address) or changing the port.

[0049] The second type of STUN binding request message, Test Case 2, involves the client sending a STUN binding request message packet to the STUN server. This request's CHANGE-REQUEST attribute sets flags for both changing the Internet Protocol (IP address) and changing the port. These flags can be either 0 or 1.

[0050] The third type of STUN binding request message, Test Case 3, is a test request: The client sends a STUN binding request message data packet to the STUN server. The CHANGE-REQUEST attribute of this request only sets the Change Port flag.

[0051] This application provides a method for detecting network address translation type, such as... Figure 3 The diagram shows a flowchart of a network address translation type detection method according to an embodiment of this application. The method is applied to a client and includes:

[0052] Step S301: Send multiple NAT type detection request messages in parallel to the STUN server for multiple public network address information.

[0053] Step S302: Receive the response messages corresponding to the multiple NAT type detection request messages returned by the STUN server using the local ports corresponding to the multiple public network address information.

[0054] Step S303: Determine the NAT type based on multiple reply messages; the multiple local ports are determined by the STUN server through the load balancing server mapping multiple public IP address information.

[0055] The NAT type detection request message can be a UDP request, or multiple messages sent in parallel for multiple public IP address information. After receiving the UDP request from the client, the STUN server responds according to the protocol, returning multiple reply messages to the client using the local ports corresponding to the multiple public IP address information. The client determines the NAT type based on whether it receives a reply message and the content of the reply message. Based on the NAT type, a hole-punching strategy is determined for port prediction to improve the success rate of point-to-point communication.

[0056] The local port can be an internal port of the STUN server, mapped to a public network port by the load balancer using routing policies. Multiple mappings between public network addresses and local ports need to be pre-configured. Upon receiving a NAT type detection request message, the load balancer determines the corresponding local ports of the STUN server for each public network address based on the mapping relationship and forwards the message to the STUN server's local port. NAT types can include any of the following: Full Cone NAT, IP-restricted Cone NAT, Port-restricted Cone NAT, and Symmetric NAT.

[0057] In one implementation, the public network address information includes the public Internet Protocol (IP) address and the public network port.

[0058] Multiple NAT type detection request messages include at least one of the following:

[0059] The first request message includes a first type STUN binding request message sent to the first public port of the first public IP address. The change request attribute of the first type STUN binding request message does not set the flag bit for changing IP or changing port.

[0060] The second request message includes a first type STUN binding request message sent to the second public port of the second public IP address.

[0061] The third request message includes a second type STUN binding request message sent to the first public port of the first public IP address. The second type STUN binding request message sets the change request attribute to the IP change flag and the port change flag.

[0062] The fourth request message includes a Type 3 STUN binding request message sent to the first public port of the first public IP address. The Type 3 STUN binding request message sets the change request attribute to the flag for changing the port.

[0063] In one example, the first type of STUN Binding Request message is a test request (Test Case 1): The client sends a STUN Binding Request packet to the STUN server. The CHANGE-REQUEST attribute of this request does not have the flags set for changing the Internet Protocol (IP address) or changing the port.

[0064] The second type of STUN binding request message, Test Case 2, involves the client sending a STUN binding request message packet to the STUN server. This request's CHANGE-REQUEST attribute sets flags for both changing the Internet Protocol (IP address) and changing the port. These flags can be either 0 or 1.

[0065] The third type of STUN binding request message, Test Case 3, is a test request: The client sends a STUN binding request message data packet to the STUN server. The CHANGE-REQUEST attribute of this request only sets the Change Port flag.

[0066] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the NAT type is determined based on multiple response messages, including:

[0067] If a first response message to a first request message, a second response message to a second request message, and a third response message to a third request message are received, and the local IP address is different from the public IP address in the first and second response messages, then the NAT type is determined to be a full cone NAT.

[0068] In this embodiment, it is not necessary to consider whether a reply message to the fourth request message has been received. The NAT type can be determined based on whether the first, second, and third reply messages have been received, and the content of the reply messages. However, when sending the request message, the NAT type cannot be predicted. Therefore, the first, second, third, and fourth request messages must be sent in parallel.

[0069] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the NAT type is determined based on multiple response messages, including:

[0070] If a first response message to a first request message and a second response message to a second request message are received, but a third response message to a third request message is not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are not exactly the same as the public IP address and public port in the second response message, then the NAT type is determined to be symmetric NAT.

[0071] The public IP address and public port in the first reply message are not completely the same as those in the second reply message. This could be because the public IP address in the first reply message is the same as that in the second reply message, but the public port in the first reply message is different from that in the second reply message; or the public IP address in the first reply message is different from that in the second reply message, but the public port in the first reply message is the same as that in the second reply message.

[0072] In this embodiment, it is not necessary to consider whether a reply message to the fourth request message has been received. The NAT type can be determined based on whether the first, second, and third reply messages have been received, and the content of the reply messages. However, when sending the request message, the NAT type cannot be predicted. Therefore, the first, second, third, and fourth request messages must be sent in parallel.

[0073] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the NAT type is determined based on multiple response messages, including:

[0074] If the first response message of the first request message, the second response message of the second request message, and the fourth response message of the fourth request message are received, but the third response message of the third request message is not received, the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be IP-restricted cone NAT.

[0075] In this context, the public IP address and public port in the first reply message being the same as those in the second reply message can mean that the public IP address in the first reply message is the same as the public IP address in the second reply message, and the public port in the first reply message is the same as the public port in the second reply message.

[0076] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the NAT type is determined based on multiple response messages, including:

[0077] If a first response message to a first request message and a second response message to a second request message are received, but a third response message to a third request message and a fourth response message to a fourth request message are not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be Port Restricted Cone NAT.

[0078] To more clearly illustrate the technical concept of this application, a specific embodiment is provided below. Figure 1 and Figure 4 The method provided in this embodiment will be described.

[0079] like Figure 1 As shown, three sets of public IP addresses are provided externally. Each IP address can serve as the primary NAT detection service. The following example, using IP1 as the primary service, illustrates how to support concurrent client-side NAT detection. Figure 4 As shown, the STUN client sends a first request message, a second request message, a third request message, and a fourth request message to the STUN server in parallel:

[0080] Request 1: The STUN client sends a request for TestCase1 to the STUN server on port A of IP1. After receiving the request, the STUN server replies with a response message from internal port a, which corresponds to port A of IP1. The response message is returned from port A of IP1.

[0081] Request 2: The STUN client sends a request for TestCase1 to the STUN server on port A of IP2. After receiving the request, the STUN server replies with a reply message from internal port c, which corresponds to port A of IP2. The reply message is returned from port A of IP2.

[0082] Request 3: The STUN client sends a request for TestCase2 to the STUN server on port A of IP1. After receiving the request, the STUN server replies with a reply message from internal port d, which corresponds to port B of IP3. The reply message is returned from port B of IP3.

[0083] Request 4: The STUN client sends a request for TestCase3 to the STUN server on port A of IP1. After receiving the request, the STUN server replies with a reply message from internal port b, which corresponds to port B of IP1. The reply message is returned from port B of IP1.

[0084] After the client sends four types of requests in parallel, it determines the network NAT type based on whether a reply message can be received and the content of the data packet in the received reply message.

[0085] If no response messages are received for requests 1 and 2, the network UDP connection is down.

[0086] If only one of the requests 1 and 2 is replied to, it indicates a network error.

[0087] If responses to both requests 1 and 2 are received simultaneously, and the local IP address matches the public IP address returned in the responses to requests 1 and 2, then further judgment should be made based on the following information:

[0088] If a response message to request 3 is received, it indicates an open public network without NAT.

[0089] If no response message is received for request 3, it is a symmetric firewall.

[0090] If responses to both requests 1 and 2 are received simultaneously, and the local IP address differs from the public IP address returned in the responses to requests 1 and 2, then further judgment should be made based on the following information:

[0091] If a response message to request 3 is received, then it is a full cone NAT.

[0092] If a response message to request 3 cannot be received, and the IP address and port in the response messages to requests 1 and 2 are not exactly the same, then it is a symmetric NAT.

[0093] If a response message for request 3 is not received, and the IP address and port in the response messages for requests 1 and 2 are exactly the same, then further judgment should be made based on the following information:

[0094] If a response message to request 4 is received, it indicates an IP-restricted cone NAT.

[0095] If a response message to request 4 is not received, it indicates a port-restricted cone NAT.

[0096] The scheme proposed in this application supports parallel NAT type detection requests from the client. The client implementation is concise and efficient, rather than involving complex serial requests. Serial requests, by their very nature, take into account the characteristics of NAT types and need to avoid the correlation between requests. If a specific destination public IP address or port has been accessed by the client beforehand, subsequent requests to that IP address or port will affect the response received by the client, thus influencing the final determination of the network NAT type. The STUN service architecture in this embodiment provides 3 IP addresses and 2 ports. This combination of 6 IP addresses and ports avoids the correlation between the 4 types of NAT type detection requests, supports parallel client requests, and, without considering UDP packet retransmission, can determine the network NAT type detection result in approximately one round-trip time (RTT).

[0097] Corresponding to the application scenarios and methods provided in the embodiments of this application, the embodiments of this application provide a network address translation type detection system, which includes the STUN server, load balancing server and client in any of the above methods.

[0098] The specific working process of the system in this application embodiment can be found in the corresponding description in the above method, and it has corresponding beneficial effects, which will not be repeated here.

[0099] Corresponding to the application scenarios and methods provided in the embodiments of this application, the embodiments of this application also provide a network address translation type detection device. For example... Figure 5 The diagram shown is a structural block diagram of a network address translation type detection device according to an embodiment of this application, which may include:

[0100] The sending unit 501 is used to respond to multiple NAT type detection request messages sent in parallel by the client for multiple public network address information, and to return reply messages corresponding to the multiple NAT type detection request messages using the local ports corresponding to the multiple public network address information, so that the client can determine the NAT type based on the multiple reply messages; wherein, the local port is determined by the load balancing server mapping the multiple public network address information.

[0101] The Network Address Translation (NAT) type detection device provided in this embodiment responds to multiple NAT type detection request messages sent in parallel by a client for multiple public IP address information. It returns response messages corresponding to the local ports corresponding to the multiple public IP address information. The client determines the NAT type based on the multiple response messages; wherein, the local port is determined by mapping the multiple public IP address information through a load balancer. In this embodiment, a two-level service architecture of STUN server and load balancer is used to meet the client's requirement to send NAT type detection request messages in parallel, simplifying the interaction process between the STUN server and the client and improving the efficiency of NAT type detection.

[0102] In one implementation, the public network address information includes the public Internet Protocol (IP) address and the public network port.

[0103] Multiple NAT type detection request messages include at least one of the following:

[0104] The first request message includes a first type STUN binding request message sent to the first public port of the first public IP address. The change request attribute of the first type STUN binding request message does not set the flag bit for changing IP or changing port.

[0105] The second request message includes a first type STUN binding request message sent to the second public port of the second public IP address;

[0106] The third request message includes a second type STUN binding request message sent to the first public port of the first public IP address. The second type STUN binding request message sets the change request attribute to the IP change flag and the port change flag.

[0107] The fourth request message includes a Type 3 STUN binding request message sent to the first public port of the first public IP address. The Type 3 STUN binding request message sets the change request attribute to the flag for changing the port.

[0108] The functions of each module in each device in the embodiments of this application can be found in the corresponding description in the above method, and they have corresponding beneficial effects, which will not be repeated here.

[0109] Corresponding to the application scenarios and methods provided in the embodiments of this application, the embodiments of this application also provide a network address translation type detection device. For example... Figure 6 The diagram shown is a structural block diagram of a network address translation type detection device according to an embodiment of this application, which may include:

[0110] The sending module 601 is used to send multiple NAT type detection request messages in parallel to the STUN server for multiple public network address information;

[0111] The receiving module 602 is used to receive the response messages corresponding to the multiple NAT type detection request messages returned by the STUN server using the local ports corresponding to the multiple public network address information.

[0112] The determination module 603 is used to determine the NAT type based on multiple reply messages; the multiple local ports are determined by the STUN server through the mapping of multiple public network address information by the load balancer server.

[0113] The Network Address Translation (NAT) type detection device provided in this embodiment sends multiple NAT type detection request messages in parallel to a STUN server for multiple public IP address information; receives response messages from the STUN server corresponding to the multiple NAT type detection request messages using the local ports corresponding to the multiple public IP address information; and determines the NAT type based on the multiple response messages. The multiple local ports are determined by the STUN server through a load balancer mapping the multiple public IP address information. In this embodiment, a two-level service architecture of STUN server and load balancer is used to meet the client's requirement to send NAT type detection request messages in parallel, simplifying the interaction process between the STUN server and the client and improving the efficiency of NAT type detection.

[0114] In one implementation, the public address information includes the public Internet Protocol (IP) address and the public port.

[0115] Multiple NAT type detection request messages include at least one of the following:

[0116] The first request message includes a first type STUN binding request message sent to the first public port of the first public IP address. The change request attribute of the first type STUN binding request message does not set the flag bit for changing IP or changing port.

[0117] The second request message includes a first type STUN binding request message sent to the second public port of the second public IP address.

[0118] The third request message includes a second type STUN binding request message sent to the first public port of the first public IP address. The second type STUN binding request message sets the change request attribute to the IP change flag and the port change flag.

[0119] The fourth request message includes a Type 3 STUN binding request message sent to the first public port of the first public IP address. The Type 3 STUN binding request message sets the change request attribute to the flag for changing the port.

[0120] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the determination module 603 is used for:

[0121] If a first response message to a first request message, a second response message to a second request message, and a third response message to a third request message are received, and the local IP address is different from the public IP address in the first and second response messages, then the NAT type is determined to be a full cone NAT.

[0122] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the determination module 603 is used for:

[0123] If a first response message to a first request message and a second response message to a second request message are received, but a third response message to a third request message is not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are not exactly the same as the public IP address and public port in the second response message, then the NAT type is determined to be symmetric NAT.

[0124] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the determination module 603 is used for:

[0125] If the first response message of the first request message, the second response message of the second request message, and the fourth response message of the fourth request message are received, but the third response message of the third request message is not received, the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be IP-restricted cone NAT.

[0126] In one implementation, the NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; the determination module 603 is used for:

[0127] If a first response message to a first request message and a second response message to a second request message are received, but a third response message to a third request message and a fourth response message to a fourth request message are not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be Port Restricted Cone NAT.

[0128] The functions of each module in each device in the embodiments of this application can be found in the corresponding description in the above method, and they have corresponding beneficial effects, which will not be repeated here.

[0129] Figure 7 This is a block diagram of an electronic device used to implement embodiments of this application. For example... Figure 7 As shown, the electronic device includes a memory 710 and a processor 720. The memory 710 stores a computer program that can run on the processor 720. When the processor 720 executes the computer program, it implements the method described in the above embodiments. The number of memories 710 and processors 720 can be one or more.

[0130] The electronic device also includes:

[0131] The communication interface 730 is used to communicate with external devices and perform data exchange and transmission.

[0132] If the memory 710, processor 720, and communication interface 730 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0133] Optionally, in a specific implementation, if the memory 710, processor 720, and communication interface 730 are integrated on a single chip, then the memory 710, processor 720, and communication interface 730 can communicate with each other through an internal interface.

[0134] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in this application.

[0135] This application also provides a chip, which includes a processor for calling and executing instructions stored in a memory, causing a communication device with the chip installed to perform the method provided in this application.

[0136] This application also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the method provided in the application embodiment.

[0137] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.

[0138] Further, optionally, the aforementioned memory may include read-only memory and random access memory. The memory may be volatile memory or non-volatile memory, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0139] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0140] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.

[0141] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0142] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process. Furthermore, the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functionality involved.

[0143] The logic and / or steps described in the flowchart or otherwise herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0144] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.

[0145] Furthermore, the functional units in the various embodiments of this application can be integrated into a single processing module, or each unit can exist physically separately, or two or more units can be integrated into a single module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a disk, or an optical disk, etc.

[0146] The above description is merely an exemplary embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope described in this application, and these should all be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for detecting Network Address Translation (NAT) types, characterized in that, The method is applied to the STUN (Network Address Translation / NAT Session Traversal Application) server in a Network Address Translation Type Detection system, wherein the Network Address Translation Type Detection system adopts a two-tier service architecture consisting of a STUN server and a load balancing server; the method includes: The system receives multiple NAT type detection request messages forwarded by the load balancer to local ports corresponding to multiple public network address information; wherein, the multiple NAT type detection request messages are NAT type detection request messages sent in parallel by the client for multiple public network address information; the multiple local ports are determined by the load balancer mapping the multiple public network address information; In response to the plurality of NAT type detection request messages, the system uses local ports corresponding to the plurality of public network address information to return reply messages to the client, each corresponding to one of the plurality of NAT type detection request messages, so that the client can determine the NAT type based on the plurality of reply messages.

2. The method according to claim 1, characterized in that, The public network address information includes the public Internet Protocol (IP) address and the public network port; The plurality of NAT type detection request messages include at least one of the following: The first request message includes a first type of STUN binding request message sent to a first public port of a first public IP address. The change request attribute of the first type of STUN binding request message does not set a flag for changing the IP address or a flag for changing the port. The second request message includes the first type of STUN binding request message sent to the second public port of the second public IP address; The third request message includes a second type of STUN binding request message sent to the first public network port of the first public network IP address. The second type of STUN binding request message sets the change request attribute to a flag for changing the IP address and a flag for changing the port. The fourth request message includes a third type STUN binding request message sent to the first public network port of the first public network IP address, wherein the change request attribute of the third type STUN binding request message sets the flag bit for changing the port.

3. A method for detecting Network Address Translation (NAT) types, characterized in that, The method is applied to a client in a network address translation type detection system, which employs a two-tier service architecture consisting of a STUN server and a load balancing server. The method includes: Multiple NAT type detection request messages are sent in parallel for multiple public network address information, so that the load balancer forwards the multiple NAT type detection request messages to the local ports on the STUN server corresponding to the multiple public network address information respectively; the multiple local ports are determined by the STUN server through the load balancer mapping the multiple public network address information. Receive response messages corresponding to the multiple NAT type detection request messages returned by the STUN server using the local ports corresponding to the multiple public network address information respectively; The NAT type is determined based on multiple of the aforementioned response messages.

4. The method according to claim 3, characterized in that, The public network address information includes the public Internet Protocol (IP) address and the public network port; The plurality of NAT type detection request messages include at least one of the following: The first request message includes a first type of STUN binding request message sent to a first public port of a first public IP address. The change request attribute of the first type of STUN binding request message does not set a flag for changing the IP address or a flag for changing the port. The second request message includes the first type of STUN binding request message sent to the second public port of the second public IP address; The third request message includes a second type of STUN binding request message sent to the first public network port of the first public network IP address. The second type of STUN binding request message sets the change request attribute to a flag for changing the IP address and a flag for changing the port. The fourth request message includes a third type STUN binding request message sent to the first public network port of the first public network IP address, wherein the change request attribute of the third type STUN binding request message sets the flag bit for changing the port.

5. The method according to claim 4, characterized in that, The NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; The step of determining the NAT type based on multiple response messages includes: If a first response message to the first request message, a second response message to the second request message, and a third response message to the third request message are received, and the local IP address is different from the public IP address in the first and second response messages, then the NAT type is determined to be a full cone NAT.

6. The method according to claim 4, characterized in that, The NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; The step of determining the NAT type based on multiple response messages includes: If a first response message to the first request message and a second response message to the second request message are received, but a third response message to the third request message is not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are not exactly the same as the public IP address and public port in the second response message, then the NAT type is determined to be symmetric NAT.

7. The method according to claim 4, characterized in that, The NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; The step of determining the NAT type based on multiple response messages includes: If the first response message of the first request message, the second response message of the second request message, and the fourth response message of the fourth request message are received, but the third response message of the third request message is not received, the local IP address is different from the public IP address in the first response message and the second response message, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be IP-restricted cone NAT.

8. The method according to claim 4, characterized in that, The NAT type detection request message includes a first request message, a second request message, a third request message, and a fourth request message; The step of determining the NAT type based on multiple response messages includes: If a first response message to the first request message and a second response message to the second request message are received, but a third response message to the third request message and a fourth response message to the fourth request message are not received, and the local IP address is different from the public IP address in the first and second response messages, and the public IP address and public port in the first response message are the same as the public IP address and public port in the second response message, then the NAT type is determined to be a port-restricted cone NAT.

9. A network address translation type detection system, characterized in that, The network address translation type detection system includes the STUN server, load balancing server, and client as described in any one of claims 1-8.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor, when executing the computer program, implements the method of any one of claims 1-8.

11. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method of any one of claims 1-8.

Citation Information

Patent Citations

  • NAT type determination method, device and system and storage medium

    CN111935333A

  • Parallel testing method and system

    CN1983990A

  • Network Address Translators (NAT) Type Detection Techniques

    US20100146099A1