Skip to main content

IPV4

Classful Address

binarydecimal
0xxxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx0~127.x.x.x
10xxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx128~191.x.x.x
110xxxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx224~239.x.x.x
1110xxxx . xxxxxxxx . xxxxxxxx . xxxxxxxx224~239.x.x.x
11110000 . xxxxxxxx . xxxxxxxx . xxxxxxxx240~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

slashbinarydecimalipclass
/811111111 . 00000000 . 00000000 . 00000000255.0.0.0A
/1611111111 . 11111111 . 00000000 . 00000000255.255.0.0B
/2411111111 . 11111111 . 11111111 . 00000000255.255.255.0C

Why Subnet Mask?

  • distinction what class of this ip it is.
  • discrimination local or remote this ip it is.

Caculation

C=IPa.netSMaIPb.netSMa{C=0localC0remoteC=IP_{a.net} \oplus SM_{a} - IP_{b.net}\oplus SM_{a} \\ \begin{cases} C=0 & local \\ C \neq 0 & remote \end{cases}

CIDR

CIDR notationnetmask 2netmask 10
/110000000 . 00000000 . 00000000 . 00000000128 . 0 . 0 . 0
/211000000 . 00000000 . 00000000 . 00000000192 . 0 . 0 . 0
/311100000 . 00000000 . 00000000 . 00000000224 . 0 . 0 . 0
/411110000 . 00000000 . 00000000 . 00000000240 . 0 . 0 . 0
/511111000 . 00000000 . 00000000 . 00000000248 . 0 . 0 . 0
/611111100 . 00000000 . 00000000 . 00000000252 . 0 . 0 . 0
/711111110 . 00000000 . 00000000 . 00000000254 . 0 . 0 . 0
/811111111 . 00000000 . 00000000 . 00000000255 . 0 . 0 . 0
/911111111 . 10000000 . 00000000 . 00000000255 . 128 . 0 . 0
/1011111111 . 11000000 . 00000000 . 00000000255 . 192 . 0 . 0
/1111111111 . 11100000 . 00000000 . 00000000255 . 224 . 0 . 0
/1211111111 . 11110000 . 00000000 . 00000000255 . 240 . 0 . 0
/1311111111 . 11111000 . 00000000 . 00000000255 . 248 . 0 . 0
/1411111111 . 11111100 . 00000000 . 00000000255 . 252 . 0 . 0
/1511111111 . 11111110 . 00000000 . 00000000255 . 254 . 0 . 0
/1611111111 . 11111111 . 00000000 . 00000000255 . 255 . 0 . 0
/1711111111 . 11111111 . 10000000 . 00000000255 . 255 . 128 . 0
/1811111111 . 11111111 . 11000000 . 00000000255 . 255 . 192 . 0
/1911111111 . 11111111 . 11100000 . 00000000255 . 255 . 224 . 0
/2011111111 . 11111111 . 11110000 . 00000000255 . 255 . 240 . 0
/2111111111 . 11111111 . 11111000 . 00000000255 . 255 . 248 . 0
/2211111111 . 11111111 . 11111100 . 00000000255 . 255 . 252 . 0
/2311111111 . 11111111 . 11111110 . 00000000255 . 255 . 254 . 0
/2411111111 . 11111111 . 11111111 . 00000000255 . 255 . 255 . 0
/2511111111 . 11111111 . 11111111 . 10000000255 . 255 . 255 . 128
/2611111111 . 11111111 . 11111111 . 11000000255 . 255 . 255 . 192
/2711111111 . 11111111 . 11111111 . 11100000255 . 255 . 255 . 224
/2811111111 . 11111111 . 11111111 . 11110000255 . 255 . 255 . 240
/2911111111 . 11111111 . 11111111 . 11111000255 . 255 . 255 . 248
/3011111111 . 11111111 . 11111111 . 11111100255 . 255 . 255 . 252
/3111111111 . 11111111 . 11111111 . 11111110255 . 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?

  1. Choose a Classful address can range all hosts.
  2. Caculation how many bits(host address) are fit for.
  3. Length of full host address-length of host address=subnet id

Example

Range=172.16.0.0
SM=11111111 . 11111111 . 00000000 . 00000000
hostsClassfulCIDR
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?

  1. Sort subnet according to number of hosts.
  2. Subnet(divide) the given network id into the number of subnet we need.
  3. 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
subnethostscidrvlsm
LAN255
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
LAN125
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
LAN312
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
Waste9+39+52=1009+7+4=20
Total55+25+12=9292+64+100=25692+144+20=256