Search

CN-121984943-A - Method for determining shortest effective survival time of network address translation mapping based on double-server collaborative detection

CN121984943ACN 121984943 ACN121984943 ACN 121984943ACN-121984943-A

Abstract

A method for determining the shortest effective survival time of network address conversion mapping based on dual server cooperative detection includes creating multiple UDP sockets locally, binding each UDP Socket to different local ports, using multiple UDP sockets to send registration message to registration server simultaneously, receiving public network address set returned by registration server and recording mapping relation between each public network address and local port, sending detection message to detection server according to preset sequence based on multiple local ports, sending public network address set to detection server to trigger detection server to send reverse detection message to all public network addresses, receiving reverse detection message and calculating shortest effective survival time of network address conversion mapping not cleared according to each reverse detection message.

Inventors

  • ZHAO LIJIE
  • YAN XU
  • TIAN YE
  • HE SHIWEI

Assignees

  • 成都安易迅科技有限公司

Dates

Publication Date
20260505
Application Date
20251231

Claims (10)

  1. 1. The method for determining the shortest effective survival time of the network address translation mapping based on the double-server collaborative detection is applied to a client and is characterized by comprising the following steps of: Creating a plurality of UDP sockets locally, respectively binding each UDP Socket to different local ports, and simultaneously sending registration messages to a registration server by using the plurality of UDP sockets so that the registration server records public network addresses corresponding to each registration message, forming a public network address set and returning; Receiving a public network address set returned by the registration server, and recording a mapping relation between each public network address in the public network address set and a corresponding local port; Based on the plurality of local ports, sending detection messages to a detection server according to a preset sequence, wherein the detection sequence numbers of the detection messages are sequentially increased according to the sending sequence; after the local ports send detection messages, the public network address set is sent to the detection server so as to trigger the detection server to send reverse detection messages to all public network addresses in the public network address set; And receiving reverse detection messages from the detection server, sending detection sequence numbers of the detection messages according to local ports corresponding to the reverse detection messages, and calculating the shortest effective survival time of the network address conversion mapping which is not cleared so as to send keep-alive messages for maintaining the address mapping to the opposite communication terminal based on the shortest effective survival time.
  2. 2. The method of claim 1, wherein before sending the probe messages to the probe server in the preset order based on the plurality of local ports, the method further comprises: Setting a position index of a local port for sending the detection message in the sending sequence, and setting a corresponding detection sequence number for the detection message sent from each local port based on the position index, wherein the detection sequence numbers are sequentially increased along with the increase of the position index.
  3. 3. The method of claim 1, wherein before calculating the shortest valid lifetime for which the network address translation map is not cleared according to the probe sequence number of the probe packet sent by the local port corresponding to each reverse probe packet, the method further comprises: starting monitoring and setting a receiving timeout window when starting to send the detection message; The method for calculating the shortest effective survival time of the network address conversion mapping which is not cleared according to the detection sequence number of the detection message sent by the local port corresponding to each reverse detection message comprises the following steps: recording all monitored reverse detection messages sent from the detection server in the receiving timeout window, and extracting local ports reached by each reverse detection message to form an effective port set; After the receiving timeout window is finished, for each local port in the effective port set, searching a detection sequence number of a detection message sent by the local port, and determining a minimum detection sequence number corresponding to the effective port set; and determining the shortest effective survival time according to the minimum detection sequence number.
  4. 4. The method of claim 3, wherein said determining said shortest effective lifetime based on said minimum probe sequence number comprises: The minimum detection sequence number is reduced by 1 and then multiplied by the transmission time interval of the detection message to obtain the shortest effective survival time, wherein the detection sequence number is numbered sequentially from 1, or And multiplying the minimum detection sequence number by a detection message sending time interval to obtain the shortest effective survival time, wherein the detection sequence number is numbered sequentially from 0.
  5. 5. The method of claim 1, wherein the using the plurality of UDP sockets to send registration messages to a registration server simultaneously, so that the registration server records a public network address corresponding to each registration message, forms a public network address set, and returns the public network address set, includes: And transmitting a registration message to the same service port of the registration server through each UDP Socket in parallel, so that the registration server receives the registration message, respectively analyzing and recording a source IP address and a source port number of each registration message, determining a public network address corresponding to the registration message according to the source IP address and the source port number, summarizing all the determined public network addresses to form a public network address set, and returning the public network address set through any return path of the UDP sockets.
  6. 6. The method of claim 5, wherein the determining, according to the source IP address and the source port number, a public network address corresponding to the registration message includes: And splicing the source IP address and the source port number according to a preset format, and taking a splicing result as the public network address, wherein the source IP address and the source port number are converted by the network address conversion equipment and filled in the head of the registration message when the registration message passes through the network address conversion equipment where the client is located.
  7. 7. The method of claim 1, wherein the sending a keep-alive message to a communication peer that maintains an address mapping based on the shortest effective lifetime comprises: Multiplying the shortest effective survival time by a preset coefficient to obtain a keep-alive message sending interval; and sending the keep-alive messages for maintaining address mapping to the opposite communication terminal by taking the keep-alive message sending interval as a period.
  8. 8. A network address translation mapping shortest effective survival time determining device based on double-server collaborative detection, applied to a client, characterized by comprising: The system comprises a registration message sending module, a registration server and a network management module, wherein the registration message sending module is used for locally creating a plurality of UDP sockets, respectively binding each UDP Socket to different local ports, using the plurality of UDP sockets to send registration messages to the registration server at the same time, so that the registration server records public network addresses corresponding to each registration message, and forms a public network address set and returns; The recording module is used for receiving the public network address set returned by the registration server and recording the mapping relation between each public network address in the public network address set and the corresponding local port; the detection message sending module is used for sending detection messages to the detection server according to a preset sequence based on the plurality of local ports, wherein the detection sequence numbers of the detection messages are sequentially increased according to the sending sequence; The address set sending module is used for sending the public network address set to the detection server after the plurality of local ports send detection messages, so as to trigger the detection server to send reverse detection messages to all public network addresses in the public network address set; and the survival time calculation module is used for receiving the reverse detection messages from the detection server, and calculating the shortest effective survival time of the network address conversion mapping which is not cleared according to the detection sequence numbers of the detection messages sent by the local ports corresponding to the reverse detection messages, so as to send a keep-alive message for maintaining the address mapping to the opposite communication terminal based on the shortest effective survival time.
  9. 9. A storage medium having stored thereon a computer program, which when executed by a processor, implements the method of any of claims 1 to 7.
  10. 10. A computer device comprising a storage medium, a processor and a computer program stored on the storage medium and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 7 when executing the computer program.

