Subnet Mask

Today we are going to talk about subnet masks, network addresses and broadcast addresses. A subnet mask is very important when it comes to the world of networking and logical addressing. Without a subnet mask, IP addressing would be chaotic and unorganized. A subnet mask is a DDN that divides the network portion from the host portion. IP addresses are usually represented by classes such as class A, B or C. (Classful addressing has been taken over the Classes inter-domain routing but for the sake of understanding subnet mask I am giving you this example). In each class there are only a certain number of hosts that can be assigned. For class A, you can assign around 16 million hosts, class B can assign around 65k hosts and class C can assign 254 hosts. But how do you know how many hosts are there for the subnet you’re given? Subnet Masks! Subnet masks are interpreted in binary where the leading 1s are for the network and the remaining 0s represent the hosts. So for class A, the subnet mask is 255.0.0.0, in binary that is 11111111.00000000.00000000.00000000. The 1s are reserved for the network, the 0s after are all free to assign to any host on the network. For class B it’s 255.255.0.0, in binary that is 11111111.11111111.00000000.00000000, that means the first two octets or bytes are reserved for the network but any 0 after is assignable for a host. For class C the subnet mask is 255.255.255.0, the binary is 11111111.11111111.11111111.00000000. The same thing applies: the 1s are for the network and the 0s after are for hosts. Subnet masks define which bits of the IP address are for the network and which bits of the IP are for the hosts. 

But what is a network address? An internet network is divided into different sections called broadcast domains or LAN. A LAN or broadcast domain in simple terms is your home router connected to your PC, your brother’s PC, the fridges’ smart touchscreen, your Xbox and more. All of those devices are in the same network. Picture a road with a street name, all of those houses share the same street name but have different house numbers. A network address basically works the same way, every device that shares a router will share the same network address as it represents “their street” and the host number added will become their unique “house number.” Network addresses in binary will always end in 0s. Say the network address is 192.168.1.0/24. The binary would be 

11000000.10101000.00000001.00000000. Or what is the network address was 192.168.0.0/16. The binary would be 11000000.10101000.00000000.00000000, the network address uniquely has the host bits in a subnet mask as ALL 0s. This is because the network address is literally the first address taken in a subnet in order to represent the subnet as a whole.

A broadcast address on the other hand is an IP address when used as a destination IP  is sent to every single host within that subnet. Broadcast addresses are used for delivery packets to all hosts on a subnet and are not allowed to be assigned.The broadcast address is usually the very last address in a subnet and its binary for the host portion is ALWAYS consecutive 1s. So if the IP address is 192.168.1.0 /24, the broadcast address is 192.168.1.255. This gives a binary of 11000000.10101000.00000001.11111111. As you can see the host portion is all 1s. What about 192.168.0.0 /16, the broadcast would be 192.168.255.255. The binary would look like 11000000.10101000.11111111.11111111 with the host portion being consecutive 1s.

Keep in mind that every subnet will need a broadcast AND network address. So for example if a /24 network has 256 addresses only 254 can be assigned to hosts. If it’s a /27 network there are 32 addresses but only 30 are assignable and so forth. 

Leave a Reply

Your email address will not be published. Required fields are marked *