April 19, 2024

What is a subnet mask?

What is a network? 

A network is 2, or more devices (computers, IoT, mobiles, etc.) connected to each other for the purpose of exchanging data electronically. 

What is a subnet mask? 

The subnet mask is a separator that defines which part of the IP address is dedicated to the hosts (connected devices) and which part is dedicated to the network address. The subnet mask gives us the size of the network that we are working with. 

Let’s see an example of a subnet mask: 

255.255.255.0 (/24)

In this case, we have 24 bits that are dedicated for the network (the first 3 groups) and 8 bits for the hosts. That provides 254 IPs for hosts. The first and the last IP are reserved (one is the network ID, and the other is the Broadcast).  

When we are looking at an IP address of a device on our network, we can see two parts: One part shows the client’s address and the second one is for the network address. The IP address that we get on the connected devices can be either manually assigned by a network administrator or automatically with an automatic IP assignment method like the DHCP. 

So subnets are 32-bit, just like IPv4 address. When we are talking about a network like our example, we have:

11111111 (Network).11111111 (Network).11111111 (Network).00000000 (Hosts). This is /24. 

Let’s see a few more examples:

/8 =11111111.00000000.00000000.00000000 = 255.0.0.0

/16 =11111111.11111111.00000000.00000000 = 255.255.0.0

/5 =11111111.00000000.00000000.00000000 = 248.0.0.0

/20 =11111111.00000000.00000000.00000000 = 255.255.240.0

IP Address Classes and Subnet Masks

There are 5 IP address classes, depending on the size of the network. The first 3 classes – A, B, and C IP address classes are broadly available for use, without any restrictions, while the D class network is dedicated to multicasting, and the E class is dedicated to the Internet Engineering Task Force. 

Class A

Class A has the following look 255.0.0.0. The first part (255) is dedicated to the network, and the rest of the part is dedicated to clients (hosts). Class A has the possibility to have 16,777,216 hosts, which makes it the class with the biggest possibility to connect devices. It also permits 128 networks.

Class B

Class B has the following look 255.255.0.0. Two octets are dedicated to the network and the other 2 for hosts. This class has the possibility to connect 65,536 hosts per network and a total of 16384 networks. 

Class C

Class C has the following look 255.255.255.0. Tree octets are dedicated to the network and the other one for hosts. This class has the possibility to connect 256 hosts per network and a total of 2,097,152 networks. 

How do computers communicate locally and remotely? 

In our example, we have 2 computers – computer 1 and computer 2 connected to a LAN network. We also have computer 3 that is located remotely. 

We assume that all of the devices are well-configured. 

The devices on the same network (same subnet mask) can communicate with each other easier through the LAN, while if one device is on one network and the other is on another, they will need a gateway for connecting. The devices understand which other devices are connected to the same network thanks to the subnet mask. 

When computer 1 wants to communicate with computer 2, it will use ARP (address resolution protocol) to ask for the MAC address of computer 2. When it gets it, it can communicate to it through a switch. 

When computer 1 wants to connect to computer 3, we have a situation when the two computers are on other networks. Computer 1 will ask for the MAC, but this time there is a need for a gateway device (router) to connect to a remote computer. 

Leave a Reply

Your email address will not be published. Required fields are marked *