Description

Method for determining shortest effective survival time of network address translation mapping based on double-server collaborative detection Technical Field The present application relates to the field of computer networks, and in particular, to a method and apparatus for determining a shortest effective lifetime of a network address translation mapping based on dual server collaborative detection, a storage medium, and a computer device. Background Under the current internet communication architecture, the network address conversion technology is widely applied to various network access devices to realize address conversion and connection sharing between a private network and the public internet. Under the technical background, if a direct peer-to-peer communication link needs to be established between devices in different private networks, usually, by means of technical means such as UDP (user datagram protocol) tunneling and the like, both parties are coordinated through a public network server to send data packets to public network addresses mapped by the other parties at the same time, so that temporary port mapping rules are created on respective network address conversion devices, and end-to-end data transmission is realized. However, in the prior art, the method still faces a plurality of key problems in actual deployment, namely, firstly, because the maintenance time of port mapping by different network address translation devices lacks unified standard and is opaque to the outside, a client is difficult to know the effective life time of the mapping before connection establishment, so that the mapping is often failed to punch holes due to overtime failure when the response of the opposite end arrives in a handshake stage, and secondly, in order to maintain the established connection, the client usually refreshes the mapping by depending on a fixed or empirical heartbeat packet sending interval, and the static strategy cannot adapt to diversified network environments, and can cause connection interruption due to overlong interval or unnecessary network overhead due to overlong interval. Disclosure of Invention In view of this, the application provides a method and a device for determining the shortest effective survival time of network address conversion mapping based on dual server collaborative detection, a storage medium and a computer device, which acquire public network mapping in batches through a registration server, perform survival verification through a detection server, combine incremental detection sequence numbers and reverse response statistics, realize accurate and self-adaptive measurement on the survival time of the network address conversion mapping, actively and efficiently obtain key detection sequence numbers before actually establishing point-to-point connection, and completely follow a client-server communication model in the whole detection process, avoid firewall security policy interception possibly triggered by traditional point-to-point detection, thereby remarkably improving success rate and efficiency of establishing and maintaining a direct communication link in a complex network environment and being beneficial to saving network overhead. According to one aspect of the present application, a method for determining a shortest effective lifetime of a network address translation mapping based on dual server collaborative exploration is provided, which is applied to a client, and includes: Creating a plurality of UDP sockets locally, respectively binding each UDP Socket to different local ports, and simultaneously sending registration messages to a registration server by using the plurality of UDP sockets so that the registration server records public network addresses corresponding to each registration message, forming a public network address set and returning; Receiving a public network address set returned by the registration server, and recording a mapping relation between each public network address in the public network address set and a corresponding local port; Based on the plurality of local ports, sending detection messages to a detection server according to a preset sequence, wherein the detection sequence numbers of the detection messages are sequentially increased according to the sending sequence; after the local ports send detection messages, the public network address set is sent to the detection server so as to trigger the detection server to send reverse detection messages to all public network addresses in the public network address set; And receiving reverse detection messages from the detection server, sending detection sequence numbers of the detection messages according to local ports corresponding to the reverse detection messages, and calculating the shortest effective survival time of the network address conversion mapping which is not cleared so as to send keep-alive messages for maintaining the address mapping to the opposite communication t