How does the computer network compute the subnet mask?

Source: Internet
Author: User

Transferred from: http://baike.baidu.com/view/65511.htm

Http://baike.baidu.com/view/878.htm

The IP address is the network number and host number to represent the host on the network, only in a network number under the computer can be "direct" interoperability, different network number of the computer through the gateway to exchange. But such a division does not seem very flexible in some cases. For this reason, the IP network is also allowed to be partitioned into smaller networks called subnets (Subnet), which creates a subnet mask. The function of the subnet mask is to determine whether any two IP addresses belong to the same subnet, when only the computer on the same subnet can be "directly" interoperable. So how do you determine the subnet mask? Referring to the IP address sub-network number and host number, to divide a network into multiple subnets, so the network number will occupy the original master, for example, for a class C address, it uses 24 bits to identify the network number, to divide it into 2 subnets will need to occupy 1 bits of the original host identity bit. At this point the network number bit becomes 25 bits, and the host label becomes 7 bits. Similarly borrowing 2 host bits can divide a class C network into 4 subnets ... How did the computer know if the network was divided into subnets? This can be seen from the subnet mask. The subnet mask is as 32bit as the IP address, and the subnet mask is determined by using "1" for all corresponding bits that identify the network number in the IP address, and the bits corresponding to the host number are "0". such as a class C IP address divided into 2 subnets with 25 bits to identify the network number, its subnet mask is: 11111111 11111111 11111111 10000000 is 255.255.255.128. So we can see that the default subnet mask for Class A addresses is the 255.0.0.0,b class of 255.255.0.0,c class 255.255.255.0.  The following table is the Class C address subnetting and related subnet masks: Number of subnet-subnet mask hosts available host number 1 255.255.255.128 128 126 2 255.255.255.192 64 62 3 255.255.255.224 32 30 4 255.255.255.240 16 14 5 255.255.255.248 8 6 6 255.255.255.252 4 2 You may notice that the above table points out the number of hosts and the number of available hosts two items, which is why. Because when all host bits of an address are "0", this address is the network address of the subnet, and is the broadcast address when all host bits are "1". We can also use a variable-length mask (VLSM), which means that a network can be configured with a different mask. This is done to make it easier to divide a network into multiple subnets. In the absence of VLSM, a network can use only one subnet mask, which limitsThe number of hosts in the given subnet number condition. For example, you are assigned a class C address that has a network number of 192.168.10.0, and you now need to divide it into three subnets, one of which has 100 hosts, and two hosts for the rest of the seven subnets. We know that a class C address has 254 available addresses, so how do you choose a subnet mask? From the table above, we find that this problem cannot be solved when we use a subnet mask in all subnets. At this point vlsm comes in handy, we can use the 255.255.255.128 mask on the subnet of 100 hosts, which can use 192.168.10.0 to 192.168.10.127 128 IP addresses, where the host number is 126. We'll take the rest of the 192.168.10.128 to 192.168.10.255. The 128 IP addresses are divided into two subnets with a subnet mask of 255.255.255.192. The address of one of the subnets is from 192.168.10.128 to 192.168.10.191, and the address of the other subnet is from 192.168.10.192 to 192.168.10.255. The subnet mask for 255.255.255.192 has 62 available host addresses for each subnet, which is required. It can be seen that the reasonable use of the subnet mask can make the IP address easier to manage and control.

、、、、、、、、、、、、、、、、、、、、、、、、、

Defining a subnet maskThe number of bits used for the subnet mask is determined by the number of possible subnets and the number of hosts per subnet. Before you define a subnet mask, you must figure out the number of subnets and hosts used. The steps to define the subnet mask are: A, determine which group addresses we use. For example, we apply for the network number "210.73.A.B", the network address is a class C IP address, the network is identified as "210.73.a", the host is identified as "B". B, depending on the number of subnets we need and the number of subnets that may be expanded in the future, define the subnet mask with some bits of the host. For example, we need 12 subnets and we may need 16 in the future. The subnet mask is determined with the first four bits of the fourth byte. The first four bits are all set to "1", that is, the fourth byte is "11110000", this number we call the new binary subnet mask for the moment. C, the corresponding initial network of the individual bits are set to "1", that is, the first three bytes are set to "1", the subnet mask of the intermittent binary form is: "11111111.11111111.11111111.11110000". D, the conversion of this number into a discontinuous decimal form: "255.255.255.240".calculation MethodBecause the number of bits in the subnet mask is determined by the number of possible subnets and the number of hosts per subnet. Before you define a subnet mask, you must figure out the number of subnets and hosts used.depending on the number of subnetsThe number of subnets is used to calculate the number of subnets that must be divided before the subnet mask is obtained, and the number of hosts required within each subnet. 1) Convert the number of subnets to binary to represent 2) obtain the number of bits of the binary, N 3) Obtain the IP address of the class subnet mask, the host address portion of the first N position 1 that is the IP address divided subnet mask. If you want to divide Class B IP address 168.195.0.0 into 27 subnets: 1) 27=11011 2) The binary is five digits, N = 5 3) The subnet mask for Class B addresses 255.255.0.0 the host address of the first 5 position 1 (the host bit of Class B addresses includes the last two bytes, So here to put the first 5 position of the third byte 1), get 255.255.248.0 that is the subnet mask of Class B IP address 168.195.0.0 divided into 27 subnets (actually zoned 32-2 = 30 subnets). This paragraph introduces the old standard calculation method, about the old standard after the introduction, in the new standard can be 27 minus 1, because the computer is calculated from 0, 0 to 27 is actually 28, so that if 27 need to be 27 minus 1.depending on the number of hostsUse the number of hosts to calculate 1) to convert the number of hosts to binary to represent 2) if the number of hosts is less than or equal to 254 (note that the reserved two IP addresses are removed), then obtain the host's bits number, N, here is definitely n<8. If it is greater than 254, then n>8, which means that the host address will occupy more than 8 bits. 3) Use 255.255.255.255来 to set the number of host address bits for that IP address to 1, and then set all n bits to 0 from the back forward, which is the subnet mask value. If you want to divide Class B IP address 168.195.0.0 into several subnets, each subnet has a host of 700 units: 1) 700=1010111100 2) The binary is 10 digits, N = 10 3) The host address of the subnet mask 255.255.0.0 of the Class B address is set to 1, Get 255.255.255.255 and then forward from the back 10 position 0, that is: 11111111.11111111.11111100.00000000 that is 255.255.252.0. This is the subnet mask that you want to divide into class B IP address 168.195.0.0, which hosts 700 units.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.