Subnetting becomes an important topic in networks.This is core of networks how network addresses are being assigned.Students find difficulty in solving the questions on subnetting. This article will help you to solve questions on subnetting.

Free All India Test Equipped with Artificial Intelligence

Start Test  

 

Classes

There are currently five different field patterns in use, each defining a class of addresses. The different classes are designed  to cover the needs of different types of organisations.An IPV4 Address is represented by 32 bits. Division of bits is done on the basis according to class type. A part of address denotes network ID. Another part denotes host ID.

Class A,B,C are used for addressing.The first octet determines the type of class.

                     0-127     →  Class A

                    128-191 →  Class B

                    192-223 →  Class C

                    234- 239 → Class D

                    240- 255 → Class E

 must read : 6 Month Study Plan/TimeTable To Crack GATE (CS) 2017 By Experts

Allocation of Host and Network Id In Classes

 

 

In class A first bit 0 is fixed , for class B two bit 10 is fixed , for class C three bits 110 is fixed. As shown above in class A first 8 bits are reserved for network id and 24 for host id. In class B first 16 bits are reserved for network id and next 16 bits are reserved for host id. Class D and Class E is not in use. So no allocation of network and host bits.

Subnetting

As above there are 2 levels of hierarchy, network and host. Subnet introduces third level of hierarchy, network, subnet and host.

                             network id   host id

                            ------------------------------

                                                    subnet id and host id

It means host id  is further divided into subnet and host.

For eg:- in class A first 8 bits are reserved for network id, the next 24 bits can be divided  into subnet id and host ID.

To have subnet of IP address we use subnet mask.

Also read : Best Books for GATE-CSE by Toppers

Subnet Mask

A subnet mask is sequence of 1 & 0’s which determines which  is subnet id to host id.

                                      classes        Mask

                                      Class A  ->  255.0.0.0

                                      Class B  ->  255.255.0.0

                                      Class C  ->  255.255.255.0

 

Types of Subnet Mask

Subnet Mask can be two types : Natural  and customed. Natural mask are mask defined above for class A,class B,class C. Customed mask is used to determine according to needs, what is subnet id and host id.

Example: suppose  10.5.0.20 is network address

Natural mask should be 255.0.0.0

If use custom 255.255.0.0

                  10→ network id

                   5→ subnet id

                  0.20 → host id (16 bits for host id, if we have used natural mask then we we had 24 bits for host id. Customed mask enables to assign subnets according to requirements of organization)

 

Free Stimulation Mock Test For GATE 2017
Start Test

Tips To Remember

 #Tip

                           10.5.0.26 -------------------and-----------255.0.0.0    => 10.5.0.0

 

[Mask only does ‘and’ operation and we get starting address of network]

#Tip

The bytes in IP address that correspond to 255 in mask will be repeated in subnetwork address

          ip address                 45    20   25  0

         mask                         255    0     0   0

                                   ------------------------------

                                           45     0     0    0

#Tip

  The bytes in IP address that correspond to 0 in mask will change 0 in subnetwork  address as shown above

#Tip

For other bytes, use network and operator

   IP address.          45           123         21           8

   Mask                     255         192         0              0

                                   45           64           0              0

#Tip

For CIDR,

          The number after slash 144.16.192.57/18, Determines number of left mask bits to be used for network mask.

                                      for this subnet mask will be  11111111.11111111.11000000.00000000

#Tip

                 The number of host address is 2host id – 2

for example, In class A the number of host address is 224 – 2

                 and  Number of network addresses is  28 – 2 

#Tip

To determine mask of variable number we check the number of subnet and the number of host per network required

                                                   2x – 2 = subnets

where, x is number of subnet bit in mask

                                                       2x – 2 = host

x is number of host bit in mask

 Also read : Tips to Solve Asymptotic Notation Questions in GATE - CS

Questions From GATE

Ques.

A company has a class C network address of 204.204.204.0. It wishes to have three subnets, one with 100 hosts and two with 50 hosts each. Which one of the following represents a feasible set of subnet address/subnet mask pairs?

a.

  1. 204.204.128/255.255.255.192

   204.204.204.0/255.255.255.128

   204.204.204.64/255.255.255.128

b.

  1. 204.204.0/255.255.255.192

   204.204.204.192/255.255.255.128

   204.204.204.64/255.255.255.128

 c.

  1. 204.204.128/255.255.255.128

    204.204.204.192/255.255.255.192

    204.204.204.224/255.255.255.192

 d.

  1. 204.204.128/255.255.255.128

    204.204.204.64/255.255.255.192

    204.204.204.0/255.255.255.192

 

Solution

Since it is class C, we can create subnetting in last octet only. First 3 octet are fixed

In last octet

we need 2 subnets,

128 host address

128 host address

The second subnet of 128 host address can be further divided into 2 blocks of 64 address each that will fulfill our requirement

The address range in lass octet can start from

             00000000

            10000000

We can treat this as 2 blocks

  • Let us consider 10000000 – 11111111] to 1 block of 128 address

 

  • In next block 00000000, it is further divided into 2 blocks of which first 2 bits are

                      01

                      00

It can be written as

                 01000000] 64

                 00000000] 0

Mask (here 2 bits are fixed)

204.204.204.0/255.255.255.192        '00'

204.204.204.64/255.255.255.192      '01'

when one bit is fixed ,

mask is 255.255.255.128                '10000000'     

The no. of addresses are 256-128= 128

when two  bit is fixed

mask is 255.255.255.192

                                                         '11000000'

The no. of addresses are = 256-192= 64

 

                               Hence answer is d

Also read : Frequently asked Questions For Gate Computer Science Interview

Question

Find the net id and host id for each address

  1. 23.145.90
  2. 34.78.7
  3. 7.3.8
  4. 6.8.4
  5. 76.9.23

Solution

First find the class and then find the net id and host id

  1. Class A, net id:4 host id 23.145.90
  2. Class D, no host id or net id
  3. Class E, no host id or net id
  4. Class B, net id:129.6 host id 8.4
  5. Class C, net id:198.76.9 host id 23

 

Question

The address of a class is to be split into subnet with 6 – bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet?

  1. 62 subnets and 262142 hosts
  2. 64 subnets and 262142 hosts
  3. 62 subnets and 1022 hosts
  4. 64 subnets and 1024 hosts

 

Solution

The class B is defined as follows

0                              16           31

1              0              net id    host id

The maximum number of subnet = 26 – 2 = 62

The maximum number of host in each subnet = 210 =1024 – 2 = 1022

 

 Best Wishes !!

 

Enroll in Mentor Program and Avail your Personalized Mentor for GATE 2017 Preparation and Doubts Clarification!

What aspirants need is the right approach along with concrete strategies to reach their goals. GATE GUARANTEE PACK has been the choice of successful GATE toppers all over India.

It is the perfect online tool to check your level of preparedness among st students preparing all over the country where you study under guidance of mentors.

Free Stimulation Mock Test For GATE 2017
Start Test

 

Search on PrepLadder