Network Classes and Subnetting,
Troubleshooting
Lecture 28-30 (Theory)
Department of Computer Science and Engineering,
Chitkara University, Punjab
Prepared by:
Dr. Suvarna Sharma
Computer Networks
Index
1. Logical Addressing
2. Classful Addressing
3. Hierarchy of IPv4 Addresses
4. Network Classes (A,B,C,D,E)
5. Subnetting
Computer Networks 2
Logical Addressing
• Network Addressing is one of the major responsibilities of the network layer.
• Network addresses are always logical, i.e., software-based addresses.
• A host is also known as end system that has one link to the network. The
boundary between the host and link is known as an interface. Therefore, the host
can have only one interface.
• A router is different from the host in that it has two or more links that connect to
it. The boundary between the router and link is known as an interface, and the
router can have multiple interfaces, one for each of its links. Each interface is
capable of sending and receiving the IP packets, so IP requires each interface to
have an address.
• Each IP address is 32 bits long, and they are represented in the form of "dot-
decimal notation" where each byte is written in the decimal form, and they are
separated by the period. An IP address would look like 193.32.216.9 where 193
represents the decimal notation of first 8 bits of an address, 32 represents the
decimal notation of second 8 bits of an address, and so on.
Computer Networks 3
Logical Addressing (contd.)
Figure 1: Router and IP Addressing
Computer Networks 4
Logical Addressing (contd.)
• In the Figure 1, a router has three interfaces labeled as 1, 2 & 3 and each router
interface contains its own IP address.
• Each host contains its own interface and IP address.
• All the interfaces attached to the LAN 1 is having an IP address in the form of
223.1.1.xxx, and the interfaces attached to the LAN 2 and LAN 3 have an IP
address in the form of 223.1.2.xxx and 223.1.3.xxx respectively.
• Each IP address consists of two parts. The first part (first three bytes in IP
address) specifies the network and second part (last byte of an IP address)
specifies the host in the network.
Computer Networks 5
IPv4 ADDRESSES
An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the
Internet.
Each computer in a TCP/IP network must be given a unique identifier, or IP address.
This address, which operates at Layer 3, allows one computer to locate another computer on a network.
An address space is the total number of addresses used by the protocol.
The address space of IPv4 is 232 or 4,294,967,296 (more than 4 billion).
If a device operating at the network layer has m connections to the internet, it needs to have m addresses. E.g.: router
Computer Networks 6
IPv4 ADDRESSES (contd.)
Figure 2: Dotted-decimal notation and binary notation for an IPv4 address
Computer Networks 7
Example
Change the following IPv4 addresses from dotted-decimal notation to binary notation.
Solution
We replace each decimal number with its binary equivalent.
Computer Networks 8
Classful Addressing
An IP address is 32-bit long. An IP address is divided into sub-classes:
• Class A
• Class B
• Class C
• Class D
• Class E
An IP address is divided into two parts:
• Network ID: It represents the number of networks.
• Host ID: It represents the number of hosts.
Computer Networks 9
Classful Addressing (contd.)
In the diagram, we observe that each class have a specific range of IP
addresses. The class of IP address is used to determine the number of
bits used in a class and number of networks and hosts available in the
class.
Figure 3: Classful Addressing
Computer Networks 10
Classful Addressing (contd.)
Figure 4: Finding the classes in binary and dotted-decimal notation
Computer Networks 11
Classful Addressing (contd.)
Figure 5: Networks and Hosts in classes
Class A
• In Class A, an IP address is assigned to those networks that contain a large
number of hosts.
• The network ID is 8 bits long.
• The host ID is 24 bits long.
• In Class A, the first bit in higher order bits of the first octet is always set to 0 and
the remaining 7 bits determine the network ID. The 24 bits determine the host
ID in any network.
• The total number of networks in Class A = 27 = 128 network address
• The total number of hosts in Class A = 224 - 2 = 16,777,214 host address
Computer Networks 13
Class B
• In Class B, an IP address is assigned to those networks that range from small-
sized to large-sized networks.
• The Network ID is 16 bits long.
• The Host ID is 16 bits long.
• In Class B, the higher order bits of the first octet is always set to 10, and the
remaining14 bits determine the network ID. The other 16 bits determine the
Host ID.
• The total number of networks in Class B = 214 = 16384 network address
• The total number of hosts in Class B = 216 - 2 = 65534 host address
Computer Networks 14
Class C
• In Class C, an IP address is assigned to only small-sized networks.
• The Network ID is 24 bits long.
• The host ID is 8 bits long.
• In Class C, the higher order bits of the first octet is always set to 110, and the
remaining 21 bits determine the network ID. The 8 bits of the host ID determine
the host in a network.
• The total number of networks = 221 = 2097152 network address
• The total number of hosts = 28 - 2 = 254 host address
Computer Networks 15
Class D
• In Class D, an IP address is reserved for multicast addresses. It does not possess
subnetting.
• The higher order bits of the first octet is always set to 1110, and the remaining
bits determines the host ID in any network.
Computer Networks 16
Class E
• In Class E, an IP address is used for the future use or for the research and
development purposes. It does not possess any subnetting. The higher order bits
of the first octet is always set to 1111, and the remaining bits determines the host
ID in any network.
Computer Networks 17
Classful Addressing
A block in class A address is too large for almost any organization. It means that most of the IP addresses in class A were wasted.
A block in class B is also very large.
A block in class C is probably too small for many organizations.
Class D addresses were designed for multicasting. Each IP address in this class is used to define one group of hosts on the Internet. The Internet
authorities wrongly predicted a need of 268,435,456 groups. This never happened and many IP addresses were wasted.
Class E IP addresses were reserved for future use; only a few were used, resulting in another waste of IP addresses
Computer Networks 18
Two level hierarchy in an IPv4 address
Leftmost n bits (prefix) define the network id and,
The right most 32-n (suffix) bits define the host id.
The prefix is common to all devices in the network, suffix changes from one device to another.
Computer Networks 19
Netid and Hostid:
• This concept does not apply to class D and E.
• For class A, one byte defines netid, and three bytes define hostid.
• In class B, two bytes define the netid, and two bytes define the hostid.
• In class C, three bytes define the netid , and one byte defines the hostid.
Computer Networks 20
Network Masks
Mask:
The concept does not apply to classes D and E.
The mask can help us find netid and hostid.
The last column shows the mask in the form /n, where n can be 8,16, or 24. This
notation is called slash notation or Classless Interdomain Routing (CIDR) notation.
Figure 6: Default masks for classful addressing
Computer Networks 21
Network Masks (Contd.)
An IP address on a Class A network that has not been subnetted would have an address/mask
pair similar to: 10.20.15.1 255.0.0.0.
In order to see how the mask helps you identify the network and node parts of the address,
convert the address and mask to binary numbers.
10.20.15.1 = 00001010.00010100.00001111.00000001
255.0.0.0 = 11111111.00000000.00000000.00000000
Once you have the address and the mask represented in binary, then identification of the
network and host ID is easier. Any address bits which have corresponding mask bits set to 1
represent the network ID. Any address bits that have corresponding mask bits set to 0 represent
the node ID.
10.20.15.1 = 00001010.00010100.00001111.00000001
255.0.0.0 = 11111111.00000000.00000000.00000000
--------------------------------------------------
net id | host id
netid = 00001010 = 10
hostid = 00010100.00001111.00000001 = 20.15.1
Computer Networks 22
Rules for assigning Host ID:
The Host ID is used to determine the host within any network. The Host ID is assigned
based on the following rules:
• The Host ID must be unique within any network.
• The Host ID in which all the bits are set to 0 cannot be assigned as it is used to
represent the network ID of the IP address.
• The Host ID in which all the bits are set to 1 cannot be assigned as it is reserved for
the multicast address.
Computer Networks 23
Rules for assigning Network ID:
If the hosts are located within the same local network, then they are assigned with the
same network ID. The following are the rules for assigning Network ID:
• The network ID cannot start with 127 as 127 is used by Class A.
• The Network ID in which all the bits are set to 0 cannot be assigned as it is used to
specify a particular host on the local network.
• The Network ID in which all the bits are set to 1 cannot be assigned as it is reserved
for the multicast address.
Computer Networks 24
Figure 7: Number of blocks and block size in classful IPv4 addressing
Computer Networks 25
Class Higher NET ID HOST No. of No. of Range
bits bits ID bits network hosts per
s network
A 0 8 24 27 224 0.0.0.0 to
127.255.255.255
B 10 16 16 214 216 128.0.0.0 to
191.255.255.255
C 110 24 8 221 28 192.0.0.0 to
223.255.255.255
D 1110 Not Not Not Not 224.0.0.0 to
defined defined defined defined 239.255.255.255
E 1111 Not Not Not Not 240.0.0.0 to
defined defined defined defined 255.255.255.255
Computer Networks 26
Classless Addressing
Classless Addressing is one of the IP(Internet Protocol) address classifications. IP addresses are unique and universal. No two hosts will simultaneously have
the same IP address in the world. The most common use of the classless addressing system Or Classless interdomain routing (CIDR) for actually addressing is
to combine two or more class C networks to create a /23 or /22 Supernet.
To overcome address depletion and give Internet access to more organizations, classless addressing was designed and implemented.
In this scheme, there are no classes but the addresses are still granted in blocks.
Number of Addresses in a Block
There is only one condition on the number of addresses in a block; it must be a power of
2 (2, 4, 8, ...).
• A household may be given a block of 2 addresses.
• A small business may be given 16 addresses.
• A large organization may be given 1024 addresses.
Computer Networks 27
Classless Addressing (Contd.)
Beginning Address
The beginning address must be evenly divisible by the number of addresses.
• For example, if a block contains 4 addresses, the beginning address must be divisible
by 4.
• If the block has less than 256 addresses, we need to check only the rightmost byte.
• If it has less than 65,536 addresses, we need to check only the two rightmost bytes,
and so on.
Computer Networks 28
Examples
Which of the following can be the beginning address of a block that contains 16
addresses?
205.16.37.32
190.16.42.44
17.17.33.80
123.45.24.52
Examples
Which of the following can be the beginning address of a block that contains 16
addresses?
205.16.37.32
190.16.42.44
17.17.33.80
123.45.24.52
Solution
The address 205.16.37.32 is eligible because 32 is divisible by16.
The address 17.17.33.80 is eligible because 80 is divisible by 16.
Examples
Which of the following can be the beginning address of a block that contains 1024
addresses?
205.16.37.32
190.16.42.0
17.17.32.0
123.45.24.52
Examples
Which of the following can be the beginning address of a block that contains 1024
addresses?
205.16.37.32
190.16.42.0
17.17.32.0
123.45.24.52
Solution
To be divisible by 1024, the rightmost byte of an address should be 0 and the second
rightmost byte must be divisible by 4. Only the address 17.17.32.0 meets this
condition.
Subnetting
• If an organization was granted a large block in class A or B, it could divide the
addresses into several contiguous groups and assign each group to smaller
networks (called subnets).
• Subnetting increases the number of 1s in the mask.
Computer Networks 33
Supernetting
• The size of a class C block with a maximum number of 256 addresses did not
satisfy the needs of most organizations.
• In supernetting, an organization can combine several class C blocks to create a
larger range of addresses.
• In other words, several networks are combined to create a super network or
supernet.
• E.g. an organization that needs 1000 addresses can be granted four contiguous
class C blocks.
• Supernetting decreases the number of 1s in the mask.
• E.g. if an organization is given four class C blocks, the mask changes from /24
to /22.
• Classless addressing eliminated the need for supernetting.
Computer Networks 34
Address Blocks
In classless addressing, when an entity small or large, needs to be connected to the Internet, it is granted a block of addresses. The size of the block varies
based on the need of the organization.
Restriction-
1. The addresses in a block must be contiguous.
2. The no of addresses in a block must be a power of 2.
3. The first address must be evenly divisible by the number of addresses.
Computer Networks 35
Example
Figure (on next slide) shows a block of addresses, in both binary and dotted-decimal notation, granted to a small business that needs 16 addresses.
We can see that the restrictions are applied to this block. The addresses are contiguous.
4
The number of addresses is a power of 2 (16 = 2 ), and the first address is divisible by 16.
The first address, when converted to a decimal number, is 3,440,387,360, which when divided by 16 results in 215,024,210.
Computer Networks 36
Example (contd.)
Figure 8: A block of 16 addresses granted to a small organization
Computer Networks 37
In IPv4 addressing, a block of
addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the addresses and the /n defines the mask.
Computer Networks 38
The first address in the block can be found by setting the rightmost
32 − n bits to 0s.
Computer Networks 39
Example
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the first address in the block?
Solution:
The block of addresses 205.16.37.39/28 represents a subnet with a subnet mask of 28 bits.
To determine the first and last addresses in the block, we need to convert the subnet mask to its binary representation and perform some calculations.
The subnet mask 28 means that the first 28 bits of the IP address represent the network portion, and the remaining 4 bits are available for host addresses.
Converting the subnet mask 28 to binary results in 32 bits with the first 28 bits set to 1 and the last 4 bits set to 0:
11111111.11111111.11111111.11110000
To calculate the first address, we perform a logical AND operation between the given address (205.16.37.39) and the subnet mask:
Address: 11001101.00010000.00100101.00100111
Subnet Mask: 11111111.11111111.11111111.11110000
AND Operation: 11001101.00010000.00100101.00100000
The result of the AND operation gives us the network address, which is 205.16.37.32.
Therefore, the first address in the block is 205.16.37.32.
Computer Networks 40
Network Address:
• The first address is called the network address and defines the
organization network
• First address is used as the network address that represents the
organization to the rest of the world.
Computer Networks 41
The last address in the block can be found by setting the rightmost
32 - n bits to 1s.
Computer Networks 42
Example
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the last address in the block?
Solution:
To calculate the last address, we need to find the highest possible host address within the block. Since we have 4 bits available for host addresses (2^4 = 16),
the highest host address is obtained by setting all 4 bits to 1:
Address: 11001101.00010000.00100101.00100111
Subnet Mask: 11111111.11111111.11111111.11110000
OR Operation: 11001101.00010000.00100101.00101111
The result of the OR operation gives us the broadcast address, which is 205.16.37.47. However, the last address in the block is always reserved as the
broadcast address, so the actual last usable address is the one before the broadcast address. Therefore, the last address in the block is 205.16.37.46.
Computer Networks 43
The number of addresses in the block can be found by using the formula
32-n
2 .
Computer Networks 44
Three level of Hierarchy: subnetting
An organization that is granted a large block of addresses may want to create clusters of networks (subnets) and divide the addresses between the different
subnets.
The rest of the world still sees the organization as one entity; however internally there are several subnets.
All messages are sent to the router that connects the organization to the rest of the Internet; the router routes the message to the appropriate subnets.
The organization has its own mask and each subnet must also have its own.
Computer Networks 45
Example
Suppose an organization is given the block 17.12.40.0/26, which contains 64 IP addresses.
The organization has three offices and needs to divide the addresses into three subblocks of
32,16, and 16 IP addresses.
We can find the new masks as
1. Suppose the mask for the first subnet is n1 then 232-n1 must be 32, which means n1=27.
2. Suppose the mask for the second subnet is n 2 then 232-n2 must be 16, which means
n1=28.
3. Suppose the mask for the third subnet is n3 then 232-n3 must be 16, which means n1=28.
Computer Networks 46
Example (contd.)
Figure 9: Configuration and addresses in a subnetted network
Computer Networks 47
Three-level hierarchy in an
IPv4 address
Figure 10: Three-level hierarchy in an IPv4 address
Computer Networks 48
Example
An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of
customers as follows:
a. The first group has 64 customers; each needs 256 addresses.
b. The second group has 128 customers; each needs 128 addresses.
c. The third group has 128 customers; each needs 64 addresses.
Design the subblocks and find out how many addresses are still available after these allocations.
Computer Networks 49
Example (contd.)
Solution
Group 1
For this group, each customer needs 256 addresses. This means that 8 (log 2 256) bits are needed to define each host. The prefix length is then 32 − 8 = 24.
The addresses are
50
Example (contd.)
Group 2
For this group, each customer needs 128 addresses. This means that 7 (log 2 128) bits are needed to define each host. The prefix length is then 32 − 7 = 25.
The addresses are
51
Example (contd.)
Group 3
For this group, each customer needs 64 addresses. This means that 6 (log264) bits are needed to each host. The prefix length is then 32 − 6 = 26. The
addresses are
Number of granted addresses to the ISP: 65,536
Number of allocated addresses by the ISP: 40,960
Number of available addresses: 24,576
52
Example (contd.)
Figure 11: An example of address allocation and distribution by an ISP
53
Practice Questions
Change the following IPv4 addresses from binary notation to dotted-decimal notation.
54
Practice Questions
Find the error, if any, in the following IPv4 addresses.
55
Practice Questions
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
56
Practice Questions
A block of addresses is granted to a small organization. we know that one of the addresses is 205.16.37.39/28. what is the (the first address, the last
address, and total number of addresses in the block?
Computer Networks 57
Practice Questions
The block of addresses 205.16.37.39/28 represents a subnet with a subnet mask of 28 bits.
To determine the first and last addresses in the block, we need to convert the subnet mask to its binary
representation and perform some calculations.
The subnet mask 28 means that the first 28 bits of the IP address represent the network portion, and the
remaining 4 bits are available for host addresses.
Converting the subnet mask 28 to binary results in 32 bits with the first 28 bits set to 1 and the last 4 bits
set to 0:
11111111.11111111.11111111.11110000
To calculate the first address, we perform a logical AND operation between the given address
(205.16.37.39) and the subnet mask:
Address: 11001101.00010000.00100101.00100111
Subnet Mask: 11111111.11111111.11111111.11110000
AND Operation: 11001101.00010000.00100101.00100000
The result of the AND operation gives us the network address, which is 205.16.37.32. Therefore, the first
address in the block is 205.16.37.32.
Computer Networks 58
Practice Questions
To calculate the last address, we need to find the highest possible host address within the
block.
Since we have 4 bits available for host addresses (2^4 = 16), the highest host address is
obtained by setting all 4 bits to 1:
Address: 11001101.00010000.00100101.00100111
Subnet Mask: 11111111.11111111.11111111.11110000
OR Operation: 11001101.00010000.00100101.00101111
The result of the OR operation gives us the broadcast address, which is 205.16.37.47. However,
the last address in the block is always reserved as the broadcast address, so the actual last
usable address is the one before the broadcast address. Therefore, the last address in the block
is 205.16.37.46.
The total number of addresses in the block can be calculated by taking the number of
available host addresses, which is 2^4 = 16, and subtracting 2 (one for the network address and
one for the broadcast address). Therefore, the total number of addresses in the block is 16 - 2
= 14.
Computer Networks 59