NET 121b: Essentials of Networking

Chapter 10: TCP/IP Addressing and Subnetting


This chapter discusses the history and structure of the TCP/IP suite. The topics of this chapter are:

  1. IP addressing
  2. Subnetting and special addressing
  3. TCP/IP installation and configuration

The purpose of an IP address is to identify each unique node on a network. On an IP network, each device is known as a host, and every host must have an address. The addresses we discuss first are actually IP version 4 addresses. (IPv6 addresses will be 16 bytes, or 128 bits long.) They are numeric addresses, stored as four bytes, which is equal to 32 bits. When we write these addresses, we usually place dots between the bytes, but you must understand that the dots do not exist in the addresses as used. This notation is sometimes referred to as dotted octet or dotted quad. (Each byte is called an octet because it has eight bits; there are four bytes in the address.)

Since the IP protocol stack was invented with networking in mind, IP addresses contain two parts: one to identify the address of the network a host is on, and the other part to identify the host itself. Every network is assigned an address which could be one, two, or three bytes, depending on the class of the network (A, B, or C). The remaining byte or bytes are typically used for hosts on networks.

Each byte in an IP address will be a number in the range 0 through 255, expressed in base 10 (decimal notation). To pass the certification test for this course, you will need to be able to convert decimal notation to binary notation and vice versa, by hand. No calculator conversion is currently allowed. You will need to know a conversion method to pass the test, so we will discuss one in class. The method presented in the text is similar to the one used in this course for several years.

Values of Positions in a Byte
Bit position: 7 6 5 4 3 2 1 0
Value of Position (if a 1 is in it): 128 64 32 16 8 4 2 1

The largest number that can be stored in one byte is 255. The is the sum of the values of all the the positions in the byte. Converting a binary number to decimal is simple: add the values of all the positions that hold a one. The only trick is to have a clear memory of the value of each position. They are all powers of two. Start on the right with 1, and double the value for the next position to the left: 2, 4, 8, 16, 32, 64, and 128.

When you convert a decimal number to binary, do a series of subtraction problems, one for each position in the byte, starting from the left. For example, let's convert 175 to binary.

  1. Ask yourself this question for each bit position: Can I subtract the value of this bit from the current number? You must be able to do it without getting a negative result.
    Can you subtract 128 from 175? Yes, you can. So you write a one in the 128 bit position, and do the math: 175 - 128 = 47.
  2. Can you subtract 64 from 47? No, so you write a zero in the 64 bit position.
  3. Can you subtract 32 from 47? Yes, so write a one in the 32 bit position, and do the math: 47 - 32 = 15.
  4. Can you subtract 16 from 15? No, so you write a zero in the 16 bit position.
  5. Can you subtract 8 from 15? Yes, so write a one in the 8 bit position, and do the math: 15 - 8 = 7.
  6. Can you subtract 4 from 7? Yes, so write a one in the 4 bit position, and do the math: 7 - 4 = 3.
  7. Can you subtract 2 from 3? Yes, so write a one in the 2 bit position, and do the math: 3 - 2 = 1.
  8. When you have 1 left, write a one in the 1 bit position. This will always be done for odd numbers.
    If there is no remainder at any of the steps, write a zero in each of the remaining bit positions.
Conversion to Binary
Bit position: 128 64 32 16 8 4 2 1
Conversion of 175 (above) 1 0 1 0 1 1 1 1

Page 10-7 shows a chart of the five address classes you need to know. The first three classes can be described by the number of bytes assigned to the network portion of their addresses:

  • one byte identifies a class A network
  • two bytes identify a class B network
  • three bytes identify a class C network

Class D and E addresses use portions of the fourth byte as well for network addressing. You may wish to know that only class A, B, and C addresses are in general use. Class D addresses are for multicasting (messages to groups of machines), and class E addresses are for experimental use.

One way to recognize the class of a given address is to know the range of possible addresses in each class, also shown on page 10-7. The five classes of addresses are defined as limited to specific ranges of values of the first byte. The numeric ranges are hard to remember until you see a chart that explains what the ranges have to do with the binary version of the first octet.

Some basic training in binary notation: a byte has eight bits. Each bit can be a digit in a binary number. Since we can only use 1s and 0s in binary notation, we either have (1) or don't have (0) the number of units represented by a position in the binary number.

Values of Positions in a Byte
Bit position: 7 6 5 4 3 2 1 0
Value of Position (if a 1 is in it): 128 64 32 16 8 4 2 1

