Computers, especially routers, do not think about IP addresses in terms of the conventions shown in Table 12-2. They think in terms of 32-bit binary numbers, which is fine because, technically, that's what IP addresses really are. Also, computers use a mask to define the structure of these binary IP addresses. A full understanding of what that means is not too difficult. However, getting accustomed to doing the binary math in your head is challenging for most of us, particularly if you don't do it every day.

In this section, you will read about two key math operations that will be used throughout the discussion of answering CCNA addressing and subnetting questions. One operation converts IP addresses from decimal to binary and then back to decimal. The other operation performs a binary math operation called a Boolean AND.

Converting IP Addresses from Decimal to Binary, and Back Again

If you already know how binary works, how binary-to-decimal and decimal-to-binary conversion works, and how to convert IP addresses from decimal to binary and back, skip to the next section, "The Boolean AND Operation."

IP addresses are 32-bit binary numbers, written as a series of decimal numbers, separated by periods. To examine an address in its true form, binary, you need to convert from decimal to binary. To put a 32-bit binary number in the decimal form that is needed when configuring a router, you need to convert the 32-bit number back to decimal, 8 bits at a time.

One key to the conversion process for IP addresses is remembering these facts:

When converting from one format to the other, each decimal number represents 8 bits.

When converting from decimal to binary, each decimal number converts to an 8-bit number.

When converting from binary to decimal, each set of 8 consecutive bits converts to one decimal number.

Consider the conversion of IP address 150.150.2.1 to binary for a moment. The number 150, when converted to its 8-bit binary equivalent, is 10010110. How do you know that? For now, look in the conversion chart in Appendix B, "Binary to Decimal Conversion Chart. The next byte, another decimal 150, is converted to 10010110. The third byte, decimal 2, is converted to 00000010; finally, the fourth byte, decimal 1, is converted to 00000001. The combined series of 8-bit numbers is the 32-bit IP address—in this case, 10010110 10010110 00000010 00000001.

If you start with the binary version of the IP address, you first separate it into four sets of eight digits. Then you convert each set of eight binary digits to its decimal equivalent. For example, writing an IP address as follows is correct but not very useful:

10010110100101100000001000000001

To convert this number to a more conveneint decimal form, first separate it into four sets of eight digits:

Then look in the conversion chart in Appendix B and find that the first 8-bit number converts to 150, and so does the second set. The third set of 8 bits converts to 2, and the fourth converts to 1—giving you 150.150.2.1.

Using the chart in Appendix B makes this much easier—but you will not have the chart on the exam, of course! So you can do a couple of things. First, you can learn how to do the conversion. The book does not cover it, but a couple of web sites referenced at the end of this section can help. The other alternative is to use the chart when studying, and study the examples that show you how to manipulate IP addresses and find the right answers to the test questions without doing any binary math. If that works for you, you actually do not need to be speedy and proficient at doing binary-to-decimal and decimal-to-binary conversions.

One last important fact: When subnetting, the subnet and host parts of the address might span only part of a byte of the IP address. But when converting from binary to decimal and decimal to binary, the rule of always converting an 8-bit binary number to a decimal number is always true. However, when thinking about subnetting, you will need to ignore byte boundaries and think about IP addresses as 32-bit numbers without specific byte boundaries. But that is explained more later in the section titled "Finding the Subnet Number."

Interestingly, you should actually be prepared to do basic binary, decimal, and hexadecimal conversions if taking the INTRO exam. While the shortcuts that can help you perform subnetting quickly are still very valuable, make sure you can convert numbers between all three types. Some sites that might help you if you want more information are as follows:

■ For basic information on base 10, base 2 (binary), and conversion practice, visit www.ibilce.unesp.br/courseware/datas/numbers.htm#mark2.

■ For a description of the conversion process, try doit.ort.org/course/inforep/135.htm.

■ For another description of the conversion process, try www.goshen.edu/compsci/ mis200/decbinary.htm.

■ For some free video classes that cover binary, conversion, and subnetting, go to www.learntosubnet.com.

George Boole, a mathemetician who lived in the 1800s, created a branch of mathematics that came to be called Boolean math, after the name of its creator. Boolean math has many applications in computing theory. In fact, you can find subnet numbers, given an IP address and subnet mask, but using a Boolean AND.

A Boolean AND is a math operation performed to a pair of one-digit binary numbers. The result is another one-digit binary number. The actual math is even simpler than those first two sentences! The following list shows the four possible inputs to a Boolean AND and the result:

In other words, the input to the equation consists of two one-digit binary numbers, and the output of the equation is one single-digit binary number. The only time the result is a binary 1 is when both input numbers are also binary 1; otherwise, the result of a Boolean AND is a 0.

