Tag: Subnetting in Networking

Subnet Mask | Subnet Mask Use

Subnet Mask-

 

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

 

We have discussed-

  • Subnet mask is a 32 bit address consisting of a sequence of 1’s and 0’s.
  • It is used to determine to which subnet the given IP Address belongs to.

 

In this article, we will discuss how subnet mask is used by the host assigned to it.

 

Concept To Know-

 

When any host connects to the internet, ISP provides following 4 things to the host-

  1. IP Address
  2. Default Gateway
  3. Subnet Mask
  4. DNS

 

1. IP Address-

 

  • ISP assigns an IP Address to the host so that it can be uniquely identified on the Internet.

 

2. Default Gateway-

 

  • Default router connected to the network in which the host is present is the default gateway for the host.

 

3. Subnet Mask-

 

  • Subnet mask is a 32 bit number that is assigned to the host.
  • It is used to determine to which network the given IP Address belongs to.

 

4. Domain Name Service (DNS)-

 

 

Subnet Mask Use-

 

Subnet mask is used to determine to which network the given IP Address belongs to.

 

  • Host use its subnet mask to determine whether the other host it wants to communicate with is present within the same network or not.
  • If the destination host is present within the same network, then source host sends the packet directly to the destination host.
  • If the destination host is present in some other network, then source host routes the packet to the default gateway (router).
  • Router then sends the packet to the destination host.

 

Example-

 

Consider-

  • There is a host A present in some network X.
  • There is a host B.
  • Host A wants to send a packet to host B.

 

Before transmitting the packet, host A determines whether host B is present within the same network or not.

 

 

Here,

  • Host A = Source host
  • Host B = Destination host

 

To determine whether destination host is present within the same network or not, source host follows the following steps-

 

Step-01:

 

  • Source host computes its own network address using its own IP Address and subnet mask.
  • After computation, source host obtains its network address with respect to itself.

 

Step-02:

 

  • Source host computes the network address of destination host using destination IP Address and its own subnet mask.
  • After computation, source host obtains the network address of destination host with respect to itself.

 

Step-03:

 

Source host compares the two results obtained in the above steps.

Then, following two cases are possible-

 

Case-01:

 

If the results are same,

  • Source host assumes that the destination host is present within the same network.
  • Source host sends the packet directly to the destination host.

 

Case-02:

 

If the results are different,

  • Source host assumes that the destination host is present in some other network.
  • Source host sends the packet via router to the destination host.

 

Important Points-

 

Note-01:

 

  • Each host knows only its own subnet mask.
  • It does not know the subnet mask of any other host.

 

Note-02:

 

  • The conclusion drawn by a host about the presence of other host within the same or different network might be wrong.

 

Note-03:

 

  • Consider host A draws some conclusion about host B.
  • Then, same conclusion might not be drawn by host B about host A.
  • Both the hosts have to perform the above procedure separately at their ends to conclude anything.

 

PRACTICE PROBLEMS BASED ON USE OF SUBNET MASK-

 

Problem-01:

 

Two computers C1 and C2 are configured as follows-

  • C1 has IP Address 203.197.2.53 and net mask 255.255.128.0
  • C2 has IP Address 203.197.75.201 and net mask 255.255.192.0

 

Which one of the following statements is true?

  1. C1 and C2 both assume they are on the same network
  2. C2 assumes C1 is on same network but C1 assumes C2 is on a different network
  3. C1 assumes C2 is on same network but C2 assumes C1 is on a different network
  4. C1 and C2 both assume they are on different networks

 

Solution-

 

At Computer C1-

 

C1 computes its network address using its own IP Address and subnet mask as-

203.197.2.53 AND 255.255.128.0

= 203.197.0.0

 

C1 computes the network address of C2 using IP Address of C2 and its own subnet mask as-

203.197.75.201 AND 255.255.128.0

= 203.197.0.0

 

