Data Communication and Computer Networks
INSY3071
Instructor: Tsegaye Berhanu
Chapter 6
Introduction to IP Addressing
and Subnetting
Objective
In this chapter, you will learn to:
Explain the structure IP addressing
convert between 8-bit binary and decimal numbers.
classify by type and describe how it is used in the
network.
Determine the network portion of the host address and
explain the role of the subnet mask in dividing networks.
Given IPv4 addressing information and design criteria,
calculate the appropriate addressing components.
3 Data Communication and Computer Networks
IP Addressing
Each device on a network must be uniquely
identified.
At the Network layer, the packets of the
communication need to be identified with the source
and destination addresses of the two end systems
With IPv4, this means that each packet has a 32-bit
source address and a 32-bit destination address in the
Layer 3 header.
4 Data Communication and Computer Networks
IP Addressing
5 Data Communication and Computer Networks
IP Addressing
These addresses are used in the data network as
binary patterns (0 and 1). Inside the devices, digital
logic is applied for their interpretation
For us in the human network, a string of 32 bits is
difficult to interpret and even more difficult to
remember.
Therefore, IPv4 addresses are represented using
dotted decimal format.
6 Data Communication and Computer Networks
IP Address
The address space in a protocol that uses N-bits to
define an Address is 2n
The address space of IPv4 is
232 or 4,294,967,296.
IPv6 addresses are 128 bits in length and are made up
of hexadecimal characters.
In IPv6, addresses are expressed as a series of eight 4-
character hexadecimal numbers, which represent 16
bits each.
2001:0db8:85a3:0000:0000:8a2e:0370:7334
7 Data Communication and Computer Networks
Dotted Decimal
Binary patterns representing IPv4 addresses are
expressed as dotted decimals by separating each byte of
the binary pattern, called an octet, with a dot.
It is called an octet because each decimal number
represents one byte or 8 bits.
For example, the address:
10101100 00010000 00000100 00010100
is expressed in dotted decimal as:
[Link]
8 Data Communication and Computer Networks
Network Address and Host Address
Some portion of the high-order bits represents
the network address.
At Layer 3, a network is a group of hosts that
have identical bit patterns in the network
address portion of their addresses.
All 32 bits define the IPv4 host address, there
are a variable number of bits that are called the
host portion of the address.
9 Data Communication and Computer Networks
Cont’d
The number of bits used in this host portion
determines the number of hosts that we can have
within the network.
[Link]
11000000 10101000 00001010 00000001
The computer using this network is on network address:
[Link]
10 Data Communication and Computer Networks
Binary to Decimal &
Decimal to Binary Conversion
Positional Notation
Positional notation means that a digit represents
different values depending on the position it occupies.
Using positional notation in the base 10 number
system, 245 represents:
245 = (2 * 10 ) + (4 * 10 ) + (5 * 10 )
or
245 = (2 * 100) + (4 * 10) + (5 * 1)
11 Data Communication and Computer Networks
Cont’d
Using positional notation in the base 2 number system,
245 represents:
2 2 2 2 2 2 2 2
128 64 32 16 8 4 2 1
The base 2 numbering system only has two digits: 0
and 1.
A byte is interpreted as a decimal number, we have the
quantity that position represents if the digit is a 1 and
we do not have that quantity if the digit is a 0.
12 Data Communication and Computer Networks
13 Data Communication and Computer Networks
Cont’d
14 Data Communication and Computer Networks
Types of IP addresses
Within the address range of each IPv4 network, we have
three types of addresses:
Network address- The address by
which we refer to the network
Broadcast address- A special address
used to send data to all hosts in the
network
Host addresses- The addresses assigned
to the end devices in the network
15 Data Communication and Computer Networks
Cont’d
Red Network Portion , Blue Host portion
Network Address: [Link]
00001010 00000000 00000000 00000000
Broadcast Address: [Link]
00001010 00000000 00000000 11111111
Host Address: [Link]
00001010 00000000 00000000 00000001
[Link] [Link]
[Link] [Link]
16 Data Communication and Computer Networks
Network Addresses
The network address is a standard way to refer to a
network. For example, we could refer to the network
shown in the figure as "the [Link] network."
The network is the first network.
All hosts in the [Link] network will have the same
network bits.
Within the IPv4 address range of a network, the lowest
address is reserved for the network address.
This address has a 0 for each host bit in the host
portion of the address.
17 Data Communication and Computer Networks
Broadcast Address
Broadcast address is a special address for each network that
allows communication to all the hosts in that network.
To send data to all hosts in a network, a host can send a
single packet that is addressed to the broadcast address of
the network.
The broadcast address uses the highest address in the
network range. This is the address in which the bits in the
host portion are all 1s.
For the network [Link] with 24 network bits, the
broadcast address would be [Link]. This address is also
referred to as the directed broadcast.
18 Data Communication and Computer Networks
Host Addresses
Every end device requires a unique address to deliver a
packet to that host.
In IPv4 addresses, we assign the host address values
between the network address and the broadcast address
to the devices in that network.
19 Data Communication and Computer Networks
Network Prefixes
How do we know how many bits represent the network
portion and how many bits represent the host portion?
When we express an IPv4 network address, we add a
prefix length to the network address.
The prefix length is the number of bits in the address that
gives us the network portion.
For example, in [Link] /24, the /24 is the prefix
length - it tells us that the first 24 bits are the network
address. This leaves the remaining 8 bits, the last octet,
as the host portion
20 Data Communication and Computer Networks
Network Prefixes
The Subnet masks in [Link] /24 can also be
represented as [Link] or
11111111 11111111 11111111 00000000
which is equivalent to /24
Specify the network portion of an IPv4 address to the
network devices.
The subnet mask consists of 32 bits, just as the address
does, and uses 1s and 0s to indicate which bits of the
address are network bits and which bits are hosts bits.
21 Data Communication and Computer Networks
Calculating Network, Host and
Broadcast addresses
Given an [Link] /25
With a 25 bit prefix, the last 7 bits are host bits,
and the 25 bits are for the network bits
To represent the network address, all of these
host bits are '0’.
22 Data Communication and Computer Networks
Calculating Network, Host and
Broadcast addresses
Given the address [Link] /25
Network address:
10101100 00010000 00010100 00000000 thus [Link]
First host address:
10101100 00010000 00010100 00000001 thus [Link]
Last host address
10101100 00010000 00010100 01111110 thus [Link]
Broad Cast address:
10101100 00010000 00010100 01111111 thus [Link]
23 Data Communication and Computer Networks
Cont’d
How many hosts can be represented in this network
/24?
28-2 =126
The minus two is because one is for network address
and the other is for broadcast address.
Given the address [Link]/29 calculate the
BA,NA,HA and number of hosts represented?
24 Data Communication and Computer Networks
Classful IP Addressing
The designers of the Internet created classes of
networks based on network size.
Subdividing an IP address into a network and node
address is determined by the class designation of
one’s network.
25 Data Communication and Computer Networks
Classful Addressing
The 32 bit IP address is divided into five sub-classes. These are:
Class A addresses
Class B addresses
Class C addresses
Class D addresses
Class E addresses
26 Data Communication and Computer Networks
Class A Addresses
The designers of the IP address scheme said that the first bit of the first
byte in a Class A network address must always be off, or 0.
This means a Class A address must be between 0 and 127, inclusive.
First Octet Range in Binary= 00000000 - 01111111
Range in Decimal = 0-127
A Class A network is defined in the first octet between 0 and 127,
Network HOST HOST HOST
Default Subnet [Link]
The 24 bits of host ID are used to determine the host in any network.
27-2= 126 network ID (Here 2 address is subtracted because [Link] and
127.x.y.z are special address. )
224 – 2 = 16,777,214 host ID
IP addresses belonging to class A ranges from 1.x.x.x – 126.x.x.x
27 Data Communication and Computer Networks
Class B Addresses
The first bit of the first byte must always be turned on, but the
second bit must always be turned off.
If you turn the other 6 bits all off and then all on, you will find the
range for a Class B network:
First Octet
10000000 = 128
10111111 = 191
A Class B network is defined when the first byte is configured from
128 to 191.
Network Network HOST HOST
Default Subnet [Link]
214 = 16384 network address
216 – 2 = 65534 host address
28 Data Communication and Computer Networks
Class C Addresses
The first 2 bits of the first octet as always turned on, but
the third bit can never be on.
Following the same process as the previous classes, convert
from binary to decimal to find the range.
First Octet
11000000 = 192
11011111 = 223
NETWORK NETWORK NETWORK HOST
Default Subnet [Link]
221 = 2097152 network address
28 – 2 = 254 host address
29 Data Communication and Computer Networks
Show that Class A has
231 = 2,147,483,648 addresses
50% of the IP addresses are used by class A
Calculate the total IP address generated in Class B
2n n=?
Calculate the total IP address generated in Class C
2n n=?
30 Data Communication and Computer Networks
Class D and Class E
The addresses between 224 and 255 are reserved for
Class D and E networks.
Class D ranges from (224–239) is used for multicast
addresses
Class E ranges from (240–255) for scientific purposes.
31 Data Communication and Computer Networks
Finding the class in Binary notation
Finding the class in decimal notation
32 Data Communication and Computer Networks
Hosts for Classes of IP Addresses
Class A (24 bits for hosts) 224 - 2* = 16,777,214 maximum hosts
Class B (16 bits for hosts) 216 - 2* = 65,534 maximum hosts
Class C (8 bits for hosts) 28 - 2* = 254 maximum hosts
33 Data Communication and Computer Networks
Network id and Host id
34 Data Communication and Computer Networks
IP Addresses as Decimal Numbers
35 Data Communication and Computer Networks
IP Addresses as Decimal Numbers
1ST OCTET Highest Default
Order Bit
CLASS RANGE Format Subnet mask
HOB
A 1-126 0------- N.H.H.H [Link]
B 128-191 10------ N.N.H.H [Link]
C 192-223 110----- N.N.N.H [Link]
D 224-239 1110---- ------- -------
E 240-255 1111---- ------- -------
36 Data Communication and Computer Networks
Blocks in class A
Millions of class A addresses are wasted.
37 Data Communication and Computer Networks
Reserved IP addresses
Expressed in dotted decimal format, the IPv4 address
range is from:
[Link] to [Link]
Not all of these addresses can be used as host
addresses for communication.
38 Data Communication and Computer Networks
Experimental Addresses
Class E addresses reserved for special purposes is the
IPv4 experimental address range from:
[Link] to [Link]
Currently, these addresses are listed as reserved for
future use.
Currently, they cannot be used in IPv4 networks.
However, these addresses could be used for research or
experimentation.
39 Data Communication and Computer Networks
Multicast Addresses
Another major block of addresses (Class D) reserved for
special purposes is the IPv4 multicast address range:
[Link] to [Link]
The IPv4 multicast addresses [Link] to [Link]
are reserved link local addresses.
These addresses are to be used for multicast groups on a
local network.
A router connected to the local network should never
forward them.
A multicast address identifies a group of hosts sharing the
same address.
40 Data Communication and Computer Networks
Host Addresses
After accounting for the ranges reserved for
experimental addresses and multicast addresses, this
leaves an address range of [Link] to
[Link] that could be used for IPv4 hosts.
However, within this range are many addresses that
are already reserved for special purposes.
41 Data Communication and Computer Networks
Private Addresses
Although most IPv4 host addresses are public
addresses designated for use in the Internet, there
are blocks of addresses that are used in networks that
require limited or no Internet access.
These addresses are called private addresses.
[Link] to [Link]
[Link] to [Link]
[Link] to [Link]
42 Data Communication and Computer Networks
Private Addresses
Private addresses are set aside for use in private
networks.
The use of these addresses need not be unique among
outside networks.
Hosts that do not require access to the Internet at
large may make unrestricted use of private addresses.
Private IP address of a system is the IP address which
is used to communicate within the same network.
Using private IP data or information can be sent or
received within the same network.
43 Data Communication and Computer Networks
Public Addresses
The vast majority of the addresses in the IPv4 unicast
host range are public addresses.
Public IP address of a system is the IP address
which is used to communicate outside the network.
Public IP address is basically assigned by the ISP
(Internet Service Provider)
These addresses are designed to be used in the hosts
that are publicly accessible from the Internet.
44 Data Communication and Computer Networks
Loopback / localhost
One such reserved address is the IPv4 loopback
address [Link].
The loopback is a special address that hosts use to
direct traffic to themselves.
You can also ping the loopback address to test the
configuration of TCP/IP on the local host.
45 Data Communication and Computer Networks
Ex. Given the network address [Link], find
the class
the block
the range of the addresses
The 1st byte is between 128 and 191. Hence, Class B
The block has a netid of 132.21.
The addresses range from [Link] to
[Link].
46 Data Communication and Computer Networks
Subnet Mask
It determines which part of an IP address is the network
field and which part is the host field
Follow these steps to determine the subnet mask:
1. Express the subnetwork IP address in binary form.
2. Replace the network and subnet portion of the address with
all 1s.
3. Replace the host portion of the address with all 0s.
4. Convert the binary expression back to dotted-decimal
notation.
47 Data Communication and Computer Networks
Subnet Mask
Subnet mask in decimal = [Link]
48 Data Communication and Computer Networks
Subnet Mask
• A mask is a 32-bit binary number.
• The mask is ANDed with IP address to get the block address
(Network address)
Mask And IP address = Block Address
49 Data Communication and Computer Networks
AND operation
50 Data Communication and Computer Networks
Default mask and subnet mask
51 Data Communication and Computer Networks
Finding the Subnet Address
What is the subnetwork address if the destination address is
[Link] and the subnet mask is [Link]?
11001000 00101101 00100010 00111000
11111111 11111111 11110000 00000000
11001000 00101101 00100000 00000000
The subnetwork address is [Link].
AND
52 Data Communication and Computer Networks
1. [Link]/24
What is the subnet mask?
What is the network address?
2. [Link]/28
What is the subnet mask?
What is the network address?
What is the broadcast address?
53 Data Communication and Computer Networks
Subnetting
Subnetting allows you to create multiple logical
networks that exist within a single Class A, B, or C
network.
If you do not subnet, you are only able to use one
network from your Class A, B, or C network, which
is unrealistic.
What happens if you wanted to take one network
address and create six networks from it?
54 Data Communication and Computer Networks
Subnetting
The process of splitting a network into smaller
networks is called subnetting, and the smaller
networks thus formed are known as subnets
If you break a major network (Class A, B, or C)
into smaller subnetworks, it allows you to create a
network of interconnecting subnetworks.
In order to subnet a network, extend the subnet
mask using some of the bits from the host ID
portion of the address to create a subnetwork ID.
55 Data Communication and Computer Networks
Subnetting
Subnets are connected to the rest of the network
through address-resolving devices called routers.
Network address translation (NAT) is a method of
remapping one IP address space into another by
modifying network address information in the IP
header of packets while they are in transit across a
traffic routing device
Subnets can be freely assigned within the organization
Internally, subnets are treated as separate networks
Subnet structure is not visible outside the organization
56 Data Communication and Computer Networks
Advantages of Subnetting
Improves efficiency of IP addresses by not consuming an
entire address space for each physical network.
Reduces router complexity. Since external routers do not
know about subnetting, the complexity of routing tables at
external routers is reduced.
Reduced network traffic
Optimized network performance
This is a result of reduced network traffic.
Simplified management
It’s easier to identify and isolate network problems in a group
of smaller connected networks than within one gigantic
network
57 Data Communication and Computer Networks
How to create subnets
To create a subnet address, a network administrator
borrows bits from the original host portion and designates
them as the subnet field.
A network with no subnets will have one of these default
subnet mask values depending upon its class address.
However, when subnetting is implemented, the actual
subnet mask value is calculated to determine valid IP
addresses for hosts on a subnet.
This means fewer bits for hosts, so the more subnets, the
fewer bits available for defining hosts.
58 Data Communication and Computer Networks
Basic Idea of Subnetting
Split the host number portion of an IP address into a
subnet number and host number.
Result is a 3-layer hierarchy
network prefix host number
network prefix subnet number host number
extended network prefix
59 Data Communication and Computer Networks
Subnetting Example
[Link] /24 divide it into four networks
First Subnet
00 000000 = 0 The network (do this first)
00 000001 = 1 The first valid host
00 111110 = 62 The last valid host
00 111111 = 63 The broadcast address (do this second)
60 Data Communication and Computer Networks
Second Subnet
01 000000 = 64 The network
01 000001 = 65 The first valid host
01 111110 = 126 The last valid host
01 111111 = 127 The broadcast address
61 Data Communication and Computer Networks
Third Subnet
10 000000 = 128 The subnet address
10 000001 = 129 The first valid host
10 111110 = 190 The last valid host
10 111111 = 191 The broadcast address
62 Data Communication and Computer Networks
Fourth Subnet
11 000000 = 192 The subnet address
11 000001 = 193 The first valid host
11 111110 = 254 The last valid host
11 111111 = 255 The broadcast address
63 Data Communication and Computer Networks
Exercise 1:
Exercise 1:
You have a network that needs 29 subnets while
maximizing the number of host addresses available on
each subnet.
How many bits must you borrow from the host field to
provide the correct subnet mask?
64 Data Communication and Computer Networks
Exercise 2:
A company is granted the site address [Link]
(class C). The subnet mask is [Link].
1. How many subnets?
2. How many total hosts in each subnet?
3. What are the Network address for each subnet?
4. What are the range of valid hosts in each subnet?
5. What are the Broadcast address for each subnet?
65 Data Communication and Computer Networks
Exercise 3:
[Link]
[Link]
1. how many subnets?
2. how many hosts?
3. what are the network address of each subnet?
4. what are the broadcast address for each subnet?
5. what are the valid hosts?
66 Data Communication and Computer Networks
Exercise 4:
If an Ethernet port on a router were assigned an IP
address of [Link]/25, what would be the valid
subnet address of this host?
A.[Link]
B.[Link]
C.[Link]
D.[Link]
67 Data Communication and Computer Networks
Exercise 5:
If an Ethernet port on a router were assigned an IP
address of [Link]/25, what would be the valid
subnet address of this host?
A.[Link]
B.[Link]
C.[Link]
D.[Link]
68 Data Communication and Computer Networks
Exercise 6:
A company would like to break its Class B private IP
address [Link] into as many subnets as possible
provided that they can get at least 300 clients per
subnet. Find ranges of IP addresses for each subnet
and new mask.
69 Data Communication and Computer Networks
Exercise 7:
A company is granted the site address [Link] (class B).
The company needs 1000 subnets. Design the subnets.
70 Data Communication and Computer Networks