Section 3.1: IP Addressing
IP addressing and subnetting is probably the single most important topic you need to know for the CCNA exam. An IP address is a network layer (Layer 3) address that uniquely identifies a host, including network components and devices, on a TCP/IP network. An IP address is composed of 32 binary bits and consists of two parts: a network ID and a host ID.
- The Network ID identifies the TCP/IP hosts that are located on the same physical network. All hosts on the same physical network must be assigned the same network ID to communicate with each other. If routers connect your networks, a unique network ID is required for each wide area connection.
- The Host ID identifies the individual hosts within a network. The host ID must be unique to the network designated by the network ID.
The boundary between the network ID and the host ID of the IP address is defined by the subnet mask, which is another 32-bit field. There is a bit-for-bit alignment between the IP address and the subnet mask. The subnet mask contains a continuous field of is followed by a continuous field of os. The contiguous is stop at the boundary between the network ID and the host ID of the IP address. The network boundary can occur at any place after the eighth bit position from the left. Once the boundary between the network part and the host part of the IP address is known, all devices addressed in that network will have a common binary pattern in the network part that identifies the device as belonging to the specified network.
There are a number of formats for referencing an IP address. These include binary, dotted decimal notation and Classless Interdomain Routing (CIDR) Notation.
3.1.1: Binary Format
Binary is a numeral system that is 2 based, i.e., it uses only os and is, to denote a value. Because binary is 2 based, each successive bit is twice the value of the preceding bit, read from right to left. A 0 denotes that the bit does not carry a value and a 1 denotes that the bit does carry a value. When binary value has more than one 1, as in 0000 1001 the decimal values for the is are added to produce the decimal value. In this example 0000 0001 is 1 and 0000 1000 is 8. Therefore the decimal value for 0000 1001 is 9 (8+1). The maximum binary value for an octet would contain all 1s, as in 1111 1111, and would have a decimal value 255 (128+64+32+16+8+4+2+1), as illustrated in Figure 3.1.
Figure 3.1: Binary Code 1111 1111
The decimal value of the binary code is the sum of decimal value of each bit. Therefore the decimal value for a binary code of
1111 1111 is 128+64+32+16+8+4+2+1=255
Note: The corresponding decimal value of the binary code is calculated from right to left and not left to right.
0 in the binary code indicates that the corresponding bit has no value. Figure 3.2 illustrates a byte with a binary code of
1110 1101 and the value of each of its eight bits.
Figure 3.2: Binary Code 1110 1101
The decimal value for this binary code is 128+64+32+0+8+4+0+1=237
Note: Each bit in the binary code that is marked with a 0 has no value. Therefore the corresponding decimal value of these bits are also 0.
3.1.2: Dotted Decimal Format
Both the IP address and its associated subnet mask contain 32 bits. However, the 32-bit IP address can be represented in other formats. The common formats include decimal (base 10) and hexadecimal (base 16) notation. The generally accepted format for representing IP addresses and subnet masks the doted decimal notation in which the 32-bit field is divided into four groups of eight bits, also called a byte, that are translated to decimal value and separated by dots. Each group of eight bits is called an octet. Thus, an IP Address expressed as 1100 0000 1010 1000 1010 0110 0111 1110 in binary format can be broken into its four octets: 1100 0000.1010 1000.1010 0110.0111 1110. These octets are converted to decimal value in Figure 3.3.
Figure 3.3: Binary Code 1100 0000.1010 1000.0111 1011
|The decimal value of the first octet is:||128+64+0+0+0+0+0+0 = 192|
|The decimal value of the second octet is:||128+0+32+0+8+0+0+0 = 168|
|The decimal value of the third octet is:||128+0+32+0+0+4+2+0 = 166|
|The decimal value of the fourth octet is:||0+64+32+16+8+4+2+0 = 126|
In dotted decimal format this IP Address would be expressed as: 192.168.166.126
3.1.3: IP Address Classes
IP addresses are divided in to 'classes', based on the decimal value represented in the first octet. This class definition is referred to as the First Octet Rule. There are five classes of IP addresses: classes A, class B, class C, class D; and class E, but only class A, B and C addresses are used to identify devices connected to the Internet. Class D addresses are used for multicasting, and Class E addresses are reserved for experimental use. The subnet mask is related to the IP address class. Thus, once the IP address class is known, the default routing mask is also known. The IP address classes and their related subnet masks are:
- Class A addresses range from 0.0.0.0 through 126.96.36.199 and use a default subnet mask of 255.0.0.0. In Class A addresses, the first octet is used as for the network ID while the last three octets are used for the host ID. In other words, the first 8 bits of the subnet mask are all is, hence a subnet mask of 255.0. 0.0. As a result, networks that use Class A addresses can theoretically support a maximum of 256 networks and 16,581,375 (255x255x255) hosts, however, the first and the last address cannot be used. The first address is the network address and the last address is the broadcast address. For example, a network with an IP address of 10.10.11.12 has a network ID of 10.0.0.0, the fist address, and a broadcast address of 10.255.255.255, the last address. Thus networks with a Class A IP address space can support a maximum of 254 networks (28-2) and 16,777,214 hosts (224-2). Consequently, Class A addresses are used for a few networks with a very large number of hosts on each network.
- Class B addresses range from 188.8.131.52 through 184.108.40.206 and 220.127.116.11 through 18.104.22.168. These addresses use a default subnet mask of 255.255.0.0. In Class B addresses, the first two bits are used as for the network ID while the last two bits are used for the host ID. As a result, networks that use Class B addresses can support a maximum of 65,534 networks (216-2) and 65,534 hosts. Consequently, Class B addresses are used for a reasonable number of medium sized networks.
Note: IP addresses with a first octet of 127, i.e. 127.0.0.0 through 127.255.255.255 do not fall in either the Class A address range or the Class B address range. IP addresses that have a first octet of 127 are reserved for diagnostics purposes.
- Class C addresses range from 192.0.0.1 through 22.214.171.124 and default subnet mask of 255.255.255.0. In Class C addresses, the first three bits are used as for the network ID while only the last bit is used for the host ID. As a result, networks that use Class C addresses can support a maximum of 16,777,214 networks and 254 hosts. Consequently, Class C addresses are used for a large number of networks with a relatively small number of hosts on each network.
- Class D addresses are in the range 126.96.36.199 through 188.8.131.52. These addresses are reserved for multicast transmissions.
- Class E addresses are in the range 240.0.0.0 through 254.255.255.255. These addresses are reserved for experimental use.
Note: InterNIC has reserved a number of IP address range, including 184.108.40.206 through 220.127.116.11, which has been reserved by for future use; 0.0.0.0, which was originally defined for use as a broadcast address; and 127.0.0.0, which is used as the loopback address. 18.104.22.168, 22.214.171.124, 192.0.0.0, and 126.96.36.199 also are reserved.
3.1.4: Classless Interdomain Routing (CIDR) Notation
Class-based IP addressing is fairly rigid. Thus, a small company with 50 hosts that wants to connect to the Internet would need a Class C address. However, a Class C address range supports 253 hosts; therefore 203 addresses would be wasted. Similarly, a company with 4,000 hosts would require a Class B address to connect to the Internet. A Class B address can support up to 65,023 hosts, resulting in 61,023 addresses being wasted. This problem can be overcome by extending the default subnet mask by adding more continuous is to it. The result is that the network can support less hosts. Thus, the company that has 4,000 hosts would use a Class B address with a subnet mask of 255.255.240.0. This is achieved by extending the subnet mask by 4 bits so that the first 20 bits represent the network ID and 12 bits only represent the host ID. Thus the address range now supports only 4,094 hosts, representing a loss of only 94 addresses. We can calculate the number of hosts supported by using the formula: 2n-2 where n is the number of bits used for the host ID. We need to subtract 2 addresses: the network address and the broadcast address. In this example, 12 bits are used for the host ID. Thus using the formula we can see that this subnet mask supports 4,094 hosts (212-2).
We can calculate the number of subnets supported by a subnet mask by using the same formula: 2n-2. However, this time n is the number of bits used for the network ID. We again need to subtract 2 addresses: the network address and the broadcast address. Thus, in the example 255.255.240.0, 20 bits represent the network ID therefore this subnet mask supports 1048,574 subnets (220-2).
This solves the problem of IP address allocation on the internet but presents a problem for routing tables, as the routing table cannot determine the subnet mask on the basses of the IP address class. Hence a different format of representing the IP address and its subnet mask is required. This format is called the Classless Interdomain Routing (CIDR) notation, or prefix notation. CIDR is in essence an adaptation of the Dotted Decimal Format and represents the subnet mask as a number of bits used for the network ID. This number of bits is indicated after the IP address by the number that follows the slash (/) symbol. For example, the CIDR notation IP address 188.8.131.52/20 indicates that the first 20 bits of the IP address is used for the subnet mask, i.e., the first 20 bits are all is. Thus, the subnet mask expressed in binary format is
1111 1111.1111 1111.1111 0000.000 00000, being represented in dotted decimal format as 255.255.240.0. In addition, the routing protocols must send the mask with the routing update.
3.1.5: Variable-Length Subnet Masks
CIDR is used within the Internet. Its counterpart within an organization is the Variable-length subnet mask (VLSM). Like CIDR, VLSM allows you to allocate the required host bits on a granular basis. In other words, it allows you to provide only the bits required to address the number of hosts on a particular subnetwork. Like CIDR, VLSM requires a routing protocol that supports the sending of the subnet mask in its updates. The routing protocols that support VLSM are: RIPv2; OSPF; IS-IS; EIGRP; and BGP-4. The routing protocols do not support VLSM are: RIPv1; IGRP; and EGP.