Displayed below is how the subnet address "255.255.252.0" is written in binary format. We'll apply this subnet mask to a Class B IP address. To subnet the Class B address, we move the dividing line between the hostid and netid so that more bits are used for the network portion of the address.
Class B
----- Netid ----- ----- Hostid ----
| 16 bits | | 16 bits |
v v v v
11111111 11111111 00000000 00000000
11111111 11111111 11111100 00000000 <-- subnet mask
255 255 252 0
The last 6 bits of the hostid are "robbed" giving the netid a total of 22 bits.(The "1"s.) The hostid portion of the address is left with 10 bits. (The "0"s.) To figure out the number of subnets and the number of hosts on each subnet, let's examine the hostid portion of the address.
---- Robbed bits ---- -- 10 bits left for hosts --
| | | |
v v v v
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
32 + 16 + 8 + 4 + 2 + 1
Add together the bits we "robbed" from the hostid and we come up with a total of 63 subnets. Okay, 64 subnets if we include "subnet 0 (zero)." Now, for the remaining host portion.
-Robbed bits - --------- 10 bits left for hosts ---------
| | | |
v v v v
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
The total number of hosts we can have on each subnet is 1023. (Note that one address must be allocated for broadcast.)
Now let's look at the subnet boundaries using the 172.32.0.0 Class B network address. Using 22 bits (like in the examples above) for the netid portion of the address, it is commonly written like this; 172.32.0.0/22.
Subnet 0
Next Subnet
Next Subnet
Next Subnet
And so on...
...the Last Subnet