Role of Subnet Mask

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Aptitude Engineering Mathematics Discrete Mathematics Operating System DBMS Computer Networks Dig

Role of Subnet Mask


Last Updated : 11 Feb, 2024
The host or client address and the network or server address are the two
parts of the IP address that are present on every computer device. Either a
DHCP server or a human, using a static IP address, configures the IP
addresses.

What is a Subnet Mask?


Setting all 0s for the host bits and all 1s for the network bits results in a 32-
bit value known as a subnet mask. The IP address is divided into the host
address and network address in this manner by the subnet mask. “255” is
always the address assigned to the broadcast address, while “0” is always
the address assigned to the network address. The subnet mask cannot be
assigned to the host because it is set aside for a specific purpose.

Function of Subnet Mask

A 32-bit address that distinguishes the network address from the host
address makes up the subnet mask. This indicates which part of the IP
address belongs in the host section and which part belongs in the network
section. The number of hosts that can be on the subnet depends on the
values of the subnet mask. This comprises bits that are initialized to 1 for the
network and 0 for the host. Routers and switches use it internally to send
packets to the destination node along the associated local network
connection.

Suppose we have a Class A network which 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
networks. Now every department will have their network. In the case of
addressing without subnetting, the process of reaching an address is done by
3 steps –

Identification of the network


Identification of the host
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.

Network Classes
The company in charge of overseeing the Internet, InterNIC, assigns IP
addresses. There are classes for these IP addresses. Classes A, B, and C are
the most prevalent ones among them. Although they exist, end users do not
use classes D or E. The default subnet mask varies for each address class. An
IP address’s first octet can be used to determine its class. The ranges of Class
A, B, and C Internet addresses are listed below, along with a sample address
for each:

Class A networks have 0-127 as their first octet and utilise 255.0.0.0 as
their default subnet mask. 10.52.36.11 is classified as a class A address.
10, its initial octet, falls between 1 and 126, inclusive.
Class B networks have 128–191 as their first octet and 255.255.0.0 as
their default subnet mask. Address 172.16.52.63 belongs to the class B
address set. Its initial octet is 172, spanning from 128 to 191, inclusive.
Class C networks have 192-223 as their first octet and utilise
255.255.255.0 as their default subnet mask.

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

The address belongs to,

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.

Advantages of Subnetting
It does this by sending out fewer broadcasts, which lowers network load.
It assists in getting around restrictions in a local area network (LAN), like
the maximum number of permitted hosts.
Without needing to access the entire network, it enables users to join to a
work network from their residences.
It keeps one network safe from another’s infiltration. For instance, no other
department within an organisation should be able to view the code
created by the Developer department.
A higher network priority may be needed for some subnets than for
others. For instance, a sales department might need to hold video
conferences or webcasts.
If the network is tiny, maintenance is easy.

Disadvantages of Subnetting
Subnetting reduces the overall number of IP addresses in the network, yet
it could necessitate purchasing extra hardware, like a router. Thus, it could
be very expensive.
Companies still assign address blocks in relation to classes, therefore it
cannot alleviate the inefficiency.

Conclusion
Subnetting improves performance by lowering network traffic and collisions.
This gives the IT administrators complete control over data packet
monitoring, router device enabling or updating, and network traffic reduction.
In order for the routers to match data packets to the intended node and
determine the optimal path for data transmission between the sender and
recipient interface, the subnet mask addresses are required to distinguish
between the host and network address.

Frequently Asked Question on Subnet Mask – FAQs

What is a Subnet Mask?

Setting all 0s for the host bits and all 1s for the network bits results in
a 32-bit value known as a subnet mask.

How is a Subnet Mask represented?

The IP address’s 32-bit value is used to identify each octet. For


instance, 255.255.255.0 is a typical Class C subnet mask because the
last two bytes are all zeros and the first two bytes are all ones
(network).

How does subnetting help in network design?

One purpose of a subnet is to reduce traffic by dividing a large network


into a collection of linked, smaller networks. In this manner, traffic can
move faster over networks by avoiding needless paths. The
segmentation of a network address space, or subnetting, increases the
effectiveness of address allocation.

