Computer Networking - Subnetting Explained (Part 2)

By: Daniel Imbellino
Updated: Feb 24, 2013

Continuing From The Last Page...

Let’s give an example of subnetting:
Let’s say our network address we are going to work with is 195.40.10.0. This is a class C IP address, and Class C addresses have a default subnet mask of 255.255.255.0. And lets suppose we need 12 subnets for our networks. The nearest power of 2 is 16, which = 2 to the 4th power.
Now we need to borrow 4 bits from the host portion to add to our network portion of the subnet mask. Our default subnet mask was 255.255.255.0, but we added 4 bits to the end of our subnet, so we now have 11110000. Why 8 bits? Because, there are8 bits per octet in an IPV4 address, and you will always borrow bits from left to right. It’s best to envision all 8 bits when calculating their values. We have 4 bits with the values: 1x2 to the 4th power = 16, + 1x2 to the 5th power = 32, + 1x2 to the 6th power = 64, + 1x2 to the 7th power = 128. So we have 16 + 32 + 64 + 128 = 240. So our new subnet mask equals 255.255.255.240.
Now we need to calculate how many host addresses we will have per subnet. We do this using the bits within the host portions octet that were not assigned to the network portion. We assigned 4 bits to the network portion, leaving us with 4 bits for host addresses. 2 to the 4th power = 16. Remember, the formula to figure out how many host addresses are available is 2 to the nth power – 2 (with N representing the number of bits you have left over in the octet). So we effectively have 2 to the 4th power – 2 which equals 16 – 2, which = 14 host addresses per subnet.
Now we need to figure out the numbers for our subnet addresses. We can do this by cycling through the 4 bits that we added to our subnet mask. Our first address we started with was 195.40.10.0, and this is where we will start. Remember, there is always 8 bits in an octet. The diagram below shows how we cycle through those 4 bits using the original IP address we started with:
195.40.10.00000000 (subnet address = 195.40.10.0)
195.40.10.00010000 (subnet address = 195.40.10.16)
195.40.10.00100000 (subnet address = 195.40.10.32)
195.40.10.00110000 (subnet address = 195.40.10.48)
195.40.10.01000000 (subnet address = 195.40.10.64)
195.40.10.01010000 (subnet address = 195.40.10.80)
195.40.10.01100000 (subnet address = 195.40.10.96)
195.40.10.01110000 (subnet address = 195.40.10.112)
195.40.10.10000000 (subnet address = 195.40.10.128)
195.40.10.10010000 (subnet address = 195.40.10.144)
195.40.10.10100000 (subnet address = 195.40.10.160)
195.40.10.10110000 (subnet address = 195.40.10.176)
195.40.10.11000000 (subnet address = 195.40.10.192)
195.40.10.11010000 (subnet address = 195.40.10.208)
195.40.10.11100000 (subnet address = 195.40.10.224)

You may now notice that we have 16 subnets, and we only needed 12, so the calculation worked for us. We also calculated that there are 16 addresses available per subnet. Remember our formula to figure the available host addresses? It was 2 to the nth power – 2. This was because you cannot use the host addresses that end in all ones (this is the broadcast address), or all zeros (this is the network address). EX: Looking back at our first subnet of 195.40.10.00000000 (subnet address = 195.40.10.0), there are 16 available addresses, but the first address of 195.40.10.00000000 (ones included for visual comprehension), or 195.40.10.0, would be the address assigned to our router. This would be our network address, therefore you could not assign this address to a host (computer) on the network. You also cannot assign the last address, which would be the broadcast address. Our full range of addresses available per subnet is 16, and so for the subnet numbered 195.40.10.11110000 (subnet address = 195.40.10.224), our affective addresses would be from 195.40.10.0 to 195.40.10.15. Actually, the first address of each subnet is typically going to be the address of your network, so it cannot be assigned to hosts. Just like the hosts on a network require an IP address in order to communicate with other hosts or networks, so do routers. Most routers use DHCP (Dynamic Host Configuration Protocol) to assign hosts on a given network with an IP address. Routers that use this protocol typically start with a class C private IP address and assign the first address to the router, and the other addresses are assigned IP addresses extending from the routers IP address. When we refer to “host”, we are referring to any device, not just a computer that is assigned an IP address. This could be a smart phone, desktop or laptop PC, tablet PC, printer, or any other mobile device on your network.