So far, we've learned about network IDs, which are used to identify networks and host IDs, which are used to identify individual hosts. If we want to split things up even further and we do, we'll need to introduce a third concept, the subnet ID. You might remember that an IP address is just a 32-bit number. In a world without subnets, a certain number of these bits are used for the network ID and a certain number of the bits are used for the host ID. In a world with subnetting, some bits that would normally comprise the host ID are actually used for the subnet ID. With all three of these IDs representable by a single IP address, we now have a single 32-bit number that can be accurately delivered across many different networks. At the Internet level, core routers only care about the network ID and use this to send the datagram along to the appropriate gateway router to that network. That gateway router then has some additional information that it can use to send the datagram along to the destination machine or the next router in the path to get there. Finally, the host ID is used by that last router to deliver the datagram to the intended recipient machine. Subnet IDs are calculated via what's known as a subnet mask. Just like an IP address, subnet masks are 32-bit numbers that are normally written out as four octets in decimal. The easiest way to understand how subnet masks work is to compare one to an IP address. Subnet masks are often glossed over as magic numbers. People just memorize some of the common ones without fully understanding what's going on behind the scenes. In this course, we're really trying to ensure that you leave with a well-rounded networking education. Even though subnet masks can seem tricky at first, stick with it and you'll get the hang of it in no time. Let's work with the IP address 9.100.100.100 again. You might remember that each part of an IP address is an octet, which means that it consists of eight bits. The Number 9 in binary is just 1001. But since each octet needs eight bits, we need to pad it with some zeros in front. As far as an IP address is concerned, having a Number 9 as the first octet is actually represented as 0000 1001. Similarly, the numeral 100 as an eight-bit number is 0110 0100. The entire binary representation of the IP address 9.100.100.100 is a lot of ones and zeros. A subnet mask is a binary number that has two sections. The beginning part, which is the mask itself, is a string of ones. Just zeros come after this. The subnet mask, which is the part of the number with all the ones, tells us what we can ignore when computing a host ID. The part with all the zeros tells us what to keep. Let's use the common subnet mask of 255.255.255.0. This would translate to 24 ones followed by eight zeros. The purpose of the mask or the part that's all ones, is to tell a router what part of an IP address is the subnet ID. You might remember that we already know how to get the network ID for an IP address. For 9.100.100.100 a class A network. We know that this is just the first octet. This leaves us with the last three octets. Let's take those remaining octets and imagine them next to the subnet mask in binary form. The numbers in the remaining octets that have a corresponding one in the subnet mask are the subnet ID. The numbers in the remaining octets that have a corresponding zero are the host ID. The size of a subnet is entirely defined by its subnet mask. For example, with a subnet mask of 2550255.255.0, we know that only the last octet is available for host IDs regardless of what size the network and subnet IDs are. A single eight-bit number can represent 256 different numbers, or more specifically, the numbers 0-255. This is a good time to point out that in general, a subnet can usually only contain two less than the total number of host IDs available. Again, using a subnet mask of 255.255.255.0, we know that the octet available for host IDs can contain the numbers 0-255, but zero is generally not used, and 255 is normally reserved as a broadcast address for the subnet. This means that really only the numbers 1-254 are available for assignment to a host. While this total number less than two approach is almost always true. Generally speaking, you'll refer to the number of hosts available in a subnet as the entire number. Even if it's understood that two addresses aren't available for assignment, you'd still say that eight-bits of host ID space have 256 addresses available, not 254. This is because those other IPs are still IP addresses, even if they aren't assigned directly to a node on that subnet. Now, let's look at a subnet mask that doesn't draw its boundaries at an entire octet or eight-bits of address. The subnet mask 255.255.255.224 would translate to 27 ones followed by five zeros. This means that we have five bits of host ID space or a total of 32 addresses. This brings up a shorthand way of writing subnet masks. Let's say we're dealing with our old friend, 9.100.100.100 with a subnet mask of 255.255.255.224. Since that subnet mask represents 27 ones followed by five zeros, a quicker way of referencing this is with the notation /27. The entire IP and subnet mask could be written out as 9.100.100.100/27. Neither notation is necessarily more common than the other, so it's important to understand both.