Network address translation method, related device and medium
By determining a wildcard prefix based on traffic change characteristics in a network address translation method and storing it in a fast cache area, the problems of high storage requirements and low conversion efficiency in the prior art are solved, and efficient network address translation is achieved.
Patent Information
- Application Number
- CN202510758630.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2025-09-16
AI Technical Summary
The existing network address translation method has high storage requirements and cannot quickly determine the translation rules under complex traffic patterns, resulting in low conversion efficiency and possible network system overload.
Based on the traffic change characteristics of the target network, multiple source addresses are determined and merged into a wildcard prefix, the mapping relationship is stored in the fast cache area, and the conversion rules of the target address are quickly queried.
It reduces storage requirements, improves the efficiency of network address translation, reduces the query time of target translation rules, and improves network performance.
Smart Images

Figure CN120658703A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer network technology, and in particular to a network address translation method, related devices and media. Background Art
[0002] Network Address Translation (NAT) is a technology that modifies the network address information in the IP header when a data packet passes through a routing device. Its main purpose is to convert private IP addresses into public IP addresses, thereby enabling communication between internal and external networks. The network address translation of existing technologies relies on precise matching and fixed mask rules to determine the conversion rules corresponding to the target address, and then performs network address conversion on the target address based on the conversion rules, that is, when the public network accesses the intranet, the public IP address is converted into a private IP address through the mapping relationship between the private IP and the public IP. However, this method has high storage requirements, and for complex traffic patterns (such as large flows, burst flows, short-term flows, etc.), it is impossible to quickly determine the conversion rules corresponding to the target address, the conversion efficiency is low, and it may cause network system overload. Summary of the Invention
[0003] The main purpose of the embodiments of the present application is to propose a network address translation method, related devices and media, aiming to reduce storage usage, improve network address translation efficiency, and improve the performance of the target network.
[0004] To achieve the above objectives, a first aspect of an embodiment of the present application provides a network address translation method, including:
[0005] Determine multiple source addresses based on traffic change characteristics of the target network;
[0006] Merging the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses;
[0007] Obtain the conversion rules corresponding to each source address from the full cache;
[0008] Storing a mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area;
[0009] In response to the received address conversion request of the target address, a wildcard prefix corresponding to the target address is determined in the fast cache area, and a target conversion rule corresponding to the target address is determined from multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
[0010] Optionally, merging the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses includes:
[0011] Performing binary conversion on the multiple source addresses to obtain multiple converted addresses;
[0012] comparing the plurality of translated addresses to determine that a first first number of values of the plurality of translated addresses are equal;
[0013] Based on first first number of values of the plurality of translated addresses, wildcard prefixes corresponding to the plurality of source addresses are determined.
[0014] Optionally, storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area includes:
[0015] For each source address, deleting the wildcard prefix from the source address to obtain an address suffix, and updating the source address in the conversion rule based on the address suffix;
[0016] Storing the wildcard prefix and the address suffixes corresponding to the multiple source addresses in a fast cache area;
[0017] The updated conversion rules corresponding to the multiple source addresses are stored in a fast cache area.
[0018] Optionally, after merging the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses, the method further includes:
[0019] Performing binary conversion on the wildcard prefix to obtain a converted prefix;
[0020] The first value in the converted prefix is used as a root node, and the last value in the converted prefix is used as a leaf node, so as to construct a prefix tree based on the order of the values in the converted prefix from high to low.
[0021] Optionally, in response to the received address translation request for the target address, determining a wildcard prefix corresponding to the target address in the fast cache area, and determining a target translation rule corresponding to the target address from a plurality of translation rules corresponding to the wildcard prefix, includes:
[0022] In response to the received address conversion request of the target address, performing binary conversion on the target address to obtain a first address;
[0023] Searching the prefix tree in the cache area based on the first address to obtain a wildcard prefix corresponding to the target address;
[0024] Deleting the wildcard prefix from the target address to obtain a target suffix;
[0025] A target conversion rule corresponding to the target address is determined from a plurality of conversion rules corresponding to the wildcard prefix based on the target suffix.
[0026] Optionally, after storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area, the method further includes:
[0027] In response to a received address translation request for a target address, searching the cache area based on the target address;
[0028] If the fast cache area does not have a target conversion rule corresponding to the target address, the full cache area is searched for a target conversion rule corresponding to the target address based on the target address, so as to perform address conversion on the target address based on the target conversion rule.
[0029] Optionally, before determining a plurality of source addresses based on traffic change characteristics of the target network, the method includes:
[0030] Get the time sliding window of the target network;
[0031] Obtaining the window length and sliding step size of the time sliding window;
[0032] Moving the time sliding window according to the sliding step size to determine the total traffic of each connection in the target network within the current window;
[0033] For each connection in the target network, determining a transmission rate of the connection based on a ratio of a total flow rate corresponding to the connection to the window length;
[0034] Based on the traffic sum and the transmission rate of each of the connections, a traffic change characteristic of the target network is determined.
[0035] Optionally, determining multiple source addresses based on traffic change characteristics of the target network includes:
[0036] For each of the connections, calculating a first difference between a traffic sum corresponding to the current window and a traffic sum corresponding to a window before the current window;
[0037] If the first difference is greater than a preset first threshold, determining a source address based on the connection;
[0038] If the transmission rate of the connection is greater than a preset second threshold, a source address is determined based on the connection.
[0039] Optionally, storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area includes:
[0040] If the first difference between the source address and the connection is greater than a preset first threshold, a transition cache window is set in the fast cache area, and a mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses is stored in the transition cache window;
[0041] After storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area, the method further includes:
[0042] After the transition duration is set for the transition buffer window, if the total traffic corresponding to the connection in the current window is less than a preset third threshold, the transition buffer window is deleted.
[0043] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a network address translation device, comprising:
[0044] An address determination unit, configured to determine a plurality of source addresses based on traffic change characteristics of a target network;
[0045] An address merging unit, configured to merge the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses;
[0046] A rule acquisition unit, configured to acquire the conversion rules corresponding to each source address from the full cache;
[0047] A fast storage unit, configured to store a mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area;
[0048] An address conversion unit is used to respond to an address conversion request of a received target address, determine a wildcard prefix corresponding to the target address in the fast cache area, and determine a target conversion rule corresponding to the target address from multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
[0049] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the network address translation method described in the first aspect when executing the computer program.
[0050] To achieve the above objectives, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the network address translation method described in the first aspect.
[0051] The network address translation method, related apparatus, and medium proposed in this application first determine multiple source addresses based on the traffic variation characteristics of the target network, merge the multiple source addresses, and obtain wildcard prefixes corresponding to the multiple source addresses, where each of the multiple source addresses contains the wildcard prefix. Subsequently, the translation rules corresponding to each source address are retrieved from the full cache, and the mapping relationship between the wildcard prefix and the translation rules corresponding to the multiple source addresses is stored in a fast cache. The multiple source addresses are determined based on the traffic variation characteristics of the target network, and the translation rules stored in the fast cache may be translation rules corresponding to bursty flows, large flows, and so on. In response to a received address translation request for a target address, if the target address corresponds to a bursty flow, large flows, or other traffic, the wildcard prefix corresponding to the target address is determined in the fast cache, and a target translation rule corresponding to the target address is determined from the multiple translation rules corresponding to the wildcard prefix. Target translation of the target address is then performed based on the target translation rule. Thus, for target addresses such as bursty flows and large flows that require frequent address translation, the provision of a fast cache effectively reduces the query time for target translation rules, improves the efficiency of network address translation, and thereby enhances the performance of the target network. In addition, the settings of the fast cache area and wildcard prefix do not need to store all conversion rules, which significantly reduces storage requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 This is a schematic diagram of a scenario in which the network address translation method provided in an embodiment of the present application is applied;
[0053] Figure 2 This is a main flow chart of the network address translation method provided by the embodiment of the present application;
[0054] Figure 3 This is a schematic diagram of the full cache area and the fast cache area provided in an embodiment of the present application;
[0055] Figure 4 This is a schematic diagram of the network address translation method provided by an embodiment of the present application;
[0056] Figure 5 yes Figure 2 A flowchart of determining a wildcard prefix corresponding to a plurality of source addresses in step 220;
[0057] Figure 6 yes Figure 2 A flowchart of step 240 storing the mapping relationship in the cache;
[0058] Figure 7 This is a flowchart of constructing a prefix tree provided by an embodiment of the present application;
[0059] Figure 8 yes Figure 2A flow chart of the target conversion rule corresponding to the target address is determined in step 250;
[0060] Figure 9 This is a flow chart of performing address conversion when there is no target conversion rule in the fast cache area provided by an embodiment of the present application;
[0061] Figure 10 This is a flow chart for determining traffic change characteristics of a target network provided by an embodiment of the present application;
[0062] Figure 11 yes Figure 2 A flow chart of determining a plurality of source addresses in step 210;
[0063] Figure 12 This is a flow chart of the transition buffer window setting provided by an embodiment of the present application;
[0064] Figure 13 is a structural diagram of a network address translation device provided in an embodiment of the present application;
[0065] Figure 14 This is the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0067] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0069] Before further explaining the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are explained. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0070] Large flow: In the field of computer network and data flow analysis, large flow usually refers to network flows with large data volume or high transmission rate.
[0071] Burst Traffic: refers to a large amount of data traffic that appears in a short period of time in the network. This traffic is usually sudden and irregular.
[0072] Short-term traffic: In computer networks, short-term traffic typically refers to traffic that transmits a small amount of data in a short period of time. This type of traffic is characterized by large volume, short duration, and sensitivity to delays.
[0073] Network Address Translation (NAT): is a technology that remaps IP addresses in an IP network. It is mainly used to enable multiple devices to share a public IP address to access the Internet, or to convert address formats between different networks.
[0074] Network address translation is a technology that modifies the network address information in the IP header when a data packet passes through a routing device. Its main purpose is to convert private IP addresses into public IP addresses, thereby enabling communication between internal and external networks. The network address translation of the existing technology relies on precise matching and fixed mask rules to determine the conversion rules corresponding to the target address, and then performs network address translation on the target address based on the conversion rules, that is, when the public network accesses the intranet, the public IP address is converted into a private IP address through the mapping relationship between the private IP and the public IP. However, this method has high storage requirements, and for complex traffic patterns (such as large flows, burst flows, short-term flows, etc.), it is impossible to quickly determine the conversion rules corresponding to the target address, the conversion efficiency is low, and it may cause network system overload.
[0075] Based on this, the present application provides a network address translation method, related devices and media. The network address translation method provided in the embodiment of the present application reduces storage occupancy, improves network address translation efficiency, and improves the performance of the target network.
[0076] The present application will be further described below with reference to the accompanying drawings.
[0077] See also Figure 1 , Figure 1 A schematic diagram of a scenario in which the network address translation method provided in an embodiment of the present application is applied, including a terminal device 130, a router 120, a server 110, etc.
[0078] The terminal device 130 includes but is not limited to a pre-configured personal computer, tablet computer, desktop computer, or other electronic device with data transmission capabilities. In addition, it can be a single device or a collection of multiple devices. The terminal device 130 can communicate with the router 120 in a wired or wireless manner to exchange data.
[0079] Server 110 refers to a computer system capable of transmitting data (e.g., training data) to terminal device 130. Compared to ordinary terminals, server 110 has higher requirements in terms of stability, security, and performance. Server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines).
[0080] A router 120 is a network device used to connect different networks and is capable of forwarding data packets between multiple networks. Its main function is to send data packets from one network to another based on the IP address in the data packet.
[0081] For example, in Figure 1 In the embodiment, the router 120 can convert the private IP address in the data transmitted by the terminal device 130 into a public IP address, which is the address of the terminal device 130, and forward the transmitted data to the server 110, so that the server 110 obtains the data transmitted by the terminal device 130. The network address translation method of the embodiment of the present disclosure can be implemented by the router 120.
[0082] It should be noted that Figure 1 The scenario diagram of the network address translation method application shown is only an example. The data management system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided by the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of network address translation technology and the emergence of new business scenarios, the technical solution provided by the embodiment of the present application is also applicable to similar technical problems.
[0083] Reference Figure 2 , Figure 2 The overall flow chart of the network address translation method provided in the embodiment of the present application. The network address translation method provided in the embodiment of the present application includes:
[0084] Step 210: Determine multiple source addresses based on traffic change characteristics of the target network;
[0085] Step 220: Merge multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses.
[0086] Step 230: Obtain the conversion rules corresponding to each source address from the full cache area;
[0087] Step 240: storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache;
[0088] Step 250: In response to the received address conversion request of the target address, determine the wildcard prefix corresponding to the target address in the fast cache area, and determine the target conversion rule corresponding to the target address from multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
[0089] In some implementations of step 210, the target network is the network to which the network address translation method is applied. Figure 1 In the case of a router shown, the target network is the network in which the router is located, and each connection in that network passes through the router.
[0090] Traffic variation characteristics refer to the changing characteristics of traffic on the target network. These characteristics can include transmission rate, total volume, and trend. To facilitate network address translation (NAT), traffic variation characteristics are categorized based on the source address (i.e., the sending address) of the packet.
[0091] The source address is the source address of the data packet determined based on traffic variation characteristics. The traffic corresponding to the source address is usually large or bursty. Assume that during a certain period of time, multiple addresses in the public network address segment 1.0.0.0 / 24 (such as 1.0.0.101, 1.0.0.102, and 1.0.0.107) frequently access intranet services. Based on the traffic variation characteristics of the target network, addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107 are determined to be multiple source addresses.
[0092] In some implementations of step 220 , the wildcard prefix is a network prefix determined based on multiple source addresses, and the multiple source addresses all include the wildcard prefix.
[0093] Assume that multiple source addresses are 1.0.0.101, 1.0.0.102, and 1.0.0.107. After merging these source addresses, the resulting wildcard prefix is 1.0.0.***, where * represents a wildcard character.
[0094] It should be noted that network addresses can usually be expressed in binary form. Therefore, the wildcard prefix corresponding to multiple source addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107 can be expressed as 1.0.0.******** or 1.0.0.01****** (the corresponding mask is / 24), where * represents the wildcard character and the 24-bit mask indicates that the first 24 bits of the source address are the network portion and the last 8 bits are the host portion.
[0095] In some embodiments of step 230, the full cache is an area storing complete conversion rules. Therefore, the full cache stores conversion rules corresponding to multiple source addresses. After determining multiple source addresses, the conversion rules corresponding to each source address can be obtained from the full cache.
[0096] A translation rule is the process for converting private IP addresses to public IP addresses. It can be fixed or dynamically assigned by a network address translation device (such as a gateway or router). When an intranet device (i.e., a device using a private IP address) sends a data packet to the router, the router replaces the private IP address in the packet with a public IP address and records this mapping. This mapping is known as the network address translation rule.
[0097] In some implementations of step 240, the fast storage area is an area storing conversion rules corresponding to high-frequency flows, burst flows, large flows, etc. The stored data in the fast cache area can be dynamically adjusted based on traffic change characteristics of the target network.
[0098] After determining multiple source addresses corresponding to high-frequency flows, burst flows, and large flows, the mapping relationship between the wildcard prefix and the multiple source addresses is first stored in a fast cache area, and then the conversion rules corresponding to the multiple source addresses are stored in the cache area.
[0099] Reference Figure 3 The mapping relationship between the wildcard prefix and the translation rules corresponding to multiple source addresses is stored in a table. The translation rules corresponding to multiple source addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107 correspond to the same cell, and the cell contains the wildcard prefix 1.0.0.********.
[0100] In some embodiments of step 250, the target address is an address that requires network address translation, and the traffic corresponding to the target address is a large flow, a burst flow, or a high-frequency flow. The address translation request is a request to perform network address translation on the target address, and the address translation request comes from the network device corresponding to the target address.
[0101] After receiving the address translation request of the target address, the wildcard prefix corresponding to the target address can be determined in the fast cache area, and the target translation rule corresponding to the target address can be determined from the multiple translation rules corresponding to the wildcard prefix. Therefore, the target address can be translated according to the target address translation rule.
[0102] Reference Figure 3 and Figure 4Suppose new traffic arrives at 1.0.0.107, resulting in an address translation request for 1.0.0.107. First, a lookup is performed in the cache to obtain the wildcard prefix 1.0.0.******** corresponding to the destination address 1.0.0.107. This wildcard prefix contains translation rules for 1.0.0.101 and 192.168.0.5, 1.0.0.102 and 192.168.0.6, and 1.0.0.107 and 192.168.0.9. Therefore, the target translation rule for the destination address 1.0.0.107 can be determined from the multiple translation rules corresponding to the wildcard prefix, and the destination address 1.0.0.107 can be translated to 192.168.0.9.
[0103] It should be noted that the network address translation method provided in this application first determines multiple source addresses based on the traffic variation characteristics of the target network, merges the multiple source addresses, and obtains wildcard prefixes corresponding to the multiple source addresses, where each of the multiple source addresses contains a wildcard prefix. Subsequently, the translation rules corresponding to each source address are retrieved from the full cache, and the mapping relationship between the wildcard prefix and the translation rules corresponding to the multiple source addresses is stored in a fast cache. The multiple source addresses are determined based on the traffic variation characteristics of the target network, and the translation rules stored in the fast cache may be translation rules corresponding to burst flows, large flows, and the like. In response to a received address translation request for a target address, if the target address corresponds to a burst flow, large flows, or the like, the wildcard prefix corresponding to the target address can be determined in the fast cache, and the target translation rule corresponding to the wildcard prefix can be determined from the multiple translation rules corresponding to the wildcard prefix. The target address can then be translated based on the target translation rule. In this way, for target addresses such as burst flows and large flows that require frequent address translation, the provision of a fast cache effectively reduces the query time for target translation rules, improves the efficiency of network address translation, and thereby enhances the performance of the target network. In addition, the settings of the fast cache area and wildcard prefix do not need to store all conversion rules, which significantly reduces storage requirements.
[0104] In one embodiment, referring to Figure 5 , step 220 includes:
[0105] Step 510: Perform binary conversion on the multiple source addresses to obtain multiple converted addresses;
[0106] Step 520: compare the multiple translated addresses and determine that the first first number of values of the multiple translated addresses are equal;
[0107] Step 530: Determine wildcard prefixes corresponding to the plurality of source addresses based on first first number of values of the plurality of translated addresses.
[0108] In some implementations of step 510 , the binary conversion is to convert the source address into a binary form, and the converted address is the binary form of the source address.
[0109] Assuming the source address is 1.0.0.107, the translated address is 00000001 0000000000000000001101011.
[0110] In some embodiments of step 520 , the first number is determined based on the plurality of translated addresses, and first values of the first number of the plurality of translated addresses are equal.
[0111] Assume that the source addresses are 1.0.0.101, 1.0.0.102, and 1.0.0.107, where the translated address for 1.0.0.101 is 00000001 00000000 00000000 01100101, the translated address for 1.0.0.102 is 00000001 00000000 00000000 01100110, and the translated address for 1.0.0.107 is 0000000100000000 00000000 01101011. Then, the first number of the translated addresses is 0000000100000000 00000000 01101***, and the first number is 29.
[0112] It should be noted that if the first number corresponding to multiple source addresses is small, the multiple source addresses can be divided to obtain multiple different wildcard prefixes. For example, if the multiple source addresses are 1.0.0.101, 1.0.0.102, 1.0.0.107, 2.0.0.110, and 2.0.0.112, the source addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107, and the source addresses 2.0.0.110 and 2.0.0.112 can be compared respectively.
[0113] In some implementations of step 530 , after determining that the first first number of values of the plurality of translated addresses are equal, the first first number of values may be directly used as wildcard prefixes corresponding to the plurality of source addresses.
[0114] Assuming that the first number of values of the multiple converted addresses are 00000001 0000000000000000001101***, the first number of values of the multiple converted addresses 000000010000000000000000 01101 can be used as a wildcard prefix.
[0115] It should be noted that to reduce the number of target address queries when determining target conversion rules, if the first number is greater than the number of bits corresponding to the network portion of the source address, the network portion of the source address can be directly used as the wildcard prefix corresponding to the multiple source addresses. For example, if the multiple source addresses are 1.0.0.101, 1.0.0.102, and 1.0.0.107, the number of source addresses is relatively small. To reduce the number of comparisons during the target conversion rule query, 1.0.0.******** can be directly used as the wildcard prefix.
[0116] The embodiments of the above steps 510 to 530 respectively convert multiple source addresses into binary form, i.e., converted addresses, and determine that the first first number of values of the multiple converted addresses are equal. Then, based on the first first number of values of the multiple converted addresses, the wildcard prefixes corresponding to the multiple source addresses are determined. This process uses binary wildcard matching to merge the multiple source addresses bit by bit to obtain a wildcard prefix, making the wildcard prefix more accurate and improving the accuracy of network address translation.
[0117] In one embodiment, referring to Figure 6 , step 240 includes:
[0118] Step 610: For each source address, remove the wildcard prefix from the source address to obtain an address suffix, and update the source address in the conversion rule based on the address suffix;
[0119] Step 620: store the wildcard prefix and the address suffixes corresponding to the multiple source addresses in a fast cache;
[0120] Step 630: Store the updated conversion rules corresponding to the multiple source addresses into a fast cache area.
[0121] In some implementations of step 610, the address suffix is the portion of the source address excluding the wildcard prefix. By removing the wildcard prefix from the source address, the address suffix corresponding to the source address can be obtained. The address suffix corresponds to the source address in a one-to-one relationship, and the address suffix can be used to determine the translation rule corresponding to the source address from among multiple translation rules under the wildcard prefix.
[0122] The wildcard prefix and address suffix can form a complete source address. Figure 3 Assume that multiple source addresses are 1.0.0.101, 1.0.0.102, and 1.0.0.107, and the wildcard prefix is 1.0.0.********. Then the address suffix corresponding to the source address 1.0.0.101 is 101, the address suffix corresponding to the source address 1.0.0.102 is 102, and the address suffix corresponding to the source address 1.0.0.107 is 107.
[0123] After determining the address suffix corresponding to the source address, the translation rule is updated based on the address suffix. Specifically, the source address in the translation rule is replaced with the address suffix. For example, if the source address is 1.0.0.102, the translation rule is a translation relationship between 1.0.0.102 and 192.168.0.6, and the address suffix corresponding to the source address is 102, then the updated translation rule is a translation relationship between 102 and 192.168.0.6.
[0124] In some implementations of step 620, the cache area stores a wildcard prefix and an address suffix corresponding to each source address. The complete source address can be determined based on the wildcard prefix and the address suffix.
[0125] For multiple source addresses, the cache only needs to store one wildcard prefix and multiple address suffixes, which significantly reduces the storage space required for the source address. For example, for source addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107, refer to Figure 3 , the fast cache area only needs to store the wildcard prefix 1.0.0.******** and the address suffixes 101, 102, and 107, which reduces the storage of overlapping bits and reduces the storage cost.
[0126] In some implementations of step 630, the updated conversion rules corresponding to the multiple source addresses are stored in a fast cache. Figure 3 , the conversion rule corresponding to the source address 1.0.0.102 is the mutual conversion between 1.0.0.102 and 192.168.0.6, and the address suffix of the source address 1.0.0.102 is 102, then the conversion rule stored in the fast cache area is the mutual conversion between 102 and 192.168.0.6.
[0127] It should be noted that, referring to Figure 3 , the fast cache area only needs to store one wildcard address. For the source addresses 1.0.0.101, 1.0.0.102, and 1.0.0.107, it only needs to store the wildcard prefix 1.0.0.******** and the address suffixes 101, 102, and 107. The storage items are significantly reduced. Compared with the complete storage of the source address, the storage of this method is effectively reduced by 30%-50%.
[0128] It should be noted that if the public IP corresponding to the private IP is updated, that is, the source address is updated, and the updated public IP only updates the host address, then only the address suffix in the fast cache area needs to be updated, which effectively reduces the number of updates and reduces the update cost.
[0129] In the embodiment of steps 610-630 above, for each source address, the wildcard prefix is deleted from the source address to obtain an address suffix. The cache stores the source addresses by storing the wildcard prefix and address suffix. The source addresses in the conversion rules are also stored based on the wildcard prefix and address suffix. If multiple source addresses have the same wildcard prefix, the cache only needs to store one wildcard prefix. This reduces the storage of overlapping bits, reduces the number of storage items, reduces the storage space occupied by the conversion rules, and effectively reduces the storage cost of the conversion rules.
[0130] In one embodiment, referring to Figure 7 After step 220, the method further includes:
[0131] Step 710: Perform binary conversion on the wildcard prefix to obtain a converted prefix;
[0132] Step 720: Use the first value in the converted prefix as a root node and the last value in the converted prefix as a leaf node to construct a prefix tree based on the order of the values in the converted prefix from high to low.
[0133] In some implementations of step 710 , the binary conversion is to convert the wildcard prefix into a binary form, and the converted prefix is the binary form of the wildcard prefix.
[0134] Assume that the wildcard prefix is 1.0.0.********, the prefix after translation is 0000000100000000000000000********.
[0135] In some embodiments of step 720, the prefix tree is a tree in the cache used to query the wildcard prefix corresponding to the target address, and the prefix tree includes wildcard prefixes corresponding to multiple source addresses. Therefore, after determining the wildcard prefix, a prefix tree can be constructed based on the converted prefix.
[0136] The root node of the prefix tree is the first value in the converted prefix, and the leaf nodes of the prefix tree are the last value in the converted prefix. Assume that the converted prefix is 00000001 00000000 00000000********, then the root node and leaf nodes of the prefix tree are both 0.
[0137] In addition, in the prefix tree, the multiple values passed from the root node to the leaf node are the converted prefix. Therefore, the prefix tree can be constructed from high to low based on the order of the values in the converted prefix. Since the converted prefix is in binary form, the number of child nodes corresponding to each node in the prefix tree is 2. Therefore, in the process of determining the wildcard prefix corresponding to the target address, each node only needs two times at most to determine the path where the wildcard prefix is located. The query speed of the wildcard prefix corresponding to the target address can be expressed as O(logn), where n is the number of bits in the binary form corresponding to the wildcard prefix, which is also the number of layers of the wildcard prefix in the prefix tree.
[0138] The related technology determines the conversion rule corresponding to the target address by bit-by-bit precise matching, and the matching speed is O(n). Compared with the related technology, the query matching speed of the embodiment of the present application is optimized from O(n) to O(logn), and the query efficiency is significantly improved.
[0139] It should be noted that the source address is usually stored in the fast cache in binary form. Compared with the decimal form, the number of child nodes corresponding to each node in the prefix tree is significantly reduced, which can quickly determine the path where the wildcard prefix corresponding to the target address is located, thereby improving the query speed.
[0140] In the embodiment of the above steps 710-720, in addition to the mapping relationship between the wildcard prefix and the conversion rules corresponding to multiple source addresses, the fast cache area also stores a prefix tree corresponding to the wildcard prefix. It can also be understood that the wildcard prefix is stored in the fast cache area through the prefix tree. In addition, the prefix tree corresponding to the wildcard prefix is based on the binary form of the wildcard prefix, that is, the converted prefix is determined. The root node of the prefix tree is the first value in the converted prefix, and the leaf node of the prefix tree is the last value in the converted prefix. The multiple values passed from the root node to the leaf node are the converted prefix. Therefore, in the process of determining the wildcard prefix corresponding to the target address, each node only needs two times at most to determine the path where the wildcard prefix is located. Compared with the bit-by-bit precise matching in the related art to determine the conversion rule corresponding to the target address, the query matching speed of the wildcard prefix corresponding to the target address determined by querying the prefix tree is significantly improved, thereby improving the query efficiency of the target conversion rule and the efficiency of network address conversion.
[0141] In one embodiment, referring to Figure 8 , step 250 includes:
[0142] Step 810: In response to the received address conversion request of the target address, perform binary conversion on the target address to obtain a first address;
[0143] Step 820: Search the prefix tree in the cache based on the first address to obtain a wildcard prefix corresponding to the target address;
[0144] Step 830: Delete the wildcard prefix in the target address to obtain the target suffix;
[0145] Step 840: Determine a target conversion rule corresponding to the target address from among multiple conversion rules corresponding to the wildcard prefix based on the target suffix.
[0146] In some embodiments of step 810, the target address is an address that requires network address translation, and the traffic corresponding to the target address is specifically a large flow, a burst flow, or a high-frequency flow. The address translation request is a request to perform network address translation on the target address, and the address translation request comes from the network device corresponding to the target address.
[0147] After receiving the address conversion request of the target address, the target address is converted into a binary form to obtain a first address. The first address refers to the binary representation of the target address.
[0148] Assume that new traffic 1.0.0.107 arrives, that is, an address translation request for the destination address 1.0.0.107 is received. The destination address 1.0.0.107 is converted into binary format, resulting in 00000001 00000000 0000000001101011.
[0149] In some embodiments of step 820, the wildcard prefix corresponding to the target address can be determined by a prefix tree in the fast cache area, and the prefix tree is constructed based on the binary form corresponding to the wildcard prefix, that is, the converted prefix. Therefore, the prefix tree in the fast cache area can be searched based on the binary form of the target address, that is, the first address, to obtain the wildcard prefix corresponding to the target address.
[0150] Since the number of bits of the wildcard prefix in the fast cache area is different, it is necessary to search the prefix tree in the fast cache area based on the complete number of bits in binary form corresponding to the target address.
[0151] It should be noted that if the wildcard prefixes in the cache are all 24 bits, then in the process of determining the wildcard prefix corresponding to the target address, the prefix tree in the cache may be searched based on the first 24 bits of the first address.
[0152] Assuming that the first address is 00000001 00000000 00000000 01101011, and the number of bits of the wildcard prefix is 24, the prefix tree is searched based on the order of each value in the first address to obtain the path from root node 0 to leaf node 0, and each node passed by the path corresponds to 00000001 00000000000000000. Finally, it can be determined that the wildcard prefix corresponding to the target address is 00000001 00000000000000000.
[0153] In some embodiments of step 830, the target suffix is the portion of the target address excluding the wildcard prefix. By deleting the wildcard prefix from the target address, the target suffix corresponding to the target address can be obtained. The target suffix corresponds to the target address, and the wildcard prefix and the target suffix can form a complete target address. Assuming that the target address is 1.0.0.107 and the wildcard prefix corresponding to the target address is 1.0.0.********, the target suffix corresponding to the target address is 107. Based on the wildcard prefix 1.0.0.******** and the target suffix 107, the complete target address 1.0.0.107 can be determined.
[0154] In some implementations of step 840 , after determining the target suffix corresponding to the target address, a target conversion rule corresponding to the target address may be determined from a plurality of conversion rules corresponding to the wildcard prefix based on the target suffix.
[0155] In the embodiment of steps 610 to 630 above, the conversion rules stored in the cache are updated conversion rules, i.e., the source address in the conversion rules is replaced with the address suffix, and the source address in the conversion rules is specifically determined based on the wildcard prefix and the address suffix. Therefore, after determining the wildcard prefix and target suffix corresponding to the target address, the target conversion rule corresponding to the target suffix can be determined from the multiple conversion rules corresponding to the wildcard prefix.
[0156] Reference Figure 3 Assuming the destination address is 1.0.0.107, the prefix tree determines that the wildcard prefix of the destination address is 1.0.0.********. In the cache, the wildcard prefix 1.0.0.******** corresponds to multiple address suffixes: 101, 102, and 107. Removing the wildcard prefix from the destination address yields a destination suffix of 107. Furthermore, the translation rule for the destination suffix 107 is determined to be between 107 and 192.168.0.9. Therefore, the destination translation rule for the destination address is between 107 and 192.168.0.9. Therefore, based on the destination translation rule, the destination address 1.0.0.107 can be translated to 192.168.0.9.
[0157] In the embodiment of the above steps 810-840, the fast cache area stores the source address in the conversion rule in the form of a wildcard address plus an address suffix. Then, in the process of querying the target conversion rule corresponding to the target address, the wildcard address corresponding to the target address is first determined, and then the target conversion rule corresponding to the target address is determined based on the multiple conversion rules under the wildcard address of the target suffix corresponding to the target address. The wildcard address corresponding to the target suffix is stored instead of the complete target address. While reducing storage costs, it can effectively reduce the number of queries and improve query efficiency. In addition, the wildcard prefix is stored in the fast cache area in the form of a prefix tree. Querying the prefix tree by the binary form of the target address can quickly determine the wildcard prefix of the target address, and each node only needs two times at most to determine the path where the wildcard prefix is located. Compared with the bit-by-bit precise matching in the related art to determine the conversion rule corresponding to the target address, the query matching speed of the wildcard prefix corresponding to the target address determined by querying the prefix tree is significantly improved, thereby improving the query efficiency of the target conversion rule and the efficiency of network address conversion.
[0158] In one embodiment, referring to Figure 9 After step 240, the method further includes:
[0159] Step 910: In response to the received address translation request for the target address, searching a cache area based on the target address;
[0160] Step 920: If the target conversion rule corresponding to the target address does not exist in the fast cache, search the full cache for the target conversion rule corresponding to the target address based on the target address, and perform address conversion on the target address based on the target conversion rule.
[0161] In some implementations of step 910 , after receiving an address translation request for a target address, a cache is first queried based on the target address to determine a target translation rule corresponding to the target address in the cache.
[0162] In some embodiments of step 920, if the wildcard prefix corresponding to the target address does not exist in the fast cache, or if the wildcard prefix corresponding to the target address exists in the fast cache but the multiple address suffixes corresponding to the wildcard prefix do not include the target suffix of the target address, the fast cache does not have a target conversion rule corresponding to the target address, and then the target conversion rule corresponding to the target address cannot be found in the fast cache based on the target address. However, the full cache stores complete conversion rules. In this case, the target conversion rule corresponding to the target address can be found in the full cache based on the target address, and the target address can be converted based on the target conversion rule.
[0163] Reference Figure 3 and Figure 4, assuming the target address is 2.1.0.101, after receiving the address translation request of the target address, the target translation rule corresponding to the target address is first searched in the fast cache area. Figure 3 In the cache shown, the wildcard prefix only contains 1.0.0.********, confirming that the cache does not have a target translation rule corresponding to the target address. Based on the target address 2.1.0.101, the full cache is searched for a target translation rule corresponding to the target address, and the target address is then translated based on the target translation rule.
[0164] It should be noted that in the full cache, the source addresses in the conversion rules can be stored in the form of a wildcard prefix plus an address suffix, or can be stored item by item. In addition, the source addresses in the conversion rules can also be stored in a tree format.
[0165] In the embodiment of the above-mentioned steps 910-920, when there is no target conversion rule corresponding to the target address in the fast cache area, the target conversion rule corresponding to the target address is searched in the full cache area based on the target address, so as to perform address conversion on the target address based on the target conversion rule. Regardless of the traffic volume, such as large flow, high-frequency flow, burst flow, or small flow, this method can determine the target conversion rule corresponding to the target address, thereby realizing network address conversion and improving the applicability and accuracy of network address conversion.
[0166] In one embodiment, referring to Figure 10 Before step 210, the method includes:
[0167] Step 1010: Obtain a time sliding window of the target network;
[0168] Step 1020: Obtain the window length and sliding step size of the time sliding window;
[0169] Step 1030: Move the time sliding window according to the sliding step size to determine the total traffic of each connection in the target network within the current window;
[0170] Step 1040: For each connection in the target network, determine the transmission rate of the connection based on the ratio of the total traffic volume corresponding to the connection to the window length;
[0171] Step 1050: Determine the traffic change characteristics of the target network based on the traffic sum and transmission rate of each connection.
[0172] In some implementations of step 1010, the time sliding window is a technology widely used in time series data processing. The core idea is to divide time into multiple continuous windows and perform statistics or analysis on the data in each window.
[0173] The time sliding window corresponds to the target network, and the relevant characteristics of the traffic of the target network can be determined based on the time sliding window.
[0174] In some implementations of step 1020, the window length is typically fixed. The window length of the time sliding window refers to the time span of each window, which determines the time range of data aggregation.
[0175] The sliding step size is the time interval between each movement of the time sliding window, which is usually equal to or less than the window length. The sliding step size determines the frequency of window updates.
[0176] In some embodiments of step 1030, after determining the window length and sliding step of the time sliding window, the time sliding window is moved according to the sliding step to determine the total traffic volume of each connection in the target network within the current window. The total traffic volume is set in a one-to-one correspondence with each connection in the target network. The total traffic volume refers to the total amount of data sent by the corresponding connection, that is, the total number of bytes. Assuming that the current window is window 1, and the public network address 1.0.0.102 frequently accesses the intranet service during the time period corresponding to window 1, the total traffic volume corresponding to the public network address 1.0.0.102 is the total amount of data sent by the public network address 1.0.0.102 to the intranet service during window 1.
[0177] In some implementations of step 1040, the traffic sum is set in one-to-one correspondence with each connection in the target network, the traffic sum refers to the sum of data sent by the corresponding connection, and the window length refers to the time span of each window. Based on the ratio of the traffic sum corresponding to the connection to the window length, the transmission rate of the connection in the current window can be determined. For example, the public network address 1.0.0.102 frequently accesses the intranet service in the time period corresponding to window 1, and the length of window 1 is 5s. The total traffic sent by the public network address segment to the intranet is 10MB. Then the average rate at which the public network address 1.0.0.102 sends data to the content in window 1 is 2MB / s, that is, the transmission rate of the connection corresponding to the public network address 1.0.0.102 is 2MB / s.
[0178] It should be noted that the transmission rate can also represent the bandwidth occupied by the corresponding connection in the target network.
[0179] In some implementations of step 1050 , the traffic change characteristic of the target network may be determined based on the total traffic volume and the transmission rate of each connection.
[0180] For each connection, based on the total traffic and transmission rate corresponding to the connection, the bandwidth, change trend, etc. of the connection in the target network can be determined. Therefore, based on the total traffic and transmission rate, the traffic change characteristics of the connection in the target network can be determined.
[0181] It should be noted that embodiments of the present application can specifically use the Sketch algorithm to perform high-frequency, low-cost data collection and feature extraction operations to determine the traffic change characteristics of the target network. This method can specifically implement the acquisition of traffic change characteristics for each connection in the target network through a time sliding window mechanism. In addition, embodiments of the present application can set up a cache area to store connections corresponding to large flows, high-frequency flows, burst flows, etc., to facilitate the subsequent determination of multiple source addresses.
[0182] It should be noted that the traffic change characteristics of the target network can be updated in real time or periodically. Updating the traffic change characteristics of the target network facilitates modifying the contents of the fast cache based on the actual conditions of the target network, so that the cached contents in the fast cache adapt to the traffic changes of the target network, thereby improving the query and matching efficiency of the target translation rule and the efficiency of network address translation.
[0183] The embodiment of the above steps 1010 to 1050 determines the traffic change characteristics of the target network through a time sliding window. Specifically, the time sliding window is moved according to the sliding step size, and the sum of the traffic of each connection in the target network within the current window is determined. For each connection, based on the ratio of the traffic sum to the window length, the transmission rate of the connection can be determined, and then the traffic change characteristics of the connection can be determined based on the traffic sum and the transmission rate of the connection. The traffic change characteristics of multiple connections together constitute the traffic change characteristics of the target network. This method can measure the traffic change characteristics of the target network in real time, so that the cache content in the fast cache area adapts to the traffic changes of the target network, thereby improving the query matching efficiency of the target conversion rule and improving the efficiency of network address translation.
[0184] In one embodiment, referring to Figure 11 , step 210 includes:
[0185] Step 1110: For each connection, calculate the first difference between the total traffic volume corresponding to the current window and the total traffic volume corresponding to the window before the current window;
[0186] Step 1120: If the first difference is greater than a preset first threshold, determine the source address based on the connection;
[0187] Step 1130: If the transmission rate of the connection is greater than a preset second threshold, determine the source address based on the connection.
[0188] In some implementations of step 1110 , the first difference is a difference between a total flow rate corresponding to the current window and a total flow rate corresponding to a previous window of the retaining wall window.
[0189] Assume that the total traffic of the public network address 1.0.0.102 in window 3 is 50 MB, and the total traffic in window 2 is 1 MB. The first difference is 49 MB.
[0190] In some embodiments of step 1120, the first threshold is a condition for determining whether the connection corresponding to the first difference is a burst flow. If the first difference corresponding to the connection is greater than the preset first threshold, the address corresponding to the connection can be used as the source address. If the total traffic of the connection in the current window is much greater than the total traffic in the previous window, indicating that the connection sent a large amount of data in a short period of time, the traffic corresponding to the connection is a burst flow.
[0191] Assuming that the first difference corresponding to the public network address 1.0.0.102 is 49 MB and the first threshold is 30 MB, the public network address 1.0.0.102 can be used as the source address.
[0192] It should be noted that the first threshold can be set according to business needs and specific parameters of the target network.
[0193] In some embodiments of step 1130, the second threshold is a condition for determining whether the connection corresponding to the transmission rate is a high-volume flow. If the transmission rate of the connection is greater than the preset second threshold, the address corresponding to the connection can be used as the source address. If the transmission rate of the connection is greater than the preset second threshold, it indicates that the connection occupies a large bandwidth on the target network, and the traffic corresponding to the connection is a high-volume flow.
[0194] Assume that the transmission rate corresponding to the public network address 1.0.0.102 is 20 MB / s and the second threshold is 15 MB / s. Then the public network address 1.0.0.102 can be used as the source address.
[0195] The embodiment of the above-mentioned steps 11110 to 11130 is based on the first difference between the total traffic corresponding to the current window and the total traffic corresponding to the previous window of the current window for each connection, and when the first difference corresponding to the connection is greater than the preset first threshold, or the transmission rate is greater than the preset second threshold, the address corresponding to the connection is used as the source address. The connection whose first difference is greater than the preset first threshold belongs to a burst flow, and the connection whose transmission rate is greater than the preset second threshold belongs to a large flow. Therefore, this method makes the network address translation method provided in the embodiment of the present application applicable to complex network environments such as burst flows and large flows, thereby improving the applicability of the network address translation method.
[0196] In one embodiment, referring to Figure 12 , step 240 includes:
[0197] Step 1210: If the first difference between the source address and the corresponding connection is greater than a preset first threshold, a transition cache window is set in the fast cache area, and a mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses is stored in the transition cache window;
[0198] After step 240, the method further includes:
[0199] Step 1220: After the transition duration is set in the transition buffer window, if the total traffic volume corresponding to the connection in the current window is less than a preset third threshold, the transition buffer window is deleted.
[0200] In some implementations of step 1210 , the transition buffer window is a window that stores a mapping relationship between a wildcard prefix corresponding to a burst flow and conversion rules corresponding to multiple source addresses.
[0201] When the first difference between the source address and the corresponding connection is greater than a preset first threshold, a transition cache window is set in the fast cache area, and the transition cache window is used to store the mapping relationship between the wildcard prefix and the conversion rules corresponding to multiple source addresses.
[0202] In some embodiments of step 1220, the transition duration is a condition for determining whether the transition buffer window should continue to be retained in the fast cache area. If, after the transition duration is set for the transition buffer window, the total traffic volume corresponding to the connection in the current window is less than a preset third threshold, the transition buffer window is deleted.
[0203] It should be noted that a burst flow is a large amount of data traffic that appears in the target network in a short period of time. The burst flow appears in the target network for a short time. Therefore, in order to reduce the occupation of the fast storage area by the conversion rules corresponding to the burst flow, a transition cache window is set in the fast cache area to store the mapping relationship between the wildcard prefix corresponding to the burst flow and the conversion rules corresponding to multiple source addresses.
[0204] If, after the transition duration is set in the transition buffer window, the total traffic volume corresponding to the connection in the current window is greater than the third threshold, the transition buffer window is retained.
[0205] It should be noted that the transition duration can be set as needed. Specifically, the transition duration can be the average duration of multiple burst flows in the target network, or the maximum duration of multiple burst flows in the target network. The third threshold can also be set as needed, specifically based on service requirements and target network parameters.
[0206] In the embodiment of steps 1210-1220, for burst flows, i.e., flows where the first difference between the source address and the corresponding connection is greater than a preset first threshold, a transition cache window is set in the fast cache area, and the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses is stored in the transition cache window. After the transition duration is set in the transition cache window, if the sum of the flows corresponding to the connections in the current window is less than a preset third threshold, the transition cache window is deleted, thereby reducing the fast cache space occupied by burst flows, i.e., short-term flows, so that the fast cache space is matched with the target network, and improving the efficiency of network address translation.
[0207] It should be noted that the embodiment of the present application can effectively compress the storage space occupied by the conversion rules, reduce about 40% of redundant data, and increase the hit rate in the peak traffic stage, that is, the efficiency of quickly finding the target conversion rules corresponding to the target address by about 30%, significantly improving the search efficiency of the conversion rules and the dynamic adaptability of the fast cache area, and is suitable for large-scale flow table scenarios in edge devices and virtual network environments.
[0208] In addition, refer to Figure 13 The embodiment of the present application provides a network address translation device 1300, which includes:
[0209] An address determination unit 1310 is configured to determine a plurality of source addresses based on traffic change characteristics of a target network;
[0210] An address merging unit 1320 is configured to merge multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses;
[0211] A rule acquisition unit 1330 is configured to acquire a conversion rule corresponding to each source address from the full cache;
[0212] A fast storage unit 1340 is configured to store a mapping relationship between a wildcard prefix and conversion rules corresponding to a plurality of source addresses in a fast cache area;
[0213] The address conversion unit 1350 is used to respond to the address conversion request of the received target address, determine the wildcard prefix corresponding to the target address in the fast cache area, and determine the target conversion rule corresponding to the target address from the multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
[0214] The specific implementation of the network address translation device is basically the same as the specific embodiment of the network address translation method described above, and will not be repeated here.
[0215] The present application also provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor implements a network address translation method when executing the computer program. The electronic device can be any smart terminal including a tablet computer, an in-vehicle computer, or the like.
[0216] See also Figure 14 , Figure 14 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0217] The processor 1401 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0218] The memory 1402 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1402 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1402 and is called by the processor 401 to execute the network address translation method of the embodiments of the present application.
[0219] The input / output interface 1403 is used to implement information input and output.
[0220] The communication interface 1404 is used to realize communication interaction between this device and other devices. Communication can be realized through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0221] The bus 1405 transmits information between various components of the device (eg, the processor 1401 , the memory 1402 , the input / output interface 1403 , and the communication interface 1404 ).
[0222] The processor 1401 , the memory 402 , the input / output interface 1403 and the communication interface 1404 are connected to each other in communication within the device via a bus 1405 .
[0223] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned network address translation method is implemented.
[0224] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0225] The network address translation method, related apparatus, and medium proposed in this application first determine multiple source addresses based on the traffic variation characteristics of the target network, merge the multiple source addresses, and obtain wildcard prefixes corresponding to the multiple source addresses, where each of the multiple source addresses contains the wildcard prefix. Subsequently, the translation rules corresponding to each source address are retrieved from the full cache, and the mapping relationship between the wildcard prefix and the translation rules corresponding to the multiple source addresses is stored in a fast cache. The multiple source addresses are determined based on the traffic variation characteristics of the target network, and the translation rules stored in the fast cache may be translation rules corresponding to bursty flows, large flows, and so on. In response to a received address translation request for a target address, if the target address corresponds to a bursty flow, large flows, or other traffic, the wildcard prefix corresponding to the target address is determined in the fast cache, and a target translation rule corresponding to the target address is determined from the multiple translation rules corresponding to the wildcard prefix. Target translation of the target address is then performed based on the target translation rule. Thus, for target addresses such as bursty flows and large flows that require frequent address translation, the provision of a fast cache effectively reduces the query time for target translation rules, improves the efficiency of network address translation, and thereby enhances the performance of the target network. In addition, the settings of the fast cache area and wildcard prefix do not need to store all conversion rules, which significantly reduces storage requirements.
[0226] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0227] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0228] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0229] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0230] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0231] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0232] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0233] The units described above 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 these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0234] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0235] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0236] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A network address translation method, characterized in that: include: Determine multiple source addresses based on traffic change characteristics of the target network; Merging the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses; Obtain the conversion rules corresponding to each source address from the full cache; Storing a mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area; In response to the received address conversion request of the target address, a wildcard prefix corresponding to the target address is determined in the fast cache area, and a target conversion rule corresponding to the target address is determined from multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
2. The network address translation method according to claim 1, wherein: The merging of the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses includes: Performing binary conversion on the multiple source addresses to obtain multiple converted addresses; comparing the plurality of translated addresses to determine that a first first number of values of the plurality of translated addresses are equal; Based on first first number of values of the plurality of translated addresses, wildcard prefixes corresponding to the plurality of source addresses are determined.
3. The network address translation method according to claim 1, wherein: The step of storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area includes: For each source address, deleting the wildcard prefix from the source address to obtain an address suffix, and updating the source address in the conversion rule based on the address suffix; Storing the wildcard prefix and the address suffixes corresponding to the multiple source addresses in a fast cache area; The updated conversion rules corresponding to the multiple source addresses are stored in a fast cache area.
4. The network address translation method according to claim 1, wherein: After merging the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses, the method further includes: Performing binary conversion on the wildcard prefix to obtain a converted prefix; The first value in the converted prefix is used as a root node, and the last value in the converted prefix is used as a leaf node, so as to construct a prefix tree based on the order of the values in the converted prefix from high to low.
5. The network address translation method according to claim 4, wherein: The method of determining, in response to a received address translation request for a target address, a wildcard prefix corresponding to the target address in the fast cache area, and determining a target translation rule corresponding to the target address from a plurality of translation rules corresponding to the wildcard prefix, includes: In response to the received address conversion request of the target address, performing binary conversion on the target address to obtain a first address; Searching the prefix tree in the cache area based on the first address to obtain a wildcard prefix corresponding to the target address; Deleting the wildcard prefix from the target address to obtain a target suffix; A target conversion rule corresponding to the target address is determined from a plurality of conversion rules corresponding to the wildcard prefix based on the target suffix.
6. The network address translation method according to claim 1, wherein: After storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area, the method further includes: In response to a received address translation request for a target address, searching the cache area based on the target address; If the fast cache area does not have a target conversion rule corresponding to the target address, the full cache area is searched for a target conversion rule corresponding to the target address based on the target address, so as to perform address conversion on the target address based on the target conversion rule.
7. The network address translation method according to claim 1, wherein: Before determining a plurality of source addresses based on traffic change characteristics of the target network, the method includes: Get the time sliding window of the target network; Obtaining the window length and sliding step size of the time sliding window; Moving the time sliding window according to the sliding step size to determine the total traffic of each connection in the target network within the current window; For each connection in the target network, determining a transmission rate of the connection based on a ratio of a total flow rate corresponding to the connection to the window length; Based on the traffic sum and the transmission rate of each of the connections, a traffic change characteristic of the target network is determined.
8. The network address translation method according to claim 7, wherein: The determining of multiple source addresses based on traffic change characteristics of the target network includes: For each of the connections, calculating a first difference between a traffic sum corresponding to the current window and a traffic sum corresponding to a window before the current window; If the first difference is greater than a preset first threshold, determining a source address based on the connection; If the transmission rate of the connection is greater than a preset second threshold, a source address is determined based on the connection.
9. The network address translation method according to claim 8, wherein: The step of storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area includes: If the first difference between the source address and the connection is greater than a preset first threshold, a transition cache window is set in the fast cache area, and a mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses is stored in the transition cache window; After storing the mapping relationship between the wildcard prefix and the conversion rules corresponding to the multiple source addresses in a fast cache area, the method further includes: After the transition duration is set for the transition buffer window, if the total traffic corresponding to the connection in the current window is less than a preset third threshold, the transition buffer window is deleted.
10. A network address translation device, characterized in that: include: An address determination unit, configured to determine a plurality of source addresses based on traffic change characteristics of a target network; An address merging unit, configured to merge the multiple source addresses to obtain wildcard prefixes corresponding to the multiple source addresses; A rule acquisition unit, configured to acquire the conversion rules corresponding to each source address from the full cache; A fast storage unit, configured to store a mapping relationship between the wildcard prefix and the conversion rules corresponding to the plurality of source addresses in a fast cache area; An address conversion unit is used to respond to an address conversion request of a received target address, determine a wildcard prefix corresponding to the target address in the fast cache area, and determine a target conversion rule corresponding to the target address from multiple conversion rules corresponding to the wildcard prefix, so as to perform address conversion on the target address based on the target conversion rule.
11. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the network address translation method according to any one of claims 1 to 10 when executing the computer program.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the network address translation method according to any one of claims 1 to 10 is implemented.