## Classless Addressing | CIDR in Networking

There are two systems in which IP Addresses are classified-

• It makes the allocation of IP Addresses more efficient.
• It replaces the older classful addressing system based on classes.
• It is also known as Classless Inter Domain Routing (CIDR).

## CIDR Block-

• CIDR dynamically assigns a block of IP Addresses based on certain rules.
• This block contains the required number of IP Addresses as demanded by the user.
• This block of IP Addresses is called as a CIDR block.

## Rules For Creating CIDR Block-

A CIDR block is created based on the following 3 rules-

## Rule-01:

• All the IP Addresses in the CIDR block must be contiguous.

## Rule-02:

• The size of the block must be presentable as power of 2.
• Size of the block is the total number of IP Addresses contained in the block.
• Size of any CIDR block will always be in the form 21, 22, 23, 24, 25 and so on.

## Rule-03:

• First IP Address of the block must be divisible by the size of the block.

### REMEMBER

If any binary pattern consisting of (m + n) bits is divided by 2n, then-

• Remainder is least significant n bits
• Quotient is most significant m bits

So, any binary pattern is divisible by 2n, if and only if its least significant n bits are 0.

### Examples-

Consider a binary pattern-

01100100.00000001.00000010.01000000

(represented as 100.1.2.64)

• It is divisible by 25 since its least significant 5 bits are zero.
• It is divisible by 26 since its least significant 6 bits are zero.
• It is not divisible by 27 since its least significant 7 bits are not zero.

## CIDR Notation-

a.b.c.d / n

• They end with a slash followed by a number called as IP network prefix.
• IP network prefix tells the number of bits used for the identification of network.
• Remaining bits are used for the identification of hosts in the network.

## Example-

An example of CIDR IP Address is-

182.0.1.2 / 28

It suggests-

• 28 bits are used for the identification of network.
• Remaining 4 bits are used for the identification of hosts in the network.

## Problem-01:

Given the CIDR representation 20.10.30.35 / 27. Find the range of IP Addresses in the CIDR block.

## Solution-

Given CIDR representation is 20.10.30.35 / 27.

It suggests-

• 27 bits are used for the identification of network.
• Remaining 5 bits are used for the identification of hosts in the network.

Given CIDR IP Address may be represented as-

00010100.00001010.00011110.00100011 / 27

So,

• First IP Address = 00010100.00001010.00011110.00100000 = 20.10.30.32
• Last IP Address = 00010100.00001010.00011110.00111111 = 20.10.30.63

Thus, Range of IP Addresses = [ 20.10.30.32 , 20.10.30.63]

## Problem-02:

Given the CIDR representation 100.1.2.35 / 20. Find the range of IP Addresses in the CIDR block.

## Solution-

Given CIDR representation is 100.1.2.35 / 20.

It suggests-

• 20 bits are used for the identification of network.
• Remaining 12 bits are used for the identification of hosts in the network.

Given CIDR IP Address may be represented as-

01100100.00000001.00000010.00100011 / 20

So,

• First IP Address = 01100100.00000001.00000000.00000000 = 100.1.0.0
• Last IP Address = 01100100.00000001.00001111.11111111 = 100.1.15.255

Thus, Range of IP Addresses = [ 100.1.0.0 , 100.1.15.255]

## Problem-03:

Consider a block of IP Addresses ranging from 100.1.2.32 to 100.1.2.47.

1. Is it a CIDR block?
2. If yes, give the CIDR representation.

## Solution-

For any given block to be a CIDR block, 3 rules must be satisfied-

## Rule-01:

• According to Rule-01, all the IP Addresses must be contiguous.
• Clearly, all the given IP Addresses are contiguous.
• So, Rule-01 is satisfied.

## Rule-02:

• According to Rule-02, size of the block must be presentable as 2n.
• Number of IP Addresses in the given block = 47 – 32 + 1 = 16.
• Size of the block = 16 which can be represented as 24.
• So, Rule-02 is satisfied.

## Rule-03:

• According to Rule-03, first IP Address must be divisible by size of the block.
• So, 100.1.2.32 must be divisible by 24.
• 100.1.2.32 = 100.1.2.00100000 is divisible by 24 since its 4 least significant bits are zero.
• So, Rule-03 is satisfied.

Since all the rules are satisfied, therefore given block is a CIDR block.

