- sk.hax.software.network.NetworkAddressTranslator
-
- All Implemented Interfaces and Traits:
- InboundDeviceListener, Task
@groovy.util.logging.Slf4j
final class NetworkAddressTranslator
Kernel for a NAT device.
Supports two network interfaces and a storage device.
The first network interface must be connected to the external network and must have assigned an external network address.
The second network interface must be connected to the internal network, usually to a switch or a router to its default network interface.
The NAT deals with received packets in the following manner:
If a packet is received from the internal network:
- its source address is replaced with the external network address
- its source port is replaced with either the external port (previously or newly) assigned by the port mapping algorithm
- in case of a new port mapping, it is stored for future use (external port <-> internal address and port)
- the packet is forwarded to the external network
If a packet is received from the external network:
- based on the destination port, the assigned port mapping is found
- the packet's destination address is replaced with the internal network address from the mapping
- the packet's destination port is replaced with the internal port from the mapping
- if the packet is empty, the port mapping is removed
- the packet is forwarded to the internal network
The network configuration for NAT contains the external network address, external port range start and external port range end values, separated by commas.
The port mapping algorithm selects the external port number from this configured range.
Network configuration patterns:
network "extAddress extPortMin extPortMax"
network "extAddress extPortMin extPortMax", "extPort1 intAddress1 intPort1", ..., "extPortN intAddressN intPortN"
- Authors:
- mio
-
-
Methods Summary
-
Inherited Methods Summary
Inherited Methods
| Methods inherited from class |
Name |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
-
-
Property Detail
-
final java.util.Map<java.lang.Integer, java.util.List<java.lang.Integer>> ext2int
-
java.net.NetworkInterface external
-
final java.util.Queue<java.lang.Integer> externalPorts
-
final java.util.Map<java.util.List<java.lang.Integer>, java.lang.Integer> int2ext
-
java.net.NetworkInterface internal
-
final java.util.Set<java.lang.Integer> protectedPorts
-
Method Detail
-
@java.lang.Override
void start()
-
@java.lang.Override
void stop()
-
@java.lang.Override
void trigger(InboundDevice origin, byte[] data)
© 2016 by mio. All Rights Reserved.