TCP/IPv4 Subnetting

0 Comments

The purpose of this article is to find out various subnet parameters from a given IP Address and its corresponding mask. This is one of a few available methods that can be used to achieve this.

This tutorial considers having basic knowledge of networking and understanding basic networking terminology.

We will be trying to find:

Network Address (ID)“NID”
Broadcast Address (ID)“BID”
Next Subnet“NsubN”
First Host IP“FHIP”
Last Host IP“LHIP”
IP Host Range“IPHR”
Number of Hosts“N°H”
Number of Subnets“N°subN”

Let’s take the following IP Address as an Example 1:

185.195.201.101 / 23

Firstly, let us break this IP Address into Binary

11111111.11111111.11111110.00000000

As we know the CIDR value of /23 tells us where the Mask Identifier ends and host identifier begins. In this case on the 23rd position. This position falls onto the 3rd Octet. Let us also mark any octet where this boundary falls into with a sign ‘|’ e.g NID(|). I will be using this to make clear which octet of the address is being meant.

Let us convert the Binary into Decimals. But let us first take a look at the Decimal value of each “Octet”

11111111
1286432168421

As we can see it all sums up to 255. Let us now translate the above Mask into Decimals

11111111.11111111.11111110.00000000
2552552540

As it can be seen our Netmask is 255.255.254.0 for the above IP Address.

The IP Address belongs also to a Class B Subnet

Network ID & Broadcast ID

Let us now try to determine the Network ID and Broadcast ID.

In order to achieve this we are going to concentrate on the 3rd Octet (because the division of Mask and Host modifier lies there).

2. Binary value of the 3rd. Octet of the IP Address11001001
1. Binary Value of the 3rd. Octet of the Mask11111110
3. Logical Conjunction of both (like a multiplier)11001000

As we can see our logical conjunction is 11001000. Translating this into the Decimal value using the decimal chart above we get: 128 + 64 + 8 = 200

This Number is our Network Address (ID) value. Therefore our network ID is:

185.195.200.0

Having our network ID we can easily find out the Broadcast ID. Here we need to look at the 3rd octet of the Mask again and convert the last positive digit of the binary into a decimal value (it is the 7th digit marked orange). I will call this LastPositiveDigitDecimalValue (LPDDV)

11111110 --> 2

Now we can find out the Broadcast ID with this small equation

NID + (LPDDV-1) = 200 + (2-1) = 201

Our Broadcast Address (ID) is:

185.195.201.255

In order to get out next Subnet Address we just leave the -1 out of the equation above.

NID + LPDDV = 200 + 2 = 202

Out next Subnet begins at:

185.195.202.0

From here it will be very easy to calculate all the remaining parameters. Let’s integrate all into a single table and use the formulae in the second column :

NID185.195.200.0
BID185.195.201.255NID(|) + (LPDDV-1)
NsubN185.195.202.0NID(|) + LPDDV
FHID185.195.200.1NID(4) + 1
LHID185.195.201.254BID(4) – 1
IPHR185.195.200.1 – 185.195.201.254
N°H256 * ((201-200)+1)-2=
=2^(32-23)-2 = 2^9-2=510
256 * ((BID(|)-NID(|))+1)-2
or
2^(32-CIDR) – 2
N°subN256 / (201-200+1)=128256 / (BID(|)-NID(|)+1)
Formulae

Example 2

Let us have a look at another example without the explanation

185.120.120.29 / 21
11111111.11111111.11111000.00000000
11111111.11111111.11111000.00000000
2552552480
Binary value of the 3rd. Octet of the IP Address01111000
Binary Value of the 3rd. Octet of the Mask11111000
Multiplier of both01111000
11111111
1286432168421
NID185.120.120.0
BID185.120.127.255NID(|) + (LPDDV-1)
NsubN185.120.128.0NID(|) + LPDDV
FHID185.120.120.1NID(4) + 1
LHID185.120.127.254BID(4) – 1
IPHR185.195.200.1 – 185.195.201.254
N°H256*((127-120)+1)-2=
=2^(32-21)-2=2046
256 * ((BID(|)-NID(|))+1)-2
or
2^(32-CIDR) – 2
N°subN256 /((127-120)+1)=32256 / (BID(|)-NID(|)+1)
Formulae

Should you have any question post a comment or send me a direct message.

Categories:

Leave a Reply

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