GFG App
Open App
Browser
Continue

Suppose we have a Class A network that means we have 16 million hosts in a network. The task we have to do is:

1. Maintenance of such a huge network
2. Security for the network â€“ For example, we have 4 departments in a company and all of the 4 departments need not access the whole network.

For this we need subnetting i.e., dividing a huge network into smaller network. Now every department will have their own network .

In case of addressing without subnetting, the process of reaching an address is done by 3 steps –

1. Identification of the network
2. Identification of the host
3. Identification of the process

In case of addressing with subnetting, the process of reaching an address is done by 4 steps â€“

1. Identification of the network
2. Identification of the subnet
3. Identification of the host
4. Identification of the process

Suppose we have a Class C network and we want to divide it into 4 subnets. To divide we need to choose 2 bits from the host part.

As the first and last IP addresses are reserved for network ID and directed broadcast address in every subnet, we have to reserve 8 IP addresses in this case.

A packet is received which has destination address -200.1.2.20 . Then how the router will identify that which subnet it belongs to . Itâ€™ll be done using Subnet Mask.

A subnet mask is a 32-bit number which is used to identify the subnet of an IP address. The subnet mask is combination of 1â€™s and 0â€™s. 1â€™s represents network and subnet ID while 0â€™s represents the host ID. For this case, subnet mask is,

```11111111.11111111.11111111.11000000
or
255.255.255.192 ```

So in order to get the network which the destination address belongs to we have to bitwise & with subnet mask.

```    11111111.11111111.11111111.11000000
&&  11001000.00000001.00000010.00010100
-----------------------------------------------------
11001000.00000001.00000010.00000000 ```

```11001000.00000001.00000010.00000000
or
200.1.2.0 ```

The internal router will forward the packet to the network through an interface . The interface will be identified by the routing table residing in the router.

Routing table :
If the network id doesnâ€™t matches with any then the packet will be sent to default entry. Default entry has network id as 0.0.0.0.

In some cases the network id may match with two entries in the routing table, so here the interface having the longest subnet mask(more 1â€™s) is selected.

My Personal Notes arrow_drop_up