Since both the results are same, so C1 assumes that C2 is on the same network.

 

At Computer C2-

 

C2 computes its network address using its own IP Address and subnet mask as-

203.197.75.201 AND 255.255.192.0

= 203.197.64.0

 

C2 computes the network address of C1 using IP Address of C1 and its own subnet mask as-

203.197.2.53 AND 255.255.192.0

= 203.197.0.0

 

Since both the results are different, so C2 assumes that C1 is on a different network.

Thus, Option (C) is correct.

 

Problem-02:

 

The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP Addresses could belong to this network?

  1. 172.57.88.62 and 172.56.87.233
  2. 10.35.28.2 and 10.35.29.4
  3. 191.203.31.87 and 191.234.31.88
  4. 128.8.129.43 and 128.8.161.55

 

Solution-

 

Let the given two IP Addresses belong to Host A and Host B.

 

Checking Option (A)-

 

  • Host A IP Address = 172.57.88.62
  • Host B IP Address = 172.56.87.233

 

At Host A-

 

Host A computes its network address using its own IP Address and subnet mask-

172.57.88.62 AND 255.255.31.0

= 172.57.24.0

 

Host A computes the network address of Host B using IP Address of Host B and its own subnet mask-

172.56.87.233 AND 255.255.31.0

= 172.56.23.0

 

Since both the results are different, so host A assumes that host B is on a different network.

Thus, both can’t belong to the same network.

Hence, this option gets eliminated.

 

Checking Option (B)-

 

  • Host A IP Address = 10.35.28.2
  • Host B IP Address = 10.35.29.4

 

At Host A-

 

Host A computes its network address using its own IP Address and subnet mask-

10.35.28.2 AND 255.255.31.0

= 10.35.28.0

 

Host A computes the network address of Host B using IP Address of Host B and its own subnet mask-

10.35.29.4 AND 255.255.31.0

= 10.35.29.0

 

Since both the results are different, so host A assumes that host B is on a different network.

Thus, both can’t belong to the same network.

Hence, this option gets eliminated.

 

Checking Option (C)-

 

  • Host A IP Address = 191.203.31.87
  • Host B IP Address = 191.234.31.88

 

At Host A-

 

Host A computes its network address using its own IP Address and subnet mask-

191.203.31.87 AND 255.255.31.0

= 191.203.31.0

 

Host A computes the network address of Host B using IP Address of Host B and its own subnet mask-

191.234.31.88 AND 255.255.31.0

= 191.234.31.0

 

Since both the results are same, so host A assumes that host B is on the same network.

 

At Host B-

 

Host B computes its network address using its own IP Address and subnet mask-

191.234.31.88 AND 255.255.31.0

= 191.234.31.0

 

Host B computes the network address of Host A using IP Address of Host A and its own subnet mask-

191.203.31.87 AND 255.255.31.0

= 191.203.31.0

 

Since both the results are different, so host B assumes that host A is on a different network.

Thus, both can’t belong to the same network.

Hence, this option gets eliminated.

 

Checking Option (D)-

 

  • Host A IP Address = 128.8.129.43
  • Host B IP Address = 128.8.161.55

 

At Host A-

 

Host A computes its network address using its own IP Address and subnet mask-

128.8.129.43 AND 255.255.31.0

= 128.8.1.0

 

Host A computes the network address of Host B using IP Address of Host B and its own subnet mask-

128.8.161.55 AND 255.255.31.0

= 128.8.1.0

 

Since both the results are same, so host A assumes that host B is on the same network.

 

At Host B-

 

Host B computes its network address using its own IP Address and subnet mask-

128.8.161.55 AND 255.255.31.0

= 128.8.1.0

 

Host B computes the network address of Host A using IP Address of Host A and its own subnet mask-

128.8.129.43 AND 255.255.31.0

= 128.8.1.0

 

Since both the results are same, so host B assumes that host A is on the same network.

Thus, both the hosts assume that they belong to the same network.

