IP Addresses 389
Decimal and Binary Conversion
There is usually more than one way to solve a math problem, and decimal-to-binary
conversion is no exception. This section explores one method, but feel free to use
another method if it is easier.
To convert a decimal number to binary, the idea is to first find the biggest power of 2
that “fits” into the decimal number, as shown in Table 7-1. If this process is designed
to work with computers, the most logical place to start is with the largest values that
fit into 1 or 2 bytes.
As mentioned, the most common grouping of bits is 8, which make up one byte. But
sometimes the largest value that can be held in 1 byte (255) is not large enough for the
values needed. In this situation you must combine bytes, so instead of having two 8-bit
numbers you have one 16-bit number, or instead of three 8-bit numbers you have one
24-bit number. The same rules apply as for 8-bit numbers: You multiply the previous
position value by 2 to get the present column value. Table 7-1 documents these values
(starting with a 2-byte/16-bit number), which are very important when you’re learning
the mechanics of subnetting.
Because working with computers often is referenced by bytes, it is easiest to start with
byte boundaries and calculate from there, as shown in Table 7-2. To better demonstrate,
look at the next couple of calculation examples, the first being 6,783. Because this
number is greater than 255, the largest value possible in a single byte, you use 2 bytes.
Start calculating from 2
15
. The result is that 6,783 equals 00011010 01111111.
Table 7-1 Calculating Available Host Addresses
2
15
2
14
2
13
2
12
2
11
2
10
2
9
2
8
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
32678 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
Table 7-2 Decimal-to-Binary Conversion Chart
Position Power Decimal Value Position Value Binary Count Remainder
2
15
6783 32678 0 6783
2
14
6783 16384 0 6783
2
13
6783 8192 0 6783
2
12
6783 4096 1 2687
continues
1102.book Page 389 Tuesday, May 20, 2003 2:53 PM
390 Chapter 7: TCP/IP Protocol Suite and IP Addressing
The second example is 104. Because this number is less than 255, the conversion can
be done in 1 byte, as shown in Table 7-3.
So 104 is 01101000.
2
11
2687 2048 1 639
2
10
639 1024 0 639
2
9
639 512 1 127
2
8
127 256 0 127
2
7
127 128 0 127
2
6
127 64 1 63
2
5
63 32 1 31
2
4
31 16 1 15
2
3
15 8 1 7
2
2
7413
2
1
3211
2
0
1110
Table 7-3 Converting an 8-Bit Number
Position Power Decimal Value Position Value Binary Count Remainder
2
7
104 128 0 104
2
6
104 64 1 40
2
5
40 32 1 8
2
4
81608
2
3
8810
2
2
0400
2
1
0200
2
0
0100
Table 7-2 Decimal-to-Binary Conversion Chart (Continued)
Position Power Decimal Value Position Value Binary Count Remainder
1102.book Page 390 Tuesday, May 20, 2003 2:53 PM
IP Addresses 391
This method works for any decimal number. Consider the decimal number 1,000,000.
Because 1,000,000 is greater than the largest value that can be held in 2 bytes (65535),
you need at least 3 bytes. By multiplying by 2 until you reach 24 bits (3 bytes), you get
the value 8,388,608, meaning that the largest value that 24 bits can hold is 16,777,215.
So starting at the 24 bit, follow the process until you get to 0. Continuing with the pro-
cedure, you’ll determine that the decimal number 1,000,000 equals the binary number
00001111 01000010 01000000.
Binary-to-decimal conversion is just the opposite. Simply place the binary number in
the table. If there is a 1 in a column position, add that value to the total. Table 7-4
demonstrates an example of this. It shows converting 00000100 00011101 to decimal,
resulting in 1053.
Table 7-4 Decimal-to-Binary Conversion of a 16-Bit Number
Position Power Decimal Value Position Value Binary Count Remainder
2
15
0 32678 0 0
2
14
0 16384 0 0
2
13
0 8192 0 0
2
12
0 4096 0 0
2
11
0 2048 0 0
2
10
0 1024 1 1024
2
9
1024 512 0 1024
2
8
1024 256 0 1024
2
7
1024 128 0 1024
2
6
1024 64 0 1024
2
5
1024 32 0 1024
2
4
1024 16 1 1040
2
3
1040 8 1 1048
2
2
1048 4 1 1052
2
1
1052 2 0 1052
2
0
1052 1 1 1053
1102.book Page 391 Tuesday, May 20, 2003 2:53 PM
392 Chapter 7: TCP/IP Protocol Suite and IP Addressing
IPv4 Addressing
IP forwards packets from the network on which they originate to the destination network,
as shown in Figure 7-16. This addressing scheme, therefore, must include an identifier
for both the source and destination networks. By using the destination network identifier,
IP can deliver a packet to the destination network. When the packet arrives at a router
connected to the destination network, IP must then locate the particular computer
connected to that network. This works in much the same way as the postal system.
When the mail is routed, it must first be delivered to the post office at the destination
city using the zip code, and then that post office must locate the final destination in
that city using the street address. This is a two-step process.
Figure 7-16 Communication Path
Accordingly, every IP address has two parts, as shown in Figure 7-17. One part identifies
the network to which the system is connected, and a second part identifies that particular
system on the network. This kind of address is called a hierarchical address, because it
contains different levels, as shown in Figure 7-18. As Figure 7-18 illustrates, each octet
ranges from 0 to 255. Each octet breaks down into 256 subgroups, and they break down
into another 256 subgroups with 256 addresses in each. By referring to the group
address directly above a group in the hierarchy, all the groups that branch from that
address can be referenced as a single unit. An IP address combines these two identifiers
into one number. This number must be unique, because duplicate addresses are not
allowed. The first part identifies the system’s network address. The second part, the
host part, tells which particular machine it is on that network.
1102.book Page 392 Tuesday, May 20, 2003 2:53 PM
IP Addresses 393
Figure 7-17 Network and Host Portions of the IP Address
Figure 7-18 Hierarchical IP Addresses
How does a user determine which portion of the address identifies the network and
which portion identifies the host? The answer begins with the designers of the Internet,
who thought networks would be built in different sizes, depending on the number of
computers (hosts) they contained, as shown in Table 7-5.
Table 7-5 IP Address Classes
Address Class Number of Networks Number of Hosts Per Network
A 126
*
*
The 127.x.x.x address range is reserved as a loopback address, used for testing and diagnostic
purposes.
16,777,216
B 16,384 65,535
C 2,097,152 254
D (multicast) — —
1.0.0.0 2.0.0.0 3.0.0.0 10.0.0.0 11.0.0.0 255.0.0.0
10.1.0.0 10.2.0.0 10.3.0.0
10.255.0.0
10.2.1.0 10.2.2.0 10.2.3.0 10.2.255.0
10.255.1.0 10.255.2.0 10.255.3.0 10.255.255.0
10.2.2.1 10.2.2.2 10.2.2.3
10.2.255.0 10.255.2.1 10.255.2.2 10.255.2.3 10.255.2.255
Internet Address
1102.book Page 393 Tuesday, May 20, 2003 2:53 PM
394 Chapter 7: TCP/IP Protocol Suite and IP Addressing
The assumption was that there would be a relatively small number of large networks,
possibly with millions of computers. The designers envisioned a larger number of
medium-sized networks, with perhaps thousands of computers each. Finally, they
saw a great number of networks having several hundred or fewer machines. Thus,
the designers divided the available IP addresses into classes to define the large (Class A),
medium (Class B), and small (Class C) networks, as shown in Table 7-6. Knowing the
class of an IP address is the first step in determining which part of the address identifies
the network and which part identifies the host.
IP Address Classes
To accommodate different-sized networks and to aid in classifying them, IP addresses
are divided into groupings called classes, as shown in Figure 7-19. This is called classful
addressing. Each complete 32-bit IP address is broken into a network part and a host
part. A bit or bit sequence at the start of each address determines the class of the address,
as shown in Figure 7-20. There are five IP address classes.
Figure 7-19 Network and Host Division
Table 7-6 Identifying Address Classes
Address Class High-Order Bits First Octet Address Range
Number of Bits in
the Network Address
A 0 0 to 127
*
*
127 (01111111) is a Class A address reserved for loopback testing and cannot be assigned to a
network.
8
B 10 128 to 191 16
C 110 192 to 223 24
D (Multicast 1110 224 to 239 28
1102.book Page 394 Tuesday, May 20, 2003 2:53 PM
IP Addresses 395
Figure 7-20 Address Class Prefixes
Class A Addresses
The Class A address, shown in Figure 7-21, was designed to support extremely large
networks. A Class A IP address uses only the first octet to indicate the network address.
The remaining three octets enumerate host addresses.
Figure 7-21 Class A Addresses
The first bit of a Class A address is always 0. With that first bit a 0, the lowest number
that can be represented is 00000000 (decimal 0), and the highest number that can be
represented is 01111111 (decimal 127). However, these two numbers, 0 and 127, are
reserved and cannot be used as a network address. Any address that has a value between
1 and 126 in the first octet is a Class A address.
Class B Addresses
The Class B address, shown in Figure 7-22, was designed to support the needs of
moderate- to large-sized networks. A Class B IP address uses two of the four octets
to indicate the network address. The other two octets specify host addresses.
NOTE
The 127.0.0.0 net-
work is reserved
for loopback testing
(routers or local
machines can use
this address to send
packets to themselves).
Therefore, it cannot
be assigned to a
network.
1102.book Page 395 Tuesday, May 20, 2003 2:53 PM
396 Chapter 7: TCP/IP Protocol Suite and IP Addressing
Figure 7-22 Class B Addresses
The first 2 bits of the first octet of a Class B address are always 10. The remaining 6 bits
may be populated with either 1s or 0s. Therefore, the lowest number that can be repre-
sented with a Class B address is 10000000 (decimal 128), and the highest number that
can be represented is 10111111 (decimal 191). Any address that starts with a value in
the range of 128 to 191 in the first octet is a Class B address.
Class C Addresses
The Class C address, shown in Figure 7-23, is the most commonly used of the original
address classes. This address space was intended to support a lot of small networks.
Figure 7-23 Class C Addresses
A Class C address begins with binary 110. Therefore, the lowest number that can be
represented is 11000000 (decimal 192), and the highest number that can be represented
is 11011111 (decimal 223). If an address contains a number in the range of 192 to 223
in the first octet, it is a Class C address.
Class D Addresses
The Class D address, shown in Figure 7-24, was created to enable multicasting in an
IP address. A
multicast address is a unique network address that directs packets that
have that destination address to predefined groups of IP addresses. Therefore, a single
station can simultaneously transmit a single stream of data to multiple recipients.
Figure 7-24 Class D Addresses
1102.book Page 396 Tuesday, May 20, 2003 2:53 PM
IP Addresses 397
The Class D address space, much like the other address spaces, is mathematically con-
strained. The first 4 bits of a Class D address must be 1110. Therefore, the first octet
range for Class D addresses is 11100000 to 11101111, or 224 to 239. An IP address
that starts with a value in the range of 224 to 239 in the first octet is a Class D address.
Class E Addresses
A Class E address, shown in Figure 7-25, has been defined. However, the Internet
Engineering Task Force (IETF) reserves these addresses for its own research. Therefore,
no Class E addresses have been released for use in the Internet. The first 4 bits of a
Class E address are always set to 1. Therefore, the first octet range for Class E addresses
is 11110000 to 11111111, or 240 to 255.
Figure 7-25 Class E Addresses
Table 7-7 shows the IP address range of the first octet (in decimal and binary) for each
IP address class.
Table 7-7 IP Address Classes: Range of the First Octet
IP Address Class IP Address Range (First Octet Decimal Value)
Class A 1 to 126 (00000001 to 01111110)
*
Determine the class based on the decimal value of the first octet.
*
127 (01111111) is a Class A address reserved for loopback testing and cannot be assigned to a
network.
Class B 128 to 191 (10000000 to 10111111)
Class C 192 to 223 (11000000 to 11011111)
Class D 224 to 239 (11100000 to 11101111)
Class E 240 to 255 (11110000 to 11111111)
1102.book Page 397 Tuesday, May 20, 2003 2:53 PM
398 Chapter 7: TCP/IP Protocol Suite and IP Addressing
Reserved IP Addresses
Certain addresses are reserved and cannot be assigned to devices on a network. These
reserved host addresses include the following:
■ Network addresses are used to identify the network itself (see Figure 7-26). The
upper box represents the 198.150.11.0 network. Data that is sent to any host
on that network (198.150.11.1 to 198.150.11.254) is seen outside the LAN as
198.159.11.0. The only time the host numbers matter is when the data is on the
LAN. The LAN in the lower box is treated the same as the upper LAN, except
that its network number is 198.150.12.0.
■ The broadcast address is used to broadcast packets to all the devices on a net-
work (see Figure 7-27). The upper box represents the 198.150.11.255 broadcast
address. Data that is sent to the broadcast address is read by any host on that
network (198.150.11.1 to 198.150.11.254). The LAN in the lower box is treated
the same as the upper LAN, except that its broadcast address is 198.150.12.255.
Figure 7-26 Network Address
An IP address that has binary 0s in all host bit positions is reserved for the network
address, as shown in Figure 7-28. This Class B address has all its host bits set to 0. That
is why it is identified as the network address. Therefore, as a Class A network example,
113.0.0.0 is the IP address of the network containing the host 113.1.2.3. A router uses
the network IP address when it forwards data on the Internet. As a Class B network
example, the IP address 176.10.0.0 is a network address, as shown in Figure 7-28.
1102.book Page 398 Tuesday, May 20, 2003 2:53 PM