## CIDR Representation-

We have-

• Size of the block = Total number of IP Addresses = 24.
• To have 24 total number of IP Addresses, total 4 bits are required in the Host ID part.
• So, Number of bits present in the Network ID part = 32 – 4 = 28.

Thus,

 CIDR Representation = 100.1.2.32 / 28

## NOTE-

For writing the CIDR representation,

• We can choose to mention any IP Address from the CIDR block.
• The chosen IP Address is followed by a slash and IP network prefix.
• We generally choose to mention the first IP Address.

## Problem-04:

Consider a block of IP Addresses ranging from 150.10.20.64 to 150.10.20.127.

1. Is it a CIDR block?
2. If yes, give the CIDR representation.

## Solution-

For any given block to be a CIDR block, 3 rules must be satisfied-

## Rule-01:

• According to Rule-01, all the IP Addresses must be contiguous.
• Clearly, all the given IP Addresses are contiguous.
• So, Rule-01 is satisfied.

## Rule-02:

• According to Rule-02, size of the block must be presentable as 2n.
• Number of IP Addresses in given block = 127 – 64 + 1 = 64.
• Size of the block = 64 which can be represented as 26.
• So, Rule-02 is satisfied.

## Rule-03:

• According to Rule-03, first IP Address must be divisible by size of the block.
• So, 150.10.20.64 must be divisible by 26.
• 150.10.20.64 = 150.10.20.01000000 is divisible by 26 since its 6 least significant bits are zero.
• So, Rule-03 is satisfied.

Since all the rules are satisfied, therefore given block is a CIDR block.

## CIDR Representation-

We have-

• Size of the block = Total number of IP Addresses = 26.
• To have 26 total number of IP Addresses, 6 bits are required in the Host ID part.
• So, Number of bits in the Network ID part = 32 – 6 = 26.

Thus,

 CIDR Representation = 150.10.20.64 / 26

## Problem-05:

Perform CIDR aggregation on the following IP Addresses-

128.56.24.0/24

128.56.25.0/24

128.56.26.0/24

128.56.27.0/24

## Solution-

All the 4 given entities represent CIDR block in itself.

We have to now perform the aggregation of these 4 blocks.

## Rule-01:

• According to Rule-01, all the IP Addresses must be contiguous.
• Clearly, all the IP Addresses are contiguous.
• So, Rule-01 is satisfied.

## Rule-02:

• According to Rule-02, size of the block must be presentable as 2n.
• Total number of IP Addresses = 28 + 28 + 28 + 28 = 22 x 28 = 210.
• So, Rule-02 is satisfied.

## Rule-03:

• According to Rule-03, first IP Address must be divisible by size of the block.
• So, 128.56.24.0 must be divisible by 210.
• 128.56.24.0 = 128.56.00011000.00000000 is divisible by 210 since its 10 least significant bits are zero.
• So, Rule-03 is satisfied.

Since all the 3 rules are satisfied, so they can be aggregated.

## CIDR Representation-

We have-

• Size of the block = Total number of IP Addresses = 210.
• To have 210 total number of IP Addresses, 10 bits are required in the Host ID part.
• So, Number of bits in the Network ID part = 32 – 10 = 22.

Thus,

 CIDR Representation = 128.56.24.0/22

## Problem-06:

Perform CIDR aggregation on the following IP Addresses-

200.96.86.0/24

200.96.87.0/24

200.96.88.0/24

200.96.89.0/24

## Solution-

All the 4 given entities represent CIDR block in itself.

We have to now perform the aggregation of these 4 blocks.

## Rule-01:

• According to Rule-01, all the IP Addresses must be contiguous.
• Clearly, all the IP Addresses are contiguous.
• So, Rule-01 is satisfied.

## Rule-02:

• According to Rule-02, size of the block must be presentable as 2n.
• Total number of IP Addresses = 28 + 28 + 28 + 28 = 22 x 28 = 210.
• So, Rule-02 is satisfied.

## Rule-03:

• According to Rule-03, first IP Address must be divisible by size of the block.
• So, 200.96.86.0 must be divisible by 210.
• 200.96.86.0 = 200.96.01010110.00000000 is not divisible by 210 since its 10 least significant bits are not zero.
• So, Rule-03 is unsatisfied.

Since all the 3 rules are not satisfied, so they can not be aggregated.

