Method, apparatus and electronic device for determining network address translation type
By sending detection messages to the first and second servers and analyzing the response messages, the client can quickly determine the network address translation type, solving the problem of long detection time in existing technologies and improving efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHUXING TECH (BEIJING) CO LTD
- Filing Date
- 2024-07-18
- Publication Date
- 2026-04-21
AI Technical Summary
Existing NAT detection technologies rely on specific protocols, resulting in long processing times and low efficiency in detecting communication between clients and servers.
The client sends detection messages to a pre-configured first and second server and receives the response messages returned by them. By analyzing the public IP address and port number in these response messages, the network address translation type can be quickly determined.
It improves the efficiency of network address translation detection and reduces detection time and system resource consumption.
Smart Images

Figure CN118764461B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network address translation technology, and in particular to a method, apparatus and electronic device for determining network address translation type. Background Technology
[0002] With the rapid development of the Internet, the depletion of IPv4 address space has become one of the key factors restricting network expansion. Network Address Translation (NAT) technology emerged as a mitigation strategy, allowing multiple private IP addresses to share one or a small number of public IP addresses to access the Internet, effectively alleviating the IPv4 address shortage problem. NAT devices modify the source or destination IP addresses of data packets, enabling devices on the internal network to communicate with the external network while hiding the specific structure of the internal network, thus enhancing network security.
[0003] When performing network services on the client side, different execution strategies are required depending on the type of network transformation the client is in. Most existing NAT detection technologies rely on specific protocols, requiring the client to send multiple detection messages to the server, which is time-consuming and inefficient. Summary of the Invention
[0004] This application provides a method for determining network address translation type, applied to a client, wherein the client is pre-configured with address information of a first server and a second server for determining the network address translation type; the method includes:
[0005] A first detection message is sent to the first server based on the address information of the first server, and a second detection message is sent to the second server based on the address information of the second server; wherein, the first detection message is used to instruct the first server to return a first response message and a second response message to the client through the first IP address and the second IP address of the first server, respectively; the second detection message is used to instruct the second server to return a third response message and a fourth response message to the client through the first port and the second port of the second server, respectively; the response message contains the public IP address and port number obtained by performing network address translation on the client's private IP address and port number;
[0006] Receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message;
[0007] Based on the received response message, determine the conversion type used by the network where the client is located when performing network address translation on the client.
[0008] Optionally, determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message includes:
[0009] If the client receives the first response message and the second response message, and the public IP address and port number contained in the first response message and the second response message are different from the client's private IP address and port number, it is determined that the network where the client is located uses a complete cone-shaped conversion type when performing network address translation on the client.
[0010] If the client receives the first response message and the third response message, and the public IP address and port number contained in the first response message are different from those contained in the third response message, it is determined that the network where the client is located uses a symmetric type of network address translation when performing network address translation on the client.
[0011] If the client receives both the third response message and the fourth response message simultaneously, it is determined that the network where the client is located uses the IP address restriction cone type for network address translation when performing network address translation on the client.
[0012] If the client receives the third response message but does not receive the fourth response message, it is determined that the network where the client is located uses port-restricted cone type for address translation when performing network address translation on the client.
[0013] Optionally, before determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message, the method further includes:
[0014] Determine whether the client has received response messages from the first server and the second server;
[0015] If no response message is received from the first server and the second server, a prompt is displayed to the user indicating that the network address translation device is blocking communication between the client and the server.
[0016] Optionally, determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message includes:
[0017] If any response message received by the client contains a public IP address and port number that are the same as the client's private IP address and port number, the client will output a message to the user indicating that the client's private IP address has not undergone network address translation.
[0018] Optionally, the client runs a custom protocol for determining the network address translation type;
[0019] Sending the detection message to the server includes:
[0020] The custom protocol is used to send detection messages to the server.
[0021] Optionally, the client and server communicate over a network via a specified User Datagram Protocol (UDP) port.
[0022] Send a detection message to the server, including:
[0023] Send a detection message to the server via the specified UDP port.
[0024] Optionally, the custom protocol is a custom protocol that uses a type-length-value TLV encoding structure as the message structure.
[0025] Optionally, the method further includes:
[0026] In response to determining the network address translation type used by the network where the client is located, the translation type is uploaded to the scheduling server, so that the scheduling server can allocate the corresponding service node when the client executes the target service based on the translation type;
[0027] The target service is executed based on the service node allocated by the scheduling server.
[0028] Optionally, the target service includes video-on-demand service; the client obtains video-on-demand resources by accessing a content delivery network (CDN); the service node includes a CDN node.
[0029] Based on the conversion type, the scheduling server allocates a corresponding service node when the client executes the target service, including:
[0030] The scheduling server determines the CDN nodes in the CDN network that support establishing connections with the client based on the conversion type.
[0031] Executing the target service based on the service nodes allocated by the scheduling server includes:
[0032] A connection is established between the client and the CDN node, and on-demand resources on the on-demand server are played based on the connection.
[0033] Optionally, the CDN network is a P2P content delivery network (PCDN); the connection includes a P2P connection.
[0034] This application also provides a device for determining network address translation type, applied to a client, wherein the client is pre-configured with address information of a first server and a second server for determining the network address translation type; the device includes:
[0035] A detection message sending unit is configured to send a first detection message to the first server based on the address information of the first server, and to send a second detection message to the second server based on the address information of the second server; wherein, the first detection message is configured to instruct the first server to return a first response message and a second response message to the client respectively through the first IP address and the second IP address of the first server; the second detection message is configured to instruct the second server to return a third response message and a fourth response message to the client respectively through the first port and the second port of the second server; the response message includes a public IP address and port number obtained by performing network address translation on the client's private IP address and port number;
[0036] A response message receiving unit is configured to receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message;
[0037] The conversion type detection unit is used to determine the conversion type used by the network where the client is located when performing network address translation on the client, based on the received response message.
[0038] This application also provides an electronic device, including a communication interface, a processor, a memory, and a bus, wherein the communication interface, the processor, and the memory are interconnected via the bus;
[0039] The memory stores machine-readable instructions, and the processor executes the above method by invoking the machine-readable instructions.
[0040] This application also provides a computer-readable storage medium storing machine-readable instructions that, when called and executed by a processor, implement the above-described method.
[0041] This application also provides a computer program product, which implements the above-described method when executed by a processor.
[0042] In the scheme described in the above embodiments, the client sends detection messages to both the first server and the second server, instructing the first server to return response messages via different IP addresses and the second server to return response messages via different ports. Therefore, by sending only one detection message to each of the two servers and based on the returned server response messages, the network address translation type used by the client during network address translation can be quickly determined, improving the efficiency of network address translation detection. Attached Figure Description
[0043] Figure 1 This is a flowchart illustrating a method for determining a network address translation type in the prior art, provided by an exemplary embodiment.
[0044] Figure 2 This is a network architecture diagram illustrating a method for determining a network address translation type, as shown in an exemplary embodiment.
[0045] Figure 3 This is an exemplary embodiment illustrating a flowchart of a method for determining a network address translation type.
[0046] Figure 4 This is a flowchart illustrating another method for determining a network address translation type provided in an exemplary embodiment.
[0047] Figure 5 This is a timing diagram of a method for determining a network address translation type, provided in an exemplary embodiment.
[0048] Figure 6 This is a timing diagram of another method for determining a network address translation type provided in an exemplary embodiment.
[0049] Figure 7 This is a hardware structure diagram of an electronic device containing a network address translation type determination device, provided as an exemplary embodiment.
[0050] Figure 8 This is a block diagram of a network address translation type determination apparatus provided in an exemplary embodiment. Detailed Implementation
[0051] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0052] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0053] To facilitate the explanation of the method for determining the network address translation type provided in this application, the following is a brief description of the method for determining the network address translation type in the prior art.
[0054] In existing technologies, the STUN (Session Traversal Utilities for NAT) protocol is typically used. The client interacts with the STUN server multiple times to determine the type of NAT translation used by the network where the client is located.
[0055] Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for determining a network address translation type in the prior art, provided by an exemplary embodiment.
[0056] Step 102: The client can send a detection message to the STUN server. The detection message may include the client's private IP address and port number.
[0057] In practical applications, the detection message can specifically be a Binding Request. A Binding Request is a basic message type in the STUN protocol. By sending a Binding Request to the STUN server, the client can obtain the public IP address and port number of its private IP address after NAT translation.
[0058] In step 104, the client can determine whether it has received the first response message returned by the first server.
[0059] Step 106: If the client does not receive the first response message from the first server, it means that the NAT device is blocking communication between the client and the server.
[0060] Step 108: If the client receives the first response message from the first server, it can further determine whether the public IP address in the first response message is the same as the client's private IP address.
[0061] Step 110: If the public IP address in the first response message is the same as the client's private IP address, it means that the client's private IP address has not undergone NAT address translation.
[0062] Step 112: If the public IP address in the first response message is not the same as the client's private IP address, the client can send a second detection message to the first server again and cause the first server to reply with a different IP address.
[0063] Step 114: The client determines whether it has received the second response message returned by the first server.
[0064] Step 116: If the client receives the second response message returned by the first server, it means that after the client sends a request to the external address, the NAT device allows any external address to send a response to the client, so the conversion type is full cone.
[0065] Step 118: If the client does not receive the second response message from the first server, the client can send a third detection message to the second server to make the second server return a third response message.
[0066] Step 120: The client determines whether it has received the third response message returned by the second server.
[0067] Step 122: If the client determines that it has not received the third response message returned by the second server, it means that the NAT device is blocking communication between the client and the server.
[0068] Step 124: If the client receives a third response message from the second server, it can further determine whether the public IP address and port number in the first response message are the same as those in the third response message.
[0069] Step 126: If the public IP address and port number in the first response message are different from those in the third response message, it means that the NAT device will create a separate mapping entry for each independent communication pair, and therefore the conversion type is symmetric.
[0070] Step 128: If the public IP address and port number in the first response message are the same as those in the third response message, then the client sends a detection message to the second server and causes the second server to reply with a fourth response message using a different port.
[0071] Step 130: The client determines whether it has received the fourth response message returned by the second server.
[0072] Step 132: If the client receives the fourth response message returned by the second server, it means that after the client sent a request to the external address, the NAT device allowed any port of the same IP address as the request to send a response to the client. Therefore, the conversion type is IP address restricted cone.
[0073] Step 134: If no fourth response message is received from the second server, it means that after the client sends a request to the external address, the NAT device only allows the external address with the same IP address and port as the requesting address to send a response to the client. Therefore, the conversion type is port-restricted cone.
[0074] In existing technologies, if it is necessary to detect the type of NAT translation used by the network where the client is located, the client needs to send four different requests to the first server and the second server respectively, which is time-consuming and wastes system resources.
[0075] In view of this, this application proposes a technical solution that simultaneously sends detection messages to a first server and a second server, and determines the NAT translation type used by the client when performing NAT translation on the client based on the response messages received from the first server and the second server.
[0076] Please see Figure 2 , Figure 2 This is a network architecture diagram of a method for determining a network address translation type, provided in an exemplary embodiment.
[0077] Figure 2 This includes a client, a NAT device, a first server, and a second server. The client is located on an internal network and needs to communicate with the first and second servers externally. The NAT device is responsible for translating the client's private IP address on the internal network into a public IP address, enabling the client to communicate with the servers on the external network. The first and second servers communicate with the client and determine the type of NAT translation used to identify the client's network location.
[0078] Please see Figure 3 , Figure 3This is a flowchart illustrating a method for determining a network address translation type, provided in an exemplary embodiment. The method may include the following steps:
[0079] Step 302: Send a first detection message to the first server based on the address information of the first server, and send a second detection message to the second server based on the address information of the second server; wherein, the first detection message is used to instruct the first server to return a first response message and a second response message to the client through the first IP address and the second IP address of the first server, respectively; the second detection message is used to instruct the second server to return a third response message and a fourth response message to the client through the first port and the second port of the second server, respectively; the response message contains the public IP address and port number obtained by performing network address translation on the client's private IP address and port number.
[0080] In this specification, the client can send a first detection message to the first server and a second detection message to the second server based on pre-configured address information.
[0081] The first and second detection messages include at least the client's private IP address and port number. The first detection message also instructs the first server to return a first response message and a second response message to the client using its first IP address and second IP address, respectively. The second detection message instructs the second server to return a third response message and a fourth response message to the client using its first port and second port, respectively.
[0082] In practical applications, servers may be deployed on hosts with multiple public IP addresses, or as part of a distributed system, each response may originate from different physical servers or different interfaces of the same server. Therefore, servers can reply to client response messages through different IP addresses and different ports.
[0083] Here, the first IP address can be the IP address of the server used by the client to initiate the detection message, and the second IP address can be another IP address of the server. Similarly, the first port can be the port number of the server used by the client to initiate the detection message, and the second port can be another port number on the server.
[0084] For example, suppose the client's private IP address is 192.168.1.100, and its port number is 45678; the client's public IP address after NAT translation is 203.0.113.42, and its port number is 56789. The first server's IP address and port number are 52.209.143.78:12345, and the second server's IP address and port number are 139.59.128.67:23456.
[0085] The client can send a first detection message to the first server based on the first server's IP address and port number 52.209.143.78:12345. The first detection message contains the client's private IP address and port number 192.168.1.100:45678.
[0086] After the client sends the first detection message, it first passes through the NAT device. The NAT device will create a new mapping entry, mapping the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789, so that the client can communicate with external devices.
[0087] It should be noted that NAT devices create different mapping entries based on different translation types, so the translation type needs to be determined subsequently based on the response message received by the client.
[0088] Furthermore, the NAT device forwards the first detection message to the first server. After receiving the first detection message, the first server generates a first response message and a second response message. Both the first and second response messages contain the client's public IP address and port number from the first detection message forwarded by the NAT device.
[0089] Furthermore, the first server can use the IP address and port number of the server used by the client to initiate the detection message, namely 52.209.143.78:12345, to return a first response message to the client. Simultaneously, the first server can also use other IP addresses on the server, such as 52.209.143.79:12345, to return a second response message to the client.
[0090] Similarly, the client can also send a second detection message to the second server based on the second server's IP address and port number 139.59.128.67:23456. The second detection message also contains the client's private IP address and port number 192.168.1.100:45678.
[0091] After the client sends the second detection message, it first passes through the NAT device. The NAT device creates a new mapping entry, mapping the private IP address and port in the second detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789, so that the client can communicate with external devices.
[0092] It should be noted that NAT devices create different mapping entries based on different translation types, so the translation type needs to be determined subsequently based on the response message received by the client.
[0093] Furthermore, the NAT device forwards the second detection message to the second server. After receiving the first detection message, the first server generates a third response message and a fourth response message, both of which contain the client's public IP address and port number from the first detection message forwarded by the NAT device.
[0094] Furthermore, the second server can use the IP address and port number of the server used by the client to initiate the detection message, namely 139.59.128.67:23456, to return a third response message to the client. Simultaneously, the second server can also use other ports on the server, such as 139.59.128.67:23457, to return a fourth response message to the client.
[0095] Step 304: Receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message.
[0096] After the first and second servers generate response messages, they will send the response messages to the NAT device, which will then forward them to the client.
[0097] Depending on the type of NAT translation used when the client is located on the network, the client may receive different response messages, that is, it may receive at least some of the first, second, third and fourth response messages.
[0098] Step 306: Based on the received response message, determine the type of NAT translation used by the network where the client is located.
[0099] After receiving at least some of the response messages in the first, second, third, and fourth response messages, the client can directly determine the type of NAT translation used by the network where the client is located based on the received response messages and the client's private IP address and port number contained in the response messages.
[0100] Specifically, if the client receives both the first response message and the second response message simultaneously, and the public IP address and port number contained in both the first and second response messages are different from the client's private IP address and port number, then the conversion type can be a complete cone.
[0101] In this context, a full cone NAT means that when a client sends a request to any external address, the NAT device creates a mapping relationship and allows any external address and port to send data to the public IP and port number mapped to that address.
[0102] For example, suppose the client's private IP address is 192.168.1.100, and its port number is 45678; the client's public IP address after NAT translation is 203.0.113.42, and its port number is 56789. The first server's IP address and port number are 52.209.143.78:12345, and the second server's IP address and port number are 139.59.128.67:23456.
[0103] The client can send a first detection message to the first server based on the first server's IP address and port number 52.209.143.78:12345. The first detection message contains the client's private IP address and port number 192.168.1.100:45678.
[0104] At the same time, the client sends a second detection message to the second server based on the second server's IP address and port number 139.59.128.67:23456. The second detection message also contains the client's private IP address and port number 192.168.1.100:45678.
[0105] After the client sends the first detection message, it first passes through the NAT device. The NAT device creates a mapping entry, mapping the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789.
[0106] Because the translation type is full cone NAT, other external addresses can also send data to this public IP address and port number if this mapping entry is present.
[0107] After receiving the first detection message, the first server can use the IP address and port number of the server used by the client to initiate the detection message, i.e., 52.209.143.78:12345, to return a first response message to the client. Simultaneously, the first server can also use other IP addresses on the server, such as 52.209.143.79:12345, to return a second response message to the client.
[0108] Because it is a full cone NAT, any external address can send data to this public IP address and port number. Therefore, the client can receive the first response message and the second response message.
[0109] After receiving the first and second response messages, it can be further determined whether the public IP address and port number in the first and second response messages match the client's private IP address and port number. If they match, it means that the client's private IP address has not undergone address translation. If they do not match, then the translation type can be determined to be a full cone.
[0110] Furthermore, if the client receives both a first response message and a third response message, and the public IP address and port number contained in the first response message are different from those contained in the third response message, it is determined that the network where the client is located uses a symmetric NAT translation method when performing NAT translation on the client.
[0111] Symmetric NAT means that the NAT device creates a separate mapping entry for each independent communication pair. This means that even if the client sends a request with the same private IP address and port, the NAT device will assign different public IP addresses and ports because the destination IP address is different, thus creating two different mapping entries.
[0112] For example, suppose the client's private IP address is 192.168.1.100 and the port number is 45678. The IP address and port number of the first server are 52.209.143.78:12345, and the IP address and port number of the second server are 139.59.128.67:23456.
[0113] The client can send a first detection message to the first server based on the first server's IP address and port number 52.209.143.78:12345. The first detection message contains the client's private IP address and port number 192.168.1.100:45678.
[0114] At the same time, the client sends a second detection message to the second server based on the second server's IP address and port number 139.59.128.67:23456. The second detection message also contains the client's private IP address and port number 192.168.1.100:45678.
[0115] After the client sends the first detection message, it first passes through the NAT device. The NAT device creates a mapping entry, mapping the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789. This mapping entry is specifically created for the client to access the first server.
[0116] Because the translation type is symmetric NAT, after the client sends the second detection message, the NAT device will create another mapping entry to map the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 204.0.113.42:56789. This mapping entry is specifically created for the client to access the second server.
[0117] After receiving the first detection message, the first server can use the IP address and port number of the server used by the client to initiate the detection message, namely 52.209.143.78:12345, to return the first response message to the client.
[0118] After receiving the second detection message, the second server can use the IP address and port number of the server used by the client to initiate the detection message, namely 139.59.128.67:23456, to return a third response message to the client.
[0119] Because it's a symmetric NAT, each independent communication has a different mapping entry. Therefore, the client will receive a first response message and a third response message.
[0120] Upon receiving the first and third response messages, it can be further determined whether the public IP address and port number in the first and third response messages are consistent.
[0121] Because it's a symmetric NAT, and the NAT device establishes different mapping entries, the public IP address and port number in the first response message should be 203.0.113.42:56789, while the second response message contains 204.0.113.42:56789. Therefore, the public IP address and port number in the first and third response messages are not consistent.
[0122] Therefore, if the client receives both a first response message and a third response message, and the public IP address and port number contained in the first response message are different from those contained in the third response message, it can be determined that the network where the client is located is using a symmetric NAT translation method for the client.
[0123] Furthermore, if the client receives both a third response message and a fourth response message simultaneously, it can be determined that the target translation type is IP address restriction cone.
[0124] In address-restricted cone NAT, once an internal client sends data to a specific external IP address through the NAT device, the NAT device will allow packets from any port of that IP address to enter. As long as the source IP address of the external response is consistent with the target IP address previously requested by the client, the response can successfully pass through the NAT and be received by the client, regardless of how the port number of the response changes.
[0125] For example, suppose the client's private IP address is 192.168.1.100 and the port number is 45678. The second server's IP address and port number are 139.59.128.67:23456.
[0126] The client sends a second detection message to the second server based on the second server's IP address and port number 139.59.128.67:23456. The second detection message also contains the client's private IP address and port number 192.168.1.100:45678.
[0127] After the client sends the second detection message, it first passes through the NAT device. The NAT device creates a mapping entry, mapping the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789. Because the translation type is IP address restricted cone, this mapping entry will allow any IP address of 139.59.128.67 to return a response to the client.
[0128] After receiving the second detection message, the second server can use the IP address and port number of the server used by the client to initiate the detection message, i.e., 139.59.128.67:23456, to return a third response message to the client. Simultaneously, the second server can also use other ports on the server, such as 139.59.128.67:23457, to return a fourth response message to the client.
[0129] Because it is an IP address-restricted cone NAT, when the client sends a request to the IP address 139.59.128.67 of the second server through the NAT device, the NAT device will allow any data packets from IP address 139.59.128.67. Therefore, even though the port number changes, the client can still receive all response messages returned by IP address 139.59.128.67.
[0130] Therefore, if the client receives the third and fourth response messages, it can be determined that the network where the client is located is using the IP address-restricted cone type for NAT translation.
[0131] Furthermore, if the client receives a third response message but does not receive a fourth response message, the target conversion type is determined to be port-restricted cone.
[0132] Port-restricted cone NAT further restricts the entry conditions of external data packets compared to address-restricted cone NAT. Under port-restricted NAT, not only must the source IP address of the external data packet match the target IP address requested by the client, but the source port number must also match the port number used in the client's request. Therefore, the response can only pass through the NAT and be received by the client if the source IP address and port of the external response are exactly the same as the target IP address and port number requested by the client.
[0133] For example, suppose the client's private IP address is 192.168.1.100 and the port number is 45678. The second server's IP address and port number are 139.59.128.67:23456.
[0134] The client sends a second detection message to the second server based on the second server's IP address and port number 139.59.128.67:23456. The second detection message also contains the client's private IP address and port number 192.168.1.100:45678.
[0135] After the client sends the second detection message, it first passes through the NAT device. The NAT device creates a mapping entry, mapping the private IP address and port in the first detection message to a public IP address and port. That is, 192.168.1.100:45678 is mapped to 203.0.113.42:56789. Because the translation type is port-restricted cone, this mapping entry will only respond to external addresses with IP address 139.59.128.67 and port number 23456.
[0136] After receiving the second detection message, the second server can use the IP address and port number of the server used by the client to initiate the detection message, i.e., 139.59.128.67:23456, to return a third response message to the client. Simultaneously, the second server can also use other ports on the server, such as 139.59.128.67:23457, to return a fourth response message to the client.
[0137] Because it's a port-restricted cone NAT, when the client sends a request to the second server's IP address and port number 139.59.128.67:23456 through the NAT device, the NAT device will only receive packets from IP address and port number 139.59.128.67:23456. Therefore, although the second server uses 139.59.128.67:23457 to return a fourth response message to the client, the client will not receive the fourth response message.
[0138] Therefore, if the client receives the third response message but not the fourth response message, it can be determined that the network where the client is located is using the port-restricted cone type for NAT translation.
[0139] In summary, by determining the response message returned by the server and the content contained in the response message, the type of NAT translation used by the network where the client is located can be quickly determined, thus improving the efficiency of NAT detection.
[0140] In one implementation, it can be determined whether the client has received response messages from the first server and the second server.
[0141] If the client does not receive any response messages from the first and second servers, it indicates that the NAT device may be blocking communication between the client and the servers for various reasons. For example, port mapping or port forwarding may not be configured correctly on the NAT device. Another example is that the mapping relationships assigned by the NAT device have timed out. Yet another example is that the NAT device may be limiting the number of concurrent active connections, and new connection requests exceeding this limit will be rejected.
[0142] Therefore, a message can be displayed to the user indicating that the NAT device is blocking communication between the client and the server, so that the user can resolve the problem and then check the type of NAT translation used by the network where the client is located.
[0143] In one implementation, if the public IP address and port number contained in any response message received by the client are the same as the client's private IP address and port number, it indicates that the client's private IP address has not undergone NAT address translation. Therefore, a message indicating that the client's private IP address has not undergone NAT address translation can also be displayed to the user.
[0144] Please see Figure 4 , Figure 4 This is a flowchart illustrating another method for determining a network address translation type provided in an exemplary embodiment.
[0145] In step 402, the client may send a first detection message to the first server so that the first server returns a first response message and a second response message. At the same time, the client sends a second detection message to the second server so that the second server returns a third response message and a fourth response message.
[0146] In step 404, the client can determine in real time whether any response message has been received.
[0147] Step 406: If the client does not receive any response message, it means that the NAT device is blocking communication between the client and the server. The user can be prompted that the NAT device is blocking communication between the client and the server.
[0148] Step 408: If the client receives any response message, it can determine whether the public IP address in the response message is the same as the client's private IP address.
[0149] Step 410: If the public IP address in any response message is the same as the client's private IP address, it means that the client's private IP address has not undergone NAT address translation. A prompt can be output to the user indicating that the client's private IP address has not undergone NAT address translation.
[0150] In step 412, the client can further determine whether it has received both the first response message and the second response message returned by the first server.
[0151] Step 414: If the client receives both the first response message and the second response message from the first server, it means that any external address can reply to the client, so the conversion type is a complete cone.
[0152] In step 416, the client can further determine whether it has simultaneously received the first response message returned by the first server and the third response message returned by the second server, and whether the public IP address in the first response message and the public IP address in the third response message are different.
[0153] Step 418: If the client receives both the first response message from the first server and the third response message from the second server, and the public IP address in the first response message is different from the public IP address in the third response message, it means that the NAT device will establish a separate mapping entry for each independent communication pair, and therefore the conversion type is symmetric.
[0154] In step 420, the client can further determine whether it has received both the third and fourth response messages returned by the second server.
[0155] Step 422: If the client receives both the third and fourth response messages from the second server, it means that the client can receive the response regardless of the port, provided the IP address remains unchanged. Therefore, the conversion type is IP address restricted cone.
[0156] Step 424: If the client only receives the third response message from the second server and not the fourth response message, it means that the server only allows the client to receive a response if the IP address and port number exactly match those used in the client's request. Therefore, the conversion type is port-restricted cone.
[0157] Please see Figure 5 , Figure 5 This is a timing diagram of a method for determining a network address translation type, provided in an exemplary embodiment.
[0158] Step 502: The client can send the first detection message to the first server.
[0159] In step 504, the client can send a second detection message to the second server.
[0160] It should be noted that in practical applications, the client sends the first detection message and the second detection message to the first server and the second server respectively, without any specific order. Figure 5 This is merely one example. In practical applications, the client can simultaneously send the first detection message and the second detection message to both the first and second servers.
[0161] Step 506: The first server returns a first response message and a second response message.
[0162] Step 508: The second server returns the third response message and the fourth response message.
[0163] In step 510, the client can determine the network address translation type based on the response message returned by the server. The specific determination method will not be described in detail here.
[0164] In one implementation, the client runs a custom protocol specifically designed to detect conversion types.
[0165] According to the specifications of the custom protocol, the client can construct a detection message corresponding to the custom protocol. Specifically, the detection message may include the client's private IP address and port, as well as identifiers and data used to instruct the server to reply with a response message, etc.
[0166] Using this custom protocol, the client can send detection messages to both a first and a second server, and the servers can respond with corresponding response messages according to the protocol's requirements. Furthermore, the client can determine the type of NAT translation used by the network it is in by the content of the response message and whether it receives the response message.
[0167] In one implementation, the custom protocol is one that uses a TLV encoding structure as its message structure. TLV is a flexible data encapsulation method that can be widely used in various protocols. It typically consists of three parts: Type: A field that identifies the type of the following data. This allows the protocol to be easily extended, as new data items can be introduced simply by defining new type values, without modifying existing code or reordering all messages. Length: Specifies the byte length of the following Value field, allowing the receiver to accurately parse each value. Value: The actual data content carried, the length of which is determined by the Length field.
[0168] By using the TLV encoding structure as the message structure, it is more concise and easier to parse than the STUN protocol, thereby saving bandwidth and computing resources, and thus enabling more efficient NAT detection.
[0169] In one implementation, communication between the client and server is accomplished via the UDP protocol, with a specified UDP port. The client can send detection messages to the server through this specified UDP port.
[0170] In one implementation, after determining the NAT translation type used by the network where the client is located, the NAT translation type can be uploaded to the scheduling server, so that the scheduling server can allocate the corresponding service node when the client performs the target service based on the NAT translation type.
[0171] Furthermore, the client can execute the target service based on the service node allocated by the scheduling server.
[0172] Specifically, if the transformation type of the business node is a complete cone, the scheduling server can usually assign any node to the client, and the client can establish a connection with the business node without special processing.
[0173] If the business node's translation type is symmetric, since the NAT device assigns a new public IP address and port for each outgoing connection request, it is necessary to rely on a third-party relay server to relay the connection and help the client establish a connection with the business node.
[0174] If the conversion type of the service node is IP address restricted cone, if the client needs to establish a connection with the service node, it may need to use a third-party relay server or a pre-established channel to assist in establishing the connection.
[0175] If the conversion type of the business node is port-restricted cone, since port-restricted cone has strict restrictions on the ports of inbound connections, it is also necessary to use existing protocols to discover the client's public network mapping information and use a third-party relay server to assist in establishing the connection.
[0176] In one implementation, the target service involves video-on-demand (VOD) services, and the client obtains VOD resources through a CDN (Content Delivery Network).
[0177] The scheduled server can typically intelligently select or allocate a CDN node capable of establishing an effective connection. Clients can then connect to the selected CDN node and obtain the corresponding on-demand resources.
[0178] Once a stable connection is established between the client and the CDN node, the CDN node acts as an intermediary, retrieving content from the video-on-demand server based on the client's video-on-demand request. The CDN node can optimize the content delivery path based on factors such as network conditions and geographical location, ensuring efficient and low-latency resource distribution.
[0179] In one implementation, the CDN network can be a PCDN (Peer-to-Peer Content Delivery Network) network.
[0180] In a PCDN network, each terminal device participating in the P2P network can act as a CDN node. This includes, for example, a user's personal computer, smartphone, smart TV, or any other hardware device capable of running the relevant software. These devices are interconnected through the network, forming a distributed network that collectively handles content storage and distribution.
[0181] When a user requests on-demand resources, such as watching videos or other media content, that user can act as a CDN node in the PCDN network and obtain data from other CDN nodes that have already partially downloaded the content, instead of downloading directly from the central server. This reduces the load on the central server while improving transmission speed and efficiency.
[0182] In a PCDN network, when a CDN node requests video-on-demand resources, the scheduling server can allocate other CDN nodes that have downloaded some video-on-demand resources to that node, and a P2P connection can be established between the two CDN nodes to obtain the video-on-demand resources.
[0183] Different CDN nodes have different NAT types, resulting in varying levels of difficulty in establishing P2P connections. Therefore, the scheduling server can intelligently select appropriate nodes for allocation, maximizing the success rate of P2P connections. For example, establishing P2P connections is relatively easy for nodes with full cone and address-restricted cone NAT types because these types of NAT allow external communication to initiate from previously established connections. However, for port-restricted cone and symmetric NAT types, more complex strategies are needed, such as using STUN / TURN servers for NAT traversal or relying on existing direct connections for relaying, to ensure the feasibility of P2P connections. When allocating nodes, the scheduling server can prioritize CDN nodes with full cone and address-restricted cone NAT types, thereby maximizing the success rate of P2P connections, ensuring the efficiency and quality of content transmission, and reducing unnecessary relay traffic, thus lowering network costs.
[0184] Please see Figure 6 , Figure 6 This is a timing diagram of a method for determining a network address translation type, provided in an exemplary embodiment.
[0185] Step 602: The client can send the first detection message to the first server.
[0186] In step 604, the client can send a second detection message to the second server.
[0187] It should be noted that in practical applications, the client sends the first detection message and the second detection message to the first server and the second server respectively, without any specific order. Figure 5 This is merely one example. In practical applications, the client can simultaneously send the first detection message and the second detection message to both the first and second servers.
[0188] Step 606: The first server returns a first response message and a second response message.
[0189] In step 608, the second server returns the third and fourth response messages.
[0190] In step 610, the client can determine the network address translation type based on the response message returned by the server. The specific determination method will not be described in detail here.
[0191] Step 612, with Figure 5 The difference is that after the client determines the network address translation type, it can further upload the translation type to the scheduling server, so that the scheduling server can allocate the corresponding CDN node when the client requests on-demand resources.
[0192] Step 614: The client, acting as a CDN node, can request on-demand resources.
[0193] Step 616: The scheduling server can allocate CDN nodes to the client based on the conversion type of each CDN node previously obtained.
[0194] In step 618, the client can establish a P2P connection with the CDN node allocated by the scheduling server and obtain on-demand resources based on the established P2P connection.
[0195] In the scheme described in the above embodiments, the client sends detection messages to both the first server and the second server, instructing the first server to return response messages via different IP addresses and the second server to return response messages via different ports. Therefore, by sending only one detection message to each of the two servers and based on the returned server response messages, the network address translation type used by the client during network address translation can be quickly determined, improving the efficiency of network address translation detection.
[0196] Please see Figure 7 , Figure 7 This is an exemplary embodiment illustrating the hardware structure of an electronic device containing a network address translation type determination device. At the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, memory 708, and non-volatile memory 710, and may also include other hardware required for various services. One or more embodiments of this specification can be implemented in software, for example, the processor 702 reads the corresponding computer program from the non-volatile memory 710 into memory 708 and then runs it. Of course, besides software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0197] Please see Figure 8 , Figure 8 This is a block diagram illustrating an apparatus for determining a network address translation type, as shown in an exemplary embodiment. The apparatus for determining a network address translation type can be applied to... Figure 7 The electronic device shown implements the technical solution of this specification. The aforementioned network address translation type determination device may include:
[0198] The detection message sending unit 802 is configured to send a first detection message to the first server based on the address information of the first server, and to send a second detection message to the second server based on the address information of the second server; wherein, the first detection message is configured to instruct the first server to return a first response message and a second response message to the client respectively through the first IP address and the second IP address of the first server; the second detection message is configured to instruct the second server to return a third response message and a fourth response message to the client respectively through the first port and the second port of the second server; the response message includes a public IP address and port number obtained by performing network translation on the client's private IP address and port number;
[0199] The response message receiving unit 604 is configured to receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message;
[0200] The conversion type detection unit 606 is used to determine the conversion type used by the network where the client is located when performing network address translation on the client based on the received response message.
[0201] In this embodiment, the conversion type detection unit is further configured to determine that the conversion type used by the network where the client is located when performing network address translation on the client is a complete cone if the client receives the first response message and the second response message, and the public IP address and port number contained in the first response message and the second response message are different from the private IP address and port number of the client.
[0202] If the client receives the first response message and the third response message, and the public IP address and port number contained in the first response message are different from those contained in the third response message, it is determined that the network where the client is located uses a symmetric type of network address translation when performing network address translation on the client.
[0203] If the client receives both the third response message and the fourth response message simultaneously, it is determined that the network where the client is located uses the IP address restriction cone type for network address translation when performing network address translation on the client.
[0204] If the client receives the third response message but does not receive the fourth response message, it is determined that the network where the client is located uses port-restricted cone as the translation type when performing network address translation on the client.
[0205] In this embodiment, the device further includes a blocking prompt unit, used to determine whether the client has received response messages returned by the first server and the second server;
[0206] If no response message is received from the first server and the second server, a prompt is displayed to the user indicating that the network address translation device is blocking communication between the client and the server.
[0207] In this embodiment, the conversion type detection unit is further configured to output a prompt to the user that the client's private IP address has not undergone network address translation if the public IP address and port number contained in any response message received by the client are the same as the client's private IP address and port number.
[0208] In this embodiment, the client runs a custom protocol for determining the network address translation type;
[0209] The detection message sending unit is used to send detection messages to the server based on the running custom protocol.
[0210] In this embodiment, the client and server communicate via a specified UDP port.
[0211] The detection message sending unit is used to send a detection message to the server through a specified UDP port.
[0212] In this embodiment, the custom protocol is a custom protocol that uses a TLV encoding structure as the message structure.
[0213] In this embodiment, the device further includes:
[0214] The service execution unit is used to upload the conversion type to the scheduling server in response to determining the network address translation used by the network where the client is located, so that the scheduling server can allocate the corresponding service node when the client executes the target service based on the conversion type;
[0215] The target service is executed based on the service node allocated by the scheduling server.
[0216] In this embodiment, the target service includes video-on-demand (VOD) services; the client obtains VOD resources by accessing a Content Delivery Network (CDN); and the service node includes a CDN node.
[0217] The scheduling server determines the CDN nodes in the CDN network that support establishing connections with the client based on the conversion type.
[0218] The service execution unit is further configured to establish a connection between the client and the CDN node, and to play on-demand resources on the on-demand server based on the connection.
[0219] In this embodiment, the CDN network is a PCDN network; the connection includes a P2P connection.
[0220] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0221] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0222] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0223] This specification also provides an embodiment of a computer-readable storage medium. The computer-readable storage medium stores machine-readable instructions, which, when invoked and executed by a processor, can implement the network address translation type determination method provided in any embodiment of this specification.
[0224] The computer-readable storage media provided in the embodiments of this specification may include, but are not limited to, any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic cards, or fiber optic cards. In other words, readable storage media include readable media capable of storing or transmitting information.
[0225] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0226] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0227] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0228] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0229] This specification also provides an embodiment of a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method as described in any of the preceding embodiments.
[0230] It should also be noted that 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 limitation, 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.
[0231] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0232] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0233] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."
[0234] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the scope of protection of one or more embodiments of this specification.
Claims
1. A method for determining network address translation type, characterized in that, Applied to a client, the client is pre-configured with address information of a first server and a second server for determining the network address translation type; the method includes: A first detection message is sent to the first server based on the address information of the first server, and a second detection message is sent to the second server based on the address information of the second server; wherein, the first detection message is used to instruct the first server to return a first response message and a second response message to the client through the first IP address and the second IP address of the first server, respectively; the second detection message is used to instruct the second server to return a third response message and a fourth response message to the client through the first port and the second port of the second server, respectively; the response message contains a public IP address and port number obtained by performing network address translation on the client's private IP address and port number, wherein the first IP address and the second IP address are different; Receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message; Based on the received response message, determine the type of network address translation used by the network where the client is located when performing network address translation on the client; Wherein, the first IP address is the target IP address used by the client to initiate the first detection message, the first port is the target port number used by the client to initiate the second detection message, and the first port and the second port are different ports under the same IP address.
2. The method according to claim 1, characterized in that, The step of determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message includes: If the client receives the first response message and the second response message, and the public IP address and port number contained in the first response message and the second response message are different from the client's private IP address and port number, it is determined that the network where the client is located uses a complete cone-shaped conversion type when performing network address translation on the client. If the client receives the first response message and the third response message, and the public IP address and port number contained in the first response message are different from those contained in the third response message, it is determined that the network where the client is located uses a symmetric type of network address translation when performing network address translation on the client. If the client receives both the third response message and the fourth response message simultaneously, it is determined that the network where the client is located uses the IP address restriction cone type for network address translation when performing network address translation on the client. If the client receives the third response message but does not receive the fourth response message, it is determined that the network where the client is located uses port-restricted cone type for address translation when performing network address translation on the client.
3. The method according to claim 1, characterized in that, Before determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message, the method further includes: Determine whether the client has received response messages from the first server and the second server; If no response message is received from the first server and the second server, a prompt is displayed to the user indicating that the network address translation device is blocking communication between the client and the server.
4. The method according to claim 1, characterized in that, The step of determining the network address translation type used by the network where the client is located when performing network address translation on the client based on the received response message includes: If any response message received by the client contains a public IP address and port number that are the same as the client's private IP address and port number, the client will output a message to the user indicating that the client's private IP address has not undergone network address translation.
5. The method according to claim 1, characterized in that, The client runs a custom protocol for determining the network address translation type; The step of sending a first detection message to the first server based on the address information of the first server, and sending a second detection message to the second server based on the address information of the second server, includes: Based on the custom protocol in operation, a first detection message is sent to the first server based on the address information of the first server, and a second detection message is sent to the second server based on the address information of the second server.
6. The method according to claim 5, characterized in that, The client and server communicate via a specified User Datagram Protocol (UDP) port. The step of sending a first detection message to the first server based on the address information of the first server, and sending a second detection message to the second server based on the address information of the second server, includes: A first detection message is sent to the first server based on the address information of the first server via the specified UDP port, and a second detection message is sent to the second server based on the address information of the second server.
7. The method according to claim 5, characterized in that, The custom protocol is a custom protocol that uses a type-length-value TLV encoding structure as the message structure.
8. The method according to claim 1, characterized in that, The method further includes: In response to determining the network address translation type used by the network where the client is located, the translation type is uploaded to the scheduling server, so that the scheduling server can allocate the corresponding service node when the client executes the target service based on the translation type; The target service is executed based on the service node allocated by the scheduling server.
9. The method according to claim 8, characterized in that, The target service includes video-on-demand service; the client obtains video-on-demand resources by accessing a content delivery network (CDN); the service node includes a CDN node. Based on the conversion type, the scheduling server allocates a corresponding service node when the client executes the target service, including: The scheduling server determines the CDN nodes in the CDN network that support establishing connections with the client based on the conversion type. Executing the target service based on the service nodes allocated by the scheduling server includes: A connection is established between the client and the CDN node, and video-on-demand resources on the video-on-demand server are played based on the connection.
10. The method according to claim 9, characterized in that, The CDN network is a P2P content delivery network (PCDN); the connection includes a P2P connection.
11. A device for determining network address translation type, characterized in that, Applied to a client, the client is pre-configured with address information of a first server and a second server for determining the network address translation type; the device includes: A detection message sending unit is configured to send a first detection message to the first server based on the address information of the first server, and to send a second detection message to the second server based on the address information of the second server; wherein, the first detection message is configured to instruct the first server to return a first response message and a second response message to the client respectively through the first IP address and the second IP address of the first server; the second detection message is configured to instruct the second server to return a third response message and a fourth response message to the client respectively through the first port and the second port of the second server; the response message includes a public IP address and port number obtained by performing network address translation on the client's private IP address and port number, wherein the first IP address and the second IP address are different; A response message receiving unit is configured to receive response messages returned by the first server and the second server; wherein the received response messages include at least a portion of the first response message, the second response message, the third response message, and the fourth response message; A conversion type detection unit is used to determine the conversion type used by the network where the client is located when performing network address translation on the client, based on the received response message; Wherein, the first IP address is the target IP address used by the client to initiate the first detection message, the first port is the target port number used by the client to initiate the second detection message, and the first port and the second port are different ports under the same IP address.
12. An electronic device, characterized in that, It includes a communication interface, a processor, a memory, and a bus, wherein the communication interface, the processor, and the memory are interconnected via the bus; The memory stores machine-readable instructions, and the processor executes the method according to any one of claims 1-10 by invoking the machine-readable instructions.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores machine-readable instructions that, when invoked and executed by a processor, implement the method described in any one of claims 1-10.
14. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Network address translation type detection method and system and electronic equipment
CN115766654A
NAT (Network Address Translation) type detection method and device and electronic equipment
CN117527655A