Reading from left to right, if the first bit (position 7, above) of the first octet is a zero, that octet must represent a number less than 128. This defines a class A address: the first octet must be 127 or less. Consider it this way:

  • Class A - first bit is a 0, range for the byte is 0 to 127
  • Class B - first bit is a 1, second is a 0, range for the byte is 128 to 191
  • Class C- first two bits are 1s, third is a 0, range for the byte is 192 to 223
  • Class D - first three bits are 1s, fourth is a 0, range for the byte is 224 to 239
  • Class E - first four bits are 1s, fifth is a 0, range for the byte is 240 to 255

So, if you can convert the first octet of an address to binary notation, you can tell the address class by the position of the first 0 in it.

Most possible network addresses (not host addresses) have been assigned already. We will discuss how network administrators work around this.

The list below shows some specific addresses that have special meanings:

  • - the default route
  • - reserved for loopback. is the Local Host.
  • All network bits set to 0, host bits set to some number - this would mean that the host bits are set to something other than 0, and that we mean that specific host on the current network.
  • All host bits set to 0, network bits set to your network number - this is the address for the network itself
  • Network bits or host bits all set to 1 - this is the equivalent of using wildcards, meaning all nets or all hosts
  • - this is all wildcards, but refers to all hosts on this network

Consider the task of assigning addresses to hosts within your network. Host addresses should follow the network address scheme you are assigned. If your network address was, you would have a class B address, and all host IP addresses should begin with 150.60.

If you do not have an assigned address, you could use any address scheme you wanted as long as you did not attach to the Internet. However, in reality, everyone wants or needs the Internet, so you should use a private address scheme, as shown in the chart below. You can choose any address scheme for your network that gives you enough host IDs.

Private addresses work inside a network, but they cannot be routed to other networks, nor can you send signals to another network if you have a private address. (Great, then how do I get to the Internet? More magic in a minute.) To understand this, you need to know that all IP addresses in the world were meant to be unique. These are called registered or public addresses. This scheme would allow any IP addressed machine to contact any other (in theory) because the address would identify the network and the host uniquely. At a certain point, however, the world began to run out of addresses. (It was also believed that there would be networks that would have no need to contact other networks. Yeah, right...)

So the Internet Assigned Numbers Authority (IANA) has designated some address ranges as private or unregistered addresses. They are also called nonroutable addresses:

Class Private Addresses
Private Addresses
Class A
Class B
Class C

Any address beginning with a 10, for example, is assumed to be a private address. This is the format used in many networks, because it provides lots of addresses for hosts, and lots of room for subnets. (Later in this chapter.)

Within any organization, addresses in these ranges may be used without registering the addresses with IANA. Each address you use within your network must still be unique in your network. The problem is that there is no guarantee whatsoever that any address I use in my organization is not already in use in your organization, which makes direct networking between our networks unreliable, if not impossible.

The magic part: To access the Internet, traffic from a private address network passes through a router that acts as a proxy server, providing a shared connection with a registered address. That router has both a private address on your network, and a registered public address that lets it communicate with other networks. The proxy server shares its public address with the devices on your network, allowing them to send signals to other networks through it. The service that does this sharing of the address is called Network Address Translation (NAT).

