Known IP address subnet mask count

The subnet mask is calculated in two ways:
  Method a: number of subnets is calculated using:
  1. First, the number of subnets conversion from decimal numbers to binary numbers;
  2. Subsequently, the number of bits of the binary number statistics obtained, provided It is N;
  3. Finally, the subnet mask to determine the IP address corresponding to the address class. Then determined host address portion of the subnet mask (i.e., "host ID") of N bits are all set to 1 before, by which means the subnet mask for the IP address subnetting.
  For example: class B IP addresses need to be divided into 28 sub 167.194.0.0:
  1) (28) = 10 (11100) 2;
  2) of the binary bits is 5, 5 = N;
  . 3) The IP address of class B addresses, the subnet mask 255.255.0.0 is class B addresses, the address and the host address after class B 2 (i.e. 0-255.1-254). So the subnet mask 255.255.0.0 host address before 5 all set 1, can be obtained 255.255.248.0, which is divided into a set of numerical class B IP addresses 167.194.0.0 netmask of the subnet 28 of .
  Method two: calculated using the number of hosts.
  1. First, the number of hosts from the decimal number into a binary number;
  2. Next, if the number of hosts is less than or equal to 254 (note: two reserved IP address should be removed), then the statistics of the number of binary numbers obtained by "1", is set to N; if the number is greater than the host 254, the N> 8, that will host addresses over 8;
  3. Finally, the use of such host address 255.255.255.255 IP addresses of all bits set to 1, and in accordance with the "back to front" in this order N bits are all set to 0, the resulting value is also desired subnet mask value.
  For example: the need to class B IP addresses 167.194.0.0 divided into several subnets, each with a host subnet 500:
  1) (500) 10 = (111 110 100) 2;
  2) of the binary digit is 9, then 9 = N;
  . 3) The address of Class B subnet mask of the host address 255. All set 255.0.0 , get 255.255.255.255. Then the forward position after 9 0, can be obtained from: 11111111 11111111.11111110.00000000 i.e., 255.255.254.0. This set of values is divided into a host station 500 subnet mask 167.194.0.0 class B IP addresses of.
----------------
Disclaimer: This article is the original article CSDN bloggers "coding1994", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/coding1994/article/details/51835691

Guess you like

Origin www.cnblogs.com/wenxin1120/p/11431532.html