High-performance gateway NAT (Network Address Translation) type identification method
By detecting the number of mapping records and multiple communication records generated on the NAT router, combined with port changes, the NAT type is gradually identified, which solves the misjudgment problem in the existing technology and improves the identification accuracy and adaptability.
Patent Information
- Application Number
- CN202411056083.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-10-11
AI Technical Summary
Existing NAT type identification methods are prone to misjudgment, affecting network optimization and management.
By detecting the number of mapping records generated on the NAT router when the private network machine communicates with the public network machine, combined with the comparison of multiple communication records and port changes, we can gradually identify symmetrical NAT, cone NAT, complete cone NAT, and restricted cone NAT. , IP restricted cone NAT and port restricted cone NAT types.
Significantly improves the accuracy of NAT type identification, reduces the possibility of misjudgment, and is suitable for different network environments and architectures.
Smart Images

Figure CN118764460A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of identifying gateway NAT types, in particular to a high-performance gateway NAT type identification method. Background Art
[0002] With the rapid development of the Internet, Network Address Translation (NAT) technology has been widely used in various network environments. NAT is mainly used to solve the problem of IPv4 address shortage. By converting private IP addresses into public IP addresses, multiple devices can share one or more public IP addresses for Internet communication. According to the working principle of NAT and its mapping strategy, NAT can be divided into Symmetric NAT, Full Cone NAT, IP Restricted Cone NAT and Port Restricted Cone NAT. Different types of NAT have different effects on network communication. For example, Symmetric NAT assigns different mappings to each new session, while Cone NAT maintains a fixed mapping for the same internal address and port. Therefore, accurately identifying the NAT type is of great significance for optimizing network performance, improving communication efficiency and ensuring network security.
[0003] Due to the lack of an effective verification mechanism, existing NAT type identification methods are prone to misjudgment in some cases, resulting in inaccurate NAT type identification, which in turn affects network optimization and management. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention provides a high-performance gateway NAT type identification method, which solves the problem that the prior NAT type identification method is prone to misjudgment.
[0005] To achieve the above purpose, the present invention is implemented by the following technical scheme: a high-performance gateway NAT type identification method, comprising the following specific steps:
[0006] S1: Identify symmetric NAT and cone NAT: Symmetric NAT and cone NAT are distinguished by detecting the number of mapping records generated on the NAT router when a private network machine communicates with different public network machines. Symmetric NAT generates N records when communicating with N public network machines, while cone NAT generates 1 record when communicating with N public network machines.
[0007] S2: Distinguishing between full cone NAT and restricted cone NAT: Distinguishing between full cone NAT and restricted cone NAT by detecting whether other public network machines can reach private network machines when sending messages to the public network IP address of the NAT router;
[0008] S3: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT by detecting whether the message data sent by other ports of the public network machine to the network process of the private network machine can be received.
[0009] Preferably, the method for distinguishing between symmetric NAT and cone NAT comprises the following specific steps:
[0010] S101: The private network machine sends a message to server 1 to record the public network IP address of the NAT router;
[0011] S102: The private network machine sends a message to server 2, recording the client IP address obtained by server 2;
[0012] S103: Server 1 sends the obtained client IP address to server 2. Server 2 compares the client IP addresses obtained by server 1 and server 2. If they are consistent, it is cone NAT. If they are inconsistent, it is symmetric NAT.
[0013] S104: When transmitting data between servers, the NAT type is further confirmed by comparing the stability of the transmission path. Symmetric NAT usually has a large path change, while cone NAT has a small path change.
[0014] Preferably, the method for distinguishing between the full cone NAT and the restricted cone NAT comprises the following specific steps:
[0015] S201: The private network machine network process sends a message to the server 1 to record the public network IP address of the NAT router;
[0016] S202: Server 1 sends the acquired client IP address to server 2;
[0017] S203: Server 2 sends a message to the client IP address to detect whether the private network machine can receive the message. If it can be received, it is a full cone NAT, otherwise it is a restricted cone NAT;
[0018] S204: After receiving the message, the private network machine network process continues to send the message to server 1. After receiving the message data, server 1 confirms the NAT type.
[0019] Preferably, in step S203 of the method for distinguishing between full cone NAT and restricted cone NAT, the server 2 attempts to send messages through different ports to further confirm whether it is a restricted cone NAT.
[0020] Preferably, the method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT comprises the following specific steps:
[0021] S301: The private network machine network process sends a message to the server to record the public network IP address of the NAT router;
[0022] S302: The server sends message data to the client IP address from another port to detect whether the private network machine can receive the message. If it can be received, it is IP restricted cone NAT. If not, it is port restricted cone NAT.
[0023] S303: The private network machine network process sends a message back to the server to detect whether the data can be received. If it can be received, it is IP restricted cone NAT, otherwise it is port restricted cone NAT.
[0024] Preferably, in step S302 and step S303 of the method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT, the server sends messages through multiple port changes.
[0025] Preferably, in the step of identifying the symmetric NAT and the cone NAT, the server 1 and the server 2 are respectively located in different public network IP address ranges.
[0026] Preferably, in the step of identifying the full cone NAT and the restricted cone NAT, the server 2 confirms the status of the private network machine by synchronizing data with the server 1 before sending the message.
[0027] Preferably, the private network machine includes a unique identifier when sending a message in each step, and all message transmissions use an encrypted communication protocol.
[0028] The present invention provides a high-performance gateway NAT type identification method, which has the following beneficial effects:
[0029] 1. The present invention gradually identifies the NAT type through hierarchical steps, and the judgment at each level is based on clear logical conditions, which enables the entire process to be completed quickly and accurately. In particular, in the identification process of symmetric NAT and cone NAT, multiple communication records are compared, which greatly reduces the possibility of misjudgment.
[0030] 2. The present invention refines each step, for example, in the identification process of symmetric NAT and cone NAT, the timestamp and sequence number verification are added; in the identification process of full cone NAT and restricted cone NAT, the type is further confirmed through multiple port changes. These measures significantly improve the accuracy of identification and reduce the possibility of misjudgment.
[0031] 3. The method of the present invention is not only applicable to common home network environments, but can also be run efficiently in complex enterprise networks. Through flexible step design and various verification methods, it can adapt to different network architectures and NAT configurations. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a NAT classification tree diagram of the present invention;
[0033] Figure 2 It is a schematic diagram of the process of judging symmetric NAT and cone NAT of the present invention;
[0034] Figure 3 It is a schematic diagram of the process of judging the full cone NAT and the restricted symmetric NAT of the present invention;
[0035] Figure 4 It is a schematic diagram of the process of judging IP restricted cone NAT and port restricted cone NAT according to the present invention. DETAILED DESCRIPTION
[0036] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] Please refer to the attached Figure 1 - Attachment Figure 4 The embodiment of the present invention provides a high-performance gateway NAT type identification method, comprising the following specific steps:
[0038] S1: Identify symmetric NAT and cone NAT: Symmetric NAT and cone NAT are distinguished by detecting the number of mapping records generated on the NAT router when a private network machine communicates with different public network machines. Symmetric NAT generates N records when communicating with N public network machines, while cone NAT generates 1 record when communicating with N public network machines.
[0039] S2: Distinguishing between full cone NAT and restricted cone NAT: Distinguishing between full cone NAT and restricted cone NAT by detecting whether other public network machines can reach private network machines when sending messages to the public network IP address of the NAT router;
[0040] S3: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT by detecting whether the message data sent by other ports of the public network machine to the network process of the private network machine can be received.
[0041] The method for distinguishing between symmetric NAT and cone NAT includes the following specific steps:
[0042] S101: The private network machine sends a message to server 1 to record the public network IP address of the NAT router;
[0043] S102: The private network machine sends a message to server 2, recording the client IP address obtained by server 2;
[0044] S103: Server 1 sends the obtained client IP address to server 2. Server 2 compares the client IP addresses obtained by server 1 and server 2. If they are consistent, it is cone NAT. If they are inconsistent, it is symmetric NAT.
[0045] S104: When transmitting data between servers, the NAT type is further confirmed by comparing the stability of the transmission path. Symmetric NAT usually has a large path change, while cone NAT has a small path change.
[0046] Specifically, distinguish between symmetric NAT and cone NAT:
[0047] Step 1: The private network machine (192.168.1.3:2341) sends a message to Server 1 (180.93.45.46:8888) and records the public IP address of the NAT router (112.93.114.33:23454).
[0048] Step 2: The private network machine (192.168.1.3:2341) sends a message to Server 2 (118.56.189.34:8888) and records the client IP address obtained by Server 2.
[0049] Step 3: Server 1 sends the obtained client IP address to Server 2. Server 2 compares the client IP addresses obtained by Server 1 and Server 2. If they are consistent, it is Cone NAT; otherwise, it is Symmetric NAT.
[0050] Step 4: When transmitting data between servers, further confirm the NAT type by comparing the stability of the transmission path. Symmetric NAT usually has a large path change, while cone NAT has a small path change.
[0051] Step 5: When the private network machine sends a message to Server 1 and Server 2, a timestamp and a sequence number may be added to improve the accuracy of data matching.
[0052] The method for distinguishing between full cone NAT and restricted cone NAT includes the following specific steps:
[0053] S201: The private network machine network process sends a message to the server 1 to record the public network IP address of the NAT router;
[0054] S202: Server 1 sends the acquired client IP address to server 2;
[0055] S203: Server 2 sends a message to the client IP address to detect whether the private network machine can receive the message. If it can be received, it is a full cone NAT, otherwise it is a restricted cone NAT;
[0056] S204: After receiving the message, the private network machine network process continues to send the message to server 1. After receiving the message data, server 1 confirms the NAT type;
[0057] In step S203 of the method for distinguishing between full cone NAT and restricted cone NAT, the server 2 attempts to send messages through different ports to further confirm whether it is a restricted cone NAT;
[0058] Specifically, distinguish between Full Cone NAT and Restricted Cone NAT:
[0059] Step 1: The private network machine network process (192.168.1.3:2341) sends a message to Server 1 (180.93.45.46:8888) and records the public IP address of the NAT router.
[0060] Step 2: Server 1 sends the obtained client IP address to Server 2.
[0061] Step 3: Server 2 sends a message to the client IP address to detect whether the private network machine can receive the message data. If it can be received, it is a full cone NAT, otherwise it is a restricted cone NAT.
[0062] Step 4: After receiving the message, the private network machine continues to send the message to Server 1. Server 1 receives the message data and confirms the NAT type.
[0063] Step 5: In step 3, server 2 may try to send packets through different ports to further confirm whether it is a restricted cone NAT.
[0064] Step 6: When data is transmitted between the private network machine and the server, a detailed log of each data transmission can be recorded to provide reference for subsequent analysis.
[0065] The method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT includes the following specific steps:
[0066] S301: The private network machine network process sends a message to the server to record the public network IP address of the NAT router;
[0067] S302: The server sends message data to the client IP address from another port to detect whether the private network machine can receive the message. If it can be received, it is IP restricted cone NAT. If not, it is port restricted cone NAT.
[0068] S303: The private network machine network process sends a message back to the server to detect whether the data can be received. If it can be received, it is IP restricted cone NAT, otherwise it is port restricted cone NAT.
[0069] In step S302 and step S303 of the method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT, the server sends a message through multiple port changes.
[0070] In the identification step of symmetric NAT and cone NAT, server 1 and server 2 are located in different public IP address ranges.
[0071] In the identification step of full cone NAT and restricted cone NAT, server 2 confirms the status of the private network machine by synchronizing data with server 1 before sending a message.
[0072] The private network machine includes a unique identifier when sending messages at each step, and all message transmissions use encrypted communication protocols.
[0073] Specifically, distinguish between IP-restricted cone NAT and port-restricted cone NAT:
[0074] Step 1: The private network machine network process (192.168.1.3:2341) sends a message to the server (180.93.45.46:8888) and records the public IP address of the NAT router.
[0075] Step 2: The server sends message data from another port (180.93.45.46:9999) to the client IP address to detect whether the private network machine can receive the message data. If it can, it is IP restricted cone NAT. If not, it is port restricted cone NAT.
[0076] Step 3: The private network machine sends a message back to another port of the server to detect whether the data can be received. If it can be received, it is IP restricted cone NAT, otherwise it is port restricted cone NAT.
[0077] Step 4: In steps 2 and 3, the server may change the port and send messages multiple times to improve the accuracy of identification.
[0078] Step 5: When the private network machine sends and receives messages, the message content is encrypted using a randomly generated encryption key to prevent data from being stolen and tampered with.
[0079] The gateway types include Full Cone NAT, Symmetric NAT, IP Restricted Cone NAT, and Port Restricted Cone NAT. The logical relationship between these four types of NAT can be divided into a binary tree, such as Figure 1 As shown. NAT is divided into two types: symmetric NAT and cone NAT. Cone NAT is divided into two types: restricted cone NAT and full cone NAT. Restricted cone NAT is divided into two types: port restricted cone NAT and IP restricted cone NAT. Leaf nodes are exactly the four types of NAT divided out. The nodes at the same level complement each other and form a whole set.
[0080] To determine which NAT solution the gateway belongs to, you can refer to Figure 1 As shown, the NAT type of the gateway is determined by judging layer by layer according to the binary tree level. The three judgments are symmetric NAT and cone NAT, restricted cone NAT and complete cone NAT, port restricted cone NAT and IP restricted cone NAT.
[0081] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A high-performance gateway NAT type identification method, characterized in that: The specific steps include: S1: Identify symmetric NAT and cone NAT: Symmetric NAT and cone NAT are distinguished by detecting the number of mapping records generated on the NAT router when a private network machine communicates with different public network machines. Symmetric NAT generates N records when communicating with N public network machines, while cone NAT generates 1 record when communicating with N public network machines. S2: Distinguishing between full cone NAT and restricted cone NAT: Distinguishing between full cone NAT and restricted cone NAT by detecting whether other public network machines can reach private network machines when sending messages to the public network IP address of the NAT router; S3: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT: Distinguishing between IP-restricted cone NAT and port-restricted cone NAT by detecting whether the message data sent by other ports of the public network machine to the network process of the private network machine can be received.
2. A high-performance gateway NAT type identification method according to claim 1, characterized in that: The method for distinguishing between symmetric NAT and cone NAT includes the following specific steps: S101: The private network machine sends a message to server 1 to record the public network IP address of the NAT router; S102: The private network machine sends a message to server 2, recording the client IP address obtained by server 2; S103: Server 1 sends the obtained client IP address to server 2. Server 2 compares the client IP addresses obtained by server 1 and server 2. If they are consistent, it is cone NAT. If they are inconsistent, it is symmetric NAT. S104: When transmitting data between servers, the NAT type is further confirmed by comparing the stability of the transmission path. Symmetric NAT usually has a large path change, while cone NAT has a small path change.
3. A high-performance gateway NAT type identification method according to claim 1, characterized in that: The method for distinguishing between the full cone NAT and the restricted cone NAT comprises the following specific steps: S201: The private network machine network process sends a message to the server 1 to record the public network IP address of the NAT router; S202: Server 1 sends the acquired client IP address to server 2; S203: Server 2 sends a message to the client IP address to detect whether the private network machine can receive the message. If it can be received, it is a full cone NAT, otherwise it is a restricted cone NAT; S204: After receiving the message, the private network machine network process continues to send the message to server 1. After receiving the message data, server 1 confirms the NAT type.
4. A high-performance gateway NAT type identification method according to claim 3, characterized in that: In step S203 of the method for distinguishing between full cone NAT and restricted cone NAT, the server 2 attempts to send messages through different ports to further confirm whether it is a restricted cone NAT.
5. A high-performance gateway NAT type identification method according to claim 1, characterized in that: The method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT comprises the following specific steps: S301: The private network machine network process sends a message to the server to record the public network IP address of the NAT router; S302: The server sends message data to the client IP address from another port to detect whether the private network machine can receive the message. If it can be received, it is IP restricted cone NAT. If not, it is port restricted cone NAT. S303: The private network machine network process sends a message back to the server to detect whether the data can be received. If it can be received, it is IP restricted cone NAT, otherwise it is port restricted cone NAT.
6. A high-performance gateway NAT type identification method according to claim 5, characterized in that: In step S302 and step S303 of the method for distinguishing between IP-restricted cone NAT and port-restricted cone NAT, the server sends a message through multiple port changes.
7. A high-performance gateway NAT type identification method according to claim 1, characterized in that: In the step of distinguishing the symmetric NAT from the cone NAT, the server 1 and the server 2 are respectively located in different public network IP address ranges.
8. A high-performance gateway NAT type identification method according to claim 1, characterized in that: In the step of identifying the full cone NAT and the restricted cone NAT, before sending a message, the server 2 confirms the status of the private network machine by synchronizing data with the server 1.
9. A high-performance gateway NAT type identification method according to claim 1, characterized in that: The private network machine includes a unique identifier when sending a message in each step, and all message transmissions use an encrypted communication protocol.
