Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Calculation of network number and host number

Shulou Source: shulou.com Published: 2022-06-01 02:11:33 10月01日 Update

The IP address currently used consists of 4 bytes (32), that is, IPV4 encoding. Each IP address packet has two parts: the network number and the host number. The more binary bits assigned to the host number, the more hosts can be identified, the fewer networks can be identified, and vice versa.

IP addresses are divided into five categories, Class An is reserved for government agencies, Class B is assigned to medium-sized companies, Class C is assigned to anyone who needs it, Class D is used for multicast, Class E is used for experiments, and the number of addresses that can be accommodated is different.

The characteristics of class A, B and C IP addresses: when the IP address is written in binary form, the first two bits of the class An address are always O, the first two bits of the class B address are always 10, and the first three bits of the class C address are always 110.

Given an IP address, we can use the subnet mask to determine the network number and host number of the IP address.

The function of the subnet mask is to divide an IP address into two parts: the network address and the host address. For example

There is a Class C address: 192.9.200.13 whose default subnet mask is 255.255.255.0.

Then its network number and host number can be obtained as follows: the ① IP address 192.9.200.13 is converted into binary 11000000 00001001 11001000 00001101 ② subnet mask 255.255.255.0 into binary 111111111111111111111111111111111100000000 ③ the result obtained after two binary number logic and (AND) operation is the network part.

11000000 00001001 11001000 00001101 AND 11111111111111111111111100000000

11000000 00001001 11001000 00000000 = 192. 9. 200. 0 means the network number is 192.9.200.0

After ④ inverts the subnet mask and AND the IP address, the result is the host part.

11000000 00001001 11001000 00001101 AND 00000000 00000000 11111111

00000000 00000000 00000000 00001101 = 0. 0. 0. 13 means the host number is 13 (or 0.0.0.13).

Tags: Address host network host number binary subnet part assignment identity result logic more different two function company and vice versa can pass byte that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei Linux MariaDB Apple