Watch this Video Lecture

Next Article-Subnetting | Examples

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

## IP Address in Networking | Problems

Before you go through this article, make sure that you have gone through the previous article on IP Address.

We have discussed-

• IP Address is a unique address assigned to each computing device in an IP network.
• ISP assigns IP Address to all the devices present on its network.
• Casting refers to transmitting data (stream of packets) over the network.

## Point-01:

• If the range of first octet is [1, 126], then IP Address belongs to class A.
• If the range of first octet is [128, 191], then IP Address belongs to class B.
• If the range of first octet is [192, 223], then IP Address belongs to class C.
• If the range of first octet is [224, 239], then IP Address belongs to class D.
• If the range of first octet is [240, 254], then IP Address belongs to class E.

## Point-02:

• IP Address of its network is obtained by setting all its Host ID part bits to 0.

## Point-03:

• Direct Broadcast Address is obtained by setting all its Host ID part bits to 1.

## Point-04:

• For any given IP Address, limited Broadcast Address is obtained by setting all its bits to 1.

## Point-05:

• Class D IP Addresses are not divided into Net ID and Host ID parts.
• Class E IP Addresses are not divided into Net ID and Host ID parts.

## Problem-01:

1. 1.2.3.4
2. 10.15.20.60
3. 130.1.2.3
4. 150.0.150.150
5. 200.1.10.100
6. 220.15.1.10
7. 250.0.1.2
8. 300.1.2.3

## Part-A:

1.2.3.4

• IP Address belongs to class A
• Network IP Address = 1.0.0.0

## Part-B:

10.15.20.60

• IP Address belongs to class A
• Network IP Address = 10.0.0.0

## Part-C:

130.1.2.3

• IP Address belongs to class B
• Network IP Address = 130.1.0.0

## Part-D:

150.0.150.150

• IP Address belongs to class B
• Network IP Address = 150.0.0.0

## Part-E:

200.1.10.100

• IP Address belongs to class C
• Network IP Address = 200.1.10.0

## Part-F:

220.15.1.10

• IP Address belongs to class C
• Network IP Address = 220.15.1.0

## Part-G:

250.0.1.2

• IP Address belongs to class E
• Network IP Address = Not available

## Part-H:

300.1.2.3

• This is not a valid IP Address.
• This is because for any given IP Address, the range of its first octet is always [1, 254].
• First and Last IP Addresses are reserved.

## Problem-02:

A device has two or more IP Addresses, the device is called-

1. Workstation
2. Router
3. Gateway
4. All of these

## Solution-

• All the given devices have a network layer.
• So, they will have at least one IP Address.

In TCP/IP suite-

• Workstation and gateway have all the 5 layers.
• Router has only 3 layers last layer being network layer.

## Workstation-

• A user may configure more than one IP Addresses in his workstation / computer.
• With more than one IP Address, it remains present in more than one networks.
• So, if one network goes down, it is always reachable from other networks.

The following figure shows a host present in more than one networks-

• It is important to note that IP Addresses are assigned to interfaces.
• When we buy a new laptop, we usually get 2-3 interfaces.
• Thus, a workstation can have more than one IP Addresses.

## Router-

• A router may be connected to various interfaces.
• Each interface has a unique IP Address.
• Thus, a router may also have more than IP Addresses.
• Similar is the case with gateways because gateways are extension of routers.

Thus, Option (D) is correct.

## Problem-03:

A host with IP Address 200.100.1.1 wants to send a packet to all the hosts in the same network.

What will be-

## Solution-

1. Source IP Address = IP Address of the sender = 200.100.1.1

## Problem-04:

A host with IP Address 10.100.100.100 wants to use loop back testing.

What will be-

## Solution-

• Source IP Address = 10.100.100.100

## Problem-05:

How many bits are allocated for Network ID and Host ID in 23.192.157.234 address?

## Solution-

Given IP Address belongs to class A.

Thus,

• Number of bits reserved for Network ID = 8
• Number of bits reserved for Host ID = 24

## Problem-06:

Which devices can use logical addressing system?

1. Hub
2. Switch
3. Bridge
4. Router

## Solution-

• Devices which have network layer as the last layer can only use logical addressing system.
• Devices which have data link layer as the last layer can only use physical addressing system.

### Option-A:

