A subnet replacement method, device, switching chip, electronic device and storage medium
By replacing the subnet address of the target IP address based on the NAT table and NAT editing behavior table during the IP address translation process, the problem of resource consumption during the IP address translation process is solved, and efficient replacement of public or private IP addresses is achieved. , saving table entry resources.
Patent Information
- Application Number
- CN202210833207.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-14
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-07-14
AI Technical Summary
The existing technology uses a 1:1 address translation method during the IP address translation process, which results in a shortage of public network IP address resources and requires the replacement of all 32-bit binary IP addresses, resulting in the consumption of NAT performance resources.
By receiving the original IP message, parsing the source IP address and destination IP address, determining the conversion request, and replacing the subnet address of the destination IP address based on the NAT table and NAT editing behavior table to avoid complete replacement of the 32-bit binary IP address.
It realizes subnet address replacement of public network or private network IP addresses, saves address translation table resources in the switching chip, and improves resource utilization efficiency.
Smart Images

Figure CN115277884B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication technology, and in particular to a subnet replacement method, device, switching chip, electronic equipment and storage medium. Background Art
[0002] In the process of network communication, each communication device needs an IP address. According to the IP address allocation plan, IP addresses can be divided into public IP addresses and private IP addresses. Communication devices need to have a valid public IP address to access the Internet. However, due to the insufficient number of public IP addresses, it is impossible to guarantee that each communication device has a public IP address. In order to enable normal communication between devices in the private network and devices in the public network, network address translation is required to convert private network IP addresses and public network IP addresses to each other to solve the problem of shortage of public network IP address resources.
[0003] At present, the IP address conversion process mainly involves establishing a NAT table on a NAT server through a protocol stack. For address conversion between private and public networks, a 1:1 address conversion method is used. When converting a private network to a public network, or when converting a public network to a private network, all 32-bit binary IP addresses need to be replaced to achieve conversion between public and private network addresses, resulting in consumption of NAT performance resources. Summary of the invention
[0004] The object of the present invention is to provide a subnet replacement method, device, switching chip, electronic equipment and storage medium, which can save table entry resources.
[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a subnet replacement method, the method comprising:
[0007] Receive the original IP message and parse it to get the source IP address and destination IP address;
[0008] Determine the destination port corresponding to the destination IP address;
[0009] Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request;
[0010] Determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table;
[0011] Based on the first subnet mask, replacing the subnet address of the target IP address with the first subnet address;
[0012] The IP message after the subnet address is replaced is sent from the destination port.
[0013] In an optional implementation, the step of determining the conversion request of the original IP message, and determining the target IP address from the source IP address and the destination IP address based on the conversion request, comprises:
[0014] In the case where the conversion request of the original IP message represents a conversion from a private network to a public network, determining the source IP address as the target IP address;
[0015] In the case where the conversion request of the original IP message represents conversion from a public network to a private network, the destination IP address is determined as the target IP address.
[0016] In an optional embodiment, the method further comprises:
[0017] Determine a receiving port for receiving the original IP message;
[0018] Determining a forwarding domain corresponding to the receiving port;
[0019] The switching chip includes a routing table, and the step of determining the destination port corresponding to the destination IP address includes:
[0020] The destination port corresponding to the forwarding domain and the destination IP address is searched in the routing table.
[0021] In an optional implementation, the NAT table and the NAT editing behavior table are connected in series, and the step of determining the first subnet address and the first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table includes:
[0022] In the NAT table, searching for a NAT edit index corresponding to the target IP address, the NAT table containing a correspondence between different IP addresses and NAT edit indexes;
[0023] In the NAT edit behavior table, the first subnet address and the first subnet mask corresponding to the NAT edit index are read, and the NAT edit behavior table contains subnet addresses and subnet masks corresponding to different NAT edit indexes.
[0024] In an optional implementation manner, the step of replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask includes:
[0025] Based on the first subnet mask, determining a field position to be replaced in the target IP address;
[0026] Based on the field position, determining a subnet address in the target IP address;
[0027] The subnet address of the target IP address is replaced with the first subnet address.
[0028] In an optional implementation manner, the switching chip includes a layer 3 interface table entry, and the step of determining the forwarding domain corresponding to the receiving port includes:
[0029] In the layer-3 interface table entry, a forwarding domain corresponding to the receiving port is searched, wherein the layer-3 interface table entry includes forwarding domains corresponding to different receiving ports.
[0030] In a second aspect, an embodiment of the present application provides a subnet replacement device, the device comprising: a receiving module, a determining module, a replacing module and a sending module;
[0031] The receiving module is used to receive and parse the original IP message to obtain the source IP address and the destination IP address;
[0032] The determination module is used to determine the destination port corresponding to the destination IP address;
[0033] Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request;
[0034] Determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table;
[0035] The replacement module is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask;
[0036] The sending module is used to send the IP message after the subnet address is replaced from the destination port.
[0037] In a third aspect, an embodiment of the present application provides a switching chip, wherein the switching chip includes an inbound processing engine and an outbound processing engine;
[0038] The inbound processing engine is used to receive and parse the original IP message to obtain a source IP address and a destination IP address; determine a destination port corresponding to the destination IP address; determine a conversion request for the original IP message, and determine a target IP address from the source IP address and the destination IP address based on the conversion request; determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table;
[0039] The outbound processing engine is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask; and send the IP message with the replaced subnet address from the destination port.
[0040] In a fourth aspect, an embodiment of the present application provides an electronic device, including a memory and a switching chip, wherein the memory stores a computer program, and the switching chip implements the steps of the subnet replacement method when executing the computer program.
[0041] In a fifth aspect, an embodiment of the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a switching chip, the steps of the subnet replacement method are implemented.
[0042] This application has the following beneficial effects:
[0043] The present application receives and parses the original IP message to obtain the source IP address and the destination IP address; determines the destination port corresponding to the destination IP address; determines the conversion request of the original IP message, and determines the target IP address from the source IP address and the destination IP address based on the conversion request; determines the first subnet address and the first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table, wherein the switching chip includes the NAT table and the NAT editing behavior table; based on the first subnet mask, replaces the subnet address of the target IP address with the first subnet address; and sends the IP message after the subnet address is replaced from the destination port. Based on the subnet replacement function, the subnet address of the public or private IP address can be replaced without replacing all 32-bit binary IP addresses, which can effectively save the table entry resources of the address conversion in the switching chip. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 A block diagram of an electronic device provided by an embodiment of the present invention;
[0046] Figure 2 One of the step flow charts of a subnet replacement method provided by an embodiment of the present invention;
[0047] Figure 3 A second step flow chart of a subnet replacement method provided by an embodiment of the present invention;
[0048] Figure 4 A flowchart of a subnet replacement method provided by an embodiment of the present invention;
[0049] Figure 5 A structural block diagram of a subnet replacement device provided by an embodiment of the present invention;
[0050] Figure 6 A structural block diagram of a switching chip provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0052] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0054] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0055] After extensive research, the inventors found that in the current IP address conversion process, a NAT table is mainly established on a NAT server through a protocol stack. For address conversion between private and public networks, a 1:1 address conversion method is adopted. When converting a private network to a public network, or when converting a public network to a private network, all 32-bit binary IP addresses need to be replaced to achieve conversion between public and private network addresses, resulting in consumption of NAT performance resources.
[0056] In view of the discovery of the above problems, the present embodiment provides a subnet replacement method, device, switching chip, electronic device and storage medium, which can complete the replacement of the subnet address of the public or private IP address based on the subnet replacement function, without the need to replace all 32-bit binary IP addresses, and can effectively save the table entry resources of address conversion in the switching chip. The solution provided by this embodiment is elaborated in detail below.
[0057] This embodiment provides an electronic device that can replace a subnet. In a possible implementation, the electronic device can be a user terminal, for example, the electronic device can be, but is not limited to, a server, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), etc.
[0058] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of the structure of the electronic device 100 provided in the embodiment of the present application. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0059] The electronic device 100 includes a subnet replacement device 110 , a memory 120 and a switch chip 130 .
[0060] The components of the memory 120 and the switching chip 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The subnet replacement device 110 includes at least one software function module that can be stored in the memory 120 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 100. The switching chip 130 is used to execute the executable modules stored in the memory 120, such as the software function modules and computer programs included in the subnet replacement device 110.
[0061] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the switching chip 130 executes the program after receiving an execution instruction.
[0062] Please refer to Figure 2 , Figure 2 For application Figure 1 A flowchart of a subnet replacement method for an electronic device 100 is provided, and the method including various steps is described in detail below.
[0063] Step 201: Receive the original IP message and parse it to obtain the source IP address and the destination IP address.
[0064] The switching chip receives the original IP message, and parses the original IP message to obtain the source IP address and the destination IP address of the original IP message.
[0065] Step 202: Determine the destination port corresponding to the destination IP address.
[0066] Specifically, a routing table is pre-stored in the switching chip, and the destination port corresponding to the destination IP address is searched in the routing table. The routing table stores the path pointing to a specific network address.
[0067] Step 203: Determine the conversion request of the original IP message, and determine the target IP address from the source IP address and the destination IP address based on the conversion request.
[0068] Specifically, when the conversion request of the original IP message represents the conversion from private network to public network, the source IP address is determined as the target IP address, that is, when the conversion request of the original IP message represents the conversion from private network to public network, the subnet address of the source IP address needs to be replaced; when the conversion request of the original IP message represents the conversion from public network to private network, the destination IP address is determined as the target IP address, that is, when the conversion request of the original IP message represents the conversion from public network to private network, the subnet address of the target IP address needs to be replaced.
[0069] Step 204: Determine the first subnet address and the first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table.
[0070] The switching chip includes a NAT table and a NAT editing behavior table, and the NAT table and the NAT editing behavior table are connected in series.
[0071] When the target IP address is the source IP address, a first subnet address and a first subnet mask corresponding to the source IP address are determined from the NAT table and the NAT edit behavior table based on the source IP address.
[0072] Exemplarily, when the source IP address is "192.168.1.100", the NAT editing index of the source IP address is determined from the NAT table and the NAT editing behavior table, and the first subnet address and the first subnet mask corresponding to the NAT editing index are directly determined from the NAT editing behavior table through the NAT editing index. For example: the first subnet address is 223.10.1, and the first subnet mask represents the field position of the address that needs to be obtained when the subnet is replaced later.
[0073] Step 205: Based on the first subnet mask, replace the subnet address of the target IP address with the first subnet address.
[0074] Specifically, based on the first subnet mask, determine the field position to be replaced in the target IP address; based on the field position, determine the subnet address in the target IP address; and replace the subnet address of the target IP address with the first subnet address.
[0075] Exemplarily, when the source IP address is "192.168.1.100", the first subnet address corresponding to the source IP address is determined to be 223.10.1, and the first subnet mask represents the prefix of the source IP address, that is, based on the first subnet mask, the subnet address of the source IP address is determined to be "192.168.1", and the subnet address "192.168.1" of the source IP address is replaced with the first subnet address "223.10.1".
[0076] Step 206: Send the IP message with the subnet address replaced from the destination port.
[0077] Replace the source IP address of the original IP packet with "223.10.1.100" and send the packet through the destination port.
[0078] In another embodiment of the present application, refer to Figure 3 , which is a flowchart of the steps of the subnet replacement method provided by an embodiment of the present invention, comprising:
[0079] Step 301: Determine a receiving port for receiving an original IP message.
[0080] Step 302: Determine the forwarding domain corresponding to the receiving port.
[0081] When the original IP message is data that needs to go through a VPN, a receiving port of the switch chip for receiving the original IP message is determined.
[0082] A virtual private network (VPN) is defined as a temporary, secure connection established through a public network (usually the Internet). It is a secure, stable tunnel that passes through a chaotic public network. A virtual private network is an extension of an enterprise's intranet.
[0083] Based on the receiving port, a forwarding domain corresponding to the receiving port is determined from the three-layer interface table entries pre-stored in the switching chip.
[0084] Step 303: Search the routing table for the destination port corresponding to the forwarding domain and the destination IP address.
[0085] Based on the forwarding domain and the destination IP address, the destination port corresponding to the forwarding domain and the destination IP address is searched in the routing table pre-stored in the switching chip.
[0086] Step 304: Obtain a first subnet address and a first subnet mask corresponding to the destination IP address based on the target IP address and the forwarding domain.
[0087] In the NAT table and the NAT edit behavior table, the corresponding first subnet address and first subnet mask are obtained based on the target IP address and the forwarding domain.
[0088] The NAT table and the NAT edit behavior table are connected in series. Based on the target IP address and the forwarding domain, the NAT edit index is determined from the NAT table. The NAT table contains the correspondence between the forwarding domain, the target IP address, and the NAT edit index. Based on the NAT edit index, the first subnet address and the first subnet mask are determined from the NAT edit behavior table. The NAT edit behavior table contains the first subnet addresses and the first subnet masks corresponding to different NAT edit indexes.
[0089] The present application receives and parses the original IP message to obtain the source IP address and the destination IP address; determines the receiving port for receiving the original IP message, determines the forwarding domain corresponding to the receiving port, and determines the destination port corresponding to the destination IP address; determines the conversion request of the original IP message, and determines the target IP address from the source IP address and the destination IP address based on the conversion request; determines the first subnet address and the first subnet mask corresponding to the target IP address and the forwarding domain from the NAT table and the NAT editing behavior table, and replaces the subnet address of the target IP address with the first subnet address based on the first subnet mask; and sends the IP message after the subnet address is replaced from the destination port. Based on the subnet replacement function, the subnet address of the public or private IP address that needs to go through the VPN can be replaced, and there is no need to replace all 32-bit binary IP addresses, which can effectively save the table entry resources of the address conversion in the switching chip.
[0090] In one embodiment, Figure 4 FIG. 2 is a schematic diagram of the sub-step flow chart of step 204, which includes the following steps:
[0091] Step 204-1: In the NAT table, search for the NAT edit index corresponding to the target IP address.
[0092] The NAT table contains the correspondence between different IP addresses and NAT editing indexes.
[0093] Step 204-2: Read the first subnet address and the first subnet mask corresponding to the NAT edit index in the NAT edit behavior table.
[0094] The NAT editing behavior table includes subnet addresses and subnet masks corresponding to different NAT editing indexes.
[0095] Exemplarily, when the target IP address is 192.168.1.100, the corresponding NAT editing index is searched in the NAT table based on 192.168.1.100. For example, the searched NAT editing index is 1, and in the NAT editing behavior list, the first subnet address 223.10.1 and the first subnet mask corresponding to the NAT editing index 1 are read.
[0096] Please refer to Figure 5 The present application embodiment also provides a method for applying Figure 1 The subnet replacement device 110 of the electronic device 100 includes:
[0097] A receiving module 111, a determining module 112, a replacing module 113 and a sending module 114;
[0098] The receiving module 111 is used to receive and parse the original IP message to obtain the source IP address and the destination IP address;
[0099] The determination module 112 is used to determine the destination port corresponding to the destination IP address;
[0100] Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request;
[0101] Determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table;
[0102] The replacement module 113 is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask;
[0103] The sending module 114 is used to send the IP message after the subnet address is replaced from the destination port.
[0104] Please refer to Figure 6 The embodiment of the present application further provides a switching chip 130, wherein the switching chip 130 includes:
[0105] The switching chip includes an inbound processing engine 131 and an outbound processing engine 132;
[0106] The inbound processing engine 131 is used to receive and parse the original IP message to obtain the source IP address and the destination IP address; determine the destination port corresponding to the destination IP address; determine the conversion request of the original IP message, and determine the target IP address from the source IP address and the destination IP address based on the conversion request; determine the first subnet address and the first subnet mask corresponding to the target IP address from the NAT table and the NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table;
[0107] The outbound processing engine 132 is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask; and send the IP message with the replaced subnet address from the destination port.
[0108] The switching chip further includes: a priority scheduling engine. The priority scheduling engine performs traffic scheduling according to the egress.
[0109] The present application also provides an electronic device 100, which includes a switching chip 130 and a memory 120. The memory 120 stores computer executable instructions, and when the computer executable instructions are executed by the switching chip 130, the subnet replacement method is implemented.
[0110] The embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by the switching chip 130, the subnet replacement method is implemented.
[0111] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0112] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.
[0113] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0114] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A subnet replacement method, applied to a switching chip, characterized in that: The method comprises: Receive the original IP message and parse it to get the source IP address and destination IP address; Determine the destination port corresponding to the destination IP address; Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request; Determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table; Based on the first subnet mask, replacing the subnet address of the target IP address with the first subnet address; Sending the IP message after replacing the subnet address from the destination port; The NAT table and the NAT editing behavior table are connected in series, and the step of determining the first subnet address and the first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table comprises: In the NAT table, searching for a NAT edit index corresponding to the target IP address, the NAT table containing a correspondence between different IP addresses and NAT edit indexes; In the NAT edit behavior table, the first subnet address and the first subnet mask corresponding to the NAT edit index are read, and the NAT edit behavior table contains subnet addresses and subnet masks corresponding to different NAT edit indexes.
2. The method according to claim 1, characterized in that The step of determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request, comprises: In the case where the conversion request of the original IP message represents a conversion from a private network to a public network, determining the source IP address as the target IP address; In the case where the conversion request of the original IP message represents conversion from a public network to a private network, the destination IP address is determined as the target IP address.
3. The method according to claim 1, characterized in that The method further comprises: Determine a receiving port for receiving the original IP message; Determining a forwarding domain corresponding to the receiving port; The switching chip includes a routing table, and the step of determining the destination port corresponding to the destination IP address includes: The destination port corresponding to the forwarding domain and the destination IP address is searched in the routing table.
4. The method according to claim 1, characterized in that: The step of replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask comprises: Based on the first subnet mask, determining a field position to be replaced in the target IP address; Based on the field position, determining a subnet address in the target IP address; The subnet address of the target IP address is replaced with the first subnet address.
5. The method according to claim 3, characterized in that: The switching chip includes a layer 3 interface table entry, and the step of determining a forwarding domain corresponding to the receiving port includes: In the layer-3 interface table entry, a forwarding domain corresponding to the receiving port is searched, wherein the layer-3 interface table entry includes forwarding domains corresponding to different receiving ports.
6. A subnet replacement device, characterized in that: The device comprises: a receiving module, a determining module, a replacing module and a sending module; The receiving module is used to receive and parse the original IP message to obtain the source IP address and the destination IP address; The determination module is used to determine the destination port corresponding to the destination IP address; Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request; Determine a first subnet address and a first subnet mask corresponding to the target IP address from the NAT table and the NAT edit behavior table; The replacement module is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask; The sending module is used to send the IP message after replacing the subnet address from the destination port; The replacement module is specifically used for: In the NAT table, searching for a NAT edit index corresponding to the target IP address, the NAT table containing a correspondence between different IP addresses and NAT edit indexes; In the NAT edit behavior table, the first subnet address and the first subnet mask corresponding to the NAT edit index are read, and the NAT edit behavior table contains subnet addresses and subnet masks corresponding to different NAT edit indexes.
7. A switching chip, characterized in that: The switching chip includes an inbound processing engine and an outbound processing engine; The inbound processing engine is used to receive and parse the original IP message to obtain the source IP address and the destination IP address; Determine the destination port corresponding to the destination IP address; Determining a conversion request for the original IP message, and determining a target IP address from the source IP address and the destination IP address based on the conversion request; Determine a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT edit behavior table, wherein the switching chip includes the NAT table and the NAT edit behavior table; The outbound processing engine is used to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask; and send the IP message after the subnet address is replaced from the destination port, wherein, in the NAT table, the NAT editing index corresponding to the target IP address is searched, and the NAT table contains the correspondence between different IP addresses and NAT editing indexes; in the NAT editing behavior table, the first subnet address and the first subnet mask corresponding to the NAT editing index are read, and the NAT editing behavior table contains subnet addresses and subnet masks corresponding to different NAT editing indexes.
8. An electronic device, characterized in that: The method comprises a memory and a switching chip, wherein the memory stores a computer program, and the switching chip implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the switching chip, the steps of the method described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Network abstraction and isolation layer rules-based federation and masquerading
US20050147120A1
Packet transmission method and apparatus, computer device, and storage medium
WO2022116848A1
