#10 MORE ABOUT IPv4: THE NETWORKING SERIES

Sudarshan S
4 min readFeb 21, 2022

Are you online? Of course you are! And that’s how you are reading this blog right now. Would you like to know how this is possible? This series is all about what it takes to be online and access internet!

Hey peeps, in the last blog of this series, we have discussed some common things about internet protocol. Now its time to dive deeper! Here, in this blog we’ll be looking at how an IPv4 address is structured and how to identify the number of hosts and networks present using IPv4 address.

Structure of IPv4 address

The logical 32-bit IPv4 address is hierarchical and made of two parts:

  • Network part: indicates the network in which the host is located
  • Host part: identifies the host

Both parts are required in an IPv4 address. As an example, lets assume that there is a host with an IPv4 address 192.168.2.45 with a subnet mask of 255.255.255.0. The first three octets, i.e. 192.168.2, identify the network portion of the address, and the last octet, i.e. 45, identifies the host. This is known as “hierarchical addressing” because the network portion indicates the network in which each unique host is located. Routers need to know how to reach different networks, rather than knowing how to know the location of the individual host.

With IPv4, multiple logical networks can exist on one physical network. If the network portion of the logical network is different. For example: There are three hosts on a single, physical local network have the same the network portion, let’s say 192.168.8 and three other hosts have different network portion, 192.168.4. The hosts with the same network portion can communicate with each other, but cannot communicate with other hosts without the help of routing.

Local and Remote networks

There are different roles involved when you are communicating to a remote network than you communicate in the local network. In local network, the host sends an ARP request to get the destination MAC address and then send the packets with the destination MAC and source MAC address. You cannot request ARP to a host on another host.

Remote networks are networks that are other than local network.

Finding whether the Destination is Local or Remote

When an IPv4 address is configured, a subnet mask is also assigned along with the IPv4 address. Like the IPv4 address, the subnet mask is 32 bit long. This subnet mask is to signify which part of the IPv4 address is network and which part is host.

In the subnet mask, the 1’s represent the network portion; the 0’s represent the host portion. For example, let’s take an IPv4 address 192.168.2.1 with subnet mask 255.255.255.0, here in this example, the first octets are network and the last octet represents the host.

When a host sends a packet to a destination, it compares the subnet mask of its own and the subnet mask of the destination IPv4 address. If the network bits match, both the source and destination host are on the same network. If they do not match, the sending host forwards the packet to the local router interface to be sent on to the other network.

Calculation of number of hosts

The subnet mask that we use often with home and small business networking are: 255.255.255.0 (24 bits), 255.255.0.0 (16 bits), 255.0.0.0 (8 bits). A subnet mask of 255.255.255.0 uses 24 bits to identify the network number which leaves 8 bits to number of hosts on that network.

11111111.11111111.11111111.00000000
-------------------------- --------
Network number Number of hosts

Let me tell you the way that I use to calculate the number of hosts on a network. So, to calculate the number of hosts that can be on that network, take the number 2 to the power of the number of host bits (2⁸=256). From the resultant number, we must subtract 2 (256–2). The reason behind this is that all 1s within the host portion of an IPv4 address is a “broadcast address” for that network and cannot be assigned to any specific hosts. All 0s within the host portion indicate the “network ID”. By the example we saw earlier, the IPv4 address 192.168.2.255 is the broadcast address and 192.168.2.0 is the network ID.

With a 16-bit mask (255.255.0.0), there are 16-bits for host addresses and a host address could have all 1s (255) in one of the octets. This might appear to be a broadcast but as long as the other octet is not all 1s, it is a valid host address.

Remember that the host looks at all the host bits together, not at octet values.

That’s all about calculating the number of hosts in a network. I’ll catch you up in the next blog!

Stay connected!!

“Buy me a coffee” is a global platform where millions of people support creators and artists, financially.

--

--

Sudarshan S

Tech enthusiast | Developer | Machine learning | Data science | Cybersecurity