Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cisco Press CCNA ICND 2004 - Cisco Press.pdf
Скачиваний:
122
Добавлен:
24.05.2014
Размер:
13.19 Mб
Скачать

Analyzing and Interpreting IP Addresses and Subnets 107

example, someone with a problem might call and tell you his IP address. After finding out the mask that’s used, you enter the show ip route command on the router. That command typically lists subnets, so you need to be able to easily figure out the subnet of which the address is a member. And not all networks use nice, easy subnet masks.

No matter how useful this book might be toward helping you with a real networking job, its primary goal is to help you pass the exam. Therefore, the rest of this chapter is geared toward helping you understand how to interpret and analyze IP addresses.

Math Operations Used to Answer Subnetting Questions

Computers, especially routers, do not think about IP addresses in terms of the conventions shown in Table 4-2. They think in terms of 32-bit binary numbers. This is fine, because technically that’s what IP addresses are. Also, computers use a mask to define the structure of these binary IP addresses. A full understanding of what this means is not too difficult. However, getting accustomed to doing the binary math in your head can be challenging, 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 work, 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 you convert from one format to the other, each decimal number represents 8 bits.

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

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

108 Chapter 4: IP Addressing and Subnetting

Consider the conversion of IP address 150.150.2.1 to binary. The number 150, when converted to its 8-bit binary equivalent, is 10010110. How do you know that? For now, look at 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-convenient decimal form, first separate it into four sets of eight digits:

10010110 10010110 00000010 00000001

Then look in the conversion chart in Appendix B. You see that the first 8-bit number converts to 150, and so does the second. 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 at 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 the websites 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 do not need to be speedy and proficient at doing binary-to-decimal and decimal-to-binary conversions.

One last important fact: With subnetting, the subnet and host parts of the address might span only part of a byte of the IP address. But when you convert 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 need to ignore byte boundaries and think of IP addresses as 32-bit numbers without specific byte boundaries. This is explained more in the section “Finding the Subnet Number.”

Here are some websites that might help you if you want more information:

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.

Analyzing and Interpreting IP Addresses and Subnets 109

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.

The Boolean AND Operation

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

A Boolean AND is a math operation performed on 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:

0 AND 0 yields a 0

0 AND 1 yields a 0

1 AND 0 yields a 0

1 AND 1 yields a 1

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, you would perform an AND on 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 4-4 shows the general idea.

Table 4-4 Bitwise Boolean AND Between Two Four-Digit Numbers

 

Four-Digit

 

 

 

 

 

Binary

First

Second

Third

Fourth

 

Number

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

 

 

 

 

 

 

110 Chapter 4: IP Addressing and Subnetting

This table separates the four digits of each original number to make the point more obvious. Look at the “First Digit” column. 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 are 1 and 1, so the AND result this time shows a binary 1. Finally, the fourth digits of the two original numbers are 0 and 1, so the Boolean AND result is 0 for that column.

When you Boolean AND together two longer binary numbers, you perform what is called a bitwise Boolean AND. This term simply means that you do what the previous example shows: You AND together the first digits from each of the two original numbers, and then the second digits, and then the third, and so on, until 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 4-4, except 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. Although humans can sometimes look at an IP address and mask in decimal and derive the subnet number, routers and other computers use a Boolean AND between the IP address and the subnet mask to find the subnet number, so you need to understand this process. In this chapter, you will also read about a process by which you can find the subnet number without using binary conversion or Boolean ANDs.

Table 4-5 shows an example of the derivation of a subnet number.

Table 4-5 Bitwise Boolean AND Example

 

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-bit 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, and then the second bit in each number, and then the third, 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.