Hence, Option (D) is correct.

 

To gain better understanding about Subnet Mask Use,

Watch this Video Lecture

 

Next Article- Internet Protocol Version 4 | IPv4 Header

 

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Subnet Mask | How to Calculate Subnet Mask

Subnetting in Networking-

 

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

 

We have discussed-

  • Subnetting is a process of dividing a single network into multiple sub networks.
  • The number of sub networks created depends upon the requirements.

 

 

Subnet Mask-

 

Subnet mask is a 32 bit number which is a sequence of 1’s followed by a sequence of 0’s where-

  • 1’s represent the global network ID part and the subnet ID part.
  • 0’s represent the host ID part.

 

How to Calculate Subnet Mask?

 

For any given IP Address, the subnet mask is calculated-

  • By setting all the bits reserved for network ID part and subnet ID part to 1.
  • By setting all the bits reserved for host ID part to 0.

 

Subnet Mask Examples-

 

Now, let us discuss some examples on how to calculate subnet mask for any given network-

 

Example-01:

 

Consider we have a network having IP Address 200.1.2.0.

 

Clearly, this IP Address belongs to class C.

 

In class C-

  • 24 bits are reserved for the Network ID part.
  • 8 bits are reserved for the Host ID part.

 

Subnet mask is obtained-

  • By setting the first 24 bits to 1.
  • By setting the remaining 8 bits to 0.

 

So, Subnet mask

= 11111111.11111111.11111111.00000000

= 255.255.255.0

 

Example-02:

 

Consider a single network having IP Address 200.1.2.0 is divided into 4 subnets as shown-

 

 

Now, let us calculate the mask subnet for each subnet.

 

For each subnet-

  • 24 bits identify the global network.
  • 2 bits identify the subnet.
  • 6 bits identify the host.

 

For each subnet, subnet mask is obtained-

  • By setting the first 26 bits to 1.
  • By setting the remaining 6 bits to 0.

 

So, Subnet mask

= 11111111.11111111.11111111.11000000

= 255.255.255.192

 

NOTE

In fixed length subnetting,

All the subnets have same subnet mask since the size of each subnet is same.

 

Example-03:

 

Consider a single network having IP Address 200.1.2.0 is divided into 3 subnets as shown-

 

 

Now, let us calculate the subnet mask for each subnet.

 

For Subnet A-

 

For subnet A-

  • 24 bits identify the global network.
  • 1 bit identify the subnet.
  • 7 bits identify the host.

 

For subnet A, subnet mask is obtained-

  • By setting the first 25 bits to 1.
  • By setting the remaining 7 bits to 0.

 

So, Subnet mask

= 11111111.11111111.11111111.10000000

= 255.255.255.128

 

For Subnet B And Subnet C-

 

For subnet B and subnet C-

  • 24 bits identify the global network.
  • 2 bits identify the subnet.
  • 6 bits identify the host.

 

For subnet B and subnet C, subnet mask is obtained-

  • By setting the first 26 bits to 1.
  • By setting the remaining 6 bits to 0.

 

So, Subnet mask

= 11111111.11111111.11111111.11000000

= 255.255.255.192

 

NOTE

In variable length subnetting,

All the subnets do not have same subnet mask since the size of each subnet is not same.

 

Use of Subnet Mask-

 

  • Subnet mask is used to determine to which subnet the given IP Address belongs to.
  • To know more, Read here.

 

Important Notes-

 

Note-01:

 

Default mask for different classes of IP Address are-

  • Default subnet mask for Class A = 255.0.0.0
  • Default subnet mask for Class B = 255.255.0.0
  • Default subnet mask for Class C = 255.255.255.0

 

Also Read- Classes of IP Address

 

Note-02:

 

  • Network size is the total number of hosts present in it.
  • Networks of same size always have the same subnet mask.
  • Networks of different size always have the different subnet mask.

 

