A message processing method and device, electronic equipment and storage medium
By generating masked binary NAT server entries in the NAT routing device, the problems of storage space and search time are solved, processing performance is improved, and network latency is reduced.
Patent Information
- Application Number
- CN202411287742.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2044-09-13
AI Technical Summary
In NAT routing devices, as the number of NAT servers increases, the configured network segments increase, occupying more DDR storage space and taking a long time to find mapping relationships, affecting processing performance and increasing network latency.
When generating NAT server entries, binary numbers with masks are used to reduce storage space usage. IP addresses are quickly found and translated based on the longest match principle.
It reduces DDR storage space usage, shortens search time, improves processing performance, and reduces network latency, especially in scenarios where multiple NAT servers are deployed.
Smart Images

Figure CN119172352B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, and in particular to a message processing method and device, electronic equipment and storage medium. BACKGROUND
[0002] In a NAT (Network Address Translation) network, in some practical application scenarios, a public network host has a demand for accessing a private network server (also referred to as a NAT server), for example, a NAT server is a File Transfer Protocol (FTP) server, etc., which requires that a mapping relationship between a public IP address and a private IP address of the NAT server is configured on a NAT routing device, so that the public network host can actively access the NAT server through the NAT routing device.
[0003] With the development of network applications, a small number of NAT servers are difficult to meet the needs of users, and more NAT servers mean that more mapping relationships need to be configured on the NAT router, so most users prefer to use a mapping configuration mode of a public network segment and a private network segment to simplify the complex configuration.
[0004] Currently, for the NAT routing device, when a configuration command for configuring a public network segment of the NAT server to map to a private network segment input by an administrator is received (wherein the configuration command carries a target public network segment (for example, A~A+N), a start IP address of the target public network segment (for example, A), a target private network segment corresponding to the target public network segment (for example, a~a+N) and a corresponding start IP address (for example, a)), the NAT routing device will configure a mapping relationship of A mapping to a in turn, a mapping relationship of A+1 mapping to a+1, and so on, until a mapping relationship of A+N mapping to a+N is configured, and N+1 mapping relationships are stored in a DDR (Double Data Rate Synchronous Dynamic Random Access Memory).
[0005] When the NAT routing device receives an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network (the destination IP address of the access message is a public IP address of the target NAT server), in the N+1 mapping relationships, a mapping relationship including the destination IP address of the access message is searched; the destination IP address of the access message is converted into a private IP address in the searched mapping relationship, and the converted access message is sent to the target NAT server for processing.
[0006] As a result, as the number of NAT servers increases, the network segments configured on the NAT routing device also increase. This requires more DDR storage space and takes longer to find the mapping relationship, significantly affecting the processing performance of the NAT routing device and increasing network latency. Summary of the Invention
[0007] In order to overcome the problems existing in the related art, the present application provides a message processing method, device, electronic device and storage medium.
[0008] According to a first aspect of an embodiment of the present application, a message processing method is provided, the method being applied to a NAT routing device, the method comprising:
[0009] Upon receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generating multiple NAT server table entries based on the target public network segment, the starting IP address of the target public network segment, the target private network segment corresponding to the target public network segment and its corresponding starting IP address carried in the configuration command, wherein each NAT server table entry includes a binary number with a mask;
[0010] Upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, searching, in accordance with a longest match principle for an IP address, for a target NAT server table entry that matches the destination IP address of the access message in all NAT server table entries, wherein the destination IP address is the public IP address of the target NAT server;
[0011] Determine the private IP address corresponding to the target NAT server according to the destination IP address and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry;
[0012] The destination IP address of the access message is converted into the private IP address, and the converted access message is sent to the target NAT server for processing.
[0013] According to a second aspect of an embodiment of the present application, a message processing device is provided, which is applied to a NAT routing device, and includes:
[0014] a generation module configured to, upon receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generate a plurality of NAT server table entries based on a target public network segment, a starting IP address of the target public network segment, a target private network segment corresponding to the target public network segment and its corresponding starting IP address carried in the configuration command, wherein each NAT server table entry includes a masked binary number;
[0015] a search module configured to, upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, search, in accordance with a longest match principle for an IP address, for a target NAT server table entry that matches a destination IP address of the access message in all NAT server table entries, wherein the destination IP address is a public IP address of the target NAT server;
[0016] A determination module, configured to determine the private IP address corresponding to the target NAT server based on the destination IP address and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry;
[0017] The processing module is used to convert the destination IP address of the access message into the private IP address, and send the converted access message to the target NAT server for processing.
[0018] According to the third aspect of an embodiment of the present application, an electronic device is provided, comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement the method steps of the above-mentioned message processing method.
[0019] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of the above-mentioned message processing method are implemented.
[0020] The technical solutions provided by the embodiments of the present application may have the following beneficial effects:
[0021] In an embodiment of the present application, the NAT server table entry generated by the NAT routing device includes a masked binary number, thereby reducing the DDR storage space occupied. Furthermore, upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, the NAT routing device can quickly find a target NAT server table entry that matches the access message according to the longest match principle of the IP address. Based on the NAT server table entry, the destination IP address of the access message is quickly converted, thereby significantly shortening the time consumed in finding the NAT server table entry, improving the processing performance of the NAT routing device, and simultaneously reducing network latency. These technical effects are particularly pronounced when NAT servers are deployed in large quantities.
[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings, which are incorporated herein and constitute part of this specification, illustrate embodiments consistent with the application and, together with the description, further serve to explain the principles of the application.
[0024] Figure 1 A flowchart of a packet processing method according to an embodiment of the application;
[0025] Figure 2 A structural diagram of a packet processing apparatus according to an embodiment of the application;
[0026] Figure 3 A structural diagram of an electronic device according to an embodiment of the application. DETAILED DESCRIPTION
[0027] The exemplary embodiments will be described in detail herein with reference to the attached drawings; however, these exemplary embodiments are not meant to limit all of the embodiments consistent with the present application. Rather, they are only examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.
[0028] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0029] It is to be understood that the singular forms "a", "an", and "the" include plural referents unless the context clearly dictates otherwise. It is to be further understood that the term "or" as used herein encompasses both exclusive and inclusive or unless otherwise indicated herein. It is to be further understood that the terms "comprises", "comprising", "includes", "including", "has", "having" and the like are inclusive and are intended to be equivalent to the term "consisting of". It is to be further understood that the terms "first", "second", "third", etc. are used merely as labels, and are not intended to impose numerical requirements on their objects.
[0030] Next, the embodiments of the present application will be described in detail.
[0031] The embodiments of the present application provide a packet processing method, which is applied to a NAT routing device, as shown in Figure 1 The method can include the following steps:
[0032] S11. When receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generate multiple NAT server table entries according to the target public network segment, the starting IP address of the target public network segment, the target private network segment corresponding to the target public network segment and its corresponding starting IP address carried in the configuration command.
[0033] In this step, each NAT server entry includes a binary number with a mask.
[0034] S12. When receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, according to the longest match principle of IP addresses, search for a target NAT server entry that matches the destination IP address of the access message in all NAT server entries.
[0035] In this step, the destination IP address is the public IP address of the target NAT server.
[0036] S13, according to the destination IP address, and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry, determine the private IP address corresponding to the target NAT server;
[0037] S14: Convert the destination IP address of the access message into a private IP address, and send the converted access message to the target NAT server for processing.
[0038] Specifically, in the above step S11, the NAT routing device may generate multiple NAT server entries in the following manner:
[0039] Divide the target public network segment into multiple binary numbers with masks;
[0040] For each masked binary number, a message is generated that includes the masked binary number, the starting IP address of the target public network segment, and the starting IP address of the target private network segment.
[0041] By generating multiple NAT server entries in this way, the DDR storage space usage can be reduced.
[0042] It should be noted that, for any public network segment, the process of dividing the masked binary number by the NAT routing device is an existing technology and will not be described in detail here.
[0043] Specifically, in the above step S12, the NAT routing device searches all NAT server entries for a NAT server entry with the longest network prefix that matches the destination IP address.
[0044] It should be noted that, since the number of NAT server entries is reduced compared to the prior art, the time consumed in searching for relevant NAT server entries is greatly shortened.
[0045] Here, the found NAT server entry is called a target NAT server entry.
[0046] Specifically, in the above step S13, the NAT routing device can determine the private IP address corresponding to the target NAT server in the following manner:
[0047] Use the following formula to calculate the private IP address of the target NAT server:
[0048] Formula 1: IP y=X–A+a;
[0049] Where X is the destination IP address;
[0050] A is the starting IP address of the public network segment included in the target NAT server entry;
[0051] a is the starting IP address of the private network segment included in the target NAT server entry;
[0052] IP y is the private IP address of the target NAT server.
[0053] It should be noted that, in this determination method, X, A and a may all be binary numbers, may all be decimal numbers, or may all be hexadecimal numbers.
[0054] It should be further explained that, through this determination method, the private IP address corresponding to the target NAT server can be quickly determined to quickly convert the destination IP address, thereby improving the processing performance of the NAT routing device and reducing network latency.
[0055] The above message processing method is described in detail below with reference to specific embodiments.
[0056] Assume that in a certain NAT network, at time 1, the NAT routing device in the NAT network receives a configuration command 1 input by an administrator for configuring a NAT server to map a public network segment to a private network segment, assume that the configuration command 1 carries a public network segment 1 (for example, 1.1.1.16~1.1.1.31 (D), D represents decimal), a start IP address of the public network segment 1 (namely, 1.1.1.16), a private network segment 1 (for example, a1~a1+N) corresponding to the public network segment 1, and a corresponding start IP address (namely, a1), at this time, the NAT routing device divides the public network segment 1 into a binary number with a mask (namely, 1.1.1.1xxxx (B), B represents a binary number, x represents a mask, 1 x represents that 1 bit of specific value is masked, xxxx represents that the specific value of the last 4 bits is masked), and generates a NAT server entry (denoted as a NAT server entry 1) including 1.1.1.1xxxx (B), 1.1.1.16, and a.
[0057] Assume that at time 2, the NAT routing device receives an access packet 1 sent by a public network host 1 in the public network 1 for accessing the NAT server 1 in the private network 1, and the NAT routing device finds the NAT server entry 1 that matches the destination IP address (for example, 1.1.1.17 (D), corresponding binary number is 1.1.1.10001 (B)) of the access packet in all NAT server entries according to the IP address longest match principle.
[0058] Next, the NAT routing device determines the private IP address of the NAT server 1 as 1.1.1.17-1.1.1.16+a1 according to the above formula one, and then converts the destination IP address of the access packet 1 to the private IP address, and sends the converted access packet to the NAT server 1 for processing.
[0059] As can be seen from the above technical solution, in the embodiment of the application, the NAT server entry generated by the NAT routing device includes a binary number with a mask, which reduces the occupation of DDR storage space; and when the NAT routing device receives an access packet sent by a target public network host in a target public network for accessing a target NAT server in a target private network, the NAT routing device can quickly find a NAT server entry that matches the access packet according to the IP address longest match principle, quickly convert the destination IP address of the access packet based on the NAT server entry, greatly shorten the conversion time of the IP address, improve the processing performance of the NAT routing device, and at the same time, reduce the network delay. Especially in the case of large-scale deployment of NAT servers, these technical effects are more obvious.
[0060] Based on the same inventive concept, the present application also provides a message processing device, which is applied to a NAT routing device, and its structural diagram is shown as follows: Figure 2 As shown, specifically including:
[0061] a generating module 21 configured to, upon receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generate a plurality of NAT server table entries based on a target public network segment, a starting IP address of the target public network segment, a target private network segment corresponding to the target public network segment, and a starting IP address thereof, carried in the configuration command, wherein each NAT server table entry includes a masked binary number;
[0062] a search module 22 configured to, upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, search, in accordance with a longest match principle for an Internet Protocol IP address, for a target NAT server table entry that matches a destination IP address of the access message in all NAT server table entries, wherein the destination IP address is a public network IP address of the target NAT server;
[0063] A determination module 23 is configured to determine the private IP address corresponding to the target NAT server according to the destination IP address and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry;
[0064] The processing module 24 is configured to convert the destination IP address of the access message into the private IP address, and send the converted access message to the target NAT server for processing.
[0065] Preferably, the generating module 21 is specifically configured to generate multiple NAT server entries in the following manner:
[0066] Dividing the target public network segment into a plurality of masked binary numbers;
[0067] For each masked binary number, a message is generated that includes the masked binary number, the starting IP address of the target public network segment, and the starting IP address of the target private network segment.
[0068] Preferably, the determining module 23 is specifically configured to determine the private IP address corresponding to the target NAT server in the following manner:
[0069] The private IP address corresponding to the target NAT server is calculated using the following formula:
[0070] Formula 1: IP y=X–A+a;
[0071] Wherein, X is the destination IP address;
[0072] A is the starting IP address of the public network segment included in the target NAT server table entry;
[0073] a is the starting IP address of the private network segment included in the target NAT server table entry;
[0074] IP y is the private IP address corresponding to the target NAT server.
[0075] Preferably, X, A and a are all binary numbers, decimal numbers or hexadecimal numbers.
[0076] As can be seen from the above technical solutions, in the embodiment of the present application, the NAT server table entry generated by the NAT routing device includes a masked binary number, which reduces the DDR storage space occupied; and when the NAT routing device receives an access message sent by a target public network host in the target public network for accessing a target NAT server in the target private network, it can quickly find a NAT server table entry that matches the access message according to the longest match principle of the IP address, and based on the NAT server table entry, quickly convert the destination IP address of the access message, greatly shortening the IP address conversion time, improving the processing performance of the NAT routing device, and also reducing network latency. These technical effects are particularly obvious when NAT servers are deployed in large quantities.
[0077] The present application also provides an electronic device, such as Figure 3 As shown, it includes a processor 31 and a machine-readable storage medium 32, the machine-readable storage medium 32 stores machine-executable instructions that can be executed by the processor 31, and the processor 1401 is prompted by the machine-executable instructions to implement the steps of the above-mentioned message processing method.
[0078] The machine-readable storage medium may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Alternatively, the machine-readable storage medium may be at least one storage device located remote from the processor.
[0079] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0080] In another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned message processing method are implemented.
[0081] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A message processing method, characterized in that: The method is applied to a NAT routing device, and the method includes: Upon receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generating multiple NAT server table entries based on the target public network segment, the starting IP address of the target public network segment, the target private network segment corresponding to the target public network segment and its corresponding starting IP address carried in the configuration command, wherein each NAT server table entry includes a binary number with a mask; Upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, searching, in accordance with a longest match principle for an IP address, for a target NAT server table entry that matches the destination IP address of the access message in all NAT server table entries, wherein the destination IP address is the public IP address of the target NAT server; Determine the private IP address corresponding to the target NAT server according to the destination IP address and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry; Convert the destination IP address of the access message into the private IP address, and send the converted access message to the target NAT server for processing; Determine the private IP address corresponding to the target NAT server by: The private IP address corresponding to the target NAT server is calculated using the following formula: Formula 1: IP y = X – A + a; Wherein, X is the destination IP address; A is the starting IP address of the public network segment included in the target NAT server table entry; a is the starting IP address of the private network segment included in the target NAT server table entry; IP y is the private IP address corresponding to the target NAT server.
2. The method according to claim 1, characterized in that Generate multiple NAT server entries in the following ways: Dividing the target public network segment into a plurality of masked binary numbers; For each masked binary number, a message is generated that includes the masked binary number, the starting IP address of the target public network segment, and the starting IP address of the target private network segment.
3. The method according to claim 1, characterized in that X, A, and a are all binary, decimal, or hexadecimal numbers.
4. A message processing device, characterized in that: The device is applied to a NAT routing device, and the device includes: a generation module configured to, upon receiving a configuration command input by an administrator for configuring a NAT server to map a public network segment to a private network segment, generate a plurality of NAT server table entries based on a target public network segment, a starting IP address of the target public network segment, a target private network segment corresponding to the target public network segment and its corresponding starting IP address carried in the configuration command, wherein each NAT server table entry includes a masked binary number; a search module configured to, upon receiving an access message sent by a target public network host in a target public network for accessing a target NAT server in a target private network, search, in accordance with a longest match principle for an IP address, for a target NAT server table entry that matches a destination IP address of the access message in all NAT server table entries, wherein the destination IP address is a public IP address of the target NAT server; A determination module, configured to determine the private IP address corresponding to the target NAT server based on the destination IP address and the starting IP addresses of the public network segment and the private network segment included in the target NAT server table entry; a processing module, configured to convert the destination IP address of the access message into the private IP address, and send the converted access message to the target NAT server for processing; The determining module is specifically configured to determine the private IP address corresponding to the target NAT server in the following manner: The private IP address corresponding to the target NAT server is calculated using the following formula: Formula 1: IP y = X – A + a; Wherein, X is the destination IP address; A is the starting IP address of the public network segment included in the target NAT server table entry; a is the starting IP address of the private network segment included in the target NAT server table entry; IP y is the private IP address corresponding to the target NAT server.
5. The device according to claim 4, characterized in that The generating module is specifically configured to generate multiple NAT server entries in the following manner: Dividing the target public network segment into a plurality of masked binary numbers; For each masked binary number, a message is generated that includes the masked binary number, the starting IP address of the target public network segment, and the starting IP address of the target private network segment.
6. The device according to claim 4, characterized in that X, A, and a are all binary, decimal, or hexadecimal numbers.
7. An electronic device, characterized in that: The method comprises a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement the method steps according to any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Maintenance method and device of route entry
CN107147581A
Network address translation management method and device
CN108124022A