IP Addresses and Subnet Masks

team lib

As the Internet takes on an ever larger role during our working hoursand perhaps our after-work hours as wellthe more people need a better understanding of how IP addressing works and the closely related topic of subnets and how they are defined.

For example, installing IP connectivity software, which the current versions of Windows, OS/2 Warp, and the Macintosh OS all include, on a desktop system generally requires that you know your IP address and your organization's subnet mask. While most organizations administer these setup parameters centrally typically through the IT departmentit can be useful for people other than the Internet guru to understand how addresses and subnets work. While the topic may seem extraordinarily complex, a little facility with binary arithmetic is sufficient to work out how the system operates.

The Internet address is the first concept you need to grasp. The parsimonious founding fathers of the Internet allowed 32 bits to identify all Internet addresses. (2 32 =4,294,967,296 addresses, which seems to be a plentiful supply at first glance.) IP addresses are normally written as a sequence of four decimal numbers separated by periods, with each number ranging from 0 to 255. (Each number is an 8-bit byte, or octet in Internet jargon. 2 8 = 256, and 4 x 8 bits = 32 bits.)

So the most common representation of an Internet address looks something like this: 192.228.17.62. Sometimes the four digits of an Internet address are represented in hexadecimal (base 16) notation. As we shall see, it sometimes makes sense to represent them in binary or base 2 notation.

Internet addresses are made up of a network number and a host number. A host can be any device that runs an application. Most hosts are computerstraditionally the term "host" has been reserved for multi- user mainframes and minicomputers, but PCs and workstations are hosts in the Internet sense of the term , as are intelligent hubs, RMON monitors , and other devices.

Hosts whose addresses share a network number can send local broadcasts to one another and communicate without a router. Hosts with differing network numbers can communicate only via an IP router.

The network ID number part of the IP address can be split off from the host ID part in several ways. If the first octet of the Internet address is used for the network number, the last three octets can be used for host addresses. Such networks are called Class A networks, and they can have 2 24 - 2 = 16,777,214 host addresses.

If the first two octets are used for the network number, the networks are called Class B networks, and they can have 2 16 - 2 = 65,534 host addresses. If the first three octets are used for the network number, the networks are Class C networks, and they can have 2 8 - 2 = 254 host addresses.

Table 1 is the binary representation of the first octet of an Internet address. The convention is that if the first (or most significant) binary digit is 0, then the address is a Class A address. Network addresses of 0 (00000000 binary) and 127 (01111111 binary) are reserved, so there are 126 potential Class A networks, recognizable by their having a first dotted decimal digit in the range of 1 to 126. These very large networks have practically all been assigned to large international organizations and government agencies.

Table 1

Binary Representation Of The First Octet Of An Internet Address

Powers of 2

2 7 (128)

2 6 (64)

2 5 (32)

2 4 (16)

2 3 (8)

2 2 (4)

2 1 (2)

2 (1)

Class A

x

x

x

x

x

x

x

Class B

1

x

x

x

x

x

x

Class C

1

1

x

x

x

x

x

Class D

1

1

1

x

x

x

x

Class E

1

1

1

1

x

x

x

x

Class B addresses are indicated by a 1 in the first bit and a 0 in the second bit of the first octet. Thus they can be identified by their having a first decimal digit in the range of 128 to 191 (10000000 binary to 10111111 binary). The second octet of a Class B address is also part of the network number. Thus there are potentially 16,382 Class B addresses.

Class C addresses have 1s in the first two bits and a 0 in the third bit of the first octet, and use both the second and third octets for the network number. Thus the first decimal digit of Class C addresses ranges from 192 to 223 (11000000 binary to 11011111 binary). There are 2,097,150 Class C addresses. Network numbers with the first digit higher than 223 are reserved for special purpose Classes D and E.

Why Do We Need Subnets?

A network with 16,777,214 host addresses (Class A) , or even one with 65,534 (Class B), is likely to be unwieldy; even a Class C network with 254 addresses may well be undesirably large for many organizations. As a result of traffic patterns and congestion, upper limits on the number of allowable nodes in a network, distance limitations on LANs, and other reasons, many organizations divide their networks into subnets.