Note-03:

 

  • For a network having larger size, its subnet mask will be smaller (number of 1’s will be less).
  • For a network having smaller size, its subnet mask will be larger (number of 1’s will be more).

 

PRACTICE PROBLEMS BASED ON SUBNET MASK-

 

Problem-01:

 

If the subnet mask 255.255.255.128 belongs to class C, find-

  1. Number of subnets
  2. Number of hosts in each subnet

 

Solution-

 

Given subnet mask

= 255.255.255.128

= 11111111.11111111.11111111.10000000

 

Since 25 bits contain the value 1 and 7 bits contain the value 0, so-

  • Number of Net ID bits + Number of Subnet ID bits = 25
  • Number of Host ID bits = 7

 

Now,

  • It is given that subnet mask belongs to class C.
  • So, Number of Net ID bits = 24.

 

Substituting in the above equation, we get-

Number of Subnet ID bits

= 25 – 24

= 1

 

Thus,

Number of subnets = 21 = 2

 

Since number of Host ID bits = 7, so-

 

Number of hosts per subnet = 27 – 2 = 126

 

Problem-02:

 

If a class B network has a subnet mask of 255.255.248.0, what is the maximum number of hosts per subnet?

  1. 1022
  2. 1023
  3. 2046
  4. 2047

 

Solution-

 

Given subnet mask

= 255.255.248.0

= 11111111.11111111.11111000.00000000

 

Since 21 bits contain the value 1 and 11 bits contain the value 0, so-

  • Number of Net ID bits + Number of Subnet ID bits = 21
  • Number of Host ID bits = 11

 

Since number of Host ID bits = 11, so-

 

Number of hosts per subnet = 211 – 2 = 2046

 

Thus, Option (C) is correct.

 

To gain better understanding about Subnet Mask,

Watch this Video Lecture

 

Next Article- Practice Problems On Subnet Mask

 

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Subnetting in Networking | Subnetting Examples

Subnetting in Networking-

 

In networking,

  • The process of dividing a single network into multiple sub networks is called as subnetting.
  • The sub networks so created are called as subnets.

 

Example-

 

Following diagram shows the subnetting of a big single network into 4 smaller subnets-

 

 

Advantages-

 

The two main advantages of subnetting a network are-

  • It improves the security.
  • The maintenance and administration of subnets is easy.

 

Subnet ID-

 

  • Each subnet has its unique network address known as its Subnet ID.
  • The subnet ID is created by borrowing some bits from the Host ID part of the IP Address.
  • The number of bits borrowed depends on the number of subnets created.

 

Types of Subnetting-

 

Subnetting of a network may be carried out in the following two ways-

 

 

  1. Fixed Length Subnetting
  2. Variable Length Subnetting

 

1. Fixed Length Subnetting-

 

Fixed length subnetting also called as classful subnetting divides the network into subnets where-

  • All the subnets are of same size.
  • All the subnets have equal number of hosts.
  • All the subnets have same subnet mask.

 

2. Variable Length Subnetting-

 

Variable length subnetting also called as classless subnetting divides the network into subnets where-

  • All the subnets are not of same size.
  • All the subnets do not have equal number of hosts.
  • All the subnets do not have same subnet mask.

 

Subnetting Examples-

 

Now, we shall discuss some examples of subnetting a network-

 

Example-01:

 

Consider-

  • We have a big single network having IP Address 200.1.2.0.
  • We want to do subnetting and divide this network into 2 subnets.

 

Clearly, the given network belongs to class C.

 

 

Also Read- Classes of IP Address

 

For creating two subnets and to represent their subnet IDs, we require 1 bit.

So,

  • We borrow one bit from the Host ID part.
  • After borrowing one bit, Host ID part remains with only 7 bits.

 

 

  • If borrowed bit = 0, then it represents the first subnet.
  • If borrowed bit = 1, then it represents the second subnet.

 

