Discrepancy when calculating hosts

Background

I'm studying subnetting and find my answer to a question does not match that of the instructor.

NOTE: This is something I have chosen to learn about myself. Not a course I am required to take.

What I've tried: searching online, contacting the site the course I'm taking is hosted on, searching for similar questions on Super User and other stack exchange sites.

Question

Given the IP address 172.20.0.0. /16 calculate a subnet mask that will accommodate 100 hosts while maximizing the number of available subnets.

My answer

Using the formula 2^n -2 and starting with a class B subnet mask of 255.255.0.0 I calculated that I need to borrow 7 bits.

Initial subnet mask: 1111 1111.1111 1111.0000 0000.0000 0000

My answer: 1111 1111.1111 1111.1111 1110.0000 0000 (255.255.254.0)

Instructor's answer

Instructor's answer: 1111 1111.1111 1111.1111 1111.1000 0000 (255.255.255.128)

I'd appreciate it if you could explain if/where I went wrong.


Solution 1:

You're right about 2^7 being the lowest power of 2 that is at least 100. You're also right about the need to use up 7 bits for the IP netmask.

The 16-bit mask in this exercise is the upper-limit, which is actually no limit, as it leaves 16 usable lower bits, while you only need 7 bits.

Since you are using 7 bits out of 32 bits, this leaves 25 bits that you don't need. The netmask is then 25 bits, which does give 1111 1111.1111 1111.1111 1111.1000 0000 (255.255.255.128).

This netmask is used for the subnets that you will be creating. As you have left 16-7=9 bits, you can create 2^9=512 different subnets, where each has the above netmask (presumably to be allocated internally to the fictional organization that was allocated the initial 16-bit netmask).

You have in your answer taken 7 bits out of the initial netmask of 16. However, this part wasn't yours to take, as you were allocated by whatever central authority/ISP only the lower 16 bits.

Solution 2:

When a question specifies a number of Hosts, without specifying the number of networks, you want to count bits from the Right to the Left (the 25-32nd bits). The goal is to establish how many bits you need for hosts, and all the remaining bits will be for networks.

If the question specifies a number of subnets without specifying anything about the number of Hosts, you count bits from the Left to the Right (the 17-24th bits).