• Hub can neither use physical addressing system nor logical addressing system.
• This is because it has physical layer as the last layer.

### Option-B:

• Switch can use physical addressing system but not logical addressing system.
• This is because it has data link layer as the last layer.

### Option-C:

• Bridge can use physical addressing system but not logical addressing system.
• This is because it has data link layer as the last layer.

### Option-D:

• Router can use physical addressing system as well as logical addressing system.
• This is because it has network layer as the last layer.

Thus, option (D) is correct.

## Problem-07:

What is the network ID of the IP Address 230.100.123.70?

## Solution-

• Given IP Address belongs to class D.
• Class D IP Addresses are not divided into the Network ID and Host ID parts.
• Thus, there is no network ID for the given IP Address.

## Problem-08:

Match the following-

#### Column-I:

1. 200.10.192.100
2. 7.10.230.1
3. 128.1.1.254
4. 255.255.255.255
5. 100.255.255.255

1. Class A
4. Class C
5. Class B

## Solution-

(I, D), (II, A), (III, E), (IV, B), (V, C)

## Problem-09:

Suppose that instead of using 16 bits for network part of a class B Address, 20 bits have been used. How many class B networks would have been possible?

## Solution-

• Total 20 bits are used for Network ID of class B.
• The first two bits are always set to 10.
• Then, with 18 bits, number of networks possible = 218

## Problem-10:

What is the default mask for 192.0.46.10?

## Solution-

• Given IP Address belongs to class C.
• For class C, default mask = 255.255.255.0

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

In networking,

• It is a unique address assigned to each computing device in an IP network.
• ISP assigns IP Address to all the devices present on its network.
• Computing devices use IP Address to identify and communicate with other devices in the IP network.

IP Addresses may be of the following two types-

• Static IP Address is an IP Address that once assigned to a network element always remains the same.
• They are configured manually.

### NOTE

• Some ISPs do not provide static IP addresses.

• Dynamic IP Address is a temporarily assigned IP Address to a network element.
• It can be assigned to a different device if it is not in use.
• DHCP or PPPoE assigns dynamic IP addresses.

• IP Address is a 32 bit binary address written as 4 numbers separated by dots.
• The 4 numbers are called as octets where each octet has 8 bits.
• The octets are divided into 2 components- Net ID and Host ID.

1. Network ID represents the IP Address of the network and is used to identify the network.
2. Host ID represents the IP Address of the host and is used to identify the host within the network.

Example of an IP Address is-

00000001.10100000.00001010.11110000

(Binary Representation)

OR

1.160.10.240

(Decimal Representation)

There are two systems in which IP Addresses are classified-

In Classful Addressing System, IP Addresses are organized into following 5 classes-

1. Class A
2. Class B
3. Class C
4. Class D
5. Class E

## 1. Class A-

 If the 32 bit binary address starts with a bit 0, then IP Address belongs to class A.

• The first 8 bits are used for the Network ID.
• The remaining 24 bits are used for the Host ID.

### Total Number Of IP Addresses-

Total number of IP Addresses available in class A

= Numbers possible due to remaining available 31 bits

= 231

### Total Number Of Networks-

Total number of networks available in class A

= Numbers possible due to remaining available 7 bits in the Net ID – 2

= 27 – 2

= 126

(The reason of subtracting 2 is explained later.)

### Total Number Of Hosts-

Total number of hosts that can be configured in class A

= Numbers possible due to available 24 bits in the Host ID – 2

= 224 – 2

(The reason of subtracting 2 is explained later.)

### Range Of 1st Octet-

We have-

• Minimum value of 1st octet = 00000000 = 0
• Maximum value of 1st octet = 01111111 = 127

From here,

• Range of 1st octet = [0, 127]
• But 2 networks are reserved and unused.
• So, Range of 1st octet = [1, 126]

## Use-

• Class A is used by organizations requiring very large size networks like NASA, Pentagon etc.

## 2. Class B-

 If the 32 bit binary address starts with bits 10, then IP Address belongs to class B.

• The first 16 bits are used for the Network ID.
• The remaining 16 bits are used for the Host ID.

### Total Number Of IP Addresses-

Total number of IP Addresses available in class B

= Numbers possible due to remaining available 30 bits

= 230

### Total Number Of Networks-

Total number of networks available in class B

= Numbers possible due to remaining available 14 bits in the Net ID

