Hi Liquidshokk,
To understand the conversion from CIDR to subnet mask, you need to think in binary. Here is a quick lesson on binary bits:
Each octet contains 8 bits. Each of these bits can be either 0 (off) or 1 (on). In the octet, each bit represents a specific number. Specifically, each bit is double the previous bit, as it is the next number that can not be represented with the existing bits. The bit representations are:
[tt]
[ul]
[li]00000001 = 1[/li]
[li]00000010 = 2[/li]
[li]00000100 = 4[/li]
[li]00001000 = 8[/li]
[li]00010000 = 16[/li]
[li]00100000 = 32[/li]
[li]01000000 = 64[/li]
[li]10000000 = 128[/li]
[/ul]
[/tt]
By turning these bits either off or on, they can be combined to give you the any number between 0 and 255.
Looking back at the subnet mask for the 172.16.0.0 network, 255.240.0.0, the bits look like this:
[tt]11111111 11110000 00000000 00000000[/tt]
or
[tt]NNNNNNNN NNNNHHHH HHHHHHHH HHHHHHHH[/tt]
Writing out the equation for converting the octets back to dotted decimal, it looks something like this:
[tt]
16 (NNNNNNNN NNN[/color grey]NHHHH HHHHHHHH HHHHHHHH[/color grey])
32 (NNNNNNNN NN[/color grey]NNHHHH HHHHHHHH HHHHHHHH[/color grey])
64 (NNNNNNNN N[/color grey]NNNHHHH HHHHHHHH HHHHHHHH[/color grey])
+128 (NNNNNNNN [/color grey]NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
240
[/tt]
and
[tt]
1 (NNNNNNN[/color grey]N NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
2 (NNNNNN[/color grey]NN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
4 (NNNNN[/color grey]NNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
8 (NNNN[/color grey]NNNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
16 (NNN[/color grey]NNNNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
32 (NN[/color grey]NNNNNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
64 (N[/color grey]NNNNNNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
+128 (NNNNNNNN NNNNHHHH HHHHHHHH HHHHHHHH[/color grey])
255
[/tt]
Now that we can visually see where the decimal numbers come from, we can turn out attention to figuring out the number of networks and the number of hosts. In the 172.16.0.0/12 network, we know that we have 20 bits available for the hosts because 32 (total number of bits) - 12 (number of bits for the network ID) = 20 bits. The simplest way to figure this out is to use the equation 2n-2 where n=the number of host bits. Broken down, the 2n is the same as adding up all of the numbers represented by the bits:
[tt]
1 (HHHH HHHHHHHH HHHHHHH[/color grey]H)
2 (HHHH HHHHHHHH HHHHHH[/color grey]HH[/color grey])
4 (HHHH HHHHHHHH HHHHH[/color grey]HHH[/color grey])
8 (HHHH HHHHHHHH HHHH[/color grey]HHHH[/color grey])
16 (HHHH HHHHHHHH HHH[/color grey]HHHHH[/color grey])
32 (HHHH HHHHHHHH HH[/color grey]HHHHHH[/color grey])
64 (HHHH HHHHHHHH H[/color grey]HHHHHHH[/color grey])
128 (HHHH HHHHHHHH [/color grey]HHHHHHHH[/color grey])
256 (HHHH HHHHHHH[/color grey]H HHHHHHHH[/color grey])
512 (HHHH HHHHHH[/color grey]HH HHHHHHHH[/color grey])
1024 (HHHH HHHHH[/color grey]HHH HHHHHHHH[/color grey])
2048 (HHHH HHHH[/color grey]HHHH HHHHHHHH[/color grey])
4096 (HHHH HHH[/color grey]HHHHH HHHHHHHH[/color grey])
8192 (HHHH HH[/color grey]HHHHHH HHHHHHHH[/color grey])
16384 (HHHH H[/color grey]HHHHHHH HHHHHHHH[/color grey])
32768 (HHHH [/color grey]HHHHHHHH HHHHHHHH[/color grey])
65536 (HHH[/color grey]H HHHHHHHH HHHHHHHH[/color grey])
131072 (HH[/color grey]HH HHHHHHHH HHHHHHHH[/color grey])
262144 (H[/color grey]HHH HHHHHHHH HHHHHHHH[/color grey])
+524288 (HHHH HHHHHHHH HHHHHHHH[/color grey])
1048576
[/tt]
Since we can not have a host with all bits set to 1 (broadcast) or all bits set to 0 (local), we subtract 2 from this total and we get 1048574 which is the same as 220-2. This can also work for determining the number of networks possible by using the number of bits in the network ID instead of the host ID.
So to make a long explination short, use 2n-2 to determine the total number of hosts on a network.
The number you are providing as an example, 255.244.4.10, is a little unusual, as it is using an uncommon practice called supernetting, which combines multiple seperate networks into one network. If you are SURE that this type of subnet mask was on the test, I suggest attending a class on IP addressing, as this is far to complex to teach over the Internet. (IP Subnetting/Supernetting is usually a 5 day class.)
-Brian-
Semper Paratus