Internet Protocol (IP)
The IP protocol provides a hierarchical, hardware-independent addressing system and offers the services necessary for delivering data on a complex, routed network. Each network adapter on a TCP/IP network has a unique IP address.
By the Way
Descriptions of TCP/IP often talk about a computer having an IP address. A computer is sometimes said to have an IP address because most computers have only one network adapter. However, computers with multiple network adapters are also common. A computer that is acting as a router or a proxy server, for instance, must have more than one network adapter and therefore has more than one IP address. The term host is often used for a network device associated with an IP address.
Under many operating systems, it is also possible to assign more than one IP address to a single network adapter.
IP addresses on the network are organized so that you can tell the location of the host—the network or subnet where the host resides—by looking at the address (see Figure 4.2). In other words, part of the address is a little like a ZIP Code (describing a general location), and part of the address is a little like the street address (describing an exact location within that general area).
It is easy for a person to look at Figure 4.2 and say, "Every address that starts with 192.132.134 must be in Building C." A computer, though, requires a bit more hand-holding. The IP address is therefore divided into two parts:
The owners of a network can also impose an additional hierarchical level by assigning a subnet ID. You'll learn more about subnets and subnet IDs in Hour 5, "Subnetting."
By the Way
Study this hour and Hour 5 together. Until you learn about subnet IDs, you haven't really mastered the art of IP addressing.
IP Header Fields
Every IP datagram begins with an IP header. The TCP/IP software on the source computer constructs the IP header. The TCP/IP software at the destination uses the information enclosed in the IP header to process the datagram. The IP header contains a great deal of information, including the IP addresses of the source and destination computers, the length of the datagram, the IP version number, and special instructions to routers.
By the Way
For additional information about IP headers, see RFC 791.
The minimum size for an IP header is 20 bytes. Figure 4.3 shows the contents on the IP header.
The header fields in Figure 4.3 are as follows:
A hop or a router hop correlates to a router that a datagram travels through on its way to its destination. If a datagram passes through five routers before arriving at its destination, the destination is said to be five hops, or five router hops, away.
An IP address is a 32-bit binary address. This 32-bit address is subdivided into four 8-bit segments called octets. Humans do not work well with 32-bit binary addresses or even 8-bit binary octets, so the IP address is almost always expressed in what is called dotted decimal format. In dotted decimal format, each octet is given as an equivalent decimal number. The four decimal values (4 x 8 = 32 bits) are then separated with periods. Eight binary bits can represent any whole number from 0 to 255, so the segments of a dotted decimal address are decimal numbers from 0 to 255. You have probably seen examples of dotted decimal IP addresses on your computer, in this book, or in other TCP/IP documents. A dotted decimal IP address looks like this: 18.104.22.168.
Part of the IP address is used for the network ID, and part of the address is used for the host ID. One complication is that the portion of the address allotted to the network ID varies, depending on the address. Most IP addresses fall into the following address classes:
More bits lead to more bit combinations. As you might guess, the Class A format provides a small number of possible network IDs and a huge number of possible host IDs for each network. A Class A network can support approximately 224, or 16,777,216 hosts. A Class C network, on the other hand, can provide host IDs for only a small number of hosts (approximately 28, or 256), but many more combinations of network IDs are available in the Class C format.
You might be wondering how a computer or router knows whether to interpret an IP address as a Class A, Class B, or Class C address. The designers of TCP/IP wrote the address rules such that the class of an address is obvious from the address itself. The first few bits of the binary address specify whether the address should be interpreted as a Class A, Class B, or Class C address (see Table 4.1). The rules for interpreting addresses are as follows:
This scheme (thankfully) is easy to convert to dotted decimal notation because these rules have the effect of limiting the range of values for the first term in the dotted decimal address. For instance, because a Class A address must have a 0 bit in the leftmost place of the first octet, the first term in a Class A dotted decimal address cannot be higher than 127. You'll learn more about converting binary numbers to decimal later in this hour. For purposes of this discussion, Table 4.1 shows the address ranges for Class A, B, and C networks. Note that some address ranges are listed as excluded addresses. Certain IP address ranges are not assigned to networks because they are reserved for special uses. You'll learn more about special IP addresses later in this hour.
By the Way
The Internet specifications also define special-purpose Class D and Class E addresses. You'll learn more about Class D and Class E addresses later in this hour.
The owner of a network can divide the network into smaller subnetworks called subnets. Subnetting essentially borrows some of the bits of the host ID to create additional networks within the network. As you can probably guess, Class A and B networks, with their large host ID address spaces, make extensive use of subnetting. Subnetting is also used on Class C networks. You'll learn more about subnetting in Hour 5.
By the Way
Theoretically, every computer on the Internet must have a unique IP address. In practice, the use of proxy server software and Network Address Translation (NAT) devices makes it possible for unregistered and non-unique addresses to operate on the Internet. You'll learn more about NAT devices in Hour 9.
Converting a 32-Bit Binary Address to Dotted Decimal Format
Binary (base 2) numbers are similar to decimal (base 10) numbers except that the place values are multiples of 2 instead of multiples of 10. As Figure 4.4 shows, a decimal whole number begins with the ones place on the right, and each successive value to the left is a higher multiple of 10. A value of a decimal number is just the sum of the values for each decimal place. For instance, (as shown) the value of the decimal number 126,325 is determined as follows: (1 x 100,000) + (2 x 10,000) + (6 x 1000) + (3 x 100) + (2 x 10) + (5 x 1) = 126,325.
A binary whole number also starts with the ones place on the right. Each successive value to the left is a higher multiple of 2 (see Figure 4.5).
By the Way
Computers work in binary because a bit pattern of zeros and ones corresponds easily to the discrete on and off states used within digital circuitry.
To determine the decimal equivalent of a binary value, add the place values of any bit that holds a one. Remember that the IP address is comprised of four octets that must each be converted separately to decimal format. Following is an example showing how to convert a 32-bit binary IP address to dotted decimal format.
Convert the binary address 01011001000111011100110000011000.
By the Way
You can use the Windows Calculator accessory to convert binary numbers to and from decimal. Select the View menu and choose Scientific. The Bin radio button places the calculator in binary mode. The Dec radio button puts the number back in decimal mode.
Converting a Decimal Number to a Binary Octet
The process of converting a decimal number to binary is a matter of going backward through the process shown in Figure 4.5. If you need to convert a dotted decimal address to a 32-bit binary address, convert each period-separated number in the address to a binary octet and then concatenate the octets. The following procedure shows how to convert the decimal number 207 to a binary octet.
By the Way
This procedure assumes you started with a decimal number representing an IP address octet. If the number you are converting is higher than 255, you'll need to extend the binary place value diagram shown in Figure 4.5 and adapt the procedure accordingly.
You have now converted the decimal number 207 to its binary equivalent 11001111.
Classes D and E
Most TCP/IP communication is either host-to-host (sent from one source computer to one destination computer) or broadcast (sent to all computers on the segment or network). Class D addresses, on the other hand, are used for multicasting. A multicast is a single message sent to a subset of the network. The four leftmost bits of a Class D network address always start with the binary pattern 1110, which corresponds to decimal numbers 224 through 239.
By the Way
Class E networks are considered experimental. They are not normally used in any production environment.
Special IP Addresses
A few IP addresses have special meanings and are not assigned to specific hosts. An all-zero host ID refers to the network itself. For instance, the IP address 22.214.171.124 refers to the Class B network with the network ID 129.152.
An all-ones host ID signifies a broadcast. A broadcast is a message sent to all hosts on the network. The IP address 126.96.36.199 is the broadcast address for the Class B network with the network ID 129.152. (Note that the dotted decimal term 255 corresponds to the all-ones binary octet 11111111.)
The address 255.255.255.255 can also be used for broadcast on the network.
Addresses beginning with the term 127 are loopback addresses. A message addressed to a loopback address is sent by the local TCP/IP software to itself. The loopback address is used to verify that the TCP/IP software is functioning. See the discussion of the ping utility in Hour 13, "Connectivity Utilities." The loopback address 127.0.0.1 is commonly used.
RFC 1597 also reserves some IP address ranges for private networks. The assumption is that these private address ranges are not connected to the Internet, so the addresses don't have to be unique. In today's world, these private address ranges are often used for the protected network behind network translation devices:
Because the private address ranges don't have to be synchronized with the rest of the world, the complete address range is available for any network. A network administrator using these private addresses has more room for subnetting, and many more assignable addresses. See Hour 9 for more on network translation devices.