= 214

### Total Number Of Hosts-

Total number of hosts that can be configured in class B

= Numbers possible due to available 16 bits in the Host ID – 2

= 216 – 2

### Range Of 1st Octet-

We have-

• Minimum value of 1st octet = 10000000 = 128
• Maximum value of 1st octet = 10111111 = 191

So, Range of 1st octet = [128, 191]

## Use-

• Class B is used by organizations requiring medium size networks like IRCTC, banks etc.

## 3. Class C-

 If the 32 bit binary address starts with bits 110, then IP Address belongs to class C.

• The first 24 bits are used for the Network ID.
• The remaining 8 bits are used for the Host ID.

### Total Number Of IP Addresses-

Total number of IP Addresses available in class C

= Numbers possible due to remaining available 29 bits

= 229

### Total Number Of Networks-

Total number of networks available in class C

= Numbers possible due to remaining available 21 bits in the Net ID

= 221

### Total Number Of Hosts-

Total number of hosts that can be configured in class C

= Numbers possible due to available 8 bits in the Host ID – 2

= 28 – 2

### Range Of 1st Octet-

We have-

• Minimum value of 1st octet = 11000000 = 192
• Maximum value of 1st octet = 110111111 = 223

So, Range of 1st octet = [192, 223]

## Use-

• Class C is used by organizations requiring small to medium size networks.
• For example- engineering colleges, small universities, small offices etc.

## 4. Class D-

 If the 32 bit binary address starts with bits 1110, then IP Address belongs to class D.

• Class D is not divided into Network ID and Host ID.

### Total Number Of IP Addresses-

Total number of IP Addresses available in class D

= Numbers possible due to remaining available 28 bits

= 228

### Range Of 1st Octet-

We have-

• Minimum value of 1st octet = 11100000 = 224
• Maximum value of 1st octet = 11101111 = 239

So, Range of 1st octet = [224, 239]

## Use-

• Class D is reserved for multicasting.
• In multicasting, there is no need to extract host address from the IP Address.
• This is because data is not destined for a particular host.

## 5. Class E-

 If the 32 bit binary address starts with bits 1111, then IP Address belongs to class E.

• Class E is not divided into Network ID and Host ID.

### Total Number Of IP Addresses-

Total number of IP Addresses available in class E

= Numbers possible due to remaining available 28 bits

= 228

### Range Of 1st Octet-

We have-

• Minimum value of 1st octet = 11110000 = 240
• Maximum value of 1st octet = 11111111 = 255

So, Range of 1st octet = [240, 255]

## Use-

• Class E is reserved for future or experimental purposes.

All the classes of IP Address are summarized in the following table-

 Class of IP Address Total Number of IP Addresses 1st Octet Decimal Range Number of Networks available Hosts per network Default Subnet Mask Class A 231 1 – 126 27 – 2 224 – 2 255.0.0.0 Class B 230 128 – 191 214 216 – 2 255.255.0.0 Class C 229 192 – 223 221 28 – 2 255.255.255.0 Class D 228 224 – 239 Not defined Not defined Not defined Class E 228 240 – 254 Not defined Not defined Not defined

## Note-01:

• All the hosts in a single network always have the same network ID but different Host ID.
• However, two hosts in two different networks can have the same host ID.

## Note-02:

• A single network interface can be associated with more than one IP Address.

## Note-03:

• There is no relation between MAC Address and IP Address of a host.

## Note-04:

• IP Address of the network called Net ID is obtained by setting all the bits for Host ID to zero.

## Note-05:

• Class A Networks accounts for half of the total available IP Addresses.

## Note-06:

 In class A, total number of IP Addresses available for networks are 2 less.

• This is to account for the two reserved network IP Addresses 0.xxx.xxx.xxx and 127.xxx.xxx.xxx.
• IP Address 127.0.0.1 is reserved for loopback address used for software testing.

## Note-07:

 In all the classes, total number of hosts that can be configured are 2 less.

• This is to account for the two reserved IP addresses in which all the bits for host ID are either zero or one.
• When all Host ID bits are 0, it represents the Network ID for the network.
• When all Host ID bits are 1, it represents the Broadcast Address.

## Note-08:

• Only those devices which have the network layer will have IP Address.
• So, switches, hubs and repeaters does not have any IP Address.