
			Virtual server mapping

Static Mapping :  

One to one mapping.
One global address mapped to one local address.	

Dynamic Mapping :

One to many mappings.
One global address mapped to many <local address, protocol, port> unique triplets.

Global address -> valid internet ip address.
Local address -> ip address known only locally.Preferrably invalid internet
ip address.(local, invalid LAN ip address of the servers).
Protocol, Port -> protocol (tcp or udp) & application port (supported by
tcp & udp protocols) pair along with global ip address uniquely identifies 
the resp local server addr to be mapped when request for that protocol & 
destination application port arrives.


If we don't want to waste a valid internet ip address, by having that
as global address,we can as well make use of wan interface ip address
of proxyserver itself as global address.But in case of ISP assigned 
dynamic ip address for our wan interface, we won't be knowing
the ip address before in hand of PPP establishment.In that scenario,
we can adopt the following mapping methods.

1. By having 0.0.0.0 as global address & mapping to any one local address
(in case of static mapping) or many <local address, protocol, port> unique 
triplets (in case of dynamic mapping).Either static or dynamic mapping,
can exist for 0.0.0.0.But not both.Because our policy in Virtual Server is,
any global address can be used in any one of mapping & not in both.Here 
0.0.0.0 can be used in place of any of the wan interface global address.
No restriction for only a particular interface address.

2. By having global addresses as 0.0.0.1, 0.0.0.2, 0.0.0.3 accordingly
depending upon the model number & number of wan ports.Mapping each of 
these	global addresses to each local address, we want to map.
In this case, we can have "port numbers" number of mappings.This is with
respect to static mapping.We can also map any one of the above global
address to dynamic mapping of many <local address, protocol, port> unqiue
triplets.But the point to be noted here is that, as of now, we support
only one global address for dynamic mapping.So either 0.0.0.0 global
address can exist or any one of 0.0.0.1, 0.0.0.2, 0.0.0.3, (again based
on model & number of wan ports of hardware.) can exist, whichever is not
mapped for static.

0.0.0.1 mapping corresponds to wan1 interface ip addr.
0.0.0.2 mapping corresponds to wan2 interface ip addr.
And 0.0.0.3 mapping corresponds to wan3 interface ip addr.

3. Having both 0.0.0.0 as well as 0.0.0.1, 0.0.0.2, 0.0.0.3 global
	addresses.

*	So in this scenario, if a nat request packet comes with wan interface 
	address as the destination addr, the order of preference for network
	address translation will be :
	{
	 	First check whether any dynamic mapping exists with exact destination 
			wan interface obtained as global addr.
		if (yes)
		{
			Any protocol & destination port pair of the nat packet matches
				with any of the dynamic mappings for that particular global 
				address ?

			if (yes)
			{
				translate the dest wan1 interface addr to the respectively 
					mapped local address for that global addr & protocol, port 
					matching pair.		
				return;
			}
		}
		
		Any static mapping exists for that wan interface addr as global addr ?
		if (yes)
		{
			translate the dest wan1 interface addr to the respectively 
				mapped local address for that global addr.		
			return;
		}

		Now check from which wan port, the request has come.Say, 
		
		rx port -> wan1

		Any static mapping for 0.0.0.1 global addr ?
		if (yes)
		{
			translate the dest wan1 interface addr to the respectively 
				mapped local address for 0.0.0.1 global addr.		
			return;
		}

		Any dynamic mapping exists as 0.0.0.1 as global address ?
		if (yes)
		{
			Any protocol & destination port pair of the nat packet matches
				with any of the dynamic mappings for 0.0.0.1 global address ?

			if (yes)
			{
				translate the dest wan1 interface addr to the respectively 
					mapped local address for 0.0.0.1 global addr & protocol, port 
					matching pair.		
				return;
			}
		}

		Any dynamic mapping exists as 0.0.0.0 as global address ?
		if (yes)
		{
			Any protocol & destination port pair of the nat packet matches
			with any of the dynamic mappings for 0.0.0.0 global address ?

			if (yes)
			{
				translate the dest wan1 interface addr to the respectively 
					mapped local address for 0.0.0.0 global addr & protocol, port 
					matching pair.		
				return;
			}
		}

		Any static mapping exists for 0.0.0.0 global addr ?
	
		if (yes)
		{
			translate the dest wan1 interface addr to the respectively 
				mapped local address for 0.0.0.0 global addr.		
			return;
		}	
		
		Whether destination port is either TELNET or WEB port ?
		if (yes)
		{
			translate the dest wan1 interface addr to the proxy server's
				local lan ip address to give our telnet or web server.
			return;
		}

		Drop the nat packet.It is not a valid packet to be processed.		

	}

	This is the entire flow, when any nat packet comes with destination
		addr as our wan interface address.The same example can be extended
		for rx port as wan2 & wan3.