You can perform a Boolean AND on longer binary numbers, but you are really just performing an AND on each pair of numbers. For instance, if you wanted to AND together two four-digit numbers 0110 and 0011, then you would perform an AND of the first digit of each number and write down the answer. Then you would perform an AND on the second digit of each number, and so on, through the four digits. Table 12-4 shows the general idea.

Four-Digit |
First |
Second |
Third |
Fourth | |

Binary |
Digit |
Digit |
Digit |
Digit | |

First number |
0110 |
0 |
1 |
1 |
0 |

Second number |
0011 |
0 |
0 |
1 |
1 |

Boolean AND result |
0010 |
0 |
0 |
1 |
0 |

The table separates the four digits of each original number to make the point more obvious. Look at the column holding the first digit's values. The first digit of the first number is 0, and the first digit of the second number is also 0. 0 AND 0 yields a binary 0, which is listed as the Boolean AND result in that same column. Similarly, the second digits of the two original numbers are 1 and 0, respectively, so the Boolean AND result in the second digit column shows a 0. For the third digit, the two original numbers' third digits were 1 and 1, so the AND result this time shows a binary 1. Finally, the fourth digits of the two original numbers were 0 and 1, so the Boolean AND result is 0 for that column in the table.

When you Boolean AND two longer binary numbers together, you actually perform what is called a bitwise Boolean AND. This term simply means that you do what the previous example showed: You AND together the first digits from each of the two original numbers, then the second digits, and then the third, and so on, until the each pair of single-digit binary numbers has been ANDed.

IP subnetting math frequently uses a Boolean AND between two 32-bit binary numbers. The actual operation works just like the example in Table 12-4, except that it is longer.

To discover the subnet number in which a particular IP address resides, you perform a bitwise AND between the IP address and the subnet mask. Humans sometimes can look at an IP address and mask in decimal and derive the subnet number, but routers and other computers use a Boolean AND between the IP address and the subnet mask to find the subnet number, so you should understand the process. In this chapter, you also will read about a process by which you can find the subnet number without using any binary conversion or Boolean ANDs.

An example of the derivation of a subnet number is shown in Table 12-5.

NOTE Appendix B has a binary-to-decimal conversion chart.

Decimal |
Binary | |

Address |
150.150.2.1 |
1001 0110 1001 0110 0000 0010 0000 0001 |

Mask |
255.255.255.0 |
1111 1111 1111 1111 1111 1111 0000 0000 |

Result of AND |
150.150.2.0 |
1001 0110 1001 0110 0000 0010 0000 0000 |

First, focus only on the third column of the table. The binary version of the IP address 150.150.2.1 is listed first. The next row shows the 32-binary version of the subnet mask (255.255.255.0). The last row shows the results of a bitwise AND of the two numbers—in other words, the first bit in each number is ANDed, then the second bit in each number, then the third pair, and so on, until all 32 bits in the first number have been ANDed with the bit in the same position in the second number.

The resulting 32-bit number is the subnet number in which 150.150.2.1 resides. All you have to do is convert the 32-bit number back to decimal, 8 bits at a time. So, the subnet number in this case is 150.150.2.0.

If you understand the basic idea but would like additional examples to make it more clear, read on. In the next section, you will use Boolean ANDs to answer basic questions about IP subnetting. Also, on the CD, look for the chapter titled "Subnetting Practice: 25 Subnetting Questions," where 25 IP addressing practice questions are available, each with the binary math worked out for performing the Boolean AND.

Prefix Notation

Finally, any Cisco-oriented IP addressing coverage would be incomplete without a discussion of prefix notation.

In this chapter, you will get more comfortable using subnet masks. The masks can be written in decimal form, or they can be written as a 32-bit binary number. However, there is a third alternative, called prefix notation, which allows a router to display mask information more succinctly.

To understand prefix notation, it is important to know that all subnet masks have some number of consecutive binary 1s, followed by binary 0s. In other words, a subnet mask cannot have 1s and 0s interspersed throughout the mask—the mask always has some number of binary 1s, followed only by binary 0s.

Prefix notation simply denotes the number of binary 1s in a mask, preceded by a /. In other words, for subnet mask 255.255.255.0, whose binary equivalent is 11111111 11111111 11111111 00000000, the equivalent prefix notation would be /24 because there are 24 consecutive binary 1s in the mask. When talking about subnets, you can say things like "That subnet uses a slash 24 prefix" or "That subnet has a 24-bit prefix" instead of saying something like "That subnet uses a mask of 255.255.255.0."

Prefix notation makes talking about subnet masks a little easier, and it makes the information displayed by the router a little briefer as well. For instance, just try saying "255.255.255.0" out loud a few times, and imagine that the network is down while you're saying it, and you will hear the benefit.

Now that the basic math tools have been covered, the specifics on how to use them to find the right answers to subnetting questions are covered next.

Was this article helpful?

## Post a comment