IP Address of the two subnets are-

  • 200.1.2.00000000 = 200.1.2.0
  • 200.1.2.10000000 = 200.1.2.128

 

 

For 1st Subnet-

 

  • IP Address of the subnet = 200.1.2.0
  • Total number of IP Addresses = 27 = 128
  • Total number of hosts that can be configured = 128 – 2 = 126
  • Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] = [200.1.2.0, 200.1.2.127]
  • Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
  • Limited Broadcast Address = 255.255.255.255

 

For 2nd Subnet-

 

  • IP Address of the subnet = 200.1.2.128
  • Total number of IP Addresses = 27 = 128
  • Total number of hosts that can be configured = 128 – 2 = 126
  • Range of IP Addresses = [200.1.2.10000000, 200.1.2.11111111] = [200.1.2.128, 200.1.2.255]
  • Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
  • Limited Broadcast Address = 255.255.255.255

 

Example-02:

 

Consider-

  • We have a big single network having IP Address 200.1.2.0.
  • We want to do subnetting and divide this network into 4 subnets.

 

Clearly, the given network belongs to class C.

 

 

For creating four subnets and to represent their subnet IDs, we require 2 bits.

So,

  • We borrow two bits from the Host ID part.
  • After borrowing two bits, Host ID part remains with only 6 bits.

 

 

  • If borrowed bits = 00, then it represents the 1st subnet.
  • If borrowed bits = 01, then it represents the 2nd subnet.
  • If borrowed bits = 10, then it represents the 3rd subnet.
  • If borrowed bits = 11, then it represents the 4th subnet.

 

IP Address of the four subnets are-

  • 200.1.2.00000000 = 200.1.2.0
  • 200.1.2.01000000 = 200.1.2.64
  • 200.1.2.10000000 = 200.1.2.128
  • 200.1.2.11000000 = 200.1.2.192

 

 

For 1st Subnet-

 

  • IP Address of the subnet = 200.1.2.0
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.00000000, 200.1.2.00111111] = [200.1.2.0, 200.1.2.63]
  • Direct Broadcast Address = 200.1.2.00111111 = 200.1.2.63
  • Limited Broadcast Address = 255.255.255.255

 

For 2nd Subnet-

 

  • IP Address of the subnet = 200.1.2.64
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.01000000, 200.1.2.01111111] = [200.1.2.64, 200.1.2.127]
  • Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
  • Limited Broadcast Address = 255.255.255.255

 

For 3rd Subnet-

 

  • IP Address of the subnet = 200.1.2.128
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] = [200.1.2.128, 200.1.2.191]
  • Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
  • Limited Broadcast Address = 255.255.255.255

 

For 4th Subnet-

 

  • IP Address of the subnet = 200.1.2.192
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] = [200.1.2.192, 200.1.2.255]
  • Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
  • Limited Broadcast Address = 255.255.255.255

 

Example-03:

 

Consider-

  • We have a big single network having IP Address 200.1.2.0.
  • We want to do subnetting and divide this network into 3 subnets.

 

Here, the subnetting will be performed in two steps-

  1. Dividing the given network into 2 subnets
  2. Dividing one of the subnets further into 2 subnets

 

Step-01: Dividing Given Network into 2 Subnets-

 

The subnetting will be performed exactly in the same way as performed in Example-01.

After subnetting, we have-

 

 

Step-02: Dividing One Subnet into 2 Subnets-

 

  • We perform the subnetting of one of the subnets further into 2 subnets.
  • Consider we want to do subnetting of the 2nd subnet having IP Address 200.1.2.128.

 

For creating two subnets and to represent their subnet IDs, we require 1 bit.

So,

  • We borrow one more bit from the Host ID part.
  • After borrowing one bit, Host ID part remains with only 6 bits.

 

 

  • If 2nd borrowed bit = 0, then it represents one subnet.
  • If 2nd borrowed bit = 1, then it represents the other subnet.

 

