Basic Subnetting Algorithm
Basic Subnetting Algorithm
CSE 323
Handout # 1
Subnetting
UIU
CSE
EEE
BBA
CSE
EEE
BBA
Student #
IP addresses are used to uniquely identify individual TCP/IP networks and hosts, such as computers and printers,
on those networks in order for devices to communicate. Workstations and servers on a TCP/IP network are called
hosts and each has a unique IP address. This address is referred to as its host address. In its basic form, the IP
address has two parts:
A network address
A host address
The IP address of a workstation, or host is a logical address, meaning it can be changed. The Media Access Control
(MAC) address of the workstation is a 48-bit physical address. This address is burned into the network interface
card (NIC) and cannot change unless the NIC is replaced. The combination of the logical IP address and the physical
MAC address helps route packets to their proper destination.
Review IP address classes and their characteristics
Address classes
There are five classes of IP addresses, A through E. Only the first three classes are used commercially. A Class A
network address is discussed in the Table 1 to get started. 127 is reserved for loopback testing. The first octet alone
defines the network ID for a Class A network address.
Default subnet mask
The default subnet mask uses all binary ones, decimal 255, to mask the first 8 bits of the Class A address, first 16 bits
of the Class B addresses, and first 24 bits of the Class C addresses. The default subnet mask helps routers and hosts
determine if the destination host is on this network or another one. It is common to subdivide the network into
smaller groupings called subnets by using a custom subnet mask.
Network and host address
The network or host portion of the address cannot be all ones or all zeros. As an example, the Class A address of
118.0.0.5 is a valid IP address. The network portion, or first 8 bits, which are equal to 118, is not all zeros and the host
portion, or last 24 bits, is not all zeros or all ones. If the host portion were all zeros, it would be the network address
itself. If the host portion were all ones, it would be a broadcast for the network address. The value of any octet can
never be greater than decimal 255 or binary 11111111.
Mohammad Mamun Elahi
Page # 1
Computer Networks
CSE 323
Handout # 1
Subnetting
Example IP Address
Page # 2
Computer Networks
CSE 323
Handout # 1
Subnetting
Table 1
Example:
Find the class of the following IP addresses.
a. 208.34.54.12
b. 238.34.2.1
c. 114.34.2.8
d. 129.14.6.8
Page # 3
Computer Networks
CSE 323
Handout # 1
Subnetting
Example:
Convert the following numbers into binary: 201, 511, 156.
Example:
Convert the following binary numbers into decimal: 11011101, 11110111, 10001100.
Example:
Change the following IP addresses from dotted-decimal notation to binary notation.
a. 114.34.2.8
b. 129.14.6.8
c. 208.34.54.12
d. 238.34.2.1
Example:
Find the network ID and the host ID of the following IP addresses
Network id
Host id
a. 114.34.2.8
b. 132.56.8.6
c. 208.34.54.12
Page # 4
Computer Networks
CSE 323
Handout # 1
Subnetting
Page # 5
Computer Networks
CSE 323
Handout # 1
Subnetting
Subnetting:
Page # 6
Computer Networks
CSE 323
Handout # 1
Subnetting
Subnetting Example
3. Steps
Page # 7
Computer Networks
CSE 323
Handout # 1
Page # 8
Subnetting
Computer Networks
CSE 323
Handout # 1
Subnetting
Example:
Write the following masks in slash notation (/n).
a. 255.255.255.0
b. 255.0.0.0
c. 255.255.224.0
d. 255.255.240.0
S (Subnetting Bits)
H (Host Bits)
mth valid IP address in the nth subnet after subnetting, follow the
Step 2: Convert n into binary in exactly S bits and write in the S (Subnet Bits) part.
Step 3: Convert m into binary in exactly H bits and write in the H (Host Bits) part.
Step 4: Group the bits from right to left 8-bits at a time and convert to the dotted
decimal format.
Example:
You have the following IP 211.63.57.0, this network is subnetted by 3-bits. Find the 50th IP
address of subnet # 6.
Example:
You have the following IP 7.0.0.0, this network is subnetted by 11-bits. Find the 500th IP address
of subnet # 60.
Example:
You have the following IP 189.23.0.0, subnetted by 9-bits. Find 100th IP address of subnet # 300.
N
Mohammad Mamun Elahi
S
Page # 9
H
June 21, 2014
Computer Networks
CSE 323
Handout # 1
Subnetting
ie Class B address
16 network bits
IP Address
Subnet Mask
Network
Host
10101100.00010000.00000000.00000000
11111111.11111111.00000000.00000000
You may be asked to supply 500 subnets; using the formula Subnets = 2n, Where n = no. of bits to borrow
Step 1
Step 2
n
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2n
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
Step 3
Mark the borrowed bits as subnet bits
IP Address
Subnet Mask
Network
Subnet
Host
10101100.00010000.00000000.00000000
11111111.11111111.11111111.10000000
Remember the borrowed bits in the mask change
from 0 (zero) to 1 (one)
Step 4
Define the subnetted network;
Address 172.16.0.0/25
Page # 10
Computer Networks
CSE 323
Handout # 1
Subnetting
Step 5: Calculate the subnet addresses and usable hosts for each subnet
IP Address
Mask
Network
Subnet
Host
10101100.00010000.00000000.00000000
11111111.11111111.11111111.10000000
00000000.00000000
For each subnet, the binary value
of the subnet bits will increment
by 1, so the first 5 subnets and
last 2 are; *See appendix
First usable network
00000000.0
00000000.1
00000001.0
00000001.1
00000010.0
etc.
11111111.0
11111111.1
Page # 11
Computer Networks
CSE 323
Handout # 1
Subnetting
Appendix
IP Value
Subnet Number
Subnet 0( Not Used)
Subnet 1 Address
Subnet 1 Host 1
Subnet 1 Host 126
Subnet 1 Broadcast
Subnet 2 Address
Subnet 2 Host 1
Subnet 2 Host 126
Subnet 2 Broadcast
Subnet 3 Address
Subnet 3 Host 1
Subnet 3 Host 126
Subnet 3 Broadcast
128
256
0
0
0
0
0
0
0
0
0
0
0
0
0
64
128
0
0
0
0
0
0
0
0
0
0
0
0
0
32
64
0
0
0
0
0
0
0
0
0
0
0
0
0
16
32
0
0
0
0
0
0
0
0
0
0
0
0
0
8
16
0
0
0
0
0
0
0
0
0
0
0
0
0
4
8
0
0
0
0
0
0
0
0
0
0
0
0
0
2
4
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
128
2
1
0
0
0
1
0
1
0
1
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
etc$.
1
0
1
0
1
0
1
0
1
1
64
32
16
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
0
0
1
0
1
0
Note: Only the final two octets are shown for clarity.
Example:
An organization is granted the address block 130.56.0.0/16. The administrator wants to create 512
subnets.
a. Find the subnet mask.
b. Find the number of addresses in each subnet.
c. Find the first and last addresses in subnet 1.
d. Find the first and last addresses in subnet 512.
Example:
In a block of addresses, we know the IP address of one host is 182.44.82.16/26. What are the
network address and the broadcast address in this block?
Example:
Assume: Network: 170.60.0.0, SM: 255.255.255.128. Which of the following table is an invalid IP?
WHY?
IP
170.60.25.1
170.60.26.127
170.60.40.139
170.60.212.212
170.60.255.190
170.60.252.16
170.60.100.63
Validity
reason
Page # 12