## What is the concept of Subnetting and Supernetting? Computer networks can be broken into many networks or small networks can be combined to form large networks depending upon our needs. This is done by IP subnetting and supernetting . In this blog, we will learn about these concepts in detail. So, let's get started.

#### Subnetting

Dividing the network into smaller contiguous networks or subnets is called subnetting.

#### Why subnetting?

Suppose we take a network of class A. So, in class A, we have 2²⁴ hosts. So to manage such a large number of hosts is tedious. So if we divide this large network into the smaller network then maintaining each network would be easy.

#### How does subnetting work?

Suppose we have a class C network having network ID as 201.10.1.0( range of class C 192–223 ). So the total number of hosts is 256(for class C host is defined by last octet i.e. 2⁸). But, the total usable host is 254. This is because the first IP address is for the network ID and the last IP address is Direct Broadcast Address( for sending any packet from one network to all other hosts of another network ).

So, in subnetting we will divide these 254 hosts logically into two networks. In the above class C network, we have 24 bits for Network ID and the last 8 bits for the Host ID. We are going to borrow the left-most bit of the host address and declare for identifying the subnet. If the leftmost bit of the host address is 0 then it is the 1st subnet network and if the leftmost bit is 1 then it would be 2nd subnet network . Using 1 bit we can divide it into 2 networks i.e. 2¹. If we want to divide it into four networks then we need 2 bits(2²=4 networks). The range of IP address which is in 1st subnet network is from 201.10.1.0 to 201.10.1.127 . The range of IP address that lies in the 2nd subnet network is from 201.10.1.128 to 201.10.1.255 . In the 1st subnet network(S1), we have a total of 126 hosts only because the first and last IP address is reserved for the network ID and the Direct Broadcast Address respectively. Similarly, in the 2nd subnet network, we have 126 hosts.

Overall, there are 252 usable hosts after subnetting. So, because of subnetting, there is a loss in the number of IP addresses.

This network will have two subnets as in the diagram below: The subnet mask is represented as 11111111.11111111.11111111.10000000 i.e. 255.255.255.128 for the above network.

The router inside the network will have the routing table which will be as follows: #### Supernetting or Aggregation

It is the opposite of Subnetting. In this multiple smaller networks are combined together to form a large network.

#### Why supernetting ?

The routing table contains the entry of a subnet mask for every network. If there are lots of small networks then the size of the routing table increases. When the router has a big routing table then it takes a lot of time for the router to process the routing table. Supernetting is used to reduce the size of the IP routing table to improve network routing efficiency.

#### How does supernetting work?

All the networks are not suitable for aggregation. There are some rules according to which the network can be aggregated. For any network to be aggregated it should follow three rules.

1. Contiguous : All the networks should be contiguous.
2. Same size: All the networks should be of the same size and also a power of 2 i.e. 2^n.
3. Divisibility: The first network ID should be divisible by the size of the block.
Note: If a binary number is divided by 2^n then last n bits are the remainder.

Example: Suppose we have four small networks with network ID as 201.1.0.0, 201.1.1.0, 201.1.2.0, 201.1.3.0.

Now, let's check if this can be aggregated or not.

1. Contiguous: As we can see that all the four networks are Class C networks. The range of the first network is from 201.1.0.0 to 201.1.0.255. The range of the second network start from 201.1.1.0. If we add 1 to the last IP address of the first network we get the starting IP address of the second network. Similarly, we can check that all the networks are contiguous.
2. Same Size: As all the networks are of class C. Each network has 2⁸ i.e. 256 hosts.
3. Divisibility: The first IP address should be divisible by the total size of the networks. The total size of the network is 4*2⁸ i.e. 2¹⁰. The last 10 bits are the remainder if we divide the first IP address by 2¹⁰. In order that they are divisible, the last ten bist should be 0.
First IP address binary representation: 11001001.00000001.000000 00.00000000

The last 10 bits are zero. Hence it divisible by the size of the network. Hence, all three conditions are satisfied.

These four networks can be combined to form a supernet. The supernet ID or the network ID for all the four networks will be 201.1.0.0 . Supernet Mask is a 32-bit number where all the fixed bits of the network are represented by 1 and the variable part is represented by 0.

Overall, there are 252 usable hosts after subnetting. So, because of subnetting, there is a loss in the number of IP addresses. The bits to the left of the red line are fixed bits and the bits right of it represent the variable bits.

The routing table at the router 2 is now reduced and contains only one entry for all four networks. But, the router 1 needs a routing table which should contain all the four entries because it should know where to forward the packet next.

The routing table at router 2: This was all about subnetting and supernetting. Hope you learned something new today.