Network and Host Portion of IPv4 Address

A unique network number is necessary for each network, and each host must require a unique IP address. The IPv4 address is a 32-bit number that uniquely identifies a network number and host. We generally express an IPv4 address in dotted decimal notation as four 8-bit fields separated by periods. Each 8-bit field represents 1 byte of the IPv4 address. The binary notation is very important to understand IP addresses and their portions. The IPv4 address consists of a network portion and a host portion.

The 32-bit stream of IPv4 addresses is significant for determining the network and host portions. Within the 32-bit stream, a number of bits identify the network portion, and a number of bits identify the host portion. The bits in the network portion must be the same for all devices in the same network.

The bits within the address’s host portion must be unique to identify a specific host within a network. If two hosts have the same bit pattern in the specified network portion of the 32-bit stream, those two hosts will be located in the same network. We can identify the host and network portions of the IP address using a subnet mask. Each host in the network has three essential parameters in a network:-

Host Unique IPv4 address.

Each host required a unique IPv4 address to identify the network’s host number.

Host Default gateway

The host default gateway is used to identify the local gateway to reach other networks. Generally, the router interface IP address works as the default gateway.

Subnet Mask

A subnet mask is a 32-bit stream that defines a range of available IP addresses within a network. It is used to subdivide large networks into more minor subnetworks.  Hosts within the same subnet mask can communicate directly with each other, while systems on different subnet masks must communicate through a router. The size of a subnet depends on the requirements and the network technology employed. A point-to-point subnet allows only two devices to connect, while a data centre subnet requires more. A subnet mask is also known as an address mask.

Understanding the subnet mask is very important to find out the network portion and host portion of the IP address. The network address represents all the devices on the same network. The figure below illustrates the dotted decimal address with a subnet mask. The network bits in the subnet mask must be 1s, and the host bits in the subnet mask must be 0s.

Network and Host Portion with Subnet Mask

The figure below illustrates the network and host portion, including the subnet mask. It is a sequence of 1 bits followed by 0 bits. It identifies the network and host portions of an IPv4 address uniquely. We can compare the subnet mask to the IPv4 address bit, from left to right, as shown in the figure. The 1s in the subnet mask identify the network portion, while the 0s in the subnet mask identify the host portion.  ANDing is the process that determines the network portion and host portion.

Host Portion

ANDing

When a source host attempts to communicate with a destination host, it uses its subnet mask to determine whether the destination host is on the local network or a remote network. Before creating an IPv4 packet, the destination network address must be extracted from the destination address. This is done using logic called ANDing.

ANDing is the essential binary operation used to determine the network address. Two other processes are also used in data networking but not for determining IP addresses. The other two are OR and NOT operation. The IPv4 address is logically ANDed with its subnet mask to determine the associated network address. When ANDing between the address and the subnet mask is performed, the result gives the network address.

AND Operation

The source and destination IP addresses are compared to the source’s subnet mask by applying the ANDing process. An AND result is created for both source and destination addresses. The hosts are on the same network if the result is the same. The destination host is on a remote network if the result is different. All traffic destined for that remote host should be directed to the default gateway. The logical AND operation of two bits gives the following result.

1 AND 1 = 1

1 AND 0 = 0

0 AND 1 = 0

0 AND 0 = 0

So, to identify the network address of an IPv4 host, the IPv4 address is logically ANDed, bit by bit, with the subnet mask. ANDing between the address and the subnet mask produces the network address. So anything ANDed with a 0 produces a 0.

As we learned previously, all bits of the subnet mask that represent the host are 0s, so the host portion of the resultant network becomes all 0s. Remember that all 0s in the host portion of an IPv4 address mean that this is the network address. As we know, all bits of the subnet mask in the network portion are all 1s. When each of these 1s is ANDed with a parallel bit of the address, the resulting bits are identical to the original address bits.

Example 1: Find out the network ID for the following IP address.