1
votes

Suppose we have a class B network with subnet mask 255.255.240.0. How can we check what is the maximum number of hosts in this subnet? And how we can determine to which subnet host with IP address 130.50.31.6 belongs?

2

2 Answers

3
votes

Subnet masks are just some number of binary 1s to denote "this space is not available". For example, take the subnet mask:

255.255.240.0

This is actually made up of four bytes, which are separated visually by dots (what is called a "dotted quad"). So, in binary, that would be:

11111111 11111111 11110000 00000000

A "mask" defining that the first 20 bits of the address are accounted for, leaving you with 12 addressable bits. So your address space is:

00000000 00000000 00000000 00000000 -
00000000 00000000 00001111 11111111

... plus whatever your base address is. ie, in this case, 4096 unique addresses (converting from the binary 00001111 11111111)

The base address is a number whose 1 bits are contained entirely within the "mask" portion of a given IP address. That is the meaning of the "mask" part of the subnet mask: Any address within the subnet mask, binary AND'ed with the subnet mask, will give you the base address of the subnet.

So, let's take a look of the address and the mask which we have in this example:

            |   dotted quad    |             binary
------------+------------------+------------------------------------
    Address | 130. 50. 31.  6  | 10000010 00110010 00011111 00000110
Subnet Mask | 255.255.240.  0  | 11111111 11111111 11110000 00000000

Using the rule above, we can then find the base address:

   10000010 00110010 00011111 00000110
 & 11111111 11111111 11110000 00000000
---------------------------------------
   10000010 00110010 00010000 00000000

or, as a dotted quad, 130.50.16.0.

As a shorthand form of describing a subnet, rather than specifying "base address" and "subnet mask", it is often written as <base address>/<number of 1 bits in the mask>. So, the full description of the subnet which 130.50.31.6 is on, given the subnet mask of 255.255.240.0, is 130.50.16.0/20