CN115277884B - Subnet replacement method and device, exchange chip, electronic equipment and storage medium - Google Patents
Subnet replacement method and device, exchange chip, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115277884B CN115277884B CN202210833207.1A CN202210833207A CN115277884B CN 115277884 B CN115277884 B CN 115277884B CN 202210833207 A CN202210833207 A CN 202210833207A CN 115277884 B CN115277884 B CN 115277884B
- Authority
- CN
- China
- Prior art keywords
- address
- subnet
- nat
- determining
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 238000006243 chemical reaction Methods 0.000 claims abstract description 55
- 230000006399 behavior Effects 0.000 claims description 42
- 238000004590 computer program Methods 0.000 claims description 10
- 230000006870 function Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 230000006854 communication Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000000739 chaotic effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/25—Mapping addresses of the same type
- H04L61/2503—Translation of Internet protocol [IP] addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/08—Protocols for interworking; Protocol conversion
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Small-Scale Networks (AREA)
Abstract
The embodiment of the invention provides a subnet replacement method, a device, a switching chip, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving an original IP message and analyzing to obtain a source IP address and a destination IP address; determining a destination port corresponding to the destination IP address; determining a conversion request of an original IP message, and determining a target IP address from a source IP address and a target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table; replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask; and sending the IP message after the subnet address is replaced from the destination port. The subnet replacement function can be based on the subnet replacement function, the subnet address of the public network or private network IP address is replaced, the 32-bit binary IP address is not required to be replaced completely, and the table entry resource of address conversion in the exchange chip can be effectively saved.
Description
Technical Field
The present invention relates to the field of data communications technologies, and in particular, to a subnet replacement method, a subnet replacement device, a switching chip, an electronic device, and a storage medium.
Background
In the network communication process, each communication device needs an IP address, and according to an IP address allocation scheme, the IP address may be divided into a public network IP address and a private network IP address, and the communication device needs to access the internet and has an effective public network IP address, but because the number of public network IP addresses is insufficient, each communication device cannot be guaranteed to have a public network IP address. In order to enable the equipment in the private network and the equipment in the public network to normally communicate, network address conversion is needed to be adopted to mutually convert the IP address in the private network and the IP address of the public network, so that the problem of shortage of IP address resources of the public network is solved.
In the current IP address conversion process, an NAT table is mainly established on an NAT server through a protocol stack, and for address conversion of a private network and a public network, a 1:1 address conversion mode is adopted, and when the private network is converted into the public network or the public network is converted into the private network, 32-bit binary IP addresses are required to be replaced completely, so that conversion of the public network address and the private network address is realized, and NAT expression resources are consumed.
Disclosure of Invention
The invention aims to provide a subnet replacement method, a subnet replacement device, a switching chip, electronic equipment and a storage medium, which can save table entry resources.
In order to achieve the above object, the technical scheme adopted by the embodiment of the application is as follows:
in a first aspect, an embodiment of the present application provides a subnet replacement method, where the method includes:
receiving and analyzing an original IP message to obtain a source IP address and a destination IP address;
determining a destination port corresponding to the destination IP address;
determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request;
determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
replacing a subnet address of the target IP address with the first subnet address based on the first subnet mask;
and sending the IP message after replacing the subnet address from the destination port.
In an alternative embodiment, the step of determining the conversion request of the original IP packet, and determining the destination IP address from the source IP address and the destination IP address based on the conversion request includes:
Under the condition that the conversion request of the original IP message represents the conversion from the private network to the public network, determining a source IP address as a target IP address;
and under the condition that the conversion request of the original IP message characterizes the public network to private network conversion, determining the target IP address as the target IP address.
In an alternative embodiment, the method further comprises:
Determining 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:
and searching a destination port corresponding to the forwarding domain and the destination IP address in the routing table.
In an optional embodiment, 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:
Searching an NAT editing index corresponding to the target IP address in the NAT table, wherein the NAT table comprises the corresponding relation between different IP addresses and the NAT editing index;
And reading a first subnet address and a first subnet mask corresponding to the NAT editing index from the NAT editing behavior table, wherein the NAT editing behavior table comprises subnet addresses and subnet masks corresponding to different NAT editing indexes.
In an alternative embodiment, the step of replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask includes:
Determining a field position to be replaced in the target IP address based on the first subnet mask;
Determining a subnet address in the target IP address based on the field location;
And replacing the subnet address of the target IP address with the first subnet address.
In an alternative embodiment, the switch chip includes three layers of interface entries, and the step of determining a forwarding domain corresponding to the receiving port includes:
And searching forwarding domains corresponding to the receiving ports in a three-layer interface table entry, wherein the three-layer interface table entry comprises forwarding domains corresponding to different receiving ports.
In a second aspect, an embodiment of the present application provides a subnet replacement device, the device comprising: the device comprises a receiving module, a determining module, a replacing module and a sending module;
The receiving module is used for receiving and analyzing the original IP message to obtain a source IP address and a destination IP address;
The determining module is used for determining a destination port corresponding to the destination IP address;
determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request;
determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
The replacing module is configured to replace, based on the first subnet mask, a subnet address of the target IP address with the first subnet address;
and the sending module is used for sending the IP message after the subnet address is replaced from the destination port.
In a third aspect, an embodiment of the present application provides an exchange chip, where the exchange chip includes an ingress direction processing engine and an egress direction processing engine;
The incoming direction processing engine is used for receiving and analyzing an original IP message to obtain a source IP address and a destination IP address; determining a destination port corresponding to the destination IP address; determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
The outbound processing engine is configured to replace a subnet address of the target IP address with the first subnet address based on the first subnet mask; and sending the IP message after replacing the subnet address from the destination port.
In a fourth aspect, an embodiment of the present application provides an electronic device, including a memory and a switching chip, where the memory stores a computer program, and the switching chip implements the steps of the subnet replacement method when executing the computer program.
In a fifth aspect, an embodiment of the present application provides a storage medium having stored thereon a computer program which, when executed by a switch chip, implements the steps of the subnet replacement method.
The application has the following beneficial effects:
The application obtains the source IP address and the destination IP address by receiving and analyzing the original IP message; determining a destination port corresponding to the destination IP address; determining a conversion request of an original IP message, and determining a target IP address from a source IP address and a target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to a target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table; replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask; and sending the IP message after the subnet address is replaced from the destination port. The subnet replacement function can be based on the subnet replacement function, the subnet address of the public network or private network IP address is replaced, the 32-bit binary IP address is not required to be replaced completely, and the table entry resource of address conversion in the exchange chip can be effectively saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic block diagram of an electronic device according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for replacing a subnet according to an embodiment of the invention;
FIG. 3 is a second flowchart illustrating a method for replacing a subnet according to the embodiment of the invention;
FIG. 4 is a third flowchart illustrating a method for replacing a subnet according to the embodiment of the invention;
fig. 5 is a block diagram of a subnet replacement device according to an embodiment of the invention;
Fig. 6 is a block diagram of a switch chip according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
Furthermore, the terms "first," "second," and the like, if any, are used merely for distinguishing between descriptions and not for indicating or implying a relative importance.
The inventor has found through a great deal of researches that in the current IP address conversion process, an NAT table is mainly established on an NAT server through a protocol stack, and for address conversion of a private network and a public network, a 1:1 address conversion mode is adopted, and when the private network is converted into the public network or the public network is converted into the private network, 32-bit binary IP addresses are required to be replaced completely, so that conversion of the public network address and the private network address is realized, and NAT expression resources are consumed.
In view of the above-mentioned problems, the present embodiment provides a subnet replacement method, device, switch chip, electronic device and storage medium, which can complete replacement of subnet addresses of public network or private network IP addresses based on a subnet replacement function, without completely replacing 32-bit binary IP addresses, so that table resources for address conversion in the switch chip can be effectively saved, and the scheme provided in the present embodiment is described in detail below.
The embodiment provides an electronic device capable of replacing a subnet. In one possible implementation, the electronic device may be a user terminal, for example, the electronic device may be, but is not limited to, a server, a smart phone, a Personal computer (PersonalComputer, PC), a tablet, a Personal digital assistant (Personal DIGITAL ASSISTANT, PDA), a Mobile internet device (Mobile INTERNET DEVICE, MID), or the like.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an electronic device 100 according to an embodiment of the application. The electronic device 100 may also include more or fewer components than shown in fig. 1, or have a different configuration than shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
The electronic device 100 includes a subnet replacement device 110, a memory 120, and a switch chip 130.
The elements of the memory 120 and the switch chip 130 are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The subnet replacement device 110 includes at least one software function module that may be stored in the memory 120 in the form of software or firmware (firmware) or cured in an Operating System (OS) of the electronic device 100. The switch chip 130 is configured to execute executable modules stored in the memory 120, such as software functional modules and computer programs included in the subnet replacement device 110.
The Memory 120 may be, but is not limited to, a random access Memory (RandomAccess Memory, RAM), a Read Only Memory (ROM), a programmable Read Only Memory (Programmable Read-Only Memory, PROM), an erasable Read Only Memory (Erasable ProgrammableRead-Only Memory, EPROM), an electrically erasable Read Only Memory (Electric Erasable ProgrammableRead-Only Memory, EEPROM), etc. The memory 120 is configured to store a program, and the switch chip 130 executes the program after receiving an execution instruction.
Referring to fig. 2, fig. 2 is a flowchart of a subnet replacement method applied to the electronic device 100 of fig. 1, and the method includes various steps described in detail below.
Step 201: and receiving and analyzing the original IP message to obtain a source IP address and a destination IP address.
The exchange chip receives the original IP message and analyzes the original IP message to obtain a source IP address and a destination IP address of the original IP message.
Step 202: and determining a destination port corresponding to the destination IP address.
Specifically, a routing table is pre-stored in the switching chip, and a destination port corresponding to the destination IP address is searched in the routing table. The routing table stores paths that point to specific network addresses.
Step 203: determining a conversion request of an original IP message, and determining a target IP address from a source IP address and a target IP address based on the conversion request.
Specifically, under the condition that the conversion request of the original IP message represents the private network-to-public network conversion, the source IP address is determined as the target IP address, namely, the subnet address of the source IP address needs to be replaced when the conversion request of the original IP message represents the private network-to-public network conversion, and the target IP address is determined as the target IP address when the conversion request of the original IP message represents the public network-to-private network conversion, namely, the subnet address of the target IP address needs to be replaced when the conversion request of the original IP message represents the public network-to-private network conversion.
Step 204: from the NAT table and NAT editing behavior table, a first subnet address and a first subnet mask corresponding to the target IP address are determined.
The exchange chip comprises an NAT table and an NAT editing behavior table, and the NAT table is connected with the NAT editing behavior table in series.
When the target IP address is a 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 editing behavior table based on the source IP address.
Illustratively, 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 characterizes the field location where the address needs to be acquired later when the subnet is replaced.
Step 205: based on the first subnet mask, the subnet address of the target IP address is replaced with the first subnet address.
Specifically, determining a field position to be replaced in the target IP address based on the first subnet mask; determining a subnet address in the target IP address based on the field location; and replacing the subnet address of the target IP address with the first subnet address.
Illustratively, 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 characterizes a prefix for acquiring 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 of the source IP address "192.168.1" is replaced with the first subnet address "223.10.1".
Step 206: and sending the IP message after the subnet address is replaced from the destination port.
And replacing the source IP address of the original IP message with 223.10.1.100, and sending the message through the destination port.
In another embodiment of the present application, referring to fig. 3, a flowchart of steps of a subnet replacement method according to an embodiment of the present application includes:
Step 301: and determining a receiving port for receiving the original IP message.
Step 302: a forwarding domain corresponding to the receiving port is determined.
When the original IP message is the data needing to walk VPN, the receiving port of the exchange chip for receiving the original IP message is determined.
Virtual Private Networks (VPNs) are defined as establishing a temporary, secure connection over a public network, typically the internet, and are a secure, stable tunnel through a chaotic public network. Virtual private networks are extensions to enterprise intranets.
Based on the receiving port, determining a forwarding domain corresponding to the receiving port in the three-layer interface list item pre-stored in the exchange chip.
Step 303: and searching a destination port corresponding to the forwarding domain and the destination IP address in the routing table.
And searching a destination port corresponding to the forwarding domain and the destination IP address in a routing table pre-stored in the switching chip based on the forwarding domain and the destination IP address.
Step 304: and obtaining a first subnet address and a first subnet mask corresponding to the target IP address based on the target IP address and the forwarding domain.
And obtaining a corresponding first subnet address and a first subnet mask based on the target IP address and the forwarding domain in the NAT table and the NAT editing behavior table.
The NAT table and the NAT editing behavior table are connected in series, the NAT editing index is determined from the NAT table based on the target IP address and the forwarding domain, and the NAT table contains the corresponding relation among the forwarding domain, the target IP address and the NAT editing index. Based on the NAT edit index, a first subnet address and a first subnet mask are determined from the NAT edit behavior table. The NAT editing behavior table contains first subnet addresses and first subnet masks corresponding to different NAT editing indexes.
The application obtains the source IP address and the destination IP address by receiving and analyzing the original IP message; determining a receiving port for receiving an original IP message, determining a forwarding domain corresponding to the receiving port, and determining a destination port corresponding to a destination IP address; determining a conversion request of an original IP message, and determining a target IP address from a source IP address and a target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to the target IP address and the forwarding domain from the NAT table and the NAT editing behavior table, and replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask; and sending the IP message after the subnet address is replaced from the destination port. The subnet replacement function can be based on the subnet replacement function, the subnet address of the public network or private network IP address needing to go to VPN is replaced, the 32-bit binary IP address is not required to be replaced completely, and the entry resource for address conversion in the exchange chip can be saved effectively.
In one embodiment, as shown in fig. 4, a schematic flow chart of the substeps of step 204 includes the following steps:
Step 204-1: and searching the NAT editing index corresponding to the target IP address in the NAT table.
The NAT table contains the corresponding relation between different IP addresses and NAT editing indexes.
Step 204-2: and reading the first subnet address and the first subnet mask corresponding to the NAT editing index in the NAT editing behavior table.
The NAT editing behavior table contains subnet addresses and subnet masks corresponding to different NAT editing indexes.
Illustratively, when the target IP address is 192.168.1.100, a corresponding NAT editing index is found in the NAT table based on 192.168.1.100, for example, the found 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.
Referring to fig. 5, an embodiment of the present application further provides a subnet replacement device 110 applied to the electronic device 100 shown in fig. 1, where the subnet replacement device 110 includes:
A receiving module 111, a determining module 112, a replacing module 113, and a transmitting module 114;
The receiving module 111 is configured to receive and parse an original IP packet to obtain a source IP address and a destination IP address;
The determining module 112 is configured to determine a destination port corresponding to the destination IP address;
determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request;
determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
The replacing module 113 is configured to replace, based on the first subnet mask, a subnet address of the target IP address with the first subnet address;
The sending module 114 is configured to send the IP packet after the subnet address is replaced from the destination port.
Referring to fig. 6, an embodiment of the present application further provides a switch chip 130, where the switch chip 130 includes:
The exchange chip comprises an in-direction processing engine 131 and an out-direction processing engine 132;
the ingress direction processing engine 131 is configured to receive and parse an original IP packet to obtain a source IP address and a destination IP address; determining a destination port corresponding to the destination IP address; determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
The outbound processing engine 132 is configured to replace the subnet address of the target IP address with the first subnet address based on the first subnet mask; and sending the IP message after replacing the subnet address from the destination port.
The switching chip further includes: a priority scheduling engine. The priority scheduling engine performs traffic scheduling according to the outlet.
The application also provides an electronic device 100, the electronic device 100 comprising a switch chip 130 and a memory 120. Memory 120 stores computer-executable instructions that, when executed by switching chip 130, implement the subnet replacement method.
The embodiment of the present application also provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by the switch chip 130, the subnet replacement method is implemented.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part. The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description is merely illustrative of various embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about variations or substitutions within the scope of the present application, and the application is intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (9)
1. A subnet replacement method applied to a switching chip, the method comprising:
receiving and analyzing an original IP message to obtain a source IP address and a destination IP address;
determining a destination port corresponding to the destination IP address;
determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request;
determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
replacing a subnet address of the target IP address with the first subnet address based on the first subnet mask;
the IP message after the subnet address is replaced is sent from the destination port;
The step of determining a first subnet address and a first subnet mask corresponding to the target IP address from the NAT table and the NAT editing behavior table, includes:
Searching an NAT editing index corresponding to the target IP address in the NAT table, wherein the NAT table comprises the corresponding relation between different IP addresses and the NAT editing index;
And reading a first subnet address and a first subnet mask corresponding to the NAT editing index from the NAT editing behavior table, wherein the NAT editing behavior table comprises subnet addresses and subnet masks corresponding to different NAT editing indexes.
2. The method of claim 1, wherein the step of determining a translation request for the original IP message, and determining a destination IP address from the source IP address and the destination IP address based on the translation request, comprises:
Under the condition that the conversion request of the original IP message represents the conversion from the private network to the public network, determining a source IP address as a target IP address;
and under the condition that the conversion request of the original IP message characterizes the public network to private network conversion, determining the target IP address as the target IP address.
3. The method according to claim 1, wherein the method further comprises:
Determining 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:
and searching a destination port corresponding to the forwarding domain and the destination IP address in the routing table.
4. The method of claim 1, wherein the step of replacing the subnet address of the target IP address with the first subnet address based on the first subnet mask comprises:
Determining a field position to be replaced in the target IP address based on the first subnet mask;
Determining a subnet address in the target IP address based on the field location;
And replacing the subnet address of the target IP address with the first subnet address.
5. The method of claim 3, wherein the switch chip includes three layers of interface entries, and the step of determining a forwarding domain corresponding to the receiving port includes:
And searching forwarding domains corresponding to the receiving ports in a three-layer interface table entry, wherein the three-layer interface table entry comprises forwarding domains corresponding to different receiving ports.
6. A subnet replacement device, the device comprising: the device comprises a receiving module, a determining module, a replacing module and a sending module;
The receiving module is used for receiving and analyzing the original IP message to obtain a source IP address and a destination IP address;
The determining module is used for determining a destination port corresponding to the destination IP address;
determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request;
determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table;
The replacing module is configured to replace, based on the first subnet mask, a subnet address of the target IP address with the first subnet address;
the sending module is used for sending the IP message after the subnet address is replaced from the destination port;
The replacement module is specifically used for:
Searching an NAT editing index corresponding to the target IP address in the NAT table, wherein the NAT table comprises the corresponding relation between different IP addresses and the NAT editing index;
And reading a first subnet address and a first subnet mask corresponding to the NAT editing index from the NAT editing behavior table, wherein the NAT editing behavior table comprises subnet addresses and subnet masks corresponding to different NAT editing indexes.
7. The exchange chip is characterized by comprising an in-direction processing engine and an out-direction processing engine;
The incoming direction processing engine is used for receiving and analyzing an original IP message to obtain a source IP address and a destination IP address; determining a destination port corresponding to the destination IP address; determining a conversion request of the original IP message, and determining a target IP address from the source IP address and the target IP address based on the conversion request; determining a first subnet address and a first subnet mask corresponding to the target IP address from a NAT table and a NAT editing behavior table, wherein the exchange chip comprises the NAT table and the NAT editing behavior table;
The outbound processing engine is configured to replace a subnet address of the target IP address with the first subnet address based on the first subnet mask; transmitting an IP message after replacing a subnet address from the destination port, wherein in the NAT table, an NAT editing index corresponding to the target IP address is searched, and the NAT table contains the corresponding relation between different IP addresses and the NAT editing index; and reading a first subnet address and a first subnet mask corresponding to the NAT editing index from the NAT editing behavior table, wherein the NAT editing behavior table comprises subnet addresses and subnet masks corresponding to different NAT editing indexes.
8. An electronic device comprising a memory and a switching chip, the memory storing a computer program, the switching chip implementing the steps of the method according to any one of claims 1-5 when the computer program is executed.
9. A storage medium having stored thereon a computer program, which when executed by a switching chip performs the steps of the method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210833207.1A CN115277884B (en) | 2022-07-14 | 2022-07-14 | Subnet replacement method and device, exchange chip, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210833207.1A CN115277884B (en) | 2022-07-14 | 2022-07-14 | Subnet replacement method and device, exchange chip, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115277884A CN115277884A (en) | 2022-11-01 |
CN115277884B true CN115277884B (en) | 2024-08-30 |
Family
ID=83765205
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210833207.1A Active CN115277884B (en) | 2022-07-14 | 2022-07-14 | Subnet replacement method and device, exchange chip, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115277884B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116016640A (en) * | 2022-12-30 | 2023-04-25 | 苏州盛科通信股份有限公司 | Session holding method and device, electronic equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022116848A1 (en) * | 2020-12-01 | 2022-06-09 | 武汉绿色网络信息服务有限责任公司 | Packet transmission method and apparatus, computer device, and storage medium |
Family Cites Families (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6393488B1 (en) * | 1999-05-27 | 2002-05-21 | 3Com Corporation | System and method for supporting internet protocol subnets with network address translators |
US7643484B2 (en) * | 2003-09-26 | 2010-01-05 | Surgient, Inc. | Network abstraction and isolation layer rules-based federation and masquerading |
CN101175030A (en) * | 2006-10-31 | 2008-05-07 | 中兴通讯股份有限公司 | Method for implementing proxy to multiple isomorphic subnets |
US8144709B2 (en) * | 2007-04-06 | 2012-03-27 | International Business Machines Corporation | Method, system and computer processing an IP packet, routing a structured data carrier, preventing broadcast storms, load-balancing and converting a full broadcast IP packet |
CN102195933B (en) * | 2010-03-05 | 2013-11-06 | 杭州华三通信技术有限公司 | Method for realizing call between isolated Internet protocol (IP) sub-networks and communication unit |
CN106953943B (en) * | 2017-04-25 | 2019-07-16 | 中国联合网络通信集团有限公司 | Method and device suitable for switch communication |
CN109218467B (en) * | 2018-11-15 | 2022-02-25 | 锐捷网络股份有限公司 | Network address conversion method and chip |
US11265289B2 (en) * | 2019-11-15 | 2022-03-01 | Cisco Technology, Inc. | Distributed network address translation over network environments |
CN114531389A (en) * | 2020-10-31 | 2022-05-24 | 华为技术有限公司 | Routing table optimization method, controller and router |
CN113271255A (en) * | 2021-06-23 | 2021-08-17 | 浪潮思科网络科技有限公司 | Method and device for converting network address to loopback |
CN114567616B (en) * | 2022-02-28 | 2023-10-31 | 天翼安全科技有限公司 | Method, system and equipment for traversing VxLAN NAT |
-
2022
- 2022-07-14 CN CN202210833207.1A patent/CN115277884B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022116848A1 (en) * | 2020-12-01 | 2022-06-09 | 武汉绿色网络信息服务有限责任公司 | Packet transmission method and apparatus, computer device, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115277884A (en) | 2022-11-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110266592B (en) | Communication method and device for SRV6 network and IP MPLS network | |
US10461958B2 (en) | Packet transmission method and apparatus | |
CN106878199B (en) | Configuration method and device of access information | |
CN114024886B (en) | Cross-resource-pool network intercommunication method, electronic equipment and readable storage medium | |
CN102571999B (en) | A kind of data transmission method, system and IAD | |
US10826868B2 (en) | NAT aware DNS | |
US8914503B2 (en) | Detected IP link and connectivity inference | |
Li et al. | IPv6 Core Protocols Implementation | |
CN109474713B (en) | Message forwarding method and device | |
CN110677337B (en) | Data forwarding method and device, network equipment and computer readable storage medium | |
US8176161B2 (en) | Method and system for content-based routing of network traffic | |
CN115277884B (en) | Subnet replacement method and device, exchange chip, electronic equipment and storage medium | |
CN107070790B (en) | Route learning method and routing equipment | |
CN103634214A (en) | Route information generating method and device | |
EP3836495B1 (en) | Communication method and communication device | |
CN109756411B (en) | Message forwarding method and device, first VTEP device and storage medium | |
CN108718277B (en) | Message forwarding method based on routing table, routing table maintenance method and related device | |
CN114244842A (en) | Security resource scheduling method and device, electronic equipment and storage medium | |
CN107786441B (en) | Communication method, OpenFlow switch and communication system | |
CN115567441A (en) | Method, device and system for generating forwarding information | |
US9749201B2 (en) | Method and system for monitoring locator/identifier separation network | |
CN113328943B (en) | Route matching method, information sending method and device | |
CN117917880A (en) | Method and device for selecting access network | |
CN110958185A (en) | QoS configuration method and device based on service | |
KR100768622B1 (en) | Direct connection method of wireless internet using wireless internet number domain |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |