Home |
Sockets, IP, and Port Addresses Blocking and Non-Blocking Sockets NAT |
NATNAT (Network Address Translation) is a protocol used by routers to translate IP addresses between a private (non-routable) and a public (routable) network. An RTIP-32 application running on a target with at least two network interfaces can act as a router, and it can apply the NAT protocol if xn_nat_init has been called. NAT enables a client with a private IP address (range 10.0.0.0-10.255.255.255, 172.16.0.0-172.31.255.255, or 192.168.0.0-192.168.255.255) to contact a server with a public IP address. This is usually not possible as the client would specify a source address to which the server cannot reply. However, if the client contacts the server through a NAT-enabled router, the router replaces the client's source address with one of its own public addresses and it replaces the source port with a unique port value. The server will then receive the request which now looks like it originated from the router, which is reachable, and the server will return its reply. When the router receives the reply, it will recognize the IP address and port it had patched into the outgoing request and will now put the client's private IP address and port back in and forward the packet to the client. In this way, many clients on a private LAN can access servers on the Internet through a single router which has only a few (or possibly just one) public addresses. NAT cannot be used to make a server on a private LAN accessible from the Internet. It can only sustain TCP and UDP connections which originated on the private LAN to the public WAN. Only replies, but not requests, can be routed to the clients on the private LAN. RTIP-32's NAT can be configured with a few RTIP-32 configuration values. NAT is enabled with function xn_nat_init. To use NAT, an application must:
|