- #1
Phys12
- 351
- 42
Homework Statement
Counting Internet Addresses In the Internet, which is made up of interconnected physical networks of computers, each computer (or more precisely, each network connection of a computer) is assigned an Internet address. In Version 4 of the Internet Protocol (IPv4), now in use, an address is a string of 32 bits. It begins with a network number (netid ). The netid is followed by a host number (hostid ), which identifies a computer as a member of a particular network. Three forms of addresses are used, with different numbers of bits used for netids and hostids. Class A addresses, used for the largest networks, consist of 0, followed by a 7-bit netid and a 24-bit hostid. Class B addresses, used for medium-sized networks, consist of 10, followed by a 14-bit netid and a 16-bit hostid. Class C addresses, used for the smallest networks, consist of 110, followed by a 21-bit netid and an 8-bit hostid. There are several restrictions on addresses because of special uses: 1111111 is not available as the netid of a Class A network, and the hostids consisting of all 0s and all 1s are not available for use in any network. A computer on the Internet has either a Class A, a Class B, or a Class C address. (Besides Class A, B, and C addresses, there are also Class D addresses, reserved for use in multicasting when multiple computers are addressed at a single time, consisting of 1110 followed by 28 bits, and Class E addresses, reserved for future use, consisting of 11110 followed by 27 bits. Neither Class D nor Class E addresses are assigned as the IPv4 address of a computer on the Internet.)
How many different IPv4 addresses are available for computers on the Internet?
Homework Equations
The Sum Rule: P1 + P2 + ... Pn
The Product Rule: P1 * P2 * ...Pn
The Attempt at a Solution
Considering that a person can either have a class A IP address or a class B IP address or a class C IP address, the number of IP addresses will be (number of class A IP addresses + number of class B IP addresses + number of class C IP addresses).
Total number of class A IP addresses = total number of possible addresses - total number of forbidden IP addresses. Since the netid is of 7 bits (the first bit is fixed) and the hostid of 24, total number of possible addresses = 2^7 * 2^24. Now, the number of forbidden addresses will be: (1*2^24 + 2^7*2) Why? Because there are two ways of having a forbidden IP addresses: you can either have the netid consist of all 1s or you can have the hostid of either all ones or all zeros. That's why in the first case, I picked the netid 1111111 and then I have 2^24 possibilities for the hostid. In the second case, there can be any netid (total ways of getting one is 2^7), and only 2 host IDs (all 0s or all 1s) and hence, (1*2^24 + 2^27*2) possiblities giving a final result of (2^7 * 2^24) - (1*2^24 + 2^7*2) = 2130706176. However, the answer is: 2130706178. Now, I understand the reasoning given in the book:
Let x be the number of available addresses for computers on the Internet, and let xA, xB, and xC denote the number of Class A, Class B, and Class C addresses available, respectively. By the sum rule, x = xA + xB + xC.
To find xA, note that there are 27 − 1 = 127 Class A netids, recalling that the netid 1111111 is unavailable. For each netid, there are 224 − 2 = 16,777,214 hostids, recalling that the hostids consisting of all 0s and all 1s are unavailable. Consequently, xA = 127 · 16,777,214 = 2,130,706,178.
But I fail to understand where my reasoning is going wrong. I'm getting two less possibilities than the book.