In binary, the total number of variations that can be displayed with n number of bits can be calculated as follows. This is used frequently in calculating the max number of subnets, max number of hosts, etc.
For binary number of n bits the Number of Representations = 2n
For example, 3 bits can represent the following :
000, 001, 010, 011, 100, 101, 110, 111
For a total of 8 variations. Note that 2n = 23 = 2x2x2 = 8
This is used to calculate the total number of Networks, and the total number of Hosts (or nodes).
The number of networks is 2n for all Classes, where n = number of addressing bits. It is confusing when reading that the max number of Class A networks is 27. Huh? The Class A addressing is always shown as /8 - not /7 !!!
Well, there is a set pattern of static leading bits for each class (Class A leading bits = 0, Class B leading Bits = 10, Class C leading bits = 110). By static, we mean that the bits cannot vary - and therefore they cannot add any address combinations, and must be subtracted to find the true value for n. The following table shows the number of leading bits, and we call that number, m. You must also subtract off the two special cases of all 1'and all 0's. For the hosts, there are no static bits, and this makes the formula simple, 2p, where p=number of bits in the host address.
Max number of possible networks = 2n-m -2 (where n = number network bits, m = number of static leading bits)
Max number of possible hosts = 2n -2 (where n = number of host bits)
|
Class |
Leading Bits (m bits) |
Decimal Range of First Byte |
Network Bits (n bits) |
Host Bits (n bits) |
Max Networks 2n-m -2 |
Max Hosts 2n-2 |
|
A |
0 (m-1) |
1 to 126 |
8 | 24 |
28-1 -2 = 126 |
224-2= 16,777,214 |
|
B |
10 (m=2) |
128 to 191 |
16 | 16 |
216-2 -2 = 16,384 |
216-2=65,534 |
|
C |
110 (m=3) |
192 to 223 |
24 | 8 |
224-3 -2 = 2,097,152 |
28-2=254 |
|
D |
1110 |
224 to 239 |
|
|
||
|
E |
1111 |
240 to 254 |
|
|
For Class A, the first bit is always 0, which effectively reduces the number of useful bits in the network portion to 7 bits. The first byte decimal value of 0 (00000000) is reserved as a network identifier or default route and 127 (01111111) is reserved for loopback (for example, 127.0.0.1 pings yourself). Therefore use 2n 2 to calculate the max number of Class A networks. The 10 network is reserved, but it still is a Class A network
The all 0's and all 1's Confusion
In some of the published tables - Class B and Class C allow the all 0s and all 1s network numbers. In other tables they are disallowed. However it is best not to use them, since older legacy networks cant handle them. In fact, RFC950 disallowed them altogether. Modern networks can use these two cases, but to be safe, the equation 2n-m 2 can be used to calculate max networks and 2n for max hosts.
Total Possible Addresses
Max Networks x Max Hosts