BSCS_CN_W22_Week11
BSCS_CN_W22_Week11
Week # 11
CS & IT Department
The University of Lahore
Powerpoint Templates
1
What is Subnet Mask?
IPv4 address has two components, the network part and the host part.
Subnet mask is a 32 bit number where all the bits of the network
part are represented as 1 and all the bits of the host part are
represented as 0.
For example, for a Class C Network, 192.168.10.0, the address part
and the subnet mask is 255.255.255.0
2
Subnet and Subnetting
A logical, visible subdivision of an IP network is called
subnet or subnetwork.
It is created by dividing the host identifier
Subnetting is the practice of dividing a network into two
or more networks.
In subnetting, a class A or class B or class C block is
divided into several subnets (each subnet with larger
prefix length than the original network).
For example, divide the class A into four subnets,
then each subnet will have prefix length as 10 (take two
bits from host id part in order to obtain subnets).
3
Subnetting
Subnetting is done by taking the bits from host part and
adding it to the network part
Remember the following [as already covered]
If all the bits in the host part are "0", that represents the
network id (network address)
If all the bits in the host part are "0" except the last bit
(RMb), it is the first usable IPv4 address
If all the bits in the host part are "1" except the last bit
(RMb), it is the last usable IPv4 address
If all the bits in the host part are "1", that represents the
broadcast
4
Class C – 1 bit subnetting
Consider class c network 192.168.10.0 (subnet mask is 255.255.255.0)
If we include one bit from the host part to the network part, the
subnet mask changes into 255.255.255.128.
The single bit can have two values in last octet, either 0 or 1 (so we
can get two subnets with a single bit subnetting)
11000000.10101000.00001010.0 | 0000000
11111111.11111111.11111111.1 | 0000000
So the network 192.168.10.0 is divided into
two networks,
each network has 128 total addresses of
which 126 are usable
Thetwo are used in each subnet to represent the network
subnet mask for one bit subnetting is 255.255.255.128.
address and broadcast address. 5
Class C – 1 bit subnetting
SN No. Description Binaries Decimal
8
Class B – 1 bit subnetting
Consider class B network 172.16.0.0 (subnet mask is 255.255.0.0)
If we include one bit from the host part to the network part, the
subnet mask changes into 255.255.128.0.
The single bit can have two values in last octet, either 0 or 1 (so we
can get two subnets with a single bit subnetting)
10101100.00010000.0 | 0000000.00000000
11111111.11111111.1 | 0000000.00000000
So the network 172.16.0.0 is divided into
two networks,
each network has 32768 total addresses
of which 32766 are
usable
two are used in each subnet to represent the network
address and broadcast address. 9
Class B – 1 bit subnetting
SN No. Description Binaries Decimal
1 Network
10101100.00010000.00000000.00000000 172.16.0.0
Address
Broadcast
Address 10101100.00010000.01111111.11111111 172.16.127.255
2 Network
10101100.00010000.10000000.00000000 172.16.128.0
Address
Broadcast
Address 10101100.00010000.11111111.11111111 172.16.255.255
10
Class B – 2 bit subnetting
SN No. Description Binaries Decimal
1 NA 10101100.00010000.00000000.00000000 172.16.0.0
1st 10101100.00010000.00000000.00000001 172.16.0.1
Last 10101100.00010000.00111111.11111110 172.16.63.254
BA 10101100.00010000.00111111.11111111 172.16.63.255
2 NA 10101100.00010000.01000000.00000000 172.16.64.0
1st 10101100.00010000.01000000.00000001 172.16.64.1
Last 10101100.00010000.01111111.11111110 172.16.127.254
BA 10101100.00010000.01111111.11111111 172.16.127.255
3 NA 10101100.00010000.10000000.00000000 172.16.128.0
1st 10101100.00010000.10000000.00000001 172.16.128.1
Last 10101100.00010000.10111111.11111110 172.16.191.254
BA 10101100.00010000.10111111.11111111 172.16.191.255
4 NA 10101100.00010000.11000000.00000000 172.16.192.0
1st 10101100.00010000.11000000.00000001 172.16.192.1
Last 10101100.00010000.11111111.11111110 172.16.192.254
11
BA 10101100.00010000.11111111.11111111 172.16.192.255
Class A – 1 bit
subnetting
Consider class A network 10.0.0.0 (subnet mask is 255.0.0.0)
If we include one bit from the host part to the network part,
the
subnet mask changes into 255.128.0.0.
The single bit can have two values in second octet, either 0 or
1 (so we can get two subnets with a single bit subnetting)
00001010.0 | 0000000.00000000.00000000
11111111.1 | 0000000.00000000.00000000
The network 10.0.0.0 is divided into two networks, each
network has 8388608 total IPv4 Addresses and 8388606
usable IPv4 Addresses (two IPv4 Addresses are used in each
subnet to represent the network address and the directed
broadcast address).
12
Class A – 1 bit
SN No
subnetting
Description Binaries Decimal
13
Class A – 2 bit
N No Description Binaries Decimal
subnetting
Network Address 00001010.00000000.00000000.00000000 10.0.0.0
First IPv4 address 00001010.00000000.00000000.00000001 10.0.0.1
1
Last IPv4 address 00001010.00111111.11111111.11111110 10.63.255.254
Broadcast Address 00001010.00111111.11111111.11111111 10.63.255.255
Network Address 00001010.01000000.00000000.00000000 10.64.0.0
First IPv4 address 00001010.01000000.00000000.00000001 10.64.0.1
2
Last IPv4 address 00001010.01111111.11111111.11111110 10.127.255.254
Broadcast Address 00001010.01111111.11111111.11111110 10.127.255.255
Network Address 00001010.10000000.00000000.00000000 10.128.0.0
First IPv4 address 00001010.10000000.00000000.00000001 10.128.0.1
3
Last IPv4 address 00001010.10111111.11111111.11111110 10.191.255.254
Broadcast Address 00001010.10111111.11111111.11111111 10.191.255.255
Network Address 00001010.11000000.00000000.00000000 10.192.0.0
First IPv4 address 00001010.11000000.00000000.00000001 10.192.0.1
4
Last IPv4 address 00001010.11111111.11111111.11111110 10.255.255.254 14
Example: Route 193.205.102.36
Classless Addressing
Classless addressing is a short term solution to solve
the address depletion problem
Uses the same address space but change the distribution
of addresses to provide a fair share to each organization.
Still uses the IPv4 addresses (class privilege was
removed from the distribution)
The long-range solution already devised called IPv6
The larger address space is obtained by increasing the
length of IP addresses (128 bits)
It means that format of IP packets need to be changed
16
Classless Addressing
In classless addressing, variable-length blocks are
assigned that belong to no class.
the entire address space is divided into blocks of
different
sizes.
Classless addressing
uses a variable number of bits for the network and
host portions of the address.
treats the IP address as a 32 bit stream of ones and
zeroes,
where the boundary between network and host
portions can fall anywhere between bit 0 and bit 31.
17
Classless Addressing
How to find the prefix length if an address is given?
As prefix length is not inherent in the address
Need to separately give the length of the prefix
So, Prefix length is added to the address, separated
by a slash
The notation is informally referred to as slash
notation and formally as classless
interdomain routing or CIDR
18
Classless Addressing
The network portion of an IP address is determined by
how many 1's are in the subnet mask.
A Subnet Mask is used to divide the IP address
into network and host addresses
A mask is a 32-bit number in which the n leftmost bits are
Is and the 32 - n rightmost bits are 0s
In x.y.z.t/n
x.y.z.t defines one of the addresses and
the /n defines the mask
19
Tabl Prefix lengths
e
21
Example 2: What is the first address in the block if one
of the addresses is 140.120.84.24/20?
Answer: The first address is 140.120.80.0/20
22
Example 3: Find the number of
addresses in the block if one of the addresses is
140.120.84.24/20.
23
Example 4: find the first and last address in the block
if one of the addresses is 140.120.84.24/20.
0 24
0
Example 5: Find the block if one of
the addresses is 190.87.140.202/29.
Solution: To find the first address, we notice that the mask (/29)
has five 1s in the last byte. So write the last byte as powers of 2 and
retain only the leftmost five as shown below:
202 ➡ 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0
The leftmost 5 numbers are ➡ 128 + 64 + 0 + 0 + 8
The first address is 190.87.140.200/29
The number of addresses is 232−29 or 8. To find the last address,
use the complement of the mask. The mask has twenty-nine 1s; the
complement has three 1s. The complement is 0.0.0.7. Add this to
the first address to get 190.87.140.207/29. So, the first address is
190.87.140.200/29, the last address is 190.87.140.207/29. There are
only 8 addresses in this block. 25
Previous Example: Network Configuration
27
Variable Length Subnet Mask (VLSM)
VLSM is a way of further subnetting a subnet.
VLSM allows us to use more than one subnet mask within the
same network address space.
29
Two-level hierarchy in an IPv4 address
FIRST DIVISION
Divide into two networks equally with 128 addresses (126
usable) using subnet mask 255.255.255.128
Two subnets each with 128 addresses
1. 192.168.10.0/25 [255.255.255.128]
11000000.10101000.00001010.00000000 [in binary]
11111111.11111111.11111111.10000000 [subnet mask]
2. 192.168.10.128/25 [255.255.255.128]
11000000.10101000.00001010.10000000
11111111.11111111.11111111.10000000 [subnet mask]
31
Variable Length Subnet Mask (VLSM)
SECOND DIVISION
Divide second subnet 192.168.10.128/25 (obtained from first
devision) again into two networks, each with 64 addresses (62
usable) using subnet mask 255.255.255.192
Two subnets each with 64 addresses
1. 192.168.10.128/26 [255.255.255.192]
11000000.10101000.00001010.10000000 [in binary]
11111111.11111111.11111111.11000000 [subnet mask]
2. 192.168.10.192/26 [255.255.255.192]
11000000.10101000.00001010.11 000000
11111111.11111111.11111111.11000000
[subnet mask]
32
Variable Length Subnet Mask (VLSM)
THIRD DIVISION
Divide second subnet 192.168.10.192/26 (obtained from second
devision) again into two networks, each with 32 addresses (30
usable) using subnet mask 255.255.255.224
Two subnets each with 64 addresses
1. 192.168.10.192/27 [255.255.255.224]
11000000.10101000.00001010.11000000 [in binary]
11111111.11111111.11111111.11100000 [subnet mask]
2. 192.168.10.224/27 [255.255.255.224]
11000000.10101000.00001010.11100000
11111111.11111111.11111111.11100000
[subnet mask]
Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each host.
The prefix length is then 32 − 7 = 25. The addresses are
Example (continued)
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
When the option field is at its maximum size, the value of this
field is 15 (15 x 4 = 60).
IPv4 datagram format
Total length:
A 16-bit field that defines the total length (header plus
data) in bytes (limited to 65,535 (216 - 1) bytes).
Length of data =total length - header length
The total length is 40 bytes, which implies that the packet is carrying
20 bytes of data (40 − 20).
Maximum transfer unit
(MTU)
21.52
IPv6
ADDRESSES
IPv6
ADDRESSES
Despite all short-term solutions, address depletion is
still a long-term problem for the Internet. This and other
problems in the IP protocol itself have been the
motivation for IPv6.
Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find how
many 0s we need to replace the double colon.