The word host is often used to described any device on a
network that sends and receives information by using an IP address. To
determine the location of a destination host with respect to the source
computer, IP addresses are organized into classes. This is called classful
IP addressing. You must assign IP addresses to all computers that are
connected on the network. Network segments connected by a router are called
subnets. Breaking down the network into subnets for the purpose of
assigning IP addresses is called subnetting.
The IP address identifies a computer's location on the network. An IP address
consists of a set of four numbers, each of which can range from 0 to 255. An
IP address has two parts, the host ID and the network ID.
Network ID
The first part of the IP address is the network ID, which identifies the
network segment on which the computer is located. All computers on the same
segment must have the same network ID.
Host ID
The second part of the IP address is the host ID, which identifies a
computer, router, or other device within a segment or network. The host ID
for each host must be unique within the network ID. Two hosts with different
network IDs can have the same host ID, although the combination of the
network ID and the host ID must be unique to all computers in communication
with each other.
IP Address Classes
Address classes are used to assign network IDs to organizations so that the
computers on their networks can communicate on the Internet. Address classes
are also used to define the dividing point between the network ID and host
ID.
Class A Networks
Class A addresses are assigned to networks with a very large number of hosts.
This class allows for 126 networks, by using the first number for the network
ID. The remaining three numbers are used for the host ID, allowing for
16,777,214 hosts per network.
Class B Networks
Class B addresses are assigned to networks that range from medium to large in
size. This class allows for 16,384 networks, by using the first two numbers
for the network ID. The remaining two numbers are used for the host ID,
allowing for 65,534 hosts per network.
Class C Networks
Class C addresses are used for small, local area networks (LANs). This class
allows for approximately 2,097,152 networks, by using the first three numbers
for the network ID. The remaining number is used for the host ID, allowing
for 254 hosts per network.
Classes D and E Networks
Classes D and E are not allocated to hosts. Class D addresses are used for
multicasting, and the class E addresses are reserved for future use.
IP Adress Class | IP Address | Network ID | Range of Values of w |
A | w.x.y.z | w.0.0.0 | 1-126 |
B | w.x.y.z | w.x.0.0 | 128-191 |
C | w.x.y.z | w.x.y.0 | 192-223 |
D | w.x.y.z | N/A | 224-239 |
E | w.x.y.z | N/A | 240-255 |
Determining the Network and Host ID
For the IP addresses in class A, the network ID is the first number in the IP
address. For class B, the network ID is the first two numbers; and for class
C, the network ID is the first three numbers in the IP address. The remaining
numbers identify the host ID.
Subnet Masks
To divide a network ID, you use a subnet mask. A subnet mask
is a screen that differentiates the network ID form a host ID in an IP
address but is not restricted by the same rules used in the classful method.
A subnet mask consists of a set of four numbers, similar to an IP address.
These numbers can range in value from 0 to 255.
In the classful method, each of the four numbers can assume only the maximum
value 255 or the minimum value 0. The four numbers are then arranged as
contiguous maximum values followed by contiguous minimum values. The 255
represents the network ID and 0 represents the host ID.
IP Adress Class | IP Address | Subnet Mask | Network ID | Host ID |
A | w.x.y.z | 255.0.0.0 | w.0.0.0 | x.y.z |
B | w.x.y.z | 255.255.0.0 | w.x.0.0 | y.z |
C | w.x.y.z | 255.255.255.0 | w.x.y.0 | z |
Classless Inter-Domain Routing (CIDR)
IP address classes provide a simple method for differentiating local hosts
from remote hosts and for locating the route to a remote host. However, this
method permits very few variations in network sizes, which has led to such
problems as inappropriately assigning IP addresses to networks. To overcome
these limitations, a method known as Classless Inter-Domain Routing (CIDR)
was developed for breaking up networks into a larger variety of sizes.
CIDR optimizes the allocation of IP addresses through the use of
supernetting and subnetting. Suppernetting is
a procedure that combines multiple addresses to form a single network ID.
Subnetting divides a large network into multiple subnets.
Binary Notation
Classless Inter-Domain Routing (CIDR) uses binary notation, whereas the
classful method uses a decimal notation. CIDR translates all IP addresses
and subnet masks to binary notation. CIDR divides an IP address into a set
of 32 values, in place of the four values used in the classful system.
CIDR does not define a default subnet mask based on the IP address. Instead,
each host is configured with a custom subnet mask, and each router is sent
the IP address as part of the data packet. The router then uses a subnet
mask from its routing table to determine the network ID of the computer to
which the packet must be forwarded.
CIDR Binary IP Addressing
In the the binary system, an IP address is represented as a string of 32
numbers. This string can be divided into four fields; each field is called
an octet, or byte. Each octet consists of eight bits. A bit has a value of
either 0 or 1. Therefore, an IP address consists of 4 bytes, or 32 bits.
Binary Subnet Masks
To be compatible with IP address in binary notation, subnet mask bits also
must be converted to binary notation. CIDR notation is an addressing method
that associated a subnet mask with the IP address. Regardless of whether the
IP address and subnet mask are specified in CIDR notation or in decimal
notation, you can calculate the network ID and the IP address by converting
all values to binary notation. After you calculate the network ID, you can
determine whether a destination host is local or remote.
Subnet Mask Bits
In binary notation, a subnet mask is represented by four octets, just as the
IP address is. The following table shows the binary notation for the default
subnet masks used in the classful method:
Decimal Representation Binary Representation
255.0.0.0 11111111 00000000 00000000 00000000
255.255.0.0 11111111 11111111 00000000 00000000
255.255.255.0 11111111 11111111 11111111 00000000
Using the binary representation of a subnet mask, you can manipulate 32
numbers in place of the four numbers in the decimal representation. This
increased capability provides a greater selection of network sizes compared
with the three fixed sizes in the classful method.
Subnet masks are always composed of contiguous maximum values followed by
contiguous minimum values. In binary notation, this translates to a series
of contiguous 1s followed by contiguous 0s. The contiguous 1s determine the
network ID and the 0s determine the host ID.
CIDR Notation
CIDR notation involves specifying a dotted decimal notation (192.168.0.1)
with a bit mask (/bits). The bit mask specifies the number of contiguous 1s
in binary notation of the subnet mask associated with the IP address. The
contiguous 1s are the leftmost bits in the subnet mask.
For example, the IP address represented in CIDR notation as 10.217.123.7/20
specifies that its subnet mask has 20 contiguous 1s. Consequently, the 12
bits remaining from the original 32 must be 0s. The IP addresses in CIDR
notation are known by the number of bits from the IP address that make up
the network ID and are represented as /x. For example, a 10-bit
network ID is represented as /10.
Note: CIDR notation is also known as network prexfix notation.
The following table lists the practical bit masks, the associated subnet
masks, and the number of classful networks possible for each.
CIDR Notation Subnet Mask Number of Classful Networks
/8 255.0.0.0 256 class Bs
/9 255.128.0.0 128 class Bs
/10 255.192.0.0 64 class Bs
/11 255.224.0.0 32 class Bs
/12 255.240.0.0 16 class Bs
/13 255.248.0.0 8 class Bs
/14 255.252.0.0 4 class Bs
/15 255.254.0.0 2 class Bs
/16 255.255.0.0 1 class B or 256 class Cs
/17 255.255.128.0 128 class Cs
/18 255.255.192.0 64 class Cs
/19 255.255.224.0 32 class Cs
/20 255.255.240.0 16 class Cs
/21 255.255.248.0 8 class Cs
/22 255.255.252.0 4 class Cs
/23 255.255.254.0 2 class Cs
/24 255.255.255.0 1 class Cs
/25 255.255.255.128 1/2 class C
/26 255.255.255.192 1/4 class C
/27 255.255.255.224 1/8 class C
/28 255.255.255.240 1/16class C
Calculating the Network ID
To calculate the network ID when the IP address is specified in CIDR
notation:
- Convert the IP address to binary format.
- Use the bit mask to determine the number of bits in the IP address that make up the network ID.
- Add 0s to the network ID to obtain its four-octet structure.
Consider the IP address 10.217.123.7/20.
Binary Notation
IP Address 00001010 11011001 01111011 00000111
Subnet Mask 11111111 11111111 11110000 00000000
Network ID 00001010 11011001 01110000 00000000
To calculate the network ID when the IP address and subnet mask are specified
in decimal notation:
- Convert the IP address to binary format.
- Convert the subnet mask to binary format.
- Use the number of contiguous 1s in the subnet mask to determine the number of bits in the IP address that make up the network ID.
Consider the IP address 10.217.123.7 with a subnet mask of 255.248.0.0.
Binary Notation
IP Address 00001010 11011001 01111011 00000111
Subnet Mask 11111111 11111000 00000000 00000000
Network ID 00001010 11011000 00000000 00000000
ID nnnnnnnn nnnnnhhh hhhhhhhh hhhhhhhh
Local Host Example
Consider two IP addresses: 10.217.123.7/10 and 10.218.102.31/10 belonging
to two computers: A and B. The following example details how the two network
IDs are calculated to determine whether they are local or remote in relation
to eachother. The two computers have the same network IDs, therefore computer
A is local in relation to computer B.
Computer A
IP Address 00001010 11011001 01111011 00000111
Subnet Mask 11111111 11000000 00000000 00000000
Network ID (bin) 00001010 11000000 00000000 00000000
Network ID (dec) 10.192.0.0
Computer B
IP Address 00001010 11011010 01100110 00000011
Subnet Mask 11111111 11000000 00000000 00000000
Network ID (bin) 00001010 11000000 00000000 00000000
Network ID (dec) 10.192.0.0
Remote Host Example
Consider two IP addresses: 10.217.123.7/20 and 10.218.102.31/20 belonging
to two computers: A and B. The following example details how the two network
IDs are calculated to determine whether they are local or remote in relation
to eachother. The two computers have different network IDs, therefore
computer A is remote in relation to computer B.
Computer A
IP Address 00001010 11011001 01111011 00000111
Subnet Mask 11111111 11111111 11110000 00000000
Network ID (bin) 00001010 11011001 01110000 00000000
Network ID (dec) 10.217.112.0
Computer B
IP Address 00001010 11011010 01100110 00000011
Subnet Mask 11111111 11111111 11110000 00000000
Network ID (bin) 00001010 11011010 01100000 00000000
Network ID (dec) 10.218.96.0
Available Host IDs
The number of hosts supported by a network ID is calculated by using the
number of 0s in the associated subnet mask. If the number of 0s is denoted
by n, the number of hosts is calculated as:
2^n-2. The two addresses that are subtracted from
the expression are the reserved IP addresses that cannot be allocated to any
host, the network address and the broadcast address.
The values of the bits in a host ID cannot be all 0s or 1s. The host ID with
the value 0 is is used to denote a network ID. The host ID consisting of all
1s is used as an IP broadcast address. The following examples show an example
of a valid host ID and a reserved host ID.
Valid Host
IP Address 11000000 10101000 11000001 00000000 192.168.193.0
Subnet Mask 11111111 11111111 11110000 00000000 255.255.240.0
Host ID 0001 00000000 1.0
Reserved Host ID
IP Address 11000000 10101000 11000000 00000000 192.168.192.0
Subnet Mask 11111111 11111111 11110000 00000000 255.255.240.0
Host ID 0000 00000000 0.0
The following table shows the possible host values for a specific
number of non-zero bits in the CIDR notation of an IP address.
Some users and small businesses are assigned the subnet mask of
255.255.255.255 by their ISP. Although many of the network IDs in
this chart are not practical, such as 2 or 2 billion, it is a useful
reference for determining the subnet mask needed for subnets of
particular sizes.
CIDR Notation Subnet Mask # of 0s # of Hosts (2^n-2)
w.x.y.z/1 128.0.0.0 31 2,147,483,646
w.x.y.z/2 192.0.0.0 30 1,073,741,822
w.x.y.z/3 224.0.0.0 29 536,870,910
w.x.y.z/4 240.0.0.0 28 268,435,454
w.x.y.z/5 248.0.0.0 27 134,217,726
w.x.y.z/6 252.0.0.0 26 67,108,862
w.x.y.z/7 254.0.0.0 25 33,554,430
w.x.y.z/8 255.0.0.0 24 16,777,214
w.x.y.z/9 255.128.0.0 23 8,388,606
w.x.y.z/10 255.192.0.0 22 4,194,302
w.x.y.z/11 255.224.0.0 21 2,097,150
w.x.y.z/12 255.240.0.0 20 1,048,574
w.x.y.z/13 255.248.0.0 19 524,286
w.x.y.z/14 255.252.0.0 18 262,142
w.x.y.z/15 255.254.0.0 17 131,070
w.x.y.z/16 255.255.0.0 16 65,534
w.x.y.z/17 255.255.128.0 15 32,766
w.x.y.z/18 255.255.192.0 14 16,382
w.x.y.z/19 255.255.224.0 13 8,190
w.x.y.z/20 255.255.240.0 12 4,094
w.x.y.z/21 255.255.248.0 11 2,046
w.x.y.z/22 255.255.252.0 10 1,022
w.x.y.z/23 255.255.254.0 09 510
w.x.y.z/24 255.255.255.0 08 254
w.x.y.z/25 255.255.255.128 07 126
w.x.y.z/26 255.255.255.192 06 62
w.x.y.z/27 255.255.255.224 05 30
w.x.y.z/28 255.255.255.240 04 14
w.x.y.z/29 255.255.255.248 03 6
w.x.y.z/30 255.255.255.252 02 2
w.x.y.z/31 255.255.255.254 01 N/A
w.x.y.z/32 255.255.255.255 00 N/A
Optimizing the Allocation of IP Addresses
In addition to providing a new method for differentiating between local and
remote hosts, CIDR also provides solutions to the problems associated with
classful IP addressing. These problems include the assignment of an incorrect
number of IP addresses or the addition of multiple entries to the Internet
routing tables.
Adding Multiple IP Addresses
Consider an organization that must connect 800 computers to the internet. It
can do this by choosing either one class B network ID that provides 65,534
IP addresses or four class C addresses that provide 1,016 addresses. The
first choice results in 64,734 unused IP addresses. With the second choice,
only 216 IP addresses go unused, but each router on the Internet is required
to add four routes to the organization in its routing table.
Supernetting
To avoid such inappropriate address allocations, CIDR uses the concept of
supernetting. Supernetting is a strategy that combines multiple
addresses from the classful environment into a single network ID in the
classless environment. Using supernetting, CIDR combines multiple class C
network IDs into a single CIDR network ID. In CIDR notation, a network ID is
represented by the number of bits in a subnet mask, similar to an IP address,
for example, 192.168.0.0/22.
Subnetting
Using supernetting, each organization is assigned a single CIDR network ID,
which represents a single network. However, it is not efficient to work with
a single large network because such factors as high network noise make the
network inefficient.
To reduce the noise on its internal network, an organization can physically
segment the network into subnets by using routers. As each subnet requires
its own network ID, the single CIDR network ID obtained for the organization
can be divided into smaller network IDs for each subnet. The process of
dividing a network ID into smaller network IDs is known as subnetting. The
smaller network IDs are known as subnet IDs.
Subnetting is an internal process that is specific to a network, any router
outside of the organization's network cannot view the seperate subnets and
their subnet IDs. In the example, if the organization wanted to have no more
than 62 computers on each subnet, it could use the subnet mask
255.255.255.192.
/
/
-->
128 128
064 192
032 224
016 240
008 248
004 252
002 254
001 255