IPV4
Classful Address
| binary | decimal |
| 0xxxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx | 0~127.x.x.x |
| 10xxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx | 128~191.x.x.x |
| 110xxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx | 224~239.x.x.x |
| 1110xxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx | 224~239.x.x.x |
| 11110000 . xxxxxxxx . xxxxxxxx . xxxxxxxx | 240~255.x.x.x |
special address
Broadcasting
- 255 . 255 . 255 . 255
- network address . 255
Loopback(in class A address range)
- 127.x.x.x
Unspecified(in class A address range)
- 0.0.0.0
Current Network(in class A address range)
- 0 . host address
Current Host
- network address . 0
Subnet Mask
| slash | binary | decimal | ipclass |
| /8 | 11111111 . 00000000 . 00000000 . 00000000 | 255.0.0.0 | A |
| /16 | 11111111 . 11111111 . 00000000 . 00000000 | 255.255.0.0 | B |
| /24 | 11111111 . 11111111 . 11111111 . 00000000 | 255.255.255.0 | C |
Why Subnet Mask?
- distinction what class of this ip it is.
- discrimination local or remote this ip it is.
Caculation
CIDR
| CIDR notation | netmask 2 | netmask 10 |
| /1 | 10000000 . 00000000 . 00000000 . 00000000 | 128 . 0 . 0 . 0 |
| /2 | 11000000 . 00000000 . 00000000 . 00000000 | 192 . 0 . 0 . 0 |
| /3 | 11100000 . 00000000 . 00000000 . 00000000 | 224 . 0 . 0 . 0 |
| /4 | 11110000 . 00000000 . 00000000 . 00000000 | 240 . 0 . 0 . 0 |
| /5 | 11111000 . 00000000 . 00000000 . 00000000 | 248 . 0 . 0 . 0 |
| /6 | 11111100 . 00000000 . 00000000 . 00000000 | 252 . 0 . 0 . 0 |
| /7 | 11111110 . 00000000 . 00000000 . 00000000 | 254 . 0 . 0 . 0 |
| /8 | 11111111 . 00000000 . 00000000 . 00000000 | 255 . 0 . 0 . 0 |
| /9 | 11111111 . 10000000 . 00000000 . 00000000 | 255 . 128 . 0 . 0 |
| /10 | 11111111 . 11000000 . 00000000 . 00000000 | 255 . 192 . 0 . 0 |
| /11 | 11111111 . 11100000 . 00000000 . 00000000 | 255 . 224 . 0 . 0 |
| /12 | 11111111 . 11110000 . 00000000 . 00000000 | 255 . 240 . 0 . 0 |
| /13 | 11111111 . 11111000 . 00000000 . 00000000 | 255 . 248 . 0 . 0 |
| /14 | 11111111 . 11111100 . 00000000 . 00000000 | 255 . 252 . 0 . 0 |
| /15 | 11111111 . 11111110 . 00000000 . 00000000 | 255 . 254 . 0 . 0 |
| /16 | 11111111 . 11111111 . 00000000 . 00000000 | 255 . 255 . 0 . 0 |
| /17 | 11111111 . 11111111 . 10000000 . 00000000 | 255 . 255 . 128 . 0 |
| /18 | 11111111 . 11111111 . 11000000 . 00000000 | 255 . 255 . 192 . 0 |
| /19 | 11111111 . 11111111 . 11100000 . 00000000 | 255 . 255 . 224 . 0 |
| /20 | 11111111 . 11111111 . 11110000 . 00000000 | 255 . 255 . 240 . 0 |
| /21 | 11111111 . 11111111 . 11111000 . 00000000 | 255 . 255 . 248 . 0 |
| /22 | 11111111 . 11111111 . 11111100 . 00000000 | 255 . 255 . 252 . 0 |
| /23 | 11111111 . 11111111 . 11111110 . 00000000 | 255 . 255 . 254 . 0 |
| /24 | 11111111 . 11111111 . 11111111 . 00000000 | 255 . 255 . 255 . 0 |
| /25 | 11111111 . 11111111 . 11111111 . 10000000 | 255 . 255 . 255 . 128 |
| /26 | 11111111 . 11111111 . 11111111 . 11000000 | 255 . 255 . 255 . 192 |
| /27 | 11111111 . 11111111 . 11111111 . 11100000 | 255 . 255 . 255 . 224 |
| /28 | 11111111 . 11111111 . 11111111 . 11110000 | 255 . 255 . 255 . 240 |
| /29 | 11111111 . 11111111 . 11111111 . 11111000 | 255 . 255 . 255 . 248 |
| /30 | 11111111 . 11111111 . 11111111 . 11111100 | 255 . 255 . 255 . 252 |
| /31 | 11111111 . 11111111 . 11111111 . 11111110 | 255 . 255 . 255 . 254 |
Why CIDR?
Think we have 2000 hosts need to distribution ipaddress.
If use class B address there will have 65535 address; 65535-2000=63536 address is wasted.
If use class C address we need almost 8 class C address.
How CIDR?
- Choose a Classful address can range all hosts.
- Caculation how many bits(host address) are fit for.
- Length of full host address-length of host address=subnet id
Example
Range=172.16.0.0
SM=11111111 . 11111111 . 00000000 . 00000000
| hosts | Classful | CIDR |
| 2000 | Range=172.16.0.0=65536 SM=255 . 255 . 0 . 0 avail=65536-2=65534 waste=65536-2000=63536 | SM=255 . 255 . [00000-11111]000.00000000 network id=172.16.0.0/5 waste=2048-2000=48 Unused=65536-2048=63488 |
VLSM
Why VLSM?
VLSM can divide a full class address to many subnet.
How VLSM?
- Sort subnet according to number of hosts.
- Subnet(divide) the given network id into the number of subnet we need.
- Subneting(vlsm) the subnet to fit the number of nodes in each subnet.
Example
Range= 192.168.4.64/24
SM=11111111 . 11111111 . 11111111 . 00000000
| subnet | hosts | cidr | vlsm |
| LAN2 | 55 | SM=255 . 255 . 255 . 00000000 network id=192.168.4.0/26 waste=64-55=9 | SM=255 . 255 . 255 . 00000000 network id=192.168.4.0/26 waste=64-55=9 |
| LAN1 | 25 | SM=255 . 255 . 255 . 01000000 network id=192.168.4.64/26 waste=64-25=39 | dived 192.168.4.64/26 to 192.168.4.[010,011]/27 192.168.4.64/27 for LAN1 wast=32-25=7 |
| LAN3 | 12 | SM=255 . 255 . 255 . 10000000 network id=192.168.4.128/26 waste=64-12=52 | dived 192.168.4.96/27 to 192.168.4.[0110,0111]/28 192.168.4.96/28 for LAN3 wast=16-12=4 |
| NoUse | SM=255 . 255 . 255 . 11000000 network id=192.168.4.196/26 64 | 255 . 255 . 255 . 10000000/26 255 . 255 . 255 . 11000000/26 255 . 255 . 255 . 0111xxxx/28 64+64+16=144 | |
| Waste | 9+39+52=100 | 9+7+4=20 | |
| Total | 55+25+12=92 | 92+64+100=256 | 92+144+20=256 |