Math operations
Computers, do not think about IP
addresses in terms of the decimal conventions. 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.
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.
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.
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
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.
0 1 1 0
AND
0 0 1 1
--------
0 0 1 0
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 next example:
Decimal
|
Binary
|
|
Address
|
150.150.2.1
|
10010110 10010110 00000010
00000001
|
Mask
|
255.255.255.0
|
11111111 11111111 11111111
00000000
|
Result of AND
Network Address |
150.150.2.0
|
10010110 10010110 00000010
00000000
|
Any Cisco-oriented IP addressing
coverage would be incomplete without a discussion of prefix notation. 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 is /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.”
You have already learned that Class
A, B, and C networks have 8, 16, or 24 bits in their network fields,
respectively. Those rules do not change. You’ve also read that, without
subnetting, Class A, B, and C addresses have 24, 16, or 8 bits in their host
fields, respectively. With subnetting, the network part of the address does not
shrink or change, but the host field shrinks to make room for the subnet field.
So the key to answering these types of questions is to figure out how many host
bits remain after subnetting. Then you can tell the size of the subnet field.
The rest of the answers follow from those two facts.
The following facts tell you how to
find the sizes of the network, subnet, and host parts of an IP address:
- The network part of the address is always defined by class rules.
- The host part of the address is always defined by the mask. Binary 0s in the mask mean that the corresponding address bits are part of the host field.
- The subnet part of the address is what’s left over in the 32-bit address.
The following table lists the only
valid decimal values in a mask and their binary equivalents. Memorizing these
values will help you convert masks between their decimal and binary forms more
quickly on the exam.
Decimal
|
Binary
|
0
|
0000 0000
|
128
|
1000 0000
|
192
|
1100 0000
|
224
|
1110 0000
|
240
|
1111 0000
|
248
|
1111 1000
|
252
|
1111 1100
|
254
|
1111 1110
|
255
|
1111 1111
|
No comments:
Post a Comment