Unique network number is necessary for each network and also each host on the network must require a unique IP address. The IPv4 address is a 32-bit number that uniquely identifies a network number as well as host in the network. We generally express an IPv4 address in doted 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 address and its portions. The IPv4 address consisting of a network portion and a host portion.
For determining the network portion and the host portion, the 32-bit stream of IPv4 address is very important. Within the 32-bit stream, a number of the bits identify the network portion, and also numbers of the bits identify the host portion.The bits in the network portion must same for all devices that exist in the same network.
The bits within the host portion of the address must 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 portion and network portion of the IP address using a subnet mask. Each host in the network are three important parameters in a network:-
Host Unique IPv4 address
Each host required unique IPv4 address for identifying the host number on the network.
Host Default gateway
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 smaller subnet works. Hosts within the same subnet mask can communicate directly with each other, while systems on different subnet mask 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 center subnet require more devices to connect. A subnet mask is also known as an address mask.
The subnet mask understanding 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. Figure below illustrates the dotted decimal address with subnet mask. The network bits in subnet mask must be 1s and the host bits in subnet mask must be 0s.
Netowork and Host Portion with Subnet Mask
The figure below illustrates the network and host portion including subnet mask. It is a sequence of 1 bits followed by a sequence of 0 bits. It identify 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 identifies the network portion while the 0s in the subnet mask identify the host portion. The ANDing is the process which identifies the network portion and host portion.
When 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 by a logic called ANDing.
ANDing is the basic binary operation to determine network address. There is two other processes that is also used in data networking but not used for determining IP address. 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 performed, the result gives the network address.
The source and destination IP addresses are compared to the source’s subnet mask applying the ANDing process. An AND result is created for both source and destination addresses. If the result is the same, the hosts are on the same network. If the result is different, the destination host is on a remote network. 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 produce the network address. So anything ANDed with a 0 produces a 0.
As we learn previously that all bits of the subnet mask that represent host are 0s, the host portion of the resultant network becomes all 0s. Remember that all 0 in the host portion of IPv4 address mean that this is the network address. As we know that all bits of subnet mask in network portion are all 1s. When each of these 1s ANDed with a parallel bit of the address, the resulting bits are identical to the original address bits.
Example 1: Find out what the network ID for the following IP address.