Detailed explanation: NAT principle and implementation on VxWorks

The original design of the Internet did not take into account the need to support such a large Internet. Therefore, in the design of IPv4, the IP address only uses 32 bits to identify a node device in the network, although this solves the IP datagram well. Alignment problems, but with the rapid development of the Internet, coupled with some unreasonable address allocation methods, the current IP address has been seriously lacking, and the shortage of IP addresses has become one of the biggest problems facing the Internet.

In order to save IP address resources, the IETF abandoned the traditional address classification method (the way of artificially dividing the IP address space into A, B, C, and D addresses). Start using the CIDR (Classless Inter-Domain RouTIng) specified in RFC 1918. At the same time, in order to solve the problem of IP address loss, in RFC 1631, the problem of using NAT to solve the problem of shared IP address accessing the Internet is proposed.

1 NAT Overview

NAT translates an IP address used in one network into an IP address that can be recognized by another network. One network is designated as an internal network and the other is an external network. Typically, a company maps its local internal network address to one or more global external IP addresses and interprets the global IP address in the received packet to the local IP address. This also helps with security, because each outgoing and incoming request must go through a translation process, which is a process of authenticating a request or matching it to a previous request.

NAT is included in the router and is usually part of the firewall. The network administrator creates a NAT table that is used to map global to local and local to global addresses. NAT can also be used with policies to route. NAT can be statically defined or dynamically based on the IP address pool.

The description of NAT is detailed in RFC 1631. It discusses the relationship between NAT and CIDR, which is a way to solve the problem of IP address exhaustion. NAT reduces the need for public IP addresses by distinguishing between public and private IP addresses. CIDR brings together public IP addresses, reducing the waste of IP addresses.

2 NAT principle

In the traditional standard TCP/IP communication process, all routers only act as a middleman, which is commonly referred to as store-and-forward. The router does not modify the forwarded packets, such as Ethernet interfaces. In addition to replacing the source MAC address with its own MAC address, the router does not make any modifications to the forwarded packets. NAT (Network Address Translate) is the operation of rewriting the source IP address, destination IP address, source port, and destination port of a packet for a specific need.

From the perspective of principle, NAT can be divided into two types, namely source NAT (SNAT) and destination NAT (DNAT). As the name implies, the so-called SNAT is to change the source address of the forwarded data packet. The so-called DNAT is to change the destination address of the forwarded data packet.

3 NAT's VxWorks implementation

3.1 Overview of the underlying interfaces of VxWorks

3.1.1 VxWorks MUX Interface Layer

In VxWorks, the TCP/IP stack uses the MUX interface to communicate with the data link layer. The purpose of the MUX interface is to isolate the data link layer from the network layer. Above the MUX interface is the network protocol layer, such as TCP/IP, MUX_PROTO_OUTPUT, MUX_PROTO_SNARF and other protocols, under the MUX is the driver of the network hardware. The MUX interface layer provides a set of interfaces to complete protocol and driver registration, data reception and transmission between protocol and driver, MulTIcast address access, MUX ioctl and so on. The entire hierarchy is shown in Figure 1.

3.1.2 Interception of IP Packets in VxWorks

To implement NAT in VxWorks, two basic operations must be implemented: interception of IP packets and masquerading of IP packets.

For the VxWorks protocol stack, the existence of NAT is transparent. Therefore, to implement the NAT function, the data must be intercepted before the VxWorks network protocol stack processes the data packet. To achieve this, VxWorks provides us with two types of hook functions, an EtherHook that intercepts the Ethernet frame and an IpFilterHook that intercepts the IP packet.

EtherHook includes EtherInputHook and EtherOutputHook, respectively, to intercept the received and sent Ethernet frames. Users can install separately via EtherInputHookAdd and EtherOutputHookAdd.

IpFilterHook provides interception of IP packets. It only corresponds to a hook function and is installed with IpFilterHookAdd. When an IP packet is received, the IpFilterHook is automatically called to achieve the purpose of intercepting the IP packet.

Comparing the two interfaces, EtherInputHookAdd will call MuxBind to add a MUX_PROTO_SNARF protocol, which will get all the packets entering the MUX interface layer. The IpFilterHook installed by IpFilterHookAdd does not belong to the MUX interface layer and is only used to intercept IP packets without receiving non-IP packets.

In view of the above differences, we use the IpFilterHook installed by the IpFilterHookAdd function to intercept IP packets, see Figure 2.

3.2 NAT camouflage strategy

3.2.1 Network Interface

The network interface is a kernel object of VxWorks that is registered by the network driver. It is used in the kernel to identify the driver of the network device, including the properties, configuration and operation interface unique to the network device. This driver can drive a specific type of network chip, such as I82557, RTL 8139, etc., can also drive some other types of devices, such as through Serial Port, CompactPCI Bus, Loopback and so on. In VxWorks, the received IP data is stored in a mBlk structure. In addition to saving the data content, the structure also stores the information structure and interface information of the management data content.

Lighting is important while dressing ,Mirror With Light will give you the best results. During the day, if the light is insufficient, fill light have could be turned on. At night, it can be used as an LED lamp for work. Moreover, it is easy to install, attractive with decoration and elegance, and beautifies your room. You can also adjust the light to create a romantic atmosphere for your room and achieve unexpected results.

Mirror With Light

Light Up Vanity Mirror,Best Makeup Mirror,Light Up Makeup Mirror,Diy Vanity Mirror

JIANGMEN LEDERLIGHT LIGHTING Co.,LTD , https://www.lederlightcn.com

This entry was posted in on