Вы находитесь на странице: 1из 8

IP Addresses

(Tewksbury) These notes draw on the presentation of IP addresses in Computer Networks and Internets with Internet Applications by Douglas E. Comer. Contents
A. CLASSFUL ADDRESSES............................................................................................................................................2 A.1 BASIC ADDRESS STRUCTURES AND SPECIAL ADDRESSES ......................................................................................2 A.2 BUILDING A NETWORK WITHIN YOUR SITE: SUBNET MASKS ................................................................................3 B. HOW CLASSLESS ADDRESSES WORK...............................................................................................................6

The following notes seek to define the structure of IP addresses, the use of subnet masks within sites in order to partition a site's network into a multiplicity of internal physical networks. In addition, some discussion on Classless network addressing is provided.

A. Classful Addresses
A.1 Basic Address Structures and Special Addresses IP addresses consist of four binary octets (each octet consisting of 8 binary digits with values 0 or 1), giving an overall IP address length of 32 bits. The original IP addressing scheme used the first four binary digits of an IP address to separate networks into five different classes (based on the first appearance of a binary 0 in the first four binary digits. Following this specification of the class of the network, a prefix specifying particular network followed by a suffix specifying the node on that particular network are used. Figure A1 illustrates the IP addresses for the five classes, denoted Class A, Class B, Class C, Class D, and Class 3 networks.
IP Address (dot-decimal form) V3.V2.V1.V0 V2 V1

V3

V0

7 8 16 24 Bit positions are numbered from most significant to least significant bit

31

(a)
Class A 0 Class B 10 Class C 110 Class D 1110 Class E 1111 Reserved for Future Use Multicast Address Prefix Suffix Prefix (Network) Suffix Prefix Suffix (Node)

(b)
Figure A1 The Class A network has a 7-bit prefix (values from 0 through 127), allowing 128 different network identities. The Class B network has a 14-bit prefix (values from 0 through16,383) allowing 16383 network identities and the Class C network has a 22-bit prefix (values from 0 through 16,777,215), allowing millions of network identities.

Not all of the prefixes can be used for network nodes since there are some special-purpose IP addresses as follows: Network's Own Address (Suffix = all 0's): Consider a Class B network, with a 14-bit prefix and a 16-bit suffix denoting nodes on that network. An example IP address (with binary "10" for the first two bits) for this network is 132.187.63.124 where "132.187" identifies the Class B network and "63.124" identifies the node on the network. The suffix with value 0 is reserved to identify the network itself to the overall Internet. Thus, the address of the network itself for this example is 132.187.0.0. Directed Broadcast Address (Suffix = all 1's): For the example network address above, the Directed Broadcast Address would be 132.187.255.255 and is used to broadcast a message to all hosts on network 132.187.255.255. Limited Broadcast Address (IP address = all 1's): In this case, the address is 255.255.255.255. Although this might appear to be a "Reserved for Future Use" address in the classes in Figure A1, it is recognized only by the end-point nodes attached directly to an local router/switch serving a single physical network of computers, printers, etc. This address is used by local computers to obtain the physical addresses of directly connected computers (and the directly connected router) from the IP address of the computer/router desired. Your Computer's Own Address (IP address = all 0's): When starting up, your computer may not know it's IP address (needs to obtain it). The all 0's IP address is used to allow it to send a packet with its unknown IP address to start the process of acquiring its IP address over the network. Loopback Address (127.0.0.1): The address 127.x.x.x designates to the operating system software in your computer that the packet's destination is your computer. Knowing this, your operating system never sends the packet out onto the network, instead simply returning it up through the Internet protocol stack. To your computer's applications, it appears as though the packet was sent across the network, even though it never got to the network. A.2 Building a Network Within your Site: Subnet Masks Let's consider the case where your site has the example Class B network address 137.187.0.0 used earlier. You can provide networking for over 16,000 computers, something of a challenge. To organize your site, you wish to build your own network within your site via a system of routers, switches, etc. For this purpose, you can use the suffix portion of the site's IP address to provide internal addressing of a number of physical networks. To achieve this, considering the network address boundary shown in Figure A1, the easiest approach is to extend the "network" portion of the address (the prefix) into the prefix portion of the IP address. This is done through internal use of subnet masks. Figure A2 illustrates the general approach, assuming a hierarchical set of physical networks at the site.

Class B Standard IP Address

10

Prefix: Site Network

Suffix

132

187 Site Network 7 8

Suffix redefined for internal network prefix 16 internal suffix 24 31

1 0 0 132 187

10

P4 P3

P2

P1

P0

11-bit internal suffix

5-bit internal network prefix

Subnet Mask
D
255 255 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 11111000 = 248 (decimal) 00000000 = 0 (decimal)

E
132 187

01101011 = 107 (decimal)

10011101 = 157 (decimal)

F
132 187

0 1

1 1

01101000 = 104 (decimal)

01 110 011 101 = 925 (decimal) Node 925 on Internal Network 132.187.104.0

Internal Network Address 132.187.104.0