The graphic and paragraph on page 10-12 give an introduction to the concept of subnets. Suppose your company has six divisions or locations, and logically needs six networks. Logically, you would want to be assigned six different network addresses (such as Suppose, however, that you either cannot get or cannot afford licenses for six networks. Then you take the one network address that you do have and create six subnets. (Six, by the way, is not a magic number, it is just an example.)

Subnetting works by borrowing bits from the host portion of an address, and using those bits to identify subsections of your network. The use of borrowed bits only works because of subnet masks. A subnet mask tells hosts on a network which bits in an address are network address bits and which bits are host address bits. It does it by the use of 1s and 0s. Consider the table below:

Subnet Masks for Classes A, B, and C
Decimal Mask Binary Mask
Class A 11111111.00000000.00000000.00000000
Class B 11111111.11111111.00000000.00000000
Class C 11111111.11111111.11111111.00000000

Network devices read a mask to learn how to interpret addresses. Address positions marked by 1s in a mask are considered network address positions. Address positions marked by 0s in a mask are considered host address positions. Another way of saying this is that certain address bits are considered to be network address bits and the rest are considered host address bits. The actual method used involves Boolean math, but understanding it is not critical to understanding or using the concept. When a device reads an actual IP address, the rule from the subnet mask is applied, and the device understands which bits are the net address and which are the host address.

By borrowing one bit, two subnets are theoretically possible. However, as a general rule, subnet numbers using all 1s and all 0s are not used, so borrowing one bit will probably not yield any usable subnet addresses. This is why the formula for number of usable subnets is:
2N - 2 = number of subnets (where N is the number of bits borrowed).

Assume we borrow two bits in each of the three classes above. Borrowed bits are shown in red in the resulting subnet mask numbers below:

Subnet Masks if Borrowing 2 Bits
Decimal Mask Binary Mask
Class A 11111111.11000000.00000000.00000000
Class B 11111111.11111111.11000000.00000000
Class C 11111111.11111111.11111111.11000000

Note that the subnet masks above do not match the standard masks from the previous table. The standard masks are classful masks, because they match the intended use of class address schemes. The masks above are classless, because they do not match any network class.

Be aware that routers on the Internet only use the network bits of an address for routing. Routers connecting subnets within a network must use the network, subnet, and host bits for routing.

Page 10-13 begins the topic of assigning subnet addresses.

  • Each address on a network must be unique. This is true for all IP addresses, not just subnet addresses.
  • The network and subnet numbers must be the same for all devices on the same network. A classic error is to assign two workstations to different subnets and expect them to communicate as if they were on the same logical LAN.
  • The host (physical) portion of the address must not be set to all 1s or all 0s.
  • Plan for growth. You will have to add more stations later to most LANs, and you may have to add more subnets than you need today. In general, you calculate the number of subnets required, then round up to the nearest power of two. Do the same with the number of hosts needed per subnet. You may find that the two goals are in conflict.
  • Don’t use IP addresses reserved for special use. These have been noted already in the text.

TCP/IP support is expected on networks. It was optional, previously, but the Internet has made it the common protocol suite for all networks of any note.

In an IP network, each device needs a unique IP address. Assignment of these addresses takes some planning. First, there are two major approaches:

  • Static assignment - someone has to manually configure the address on each device, including workstations, servers, and printers. Unless your network is small, this is very painful.
  • Dynamic assignment - a server on the network can assign an address to workstations as they are signed on. You will still want to manually configure addresses on servers, printers, routers, and other network resource devices. However, you can still automate the manual part: see below.

Dynamic Host Configuration Protocol (DHCP) service allows us to dynamically assign IP addresses to hosts on an IP network. You need to understand that, as far as IP is concerned, "host" means any device on the network. Three methods for assigning addresses are listed:

  • Automatic Allocation: DHCP assigns a permanent IP address to a host.
  • Dynamic Allocation: An IP address is assigned to a host for a limited period of time (or until the host relinquishes the address). Also called address leasing.
  • Manual Allocation: This method requires that you assign the address. DHCP simply delivers the address to the host. Read that carefully: you can make the assignment, but you tell the DHCP server about it, you don't visit the host yourself.

Whether you use dynamic or static assignment, you can assign more than the IP address of a device. You can also specify what server to use for Domain Name Service (DNS), and what server to use for Gateway service (route to other networks). A DHCP server can provide this information when the device powers up, or it can be configured by hand as shown in the text.

A concept that is not covered in your book, but that belongs in this chapter is Classless Inter-Domain Routing (CIDR). CIDR is a router standard that allows the use of classless subnet masks. In the CIDR standard, IP addresses are followed by a slash and the decimal number of bits used in the network portion of the subnet mask.

An example of CIDR notation might be This example shows a network address, It is followed by a forward slash, and the number 24. The number 24 means that the subnet mask for addresses on this network uses 24 bits as network identifiers. This is the same thing as saying that the subnet mask for this network uses 3 bytes as network identifiers, which is the same thing as saying the subnet mask is In the table below, the same network is described three ways. Each is telling us the same thing: IP addresses on this network hold network information in the first three numbers, and host information in the fourth.
3 descriptions of the same network Example
subnet mask
number of bytes that hold network bits 3
CIDR notation /24

When addresses are sent on networks that allow CIDR notation, they can include this helpful notation that is the equivalent of sending the subnet mask along with the address. This is particularly helpful in networks that use subnetting. In such cases, the number following the forward slash probably will not be a multiple of 8.