************************************************
* Description: Knowledge of network subnet mask
* Compatiablity: RDBMS 11g, 12c
* Date: 03:39 PM EST, 05/29/2017
************************************************


 
<1> Network Subnet Mask:
     |
     |__ o. A subnetwork or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting.
            By rational design, each device connecting to the internet should be assigned an unique address to be identified. But, currently, there are billion computers,
            tablets, and other devices are connecting to internet, which would be impossible to create a huge enough indexs recording all the addresses.

         o. So, subnet mask is introduced. The main purpose is deviding one IP address into Network address (or network prefix or network block) and Host address to more quicker 
            being searchable within the whole internet. 			
     
         o. Backgrouds:
             |
             |__ o. In Ethernet, nodes use MAC to broadcast data packet for communication purpose. And, for internet, servers start using IP to address each other.
             |      In prior to forwarding message, the sender uses subnet mask to And-bitting source IP with destination IP to identify if the network addresses are same.
             |      >> If network addresses are same, so data packet will be deliver by MAC address.
             |	    >> If network addresses are not same, IP will be needed.
             |
             |__ o. Based on above, subnet mask is introduced:
                     |
                     |__ Previously, almost before 1993, there are three IP classes:
                     |       Class A with subnet mask: 255.0.0.0
                     |       Class B with subnet mask: 255.255.0.0
                     |       Class C with subnet mask: 255.255.255.0
                     |   
                     |__ But, then found that Class C can only holds 256 servers, which is quite small for a enterprise, and Class B is capble of containing 65,536 servers
                     |   which is too large to be used, and many priviate IP will be wasted. This method is not flexiable enough to suit various cases.					 
                     |
                     |__ To solve above problem, Classless inter-domain Routing [CIDR] is introduced, and IP range concept was brought up.
                         |
                         |__ o. So, via CIDR, when you create/setup a gateway for a subnet, address range will be required to be fulfilled with like 192.168.1.0/24.
                         |      The number behind slash [/], means how many bits are for subnet mask. In this case, the first 24 out of 32 bits binary IP are belongs to subnet mask.
                         |
                         |__ o. The / is how a computer can quickly calculate what is part of its network and what is not.
                         |
                         |__ o. A computer performs binary math of ANDing the IP address and the network mask. For example,
                                 |							  
                                 |__ IP Address 10.10.15.10/16
                                     |
                                     |__ Step 1) Translate the IP address 4 octets into binary: 00001010.00001010.00001111.00001010
                                         Step 2) Translate the Subnet mask 4 octets into binary, which is easy using CIDR: 11111111.11111111.00000000.00000000
                                         Step 3) Perform the ANDing operation on the two addresses. This will give you the Network Address for the subnet. ANDing rules are as follows:
										 
                                                                   1 AND 1 = 1
                                                                   0 AND 1 = 0
                                                                   0 AND 0 = 0
                                                                   1 AND 0 = 0
													 
                                                         00001010.00001010.00001111.00001010
                                                     AND 11111111.11111111.00000000.00000000
                                                         -----------------------------------
                                                         00001010.00001010.00000000.00000000

                                         Step 4) Convert it back to decimal: 10.10.0.0 
                                                 So now a computer knows that any address from 10.10.0.0 to 10.10.255.255 is part of its network and any other address is not.