11/12/2022
CSC4304:
Computer Network Design
Subnets
Routing within an Organization
Subnet
Subnets are a subset of the entire
network
Networks can be divided into subnets
Subnets can be divided into subnets
Each subnet is treated as a separate
network
A subnet can be a WAN or LAN
1
11/12/2022
Subnets
Subnet 1 Subnet 2
Subnet 3 Subnet 4
Subnet Addresses
Typical (classed) IP addresses (e.g.
137.207.32.2) have two parts:
A network ID (e.g. 137.207.0.0)
A host ID (e.g. 0.0.32.2)
A subnetted network will divide the IP
address differently
Part of the host ID will be used to specify the
subnet number
The network ID and subnet portion of the host
ID can be considered the subnet ID
2
11/12/2022
Subnet Addresses
For example, if we want to divide a
network into 4 subnets, we can use
the following scheme:
4 subnets can be represented with 2
bits (22 = 4)
For a class B address, which already
uses 16 bits for the network portion,
the address would use 18 bits for the
subnet portion
External Routing with Subnets
Subnetting is transparent outside
an organization
e.g. If subnetting is used in the
University, routers outside the
University will not consider subnetting
at all
Thus, subnetting is only relevant within
an organization
3
11/12/2022
Internal Routing with Subnets
When a packet enters a network
with subnetting, the routers will
behave differently
A route may use the subnet ID
(network portion + subnet portion,
followed by zeroes) to determine which
route to take
What is subnetting?
Network Network Host Host
172 16 0 0
Network Network Subnet Host
Subnetting is the process of borrowing bits from the HOST bits, in
order to divide the larger network into small subnets.
Subnetting does NOT give you more hosts, but actually costs you
hosts.
You lose two host IP Addresses for each subnet, and perhaps one for
the subnet IP address and one for the subnet broadcast IP address.
You lose the last subnet and all of it’s hosts’ IP addresses as the
broadcast for that subnet is the same as the broadcast for the
network.
In older networks, you would have lost the first subnet, as the subnet
IP address is the same as the network IP address. (This subnet can
be used in most networks.)
8
4
11/12/2022
Subnet Example
Network address 172.16.0.0 with /16 network mask
Network Network Host Host
172 16 0 0
Subnet Example
Network address 172.16.0.0 with /16 network mask
Network Network Host Host
172 16 0 0
Using Subnets: subnet mask 255.255.255.0 or /24
Network Network Subnet Host
Network Mask:
255.255.0.0 or /16 11111111 11111111 00000000 00000000
Subnet Mask:
255.255.255.0 or /24
11111111 11111111 11111111 00000000
Applying a mask which is larger than the default
subnet mask, will divide your network into subnets.
Subnet mask used here 10is 255.255.255.0 or /24
5
11/12/2022
Subnet Example
Network address 172.16.0.0 with /16 network mask
Using Subnets: subnet mask 255.255.255.0 or /24
Network Network Subnet Host
172 16 0 Host Subnets
172 16 1 Host
172 16 2 Host
255
172 16 3 Host Subnets
172 16 Etc. Host 28 - 1
172 16 254 Host
Cannot use last
172 16 255 Host subnet as it
contains broadcast
11
address
Subnet Example
Network address 172.16.0.0 with /16 network mask
Using Subnets: subnet mask 255.255.255.0 or /24
Network Network Subnet Host
172 16 0 0 Subnets
Addresses
172 16 1 0
172 16 2 0
255
172 16 3 0 Subnets
172 16 Etc. 0 28 - 1
172 16 254 0
Cannot use last
172 16 255 0 subnet as it
contains broadcast
12
address
6
11/12/2022
Subnet Example
Class B address 172.16.0.0 with /16 network mask
Using Subnets: subnet mask 255.255.255.0 or /24
Network Network Subnet Hosts Hosts
Addresses
172 16 0 1 254
172 16 1 1 254
172 16 2 1 254
172 16 3 1 254
172 16 Etc. 1 254
172 16 254 1 254
Each subnet has
172 16 255 Host 254 hosts, 28 – 2
13
Subnet Example
Network address 172.16.0.0 with /16 network mask
Using Subnets: subnet mask 255.255.255.0 or /24
Network Network Subnet Host
172 16 0 255 Broadcast
Addresses
172 16 1 255
172 16 2 255
255
172 16 3 255 Subnets
172 16 Etc. 255 28 - 1
172 16 254 255
Cannot use last
172 16 255 255 subnet as it
contains broadcast
14
address
7
11/12/2022
Subnet Example
Network address 172.16.0.0 with /16 network mask
Using Subnets: subnet mask 255.255.255.0 or /24
172.16.0.0/24 172.16.10.0/24
172.16.5.0/24 172.16.25.0/24
15
Important things to remember about Subnetting
You can only subnet the host portion, you do not have
control of the network portion.
Subnetting does not give you more hosts, it only allows
you to divide your larger network into smaller networks.
When subnetting, you will actually lose hosts:
For each subnet you lose the address of that subnet
For each subnet you lose the broadcast address of
that subnet
You “may” lose the first and last last subnets
(coming)
Analogy: Large barrel of 100 apples.
Why subnet?
Divide larger network into smaller network.
Limit layer 2 and layer 3 broadcasts to their subnet.
Better management of16 traffic.
8
11/12/2022
Subnetting – Example #1 (on the board)
Host IP Address: 172.16.18.33
Network Mask: 255.255.0.0
Subnet Mask: 255.255.255.0
Given the following Host IP Address, Network Mask and Subnet mask
find the following information:
Major Network Information
Major Network Address
Major Network Broadcast Address
Range of Hosts if not subnetted
Subnet Information
Subnet Address
Range of Host Addresses (first host and last host)
Broadcast Address
Other Subnet Information
Total number of subnets
Number of hosts per subnet
17
Subnetting – Example #2
Host IP Address: 138.101.114.250
Network Mask: 255.255.0.0
Subnet Mask: 255.255.255.192
Given the following Host IP Address, Network Mask and Subnet mask
find the following information:
Major Network Information
Major Network Address
Major Network Broadcast Address
Range of Hosts if not subnetted
Subnet Information
Subnet Address
Range of Host Addresses (first host and last host)
Broadcast Address
Other Subnet Information
Total number of subnets
Number of hosts per subnet
18
9
11/12/2022
Major Network Information
Host IP Address: 138.101.114.250
Network Mask: 255.255.0.0
Subnet Mask: 255.255.255.192
Major Network Address: 138.101.0.0
Major Network Broadcast Address:
138.101.255.255
Range of Hosts if not Subnetted: 138.101.0.1
to 138.101.255.254
19
Step 1: Convert to Binary
128 64 32 16 8 4 2 1
138. 101. 114. 250
IP Address 10001010 01100101 01110010 11111010
Mask 11111111 11111111 11111111 11000000
255. 255. 255. 192
Step 1:
Translate Host IP Address and Subnet Mask into binary
notation
20
10
11/12/2022
Step 2: Find the Subnet Address
138. 101. 114. 250
IP Address 10001010 01100101 01110010 11111010
Mask 11111111 11111111 11111111 11000000
Network 10001010 01100101 01110010 11000000
138 101 114 192
Step 2:
Determine the Network (or Subnet) where this Host
address lives:
1. Draw a line under the mask
2. Perform a bit-wise AND operation on the IP Address and the
Subnet Mask
Note: 1 AND 1 results in a 1, 0 AND anything results in a 0
3. Express the result in Dotted Decimal Notation
4. The result is the Subnet Address of this Subnet or “Wire”
which is 138.101.114.192
21
Step 2: Find the Subnet Address
138. 101. 114. 250
IP Address 10001010 01100101 01110010 11111010
Mask 11111111 11111111 11111111 11000000
Network 10001010 01100101 01110010 11000000
138 101 114 192
Step 2:
Determine the Network (or Subnet) where this Host
address lives:
Quick method:
1. Find the last (right-most) 1 bit in the subnet mask.
2. Copy all of the bits in the IP address to the Network Address
3. Add 0’s for the rest of the bits in the Network Address
22
11
11/12/2022
Step 3: Subnet Range / Host
Range G.D. S.D.
IP Address 10001010 01100101 01110010 11 111010
Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range
Step 3:
Determine which bits in the address contain Network
(subnet) information and which contain Host
information:
Use the Network Mask: 255.255.0.0 and divide (Great
Divide) the from the rest of the address.
Use Subnet Mask: 255.255.255.192 and divide (Small
Divide) the subnet from the hosts between the last “1” and
the first “0” in the subnet mask.
23
Step 4: First Host / Last Host
G.D. S.D.
IP Address 10001010 01100101 01110010 11 111010
Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range
First Host 10001010 01100101 01110010 11 000001
138 101 114 193
Last Host 10001010 01100101 01110010 11 111110
138 101 114 254
Broadcast 10001010 01100101 01110010 11 111111
138 101 114 255
Host Portion
Subnet Address: all 0’s
First Host: all 0’s and a 1
Last Host: all 1’s and a 0
Broadcast: all 1’s
24
12
11/12/2022
Step 5: Total Number
G.D. of Subnets
S.D.
IP Address 10001010 01100101 01110010 11 111010
Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range
Total
First number
Host of subnets
10001010
138
01100101
101
01110010
114
11 000001
193
Number of subnet bits 10
Last Host 10001010 01100101 01110010 11 111110
210 = 1,024 138 101 114 254
1,024
Broadcasttotal 10001010
subnets 01100101 01110010 11 111111
138 101 114 255
Subtract one “if” all-zeros subnet cannot be used
Subtract one “if” all-ones subnet cannot be used
25
Step 6: Total Number of Hosts per
Subnet G.D. S.D.
IP Address 10001010 01100101 01110010 11 111010
Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range
Total
First number
Host of hosts
10001010
138 101
per subnet
01100101 01110010
114
11 000001
193
Number of host bits 6
Last Host 10001010 01100101 01110010 11 111110
26 = 64 138 101 114 254
64 host per10001010
Broadcast subnets 01100101 01110010 11 111111
138 101 114 255
Subtract one for the subnet address
Subtract one for the broadcast address
62 hosts per subnet
26
13
11/12/2022
Subnet Convention
Consider the following Class C
example
195.175.25.0/27
In the above case, the first three
octets and the first three higher-
order bits of the fourth octet are
used in subnet masking
3*8+3 = 27 bits from the beginning of
the 32 bit IP address
© N. Ganesan, All rights reserved.
Subnet Convention Illustrated
8 Bits 8 Bits 8 Bits 3 Bits
11111111 11111111 11111111 11100000
Total number of masking bits = 27
195.175.25.0/27
Network ID
© N. Ganesan, All rights reserved.
14
11/12/2022
Variable Length Subnets
135.41.0.0/16
Subnet
135.41.0.0/17 135.41.128.0.0/17
135.41.128.0./17
1 Network, 32,766 hosts Subnet
135.41.128.0/21 135.41.248.0/21
15 Networks, 2046 hosts per network
135.41.248.0/24 135.41.255.0/21
8 Networks, 254 hosts per network
Your Turn!
Problem 1
Host IP Address: 10.10.10.193
Network Mask: 255.255.0.0
Subnet Mask: 255.255.255.0
Problem 2
Host IP Address: 10.10.10.193
Network Mask: 255.255.255.0
Subnet Mask: 255.255.255.240
Problem 3
Host IP Address: 10.10.10.193
30
Network Mask: 255.255.255.0
15