Can subnet masks be variable in length?

Yes Subnet mask can be variable in length.


Why is subnetting important for security?

By quarantining infected areas of the network and making it more


difficult for intruders to navigate an organization’s network, subnetting
enables network managers to lessen hazards to the entire network.

"GeeksforGeeks helped me ace the GATE exam! Whenever I had any doubt
regarding any topic, GFG always helped me and made my concepts quiet
clear." - Anshika Modi | AIR 21

Choose GeeksforGeeks as your perfect GATE 2025 Preparation partner with


these newly launched programs
GATE CS & IT
GATE DS & AI
GATE Offline (Delhi/NCR)

Over 125,000+ students already trust us to be their GATE Exam guide. Join
them & let us help you in opening the GATE to top-tech IITs & NITs!

14 Suggest improvement

Previous Next

What is IPv4? Introduction of Classful IP


Addressing

Share your thoughts in the comments Add Your Comment

Similar Reads
Finding Network ID of a Subnet (using How do You Calculate the Subnet
Subnet Mask) Address from an IP Address and Subnet
Mask?
Fixed Length and Variable Length C Program to find IP Address, Subnet
Subnet Mask Numericals Mask & Default Gateway

Is 255.0.255.0 a Subnet Mask? How to Calculate a Subnet Mask from IP


Address?

How do I Find Subnet Mask for an IP What is Subnet Mask for the
Address? 255.255.255.248?

Subnet Mask Cheat Sheet IPv4 Classless Subnet equation

A AnshuMis…

Article Tags : Computer Networks , GATE CS

A-143, 9th Floor, Sovereign Corporate


Tower, Sector-136, Noida, Uttar Pradesh -
201305
Company Explore Languages DSA Data Science & Web
About Us Job-A-Thon Hiring Python Data Structures ML Technologies
Legal Challenge Java Algorithms Data Science With HTML
Careers Hack-A-Thon C++ DSA for Beginners Python CSS
In Media GfG Weekly PHP Basic DSA Data Science For JavaScript
Contact Us Contest GoLang Problems Beginner TypeScript
Advertise with us Offline Classes SQL DSA Roadmap Machine Learning ReactJS
GFG Corporate (Delhi/NCR) R Language DSA Interview Tutorial NextJS
Solution DSA in JAVA/C++ Android Tutorial Questions ML Maths NodeJs
Placement Master System Competitive Data Visualisation Bootstrap
Training Program Design Programming Tutorial Tailwind CSS
Master CP Pandas Tutorial
GeeksforGeeks NumPy Tutorial
Videos NLP Tutorial
Geeks Community Deep Learning
Tutorial

Python Computer DevOps System Design School Commerce


Tutorial Science Git High Level Design Subjects Accountancy
Python GATE CS Notes AWS Low Level Design Mathematics Business Studies
Programming Operating Systems Docker UML Diagrams Physics Economics
Examples Computer Kubernetes Interview Guide Chemistry Management
Django Tutorial Network Azure Design Patterns Biology HR Management
Python Projects Database GCP OOAD Social Science Finance
Python Tkinter Management DevOps Roadmap System Design English Grammar Income Tax
Web Scraping System Bootcamp
OpenCV Tutorial Software Interview
Python Interview Engineering Questions
Question Digital Logic
Design
Engineering Maths

UPSC Study Preparation Competitive More Tutorials Free Online Write & Earn
Material Corner Exams Software Tools Write an Article
Polity Notes Company-Wise JEE Advanced Development Typing Test Improve an Article
Geography Notes Recruitment UGC NET Software Testing Image Editor Pick Topics to
History Notes Process SSC CGL Product Code Formatters Write
Science and Resume Templates SBI PO Management Code Converters Share your
Technology Notes Aptitude SBI Clerk Project Currency Experiences
Economy Notes Preparation IBPS PO Management Converter Internships
Ethics Notes Puzzles IBPS Clerk Linux Random Number
Previous Year Company-Wise Excel Generator
Papers Preparation All Cheat Sheets Random Password
Companies Generator
Colleges

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like