IP Subnetting
Computer and Data Communication Laboratory
2
Topics
� IP Subnetting
� Assigning to the network
3
IP in network
� IP can be
� Network address
All bits in host field are zero
First address of network
� Broadcast address
All bits in host field are one
Last address of network
� Host addressAll that is not network and broadcast address
IP Subnetting
5
Subnet Basics
� Addressing without subnetting
• Class B network can have 65,534 hosts
• Hard to manage
• Low Performance
172.16.0.1 172.16.0.2 172.16.0.3 172.16.255.255
172.16.0.0 Network
6
Subnet Basics
� Addressing with subnetting
� A Class B is divided to smaller group by router
172.16.1.2 172.16.1.3 172.16.2.2 172.16.2.3
172.16.3.2 172.16.3.3
7
Subnet Basics
� Subnetwork Benefits
• Overall traffic is reduced, may improve performance
• Smaller networks are easy to manage and
troubleshoot
• Increase controllable of address space
Subdivide on IP network numberis an important initial task of
network managers
8
Subnet Address
� Addressing
� Before Subnet
� After Subnet
• Subnet address create by borrow Host ID bits and designate
as a Subnet ID
Network ID Host ID
Network ID Subnet ID Host ID
9
Subnet Address
� Assign Subnet ID
• Each Class has difference size of subnet field
Network ID Subnet ID Host ID
Class A 2 to 22 bits
Class B 2 to 14 bits
Class C 2 to 6 bits
choose appropriate size
define physical subnetwork define individual host
10
Subnet Address
� Subnet Example
• Class B 172.16.0.0 divided to 254 subnets by
borrow 8 Host ID bits
11
Subnet Mask
� Masking
� bit-wise and between IP Address and subnet mask yields a network address
� Note that zeros bit are used to mask out the host number resulting the network address
12
Subnet Calculation
� Default Subnet Mask : Class full Subnet
� A default subnet mask : a subnet mask with no subnetting
13
Subnet Calculation
� Range of bit
� Network ID’s bits that extended from default subnet :
Subnet ID
8 bits extending range
14
Subnet Calculation
� Net and Host number
� Calculate network and host number of subnet
8 bit subnet ID = 28=256 => 254 subnets
8 bit host ID = 28=256 => 254 hosts per subnet
15
Subnet Calculation
� Subnet Mask Computation
� Decimal equivalents of bit patterns
16
Subnet Interpretation
� Interpretation
� From IP address and subnet mask, define it’s host
number in which subnetwork
17
Subnet Routing
� Routing
� Hosts and routers perform logical AND to send packets.
172.16.1.2 172.16.1.3 172.16.2.2 172.16.2.3
172.16.3.2 172.16.3.3
to 172.16.3.3
1
2
3
� 172.16.1.2 has a packet to 172.16.3.3 and determine it’s not on the same subnetwork
� The packet is sent to router
� The router performs
a subnet masking and sends the packet to the destination network
255.255.255.0
255.255.255.0
18
Subnet Calculation
� 200.1.2.163 / 26 2 bits subnet - - > 4 subnets
200.1.2.0
200.1.2.0200.1.2. 00000000
200.1.2.64200.1.2. 01000000
200.1.2.128200.1.2. 10000000
200.1.2.192200.1.2. 11000000
2 bits borrow
0 - 63
64 - 127
128 - 191
192 - 255
19
Subnet Calculation
� 200.1.2.163 / 27 3 bits subnet - - > 8 subnets
200.1.2.0
200.1.2.0200.1.2. 00000000
200.1.2.32200.1.2. 00100000
200.1.2.64200.1.2. 01000000
200.1.2.96200.1.2. 01100000
200.1.2.128200.1.2. 10000000
200.1.2.160200.1.2. 10100000
200.1.2.192200.1.2. 11000000
200.1.2.224200.1.2. 11100000
3 bits borrow
0 - 31
32 - 63
64 - 95
96 - 127
128 - 159
160 - 191
192 - 223
224 - 255
Assigning to the Networks
21
Connection between Networks
� Router – connecting network, each “interface”connect to 1 network
...
...
...
...
...
How many networks ?
22
Address Amount of Networks� Host amount – amount of host that require IP� Router IP – at least 1 IP for router
...
...
...
...
...
How many IP ?
12
16
29
5
7
12+1 = 13 IPs
23
Subnetting for Networks
� If we have 1 assigned network address “200.1.2.0/24”
� Have to assign to more networks - - > “Subnetting”
...
...
...
...
...
24
Subnetting
� Assigned network 200.1.2.0/24
� Subnet to at least 5 networks
� Borrow subnet bits = 3 � 23 = 8
� Each network has = 2(8-3) = 32 IP
� Available hosts = 30
...
...
...
1
2
3
4
5
200.1.2.0/27
200.1.2.32/27
200.1.2.64/27200.1.2.96/27
200.1.2.128/27
25
VLSM
� Network need to add host to 50
� Network and need only 2 IPs
� VLSM to solve these problems
(variable length subnet mask)
...
...
...
1
2
3
4
5
200.1.2.0/27
200.1.2.32/27
200.1.2.64/27200.1.2.96/27
200.1.2.128/27
4 5
1
26
VLSM
...
...
...
1
2
3
4
5
50 hosts
20 hosts
80 hosts2 IPs
2 IPs
Network Hosts/IP Host bits
1 50 6
2 20 5
3 80 7
4 2 2
5 2 2
27
VLSMNetwork Hosts/IP Host bits
3 80 7
1 50 6
2 20 5
4 2 2
5 2 2
200.1
.2.0 .0 / 25
200.1.2. 10000000 10000000
200.1.2. 00000000
11000000 11000000
11100000
.128 / 26
.192 / 27
11100000 11100100 11101000 11111111….224 / 30 .228 / 30 .232 .255
1
3
2
4 528
VLSM
...
...
...
1
2
3
4
5
200.1.2.128 /26
200.1.2.192 /27
200.1.2.0 /25200.1.2.224 /30
200.1.2.228 /30
Network Subnet
1 200.1.2.128 /26
2 200.1.2.192 /27
3 200.1.2.0 /25
4 200.1.2.224 /30
5 200.1.2.228 /30
29
VLSM – unassigned IP
Network Subnet
1 200.1.2.128 /26
2 200.1.2.192 /27
3 200.1.2.0 /25
4 200.1.2.224 /30
5 200.1.2.228 /3011100000
11100000 11100100 11101000 11111111….224 / 30 .228 / 30 .232 .255
4 5
11101000
11101111
.232 /29
11110000
11111111
.240 /28 30
Lab Work
� IP Subnet 192.168.1.0/24
...
...30 hosts
15 hosts
31
Lab Work
� IP Subnet 192.168.1.0/24
...
...
...30 hosts
8 Hosts
15 hosts
...
5 hosts
32
Lab Work
� IP Subnet 192.168.1.0/24
...
...
...31 hosts
8 Hosts
15 hosts
...
5 hosts
33
Lab Work
� IP Subnet 160.100.1.0/24
...
...
...30 hosts
8 Hosts
15 hosts
...
5 hosts
34
Lab Work
� IP Subnet 160.100.1.0/24
...
...
...32 hosts
8 Hosts
15 hosts
...
5 hosts
36
Lab Assignment
� จงแบ่งเบอร์เครือข่ายแบบ VLSM ของโครงสร้างเครือข่ายต่อไปนี� กาํหนดหมายเลขเครือข่ายใหป้้อนรหสันิสิตใน http://www.ict.up.ac.th/
apiwatw/226351/lab2.php และใชจ้าํนวน host bit นอ้ยที,สุด
...
Net3 hosts
...
Net 1 hosts
1 2
3
...
Net4 hosts
4
37
Lab Assignment
� เขียนตอบเป็นภาพและเบอร์เครือข่ายกาํกบั พร้อมทั�งแสดงรายละเอียดตามตาราง
� และบอกเบอร์ IP ที,เหลือ(ไม่ไดใ้ช)้ วา่เป็นตั�งแต่เบอร์ใดถึงเบอร์ใด� ส่งก่อนเรียน lab ครั� งหนา้
NetworkNetwork address
Subnet mask
Borowed bit
First host address
Last host address
Net1
…
Net4