In effect, some number of the leftmost (or most significant) bits of the host addresses are expropriated and used to designate subnets. The subnet is part of the network identified by the network number, but only those hosts that are on the same subnet can communicate without a router. Members of different subnets will not see each other's local broadcasts, and they will need to go through a router to communicate, even though they may be on the same network.

The subnet mask is the method IP software uses to mark off which host bits will be transformed into subnet numbers. A subnet mask is a 32-bit number, often written in dotted decimal form like an IP addressfor example, 255.255.255.192. If we write the subnet mask in binary notation (see Table 2), it's easier to see how it works. Think of the subnet mask as a strip of masking tape laid over the host part of the binary IP address wherever there are 0s in the mask.

Table 2: Network numbers with the first digit higher than 223 are reserved for special purpose Classes D and E.

Dotted Decimal And Binary Representations Of Ip Address And Subnet Mask

 

Dotted decimal

Binary representation

IP address

192.228.17.126

11000000.11100100.00010001.01111110

Subnet mask

255.255.255.192

11111111.11111111.11111111.11000000

Bitwise

192.228.17.64

11000000.11100100.00010001.01000000

AND of address and mask (resultant network number)

   

Subnet number

1

00000000.00000000.00000000.01

Host number

0.0.0.62

00000000.00000000.00000000.00111110

If the subnet mask stops at an octet boundary, it may be the same as the default mask, which is no mask at all (see Table 3). In other words, if you perform a bitwise logical "AND" with a Class B address and the Class B default mask, you get precisely the same network number you would get by simply looking at the first two octets, and there is no subnet number carved out of the Class B host octets.

Table 3

default subnet masks

Class A default mask

255.0.0.0

11111111.00000000.00000000.00000000

Example Class A mask

255.192.0.0

11111111.11000000.00000000.00000000

Class B default mask

255.255.0.0

11111111.11111111.00000000.00000000

Example Class B mask

255.255.248.0

11111111.11111111.11111000.00000000

Class C default mask

255.255.255.0

11111111.11111111.11111111.00000000

Example Class C mask

255.255.255.252

11111111.11111111.11111111.11111100

It is considered good practice to use contiguous bits, starting from the left, for subnet mask values, though it is not always an absolute requirement. Following this rule, decimal representations of subnet mask values follow the sequence 128, 192, 224, 240, 248, 252, 254, 255.

A Sample Subnet Mask

If you have a Class C network address and you would prefer to configure six networks of 30 hosts each, you would use the subnet mask 255.255.255.224. Subnet 0, with the binary representation 000, is reserved to refer to "this subnet," and subnet 7, with the binary representation 111, is often reserved for broadcasts to all subnets on this network. Thus subnets one through six are available. Host number 0 (00000 binary) and host number 31 (11111 binary) are reserved, so there are 30 potential host IDs, numbered 1 to 30, that could be assigned.

With this subnet mask, there are 180 total IP addresses possible on this Class C network (six subnets times 30 host numbers). With no subnetting, a Class C network has 254 total addresses. Subnets clearly can result in wasted IP addresses, although the alternative of not employing subnets at all will likely result in even worse wastefor example, multiple Class C networks being used to segment a small number of users.

In most cases, every host and router on a particular IP network should have the same subnet mask. Exceptions to this rule should be made only by those who understand fully what they want to accomplish in their network design and how using multiple subnet masks on the network achieves that goal.

It's not a good idea to experiment with subnet masks, or for that matter, with IP addresses. Each organization with an IP network connected to the Internet is obligated to request network IDs from the Network Information Center, to which the Internet Activities Board has delegated the responsibility of administering addresses.

Duplicate network numbers, duplicate host addresses, and inconsistent subnet masks can create havoc, and if you are using unregistered numbers, you are presumed to be at fault. If you are installing Internet applications on an organization's network, you must get an appropriate address and the organization's subnet mask from the person in your organization who is in charge of administering them. Aside from the hard-to-find problems that may result from ignorant experimentation with IP addresses and subnet masks, it is a lot of work to go back and reinstall IP software that has been configured improperly.

This tutorial, number 86, by Steve Steinke, was originally published in the October 1995 issue of LAN Magazine/Network Magazine.

 
team lib


Network Tutorial
Lan Tutorial With Glossary of Terms: A Complete Introduction to Local Area Networks (Lan Networking Library)
ISBN: 0879303794
EAN: 2147483647
Year: 2003
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net