IP Address of the two subnets are-

  • 200.1.2.10000000 = 200.1.2.128
  • 200.1.2.11000000 = 200.1.2.192

 

 

Finally, the given single network is divided into 3 subnets having IP Address-

  • 200.1.2.0
  • 200.1.2.128
  • 200.1.2.192

 

For 1st Subnet-

 

  • IP Address of the subnet = 200.1.2.0
  • Total number of IP Addresses = 27 = 128
  • Total number of hosts that can be configured = 128 – 2 = 126
  • Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] = [200.1.2.0, 200.1.2.127]
  • Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
  • Limited Broadcast Address = 255.255.255.255

 

For 2nd Subnet-

 

  • IP Address of the subnet = 200.1.2.128
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] = [200.1.2.128, 200.1.2.191]
  • Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
  • Limited Broadcast Address = 255.255.255.255

 

For 3rd Subnet-

 

  • IP Address of the subnet = 200.1.2.192
  • Total number of IP Addresses = 26 = 64
  • Total number of hosts that can be configured = 64 – 2 = 62
  • Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] = [200.1.2.192, 200.1.2.255]
  • Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
  • Limited Broadcast Address = 255.255.255.255

 

Disadvantages of Subnetting-

 

Point-01:

 

Subnetting leads to loss of IP Addresses.

 

During subnetting,

  • We have to face a loss of IP Addresses.
  • This is because two IP Addresses are wasted for each subnet.
  • One IP address is wasted for its network address.
  • Other IP Address is wasted for its direct broadcasting address.

 

Point-02:

 

Subnetting leads to complicated communication process.

 

After subnetting, the communication process becomes complex involving the following 4 steps-

  1. Identifying the network
  2. Identifying the sub network
  3. Identifying the host
  4. Identifying the process

 

PRACTICE PROBLEMS BASED ON SUBNETTING IN NETWORKING-

 

Problem-01:

 

Suppose a network with IP Address 192.16.0.0. is divided into 2 subnets, find number of hosts per subnet.

Also for the first subnet, find-

  1. Subnet Address
  2. First Host ID
  3. Last Host ID
  4. Broadcast Address

 

Solution-

 

  • Given IP Address belongs to class C.
  • So, 24 bits are reserved for the Net ID.
  • The given network is divided into 2 subnets.
  • So, 1 bit is borrowed from the host ID part for the subnet IDs.
  • Then, Number of bits remaining for the Host ID = 7.
  • Thus, Number of hosts per subnet = 27 = 128.

 

For 1st Subnet-

 

  • Subnet Address = First IP Address =  192.16.0.00000000 = 172.16.0.0
  • First Host ID = 192.16.0.00000001 = 192.16.0.1
  • Last Host ID = 192.16.0.01111110 = 192.16.0.126
  • Broadcast Address = Last IP Address = 192.16.0.01111111 = 172.16.0.127

 

Problem-02:

 

What is not true about subnetting?

  1. It is applied for a single network
  2. It is used to improve security
  3. Bits are borrowed from network portion
  4. Bits are borrowed from Host portion

 

Solution-

 

Clearly, Option (C) is correct.

 

Problem-03:

 

In a class B, network on the internet has a subnet mask of 255.255.240.0. What is the maximum number of hosts per subnet?

  1. 4096
  2. 4094
  3. 4092
  4. 4090

 

Solution-

 

  • Number of bits reserved for network ID in the given subnet mask = 20.
  • So, Number of bits reserved for Host ID = 32 – 20 = 12 bits.
  • Thus, Number of hosts per subnet = 212 – 2 = 4094.
  • In class B, 16 bits are reserved for the network.
  • So, Number of bits reserved for subnet ID = 20 – 16 = 4 bits.
  • Number of subnets possible = 24 = 16.
  • Thus, Option (B) is correct.

 

To gain better understanding about IPv4 Subnetting,

Watch this Video Lecture

 

Next Article- Subnet Mask | Calculating Subnet Mask

 

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.