# Daily Learning: Computer Networks – Classless Inter Domain Routing(CIDR)

In classfull representation Every network used to get same amount of host regarding of the class of the network. But that is a waste in many cases where if a user need 2^14 host and buy the class B network then 49152 network are wasted. To counter this situation IANA came up with a new technique –

## CIDR

It is also a 32 bit number but it has a special number which represents the number of bit present in block ID.

``````a.b.c.d/n
20.10.50.100/20``````

Here the number of Host present in the network is 2^(32-n) or here 2^12.

• Rules
1. All the IP addresses re contiguous. Means there can’t be any fragmentation.
2. Block size must be power of 2(2^n). If the block size is 2^5 then the Host ID will contain 5 bits and the Block ID will be 27 bits.
3. First IP address must be evenly divisible by the size of the block. Means the least significant part should always start with zeroes in Host ID.
• Check whether 100.1.2.32 to 100.1.2.47 is a valid IP address block or not?
1. All the IP addresses are contiguous.
2. Total number of IP addresses in the Block = 16 = 2^4
3. 1st IP address: 100.1.2.00100000 . Since, Host Id will contains last 4 bits and all the least significant 4 bits are zero. Hence, first IP address is evenly divisible by the size of the block.

## Subnetting

Suppose our CIDR address is 20.30.40.10/25 means the host ID is 7 bit 20.30.40.00001010

So the network ID will be 20.30.40.00000000 . Now If I want to divide the network in 2 part I will need to use 1 bit from the host ID. So the total ID part is now 26. 1st part : starting address is 20.30.40.00000000(20.30.40.0/26) & the direct broadcast address is 20.30.40.00111111(20.30.40.63/26).

2nd Part : Starting address is 20.30.40.01000000(20.30.40.64/26) & the direct broadcast address is 20.30.40.01111111(20.30.40.127/26). Same as if we wanted to divide the network in 4 parts we will have we will have ID part will be 27.