Subnet mask as the network address consists of four single-byte numbers (for the IPv4 Protocol, the IPv6 Protocol, they represent the 8 groups shestnadcatiletnih digits). For example: IP address 192.168.1.3, subnet mask 255.255.255.0. In TCP/IP networks, mask called a bitmap that specifies which portion of the network address is the network address and which the node address. For this subnet mask has to be binary. The bits whose values are set in the unit indicate the network address, and bits whose values equal to zero indicate the host address. For example, a subnet mask of 255.255.255.0. You can represent it in binary form: 11111111.11111111.11111111.00000000. Then for the address 192.168.1.1 part 192.168.142 will be the network address, and the .142 address of the node.
As you can see from the previous step, there is a limit to the number of nodes and networks. It is obtained from limitation on the number representable by the given number of bits of options. One bit can encode only 2 States: 0 and 1. 2 bits – four States: 00, 01, 10, 11. In General, n bits to encode 2^n States. Please remember that all ones and all zeros in the node address and network are reserved in the standard notation for "current node" and "all nodes". Thus, it appears that the total number of nodes in the network is determined by the formula N=(2^z)-2, where N is the total number of nodes, z is the number of zeros in the binary representation of the subnet mask.
Remember that the mask can be composed not of random numbers. The first mask bits are always isolated, the last one is zero. So sometimes you can find format addresses 192.168.1.25/11. It means that the first 11 bits of the address is a network address, the last 21 address of a node in the network. This entry corresponds to the address of 192.168.1.25 and a subnet mask of 255.224.0.0. When calculating the subnet mask should be based on the number of computers in the network. Keep in mind, and its possible extension: if the number of computers exceeds the effort for this network, you will need to manually change all the addresses and masks on each computer.
Addressing is class and classless. The division into classes was used in earlier implementations of the Protocol, and later, with the growth of the Internet, it was supplemented by classless addressing. Addressing the class divided into 5 classes: A, B, C, D, E. Class determines how many bits of the address is reserved for the network address and how many under the node address. In this case I do not have to count. In the class And the network address is allocated 7 bits in class B, 14 – bit, p – bit 21. Class D used for multicasting and class E is reserved for experimental use. The first few bits of the address are used to determine its class. In class-A this 0 in the first bit, class – 10, p – 110, D – 1110, in the class E – 11110.
Class addressing reduced flexibility of the IP Protocol in allocating addresses and reduced the number of possible. Therefore, was adopted classless. To find the mask first, determine how many nodes will you have in the network, including the gateways and other network equipment. Add to this number by two and round up to the nearest power of two. For example, you have planned 31 computer. Add to this two to get 33. The closest power of two is 64, i.e. 100 0000. Then complement all bits units. Get a mask 1111 1111 . 1111 1111 . 1111 1111 . 1100 0000, what in decimal system will be 255.255.255.192. In a network with a mask you can get 62 different IP addresses that are not reserved in the standard.
For IPv6 satisfies all of the above, given the greater length'.
On the Internet there are ready calculators to calculate masks of the networks. You can use them.