This topic works hand in hand with IPv4.
Subnet consists of 32bits in binary form, and usually written in dot-decimal notation (eg. 255.255.255.0)
Sample Calculation #1
Prefix
/24
What does it mean in binary?
Starting from left most side, there are 24 ones, as shown below
11111111.11111111.11111111.00000000
How it is written in dot-decimal?
| 11111111 | . | 11111111 | . | 11111111 | . | 00000000 |
| 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0
= 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 |
||||||
| 255 | . | 255 | . | 255 | . | 0 |
What is the total range?
2^( Default bits 32 – prefix 24 )
= 2^8
= 256
For the total range, how many hosts can it have? <total range> – 2
256 – 2
= 254
Sample Calculation #2
Prefix
/20
What does it mean in binary?
Starting from left most side, there are 20 ones, as shown below
11111111.11111111.11110000.00000000
How it is written in dot-decimal?
| 11111111 | . | 11111111 | . | 11110000 | . | 00000000 |
|
|
|
|
|
2^7 + 2^6 + 2^5 + 2^4
= 128 + 64 + 32 + 16 = 240 |
|
|
| 255 | . | 255 | . | 240 | . | 0 |
What is the total range?
2^( Default bits 32 – prefix 20)
= 2^12
= 4096
For the total range, how many hosts can it have? <total range> – 2
4096 – 2
= 4094
Subnet Table
| Prefix | Binary Form | Dot-Decimal Notation | Total range | Total hosts |
| /14 | 11111111.11111100.00000000.0000000 | 255.252.0.0 | 262,144 | 262,142 |
| /15 | 11111111.11111110.00000000.0000000 | 255.254.0.0 | 131,072 | 131,070 |
| /16 | 11111111.11111111.00000000.0000000 | 255.255.0.0 | 65,536 | 65,534 |
| /17 | 11111111.11111111.10000000.0000000 | 255.255.128.0 | 32,768 | 32,766 |
| /18 | 11111111.11111111.11000000.0000000 | 255.255.192.0 | 16,384 | 16,382 |
| /19 | 11111111.11111111.11100000.0000000 | 255.255.224.0 | 8,192 | 8,190 |
| /20 | 11111111.11111111.11110000.0000000 | 255.255.240.0 | 4,096 | 4,094 |
| /21 | 11111111.11111111.11111000.0000000 | 255.255.248.0 | 2,048 | 2,046 |
| /22 | 11111111.11111111.11111100.0000000 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 11111111.11111111.11111110.0000000 | 255.255.254.0 | 512 | 510 |
| /24 | 11111111.11111111.11111111.00000000 | 255.255.255.0 | 256 | 254 |
| /25 | 11111111.11111111.11111111.10000000 | 255.255.255.128 | 128 | 128 |
| /26 | 11111111.11111111.11111111.11000000 | 255.255.255.192 | 64 | 62 |
| /27 | 11111111.11111111.11111111.11100000 | 255.255.255.224 | 32 | 30 |
| /28 | 11111111.11111111.11111111.11110000 | 255.255.255.240 | 16 | 14 |
| /29 | 11111111.11111111.11111111.11111000 | 255.255.255.248 | 8 | 6 |
| /30 | 11111111.11111111.11111111.11111100 | 255.255.255.252 | 4 | 2 |
| /31 | 11111111.11111111.11111111.11111110 | 255.255.255.254 | 2 | 0 |
| /32 | 11111111.11111111.11111111.11111111 | 255.255.255.255 | 1 | 1 |