A kind of method for network address translation based on pure hardware structure
Technical field
The present invention relates to method for network address translation and device, particularly a kind ofly only need one very to simplify, the low speed CPU, and can be issued to the method for network address translation and the device of maximum frequency range of minimum package zero loss of IEEE802.3 defined at the environment of 100MHZ Ethernet.
Background technology
Along with the quick growth and the population in use of Global Internet constantly increases, the Internet is just meeting with available internet address (IP address) and is not applying the problem of using at last, therefore, (Network Address Translation, conception NAT) also arises the internet address transformation approach thereupon.The basic principle of NAT is exactly that the address in the package is exchanged between virtual network address and real internet address, and the main frame that has a virtual network address just can connect the Internet by such mechanism operation.
When the computer in the local network will connect the Internet,,, the virtual network address and the live network address of package inside can be translated mutually as router by the equipment of tool nat feature.Die, only need the live network address of minority, just can allow the interior all computers of LAN connect the Internet, to reduce demand to the live network address.
With regard to existing NAT framework, mainly finish with CPU (CPU) collocation hardware circuit.Please refer to Fig. 1, Fig. 1 is the schematic diagram of known network address translation framework.In Fig. 1, the chip 130 that network address translation framework 100 includes CPU (CPU does not illustrate), memory 110 and has LAN medium access control circuit 120 and the Internet media access-control scheme 125.
Wherein, when the Internet media access-control scheme 125 receives by package 150 that the Internet entered, the Internet media access-control scheme 125 is deposited this package 150 to the Internet of memory 110 and is received in the formation 111, and sends the Internet driver of informing in the network address translation framework 100.And after package 150 enters the Internet reception formation 111, the Internet driver is about to package 150 and is deposited in the working area 113 of memory 110 by the Internet reception formation 111, and the Internet driver also carries out address transition with the package in the working area 113 150 and recomputates Cyclical Redundancy Check (CRC, Cyclic Redundancy Check) and the package after the address transition 150 is changed in the LAN by the Internet.Wherein, so-called " address " comprised the destination-address and the address, source place of the second layer medium access control layer in network seven layer protocols, the destination-address of the 3rd layer (IP layer) and address, source place, the destination-address of the 4th layer (TCP/UDP layer) and address, source place.And so-called " Cyclical Redundancy Check " comprised the 32-bit CRC of the second layer (medium access control layer) in network seven layer protocols, the 16-bit CRC of the 3rd layer (IP layer), the 16-bit CRC of the 4th layer (TCP/UDP layer).
Therefore, the LAN driver in this network address translation framework 100 is just put the package after the address transition 150 to LAN transmit queue 115 by working area 113.And the LAN driver inform LAN medium access control circuit 120 by the package 150 of acquisition after the address transition in the LAN transmit queue 115 with output.
Under these known network address translation framework 100 frameworks, the performed computing of the Internet driver and LAN driver all must be carried out by CPU, so need very complicated, the CPU that operational capability is extremely strong could be issued to the maximum frequency range of minimum package zero loss of IEEE802.3 defined at the environment of 100MHZ Ethernet (Ethernet).The spacing that so-called maximum frequency range promptly is a package is 96 bit times (bit time).
Summary of the invention
Main purpose of the present invention provides a kind of method for network address translation based on pure hardware structure, it mainly comprises: when the first medium access control circuit received a package, the first medium access control circuit directly carried out depositing in after the address transition LAN address transition transmit queue in the memory to this package.And, the first medium access control circuit informs that with hardware signal the second medium access control circuit is exported by LAN address transition transmit queue access this package after address transition in this memory, wherein, these first medium and second medium are respectively the Internet and LAN.
In preferred embodiment of the present invention, when the second medium access control circuit receives another package, also can directly carry out depositing memory in after the address transition to this another package; And second the medium access control circuit notify the first medium access control circuit to be exported by storage access this another package after address transition.
In above-mentioned method for network address translation, after the medium access control circuit carries out address transition to a package, can recomputate Cyclical Redundancy Check (CRC).
In the practical application, the first medium access control circuit can for example use a Internet media access-control scheme, and the second medium access control circuit can for example use LAN medium access control circuit.Storage device can for example use memory, particularly SDRAM.
Under these conditions, also comprise in the preferred embodiment of the present invention: the package of the Internet media access-control scheme after with address transition deposits in the LAN address transition transmit queue of memory, and LAN medium access control circuit is directly transmitted and needn't CPU get involved computing to LAN by the package of access after address transition in the LAN address transition transmit queue.And, the package of LAN medium access control circuit after with address transition deposits in the internet address conversion transmit queue of memory, and the Internet media access-control scheme directly transmit and needn't CPU intervention computing to the Internet by the package of access after address transition in the internet address conversion transmit queue.
Medium are in order to allow the whole network package can be more smooth when the address transition, and LAN medium access control circuit can be according to the flow of package with in the arbitration access LAN address transition transmit queue or the package in the LAN transmit queue.
For instance, when local network media access-control scheme just in access LAN transmit queue during the package after address transition, remove another package after address transition in the access LAN address transition transmit queue if LAN medium access control circuit is notified, after LAN medium access control circuit then finishes to present packet access, improve row the package in the local network address translation transmit queue is given access.
Another main purpose of the present invention is to provide a kind of method for network address translation based on pure hardware structure, comprises
When the first medium access control circuit received second package, the internet address that the first medium access control circuit is selected directly this second package to be carried out depositing in the memory after the address transition was changed transmit queue; And
The first medium access control circuit with hardware signal inform the second medium access control circuit by the internet address in this memory conversion transmit queue acquisition this second package after address transition with output, wherein, these first medium and second medium are respectively LAN and the Internet.
Another main purpose of the present invention is for providing a kind of network address conversion device based on pure hardware structure, and it mainly comprises: memory, chip, CPU.Wherein, chip more includes the Internet media access-control scheme, LAN medium access control circuit, also CPU can be integrated wherein.Wherein, the Internet media access-control scheme, can receive the package of desiring to enter LAN and directly carry out depositing memory in after the address transition by the Internet, but and the package after address transition of desiring to enter the Internet in the access memory by LAN directly transmitted to the Internet.LAN medium access control circuit, can receive the package of desiring to enter the Internet and directly carry out depositing memory in after the address transition by LAN, but and the package after address transition of desiring to enter LAN in the access memory by the Internet directly transmitted to LAN.And LAN medium access control circuit and the Internet media access-control scheme can be notified mutually with the package after address transition in the access memory.
CPU, still be left the package that only a few can't be handled by LAN medium access control circuit and the Internet media access-control scheme, and the parameter setting medium of LAN medium access control circuit and the Internet media access-control scheme are provided.
In preferred embodiment of the present invention, wherein memory can have internet address conversion transmit queue, internet transmission formation, the Internet reception formation, LAN address transition transmit queue, LAN transmit queue, LAN reception formation and working area.
Comprehensively above-mentioned, the present invention proposes a kind of method for network address translation and device based on pure hardware structure, only need use the lower CPU of operational capability, just can be issued to the maximum frequency range of minimum package zero loss of IEEE802.3 defined at the environment of 100MHZ Ethernet.
For the load capacity of the CPU that reduces the network address translation framework, use cost of the present invention is lower, the CPU that power consumption is lower, the maximum frequency range when reaching the network address translation framework package being made address transition.
The present invention specially marries again the enforcement major part of package address transition to the Internet media access-control scheme and LAN medium access control circuit by CPU.
In order further to understand feature, purpose and the function of invention, the present invention is described in detail with instantiation below in conjunction with accompanying drawing.
Description of drawings
Fig. 1 is the schematic diagram of known network address translation framework;
Fig. 2 be preferred embodiment of the present invention based on the network address conversion device of pure hardware structure and the schematic diagram of operation workflow;
Fig. 3 is the schematic diagram of another operation workflow of network address conversion device of preferred embodiment of the present invention;
Fig. 4 is the schematic diagram of the another operation workflow of network address conversion device of preferred embodiment of the present invention.
Description of reference numerals: 100 internet address converting structures; 110,210 memories; 111,211 the Internets receive formation; 115,215 LAN transmit queues; 120,220 LAN medium access control circuits, 125,225 the Internet media access-control schemes; 130 chips; 150,250,350,410,420 packages; 200 network address conversion devices; 113,213 working areas; 214 internet transmission formations; 216 LAN receive formation; 260 LAN address transition transmit queues; 270 internet address conversion transmit queue.
Embodiment
Please refer to Fig. 2, Fig. 2 be preferred embodiment of the present invention based on the network address conversion device of pure hardware structure and the schematic diagram of operation workflow.In Fig. 2, the chip 230 that this network address conversion device 200 includes CPU (not shown, as can be integrated among the chip 230), memory 210 and has LAN medium access control circuit 220 and the Internet media access-control scheme 225.Particularly, LAN medium access control circuit 220 has the function of package being carried out address transition with the Internet media access-control scheme 225.
Under framework of the present invention, when the Internet media access-control scheme 225 receives when desiring to enter the package 250 of LAN by the Internet, the Internet media access-control scheme 225 promptly directly carries out address transition to package 250, and the package after will changing 250 deposits in the LAN address transition transmit queue 260 of memory 210.And because the address transition of package 250 is not to change by driver, therefore, LAN medium access control circuit 220 will be informed with the hardware signal by the Internet media access-control scheme 225 by the action of acquisition package 250 after address transition in the LAN address transition transmit queue 260.So, package 250 is directly done to deposit LAN address transition transmit queue 260 in after the address transition by the Internet media access-control scheme 225, and LAN medium access control circuit 220 also directly by the package 250 of acquisition after address transition in the LAN address transition transmit queue 260 to export LAN to.
Accordingly, LAN medium access control circuit 220 receives when desiring to enter the package of the Internet by LAN, also directly do to deposit in the internet address conversion transmit queue 270 of memory 210 after the address transition by 220 pairs of packages of LAN medium access control circuit, and the Internet media access-control scheme 225 directly by acquisition in the internet address conversion transmit queue 270 through the package of address transition with output.
After above-mentioned the Internet media access-control scheme 225 carries out address translation feature with 220 pairs of packages of LAN medium access control circuit, and can recomputate Cyclical Redundancy Check (CRC), to guarantee the correctness of the message that package carries.
Therefore, when the Internet media access-control scheme 225 and LAN medium access control circuit 220 all have when package carried out address translation feature, the required operational capability of CPU certainly will not need too high, and can use all lower CPU of operational capability and cost.And under the situation of using all lower CPU of this operational capability and cost, network address conversion device 200 of the present invention still can be issued to the maximum frequency range of minimum package zero loss of IEEE802.3 defined at the environment of 100MHZ Ethernet.
Yet, be not that the transmission of all packages between the Internet and LAN all can be made address transition by pure hardware.Also have the special package of some only a fews still must handle with CPU by driver.Because the special package of only a few realizes it being uneconomic with huge hardware.Also therefore, in preferred embodiment of the present invention, still possess the Internet identical in the memory 210 and receive formation 211, internet transmission formation 214, LAN transmit queue 215, LAN reception formation 216 and working area 213, to allow CPU that package is carried out some special action with tradition.
Please refer to Fig. 3, Fig. 3 is the schematic diagram of another operation workflow of network address conversion device of preferred embodiment of the present invention.In Fig. 3, when the Internet media access-control scheme 225 receives special package 350, though the Internet media access-control scheme 225 directly carries out address transition to package 350, be not to deposit in the LAN address transition transmit queue 260 but the Internet that deposits internal memory 210 in receives in the formation 211 after the conversion.Therefore, the Internet media access-control scheme 225 can be informed driver, restore in the working area 213 of memory 210 will receive formation 211 by the Internet through the package 350 of address transition, and CPU can be to carrying out other action through the package after the address transition 350 and depositing in the LAN transmit queue 215 after other action is finished in working area 213 by CPU.And CPU is after the package 350 through address transition and other action deposits LAN transmit queue 215 in, promptly notify in the LAN medium access control circuit 220 capturing multimedia LAN transmit queues 215 through the package 350 of address transition and other action with output.
In addition, the above-mentioned notion according to the present invention, when the Internet media access-control scheme 225 receives package 350, and when the Internet media access-control scheme 225 can not carry out address transition to package 350, the Internet media access-control scheme 225 promptly directly deposits package 350 in the Internet and receives in the formation 211, change by CPU package 350 is deposited in the working area 213 carrying out address transition, and will deposit in the LAN transmit queue 215 through the package 350 of address transition.At last, CPU can notify LAN medium access control circuit 220 by in the LAN transmit queue 215 acquisition after address transition package 350 with output.
The above-mentioned notion according to the present invention again, when package that the Internet media access-control scheme 225 is received after address transition or other action, can be by being captured by LAN medium access control circuit 220 in LAN address transition transmit queue 260 or the LAN transmit queue 215.And just because of this, when LAN medium access control circuit 220 captures package in LAN address transition transmit queue 260 and the LAN transmit queue 215 simultaneously, must produce conflict, LAN medium access control circuit 220 then needs has a moderator to solve.
Please refer to Fig. 4, Fig. 4 is the schematic diagram of the another operation workflow of network address conversion device of preferred embodiment of the present invention.In Fig. 4, when local network media access-control scheme 220 just captures package 410 by the LAN transmit queue, if package 420 is when the Internet media access-control scheme 225 deposits LAN address transition transmit queue 260 in simultaneously, after moderator 430 in the LAN medium access control circuit 220 can finish in the acquisition of 220 pairs of packages 410 of LAN medium access control circuit, change 220 pairs of packages 420 of indication LAN medium access control circuit and capture.Its reason is, in preferred embodiment of the present invention, the package 420 that deposits in the LAN address transition transmit queue 260 is the package of general aspects, and be not the special package 410 that deposits in the LAN transmit queue, and with package 420 connatural package flows be the majority that accounts for whole package.In order to make the smoothness of these network address conversion device 200 runnings,, can behind the package 420 of acquisition some, capture a package 410 more earlier according to a ratio when local network media access-control scheme 220.
Comprehensively above-mentioned, the present invention proposes a kind of method for network address translation and device based on pure hardware structure, by the Internet media access-control scheme and LAN medium access control circuit all has address transition and the function of the CRC that can rerun, only need use the lower CPU of operational capability, just can be issued to the maximum frequency range of minimum package zero loss of IEEE802.3 defined at the environment of 100MHZ Ethernet.
The above only is preferred embodiment of the present invention, can not limit the scope of the invention with this.Be that all equalizations of doing according to claim of the present invention change and modify, still do not lose main idea of the present invention place, also do not break away from the spirit and scope of the present invention, all should be considered as further enforcement of the present invention.