Figure A2: Use of subnet mask for intra-site network building Row A in Figure A2 shows the standard form of an IP address for a Class B network at a site. The prefix identifies this network as our example 132.187.0.0 Class B network. The 16 bit suffix identifies nodes within the site with address 132.187.0.0. As shown in Row B in Figure A2, the site may use the 16 bit suffix to establish the IP addresses for a set of networks within the site. The "Suffix" (capitalized) for the standard IP address in row A is divided into an internal network address "prefix" (lower case) and "suffix" (again lower case to designate in these notes that these have been established by the site itself for internal use. Row C shows the internal "prefix" and "suffix" fields expanded to enter details in each of the bit fields. The 5-bit prefix was selected, leaving 11 bits for the internal "suffix." Row D in Figure A2 shows the subnet mask used in combination with the 5-bit "prefix" to identify the network addresses of up to about 30 internal physical networks (remember that some of the possible addresses are "special" addresses discussed in Section A.1). The bits in the "prefix" are set to "1" (and will be ANDed with the overall IP address to separate out network addresses from suffixes). The "suffix" bits are set to "0". The subnet mask is read using the

octet (8-bit fields) as shown by the numbers under the subnet mask in row D. Using those boundaries, the subnet mask is 255.255.248.0. Row E in Figure A2 shows the bit field of an address arriving at the site. The example address is 132.187.107.157. In row F, the internal network address has been separated from the "suffix" to show the address of the specific network that is being addressed in the site. As shown, that internal network address is 132.187.104.0. When ANDing the subnet mask with the IP address in row E of Figure A2, the bits of the "suffix" are set to zero, leaving only the site address bits and the internal 8-bit (everything is done on octet boundaries) address of 01101000, or 104 decimal. Also shown in row E is the value of the "suffix," identifying node 925 on internal network 132.187.104.0. In the discussion above, the "1" bits used for the subnet mask defining internal networks were placed together at the start of the region containing the "prefix" and "suffix." This is not absolutely required. For our example, you merely need to have 5 bits in the 16 bit field set to "1". However, scattering the "1" bits throughout the field complicates the approach unnecessarily, and provides no advantage - bottom line, not recommended.

B. How Classless Addresses Work


You are probably already familiar with the original organization of IP addresses, using the most significant bits to establish a sequence of successively lower groups of IP addresses. This was all related to the first appearance (starting at the most significant bit of the IP address) of a binary "1". This organization was highly wasteful of IP address values and a limitation as the Internet developed. To provide a more flexible IP addressing scheme, the original Class-based IP address scheme has been replaced by the Classless IP address scheme, discussed below. The term "octet" is used to represent an 8-bit binary code (what is also commonly called a "byte"). The top (row A) of Figure B1 illustrates an octet in terms of the binary digits b7, b6, ...,b0 in the octet. The smallest value is decimal 0 (octet is 00000000) and the largest value is decimal 255 (octet is 11111111).
Octet - 8 bits: Values = 0, 1, 2, ... 255 A b7 b6 b5 b4 b3 b2 b1 b0 IP Address (dot-decimal form) V3.V2.V1.V0

V3

V2

V1

V0

Network Address

Host Address

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0

11111111 = 255

11111111 = 255 11111100 = 252 Subnet Mask

00000000 = 0

Figure B1: IP address and subnet mask octets Row B of Figure B1 illustrates the IP address, consisting of four octets. I have labeled the decimal values of the binary code in each octet as V3, V2, V1, and V0. The IP address in dotdecimal form would be V3.V2.V1.V0 (e.g. 155.246.66.138). I have also shown the boundary between the octets with the longer lines extending above the bit positions of the octets. Row C of Figure B1 illustrates the two parts of an IP address - the network address and the node address. Row D of Figure B1 illustrates an address mask (often called a subnet mask, the terminology used in the site address maintenance discussed in Section 1. I have used an address

mask 255.255.252.0 to illustrate the flexibility in placement of the line separating the network address and the node address within the overall IP address. As this separating line moves to the left, the network can have a larger number of nodes. The network address corresponds to those bits of the IP address having address mask bits equal to one. Formally, one obtains the network address by forming the logical AND of the IP address and the address mask.

Example IP address of your site: 155.246.66.138 Address mask of your site: 255.255.252.0 155 246 66 138 10111111 11110110 01000010 10001010 IP Address 11111111 11111111 11111100 00000000 Site address mask 255 255 252 0 155 246 66 138 10111111 11110110 01000010 10001010 IP Address 11111111 11111111 11111100 00000000 Site address mask 255 255 252 0 10111111 11110110 01000000 00000000 155 246 64 0 Network address

10111111 11110110 01000010 10001010 Node address 10111111 10 10001010 = 650decimal Node 650

Figure B2: Illustration of classless IP addressing Figure B2 illustrates an example, using the 255.255.252.0 address mask and the IP address 155.246.66.138. Row A shows the IP address aligned with the subnet mask. In row B, I have highlighted the 0 valued subnet mask bits and the corresponding bits of your IP address in red italics. Row C shows the separation of the network address (used by the overall Internet system) and the node address. Taking the logical AND of your IP address and your subnet mask, the network address is seen to be 155.246.64.0. This is the network address of your overall site. As discussed in Section 1, your site may use subnet masks internally to establish a set of physical networks appearing under this network at 155.246.64.0. As a node in the network, the node address corresponds to those bits in the IP address whose subnet mask bits equal zero. In this example, your node address is, in binary, 1010001010 or node 650 in decimal. I have used the term "node address" as the address used internally at your site to identify a particular end-node. However, this "node address" can be used by your site's system in many ways, including use of subnet masks (contained fully within the part of the IP address whose

address mask bits are equal to zero) to separate the internal network into multiple physical networks.

Вам также может понравиться