A network mask helps you know which portion of the address identifies the network and which portion of the address identifies the node. Class A, B, and C networks have default masks, also known as natural masks, as shown here:
Class A: 255.0.0.0 Class B: 255.255.0.0 Class C: 255.255.255.0
An IP address on a Class A network that has not been subnetted would have an address/mask pair similar to: 8.20.15.1 255.0.0.0. In order to see how the mask helps you identify the network and node parts of the address, convert the address and mask to binary numbers.
8.20.15.1 = 00001000.00010100.00001111.00000001 255.0.0.0 = 11111111.00000000.00000000.00000000
Subnetting is a process of breaking large network in small networks known as subnets. Subnetting happens when we extend default boundary of subnet mask. Basically we borrow host bits to create networks. Let's take a example
Being a network administrator you are asked to create two networks, each will host 30 systems.
Single class C IP range can fulfill this requirement, still you have to purchase 2 class C IP range, one for each network. Single class C range provides 256 total addresses and we need only 30 addresses, this will waste 226 addresses. These unused addresses would make additional route advertisements slowing down the network.
With subnetting you only need to purchase single range of class C. You can configure router to take first 26 bits instead of default 24 bits as network bits. In this case we would extend default boundary of subnet mask and borrow 2 host bits to create networks. By taking two bits from the host range and counting them as network bits, we can create two new subnets, and assign hosts them. As long as the two new network bits match in the address, they belong to the same network. You can change either of the two bits, and you would be in a new subnet.
Subnetting process involves binary math calculation. Computers communicate with each other's in binary language. To succeed in any kind of networking career, you might be fluent in binary math calculation. Subnetting needs two type of calculation, convert decimal to binary and convert binary to decimal.
Binary system works exactly same as decimal system, except the base number. Base number is 2 in binary system and 10 in decimal system. To calculate decimal equivalent value of a binary number, you have to replace base value 10 with 2. Binary numbers are displayed in columns and each position in binary system has double value than the position in right. From earlier section of this article you know that each number of an IP address is made from eight individual bits known as octet. So you should remember at least eight decimal equivalent value from binary position.
Base position | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Decimal value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Convert decimal to binary
Base position | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
Decimal value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Bit status | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
Decimal value in addition | 0 | 64 | 32 | 16 | 0 | 4 | 0 | 1 |
Binary value of 117 is 01110101.
Decimal calculation | Bit in binary |
128 is greater than 117 | off the bit |
0+64 = 64 is less than 117 | on the bit |
0+64+32 = 96 is less than 117 | on the bit |
0+64+32+16 = 112 is less than 117 | on the bit |
0+64+32+16+8 = 120 is greater than 117 | off the bit |
0+64+32+16+0+4 = 116 is less than 117 | on the bit |
0+64+32+16+0+4+2 = 118 is greater than 117 | off the bit |
0+64+32+16+0+4+0+1 = 117 is equivalent to 117 | on the bit |
Convert binary in decimal
To convert a binary in decimal we will follow above method in reverse mode. We will find the decimal value of on binary bit position and add them. For example convert 10101010 binary number in decimal.
Target binary number 10101010
Move direction From Left ===========================> to Right
Base position | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
Decimal value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Bit status | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
Decimal value in addition | 128 | 0 | 32 | 0 | 8 | 0 | 2 | 0 |
Decimal value of 10101010 is 170 [ 128+0+32+0+8+0+2+0 ]
Binary bit | Decimal value |
1 On bit | 128 |
0 Off bit | 0 |
1 On bit | 64 |
0 Off bit | 0 |
1 On bit | 32 |
0 Off bit | 0 |
1 On bit | 8 |
0 Off bit | 0 |
1 On bit | 2 |
0 Off bit | 0 |