IP Subnetting Step #4: Determining Subnet Identifiers and Subnet Addresses
(Page 5 of 5)
Subnet Formula Calculations With More Than 8 Subnet Bits
When the number of subnet bits is greater than 8, some of the octets are of the form N divided by an integer, such as N/8. This is an integer division, which means divide N by 8, keep the integer part and drop the fractional part or remainder. Other octets are calculated based on the modulo of N, shown as N%8. This is the exact opposite: it means, divide N by 8, drop the integer and keep the remainder. For example, 33/5 in integer math is 6 (6 with a remainder of 3, drop the remainder, or alternately, 6.6, drop the fraction). 33%5 is 3 (6 with a remainder of 3, drop the 6, keep the remainder).
Let's take as an example our Class B network and suppose that for some strange reason we decided to use 10 bits for the subnet ID instead of 5. In this case, the formula is x.y.N/4.(N%4)*64. Subnet #23 in this case would have the address 166.113.23/4.(23%4)*64. The 23/4 becomes just 5 (the fractional.75 is dropped). 23 modulo 4 is 3, which is multiplied by 64 to get 192. So the subnet address is 18.104.22.168. Subnet #709 would be 116.113.709/4.(709%4)*64, which is 22.214.171.124.
Okay, now for the real fun. If you subnet a Class A address using more than 16 bits for the subnet ID, you are crossing two octet boundaries, and the formulas become very interesting, involving both integer division and modulo. Suppose we were in charge of Class A address 126.96.36.199 and choose to subnet it. However, we sat down to do this after having had a few stiff ones at the office holiday party, so our judgment is a bit impaired. We decide that it would be a great idea to choose 21 bits for our subnet ID, since we like the number 21. This gives us a couple million subnets.
The formula for subnet addresses in this case, is x.N/8192.(N/32)%256.(N%32)*8. Yikes. Well, this is a bit involvedso much so that it might be easier to just take a subnet number and do it in binary, the long way. But let's take an example and see how it works, for, say, subnet #987654. The first octet is of course 21. The second octet is 987654/8192, integer division. This is 120. The third octet is (987654/32)%256. The result of the division is 30864 (we drop the fraction). Then, we take 30864%256, which yields a remainder of 144. The fourth octet is (987654%32)*8. This is 6*8 or 48. So subnet address #987654 is 188.8.131.52.
(Don't drink and drive. Don't drink and subnet either. J)
Home - Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.