IP Addressing
What is an IP Address?
• The address space in a protocol That uses N-bits
• An IP address is a unique global address for a network
interface
1
• An IP v4 address:
- is a 32 bit long identifier
address space =2^32= 4,294,967,296.
IP addresses are written in a so-called
• Binary Notation
• Dotted Decimal Notation
• Hexadecimal Notation
• Example:
10000000 10001111 10001001 10010000
1st Byte 2nd Byte 3rd Byte 4th Byte
= 128 = 143 = 137 = 144
128.143.137.144
2
CLASSFUL ADDRESSING
• In classful addressing the address space is divided into 5
classes:
A, B, C, D, and E.
• Occupation of the address space
Finding the class in binary notation
3
Finding the class in decimal notation
Network prefix and Host number
• The network prefix identifies a network and the host number
identifies a specific host (actually, interface on the network).
network prefix(Netid) host number(hostid)
4
Default Sebnet Mask
• Class A default mask is 255.0.0.0
• 11111111 00000000 00000000 00000000
• Number of N= 128 (27) why (27) not (28)
• Number of H= (224)
• Class B default mask is 255.255.0.0
• 11111111 11111111 00000000 00000000
• Number of N= 16,384 (214)
• Number of H= 65,536 (216)
•
• Class C Default mask 255.255.255.0
• 11111111 11111111 11111111 00000000
• Number of N= (221)
• Number of H= 256 (28)
Size
of networ Size Total
Leading Number Addresses Start End
Class k of rest addresses
bits of networks per network address address
number bi bit field in class
t field
2,147,483, 127.255.255.
Class A 0 8 24 128 (27) 16,777,216 (224) 0.0.0.0
648 (231) 255
1,073,741, 191.255.255.
Class B 10 16 16 16,384 (214) 65,536 (216) 128.0.0.0
824 (230) 255
2,097,152 536,870,9 223.255.255.
Class C 110 24 8 256 (28) 192.0.0.0
(221) 12 (229) 255
Class D not not 268,435,4 239.255.255.
1110 not defined not defined 224.0.0.0
(multicast) defined defined 56 (228) 255
Class E not not 268,435,4 255.255.255.
1111 not defined not defined 240.0.0.0
(reserved) defined defined 56 (228) 255
5
IP validator
IP
10.168.0001.100 Invalid
256.255.255.255 Invalid ,number exceeds 255
256.0.0.0 Invalid
192.168. 224 Invalid
192.168.224.0 1 Invalid
150.100.255.255 valid class B-broadcast address
195.234.253.0 valid, class-C network address
224.156.217.73 valid, class D (multicast)
175.100.255.18 valid, class B
Appendix: Reserved IP Addresses
• Another set of IP addresses that are restricted even further
are called reserved IP addresses.
• In the Internet addressing architecture, the Internet Engineering Task Force (IETF)
and the Internet Assigned Numbers Authority (IANA) have reserved various
Internet Protocol (IP) addresses for special purposes.
12
6
13
Classful vs Classless
7
Classful subnetting
• Network ID = 192.168.1.0 and divided it 4 blocks
I. 1subnet with 12 hosts.
II. 2subnet with 44 hosts.
III. 3subnet with 2 hosts
IV. 4subnet with 24 hosts.
15
Classless Variable-Length Subnet Masking
(VLSM)
• The first step must be to arrange subnet networks and then
convert the number to multiples number 2.
I. 12 hosts, the smallest subnet would be a block of 16.
II. 44 hosts, the smallest subnet would be a block of 64.
III. 2 hosts, the smallest subnet would be a block of 4.
IV. 24 hosts, the smallest subnet would be a block of 32
16
8
Example1:
Company have three departments connected with wan links.
• Development department have 74 computers.
• Production department have 52 computers.
• Administrative department have 28 computers.
• All departments are connected with each other via wan link.
• Each wan link requires two IP addresses.
192.168.1.0/24
Subnet Segment Hosts
1 Development 74
2 Production 52
3 Administrative 28
4 Wan link 1 2
5 Wan link 2 2
6 Wan link 3 2
17
Three departments and 3 WANs
wan
wan
wan
74 hosts 52 hosts 28 hosts
18
9
IP Address=192.168.1.0/24
Subnet Mask = 255.255.255.0 = 11111111.11111111.11111111.00000000
Solution:
Network1:
largest segment needs 74 host addresses
74 27 = 128
Subnet Mask = 255.255.255.128 = 11111111.11111111.11111111.10000000
Or 256 – subnet size = subnet mask 256-128=128
Segment Development
Requirement 74
CIDR /25
Subnet mask 255.255.255.128
Network ID 192.168.1.0
First hosts 192.168.1.1
Last hosts 192.168.1.126
Broadcast ID 192.168.1.127 19
Network2:
second largest segment needs 52 host addresses
52 26 = 64
Subnet Mask = 255.255.255.192 = 11111111.11111111.11111111.11000000
Segment Production
Requirement 52
CIDR /26
Subnet mask 255.255.255.192
Network ID 192.168.1.128
First hosts 192.168.1.129
Last hosts 192.168.1.190
Broadcast ID 192.168.1.191
20
10
Network3:
second largest segment needs 28 host addresses
28 25 = 32
Subnet Mask = 255.255.255.224 = 11111111.11111111.11111111.11100000
Segment Administrative
Requirement 28
CIDR /27
Subnet mask 255.255.255.224
Network ID 192.168.1.192
First hosts 192.168.1.193
Last hosts 192.168.1.222
Broadcast ID 192.168.1.223
21
Segments Wan Link 1 Segments Wan Link 2
Requirement 2 Requirement 2
CIDR /30 CIDR /30
Subnet mask 255.255.255.252 Subnet mask 255.255.255.252
Network ID 192.168.1.224 Network ID 192.168.1.228
First hosts 192.168.1.225 First hosts 192.168.1.229
Last hosts 192.168.1.226 Last hosts 192.168.1.230
Broadcast ID 192.168.1.227 Broadcast ID 192.168.1.231
Segments Wan Link 3
Requirement 2
CIDR /30
Subnet mask 255.255.255.252
Network ID 192.168.1.232
First hosts 192.168.1.233
Last hosts 192.168.1.234
Broadcast ID 192.168.1.235
22
11
Example2:
Company have three departments connected with wan links.
• HQ = 50 host
• RO1 = 30 hosts
• RO2 = 10 hosts
• 2 WAN links
192.168.10.0/24. Class C
23
IP Address=192.168.10.0/24
Subnet Mask = 255.255.255.0 = 11111111.11111111.11111111.00000000
Solution:
Network1:
largest segment needs 50 host addresses
50 26 = 64
Subnet Mask = 255.255.255.192 = 11111111.11111111.11111111.11000000
Segment HQ
Requirement 50
CIDR /26
Subnet mask 255.255.255.192
Network ID 192.168.10.0
First hosts 192.168.10.1
Last hosts 192.168.10.62
Broadcast ID 192.168.10.63 24
12
Network2:
second largest segment needs 30 host addresses
30 25 = 32
Subnet Mask = 255.255.255.224 = 11111111.11111111.11111111.11100000
Segment RO1
Requirement 30
CIDR /27
Subnet mask 255.255.255.224
Network ID 192.168.10.64
First hosts 192.168.10.65
Last hosts 192.168.10.94
Broadcast ID 192.168.10.95
25
Network3:
second largest segment needs 28 host addresses
10 24 = 16
Subnet Mask = 255.255.255.240 = 11111111.11111111.11111111.11110000
Segment RO2
Requirement 16
CIDR /28
Subnet mask 255.255.255.240
Network ID 192.168.10.96
First hosts 192.168.10.97
Last hosts 192.168.10.110
Broadcast ID 192.168.10.111
26
13
Segments Wan Link 1 Segments Wan Link 2
Requirement 2 Requirement 2
CIDR /30 CIDR /30
Subnet mask 255.255.255.252 Subnet mask 255.255.255.252
Network ID 192.168.10.112 Network ID 192.168.10.116
First hosts 192.168.10.113 First hosts 192.168.10.117
Last hosts 192.168.10.114 Last hosts 192.168.10.118
Broadcast ID 192.168.10.115 Broadcast ID 192.168.10.119
27
Example4:
• Network: 171.2.0.0/22
Subnet Needed Size Addres Broadca Ma
Assignable Range
st
Dec Mask
NO Size 2^ s sk
1 400 512 171.2.0.0 171.2.0.1 - 171.2.1.254 171.2.1.255 255.255.254.0 /23
2 180 256 171.2.2.0 171.2.2.1 - 171.2.2.254 171.2.2.255 255.255.255.0 /24
3 40 64 171.2.3.0 171.2.3.1 - 171.2.3.62 171.2.3.63 255.255.255.192 /26
4 18 32 171.2.3.64 171.2.3.65 - 171.2.3.94 171.2.3.95 255.255.255.224 /27
5 4 8 171.2.3.96 171.2.3.97 - 171.2.3.102 171.2.3.103 255.255.255.248 /29
6 4 8 171.2.3.104 171.2.3.105 - 171.2.3.110 171.2.3.111 255.255.255.248 /29
28
14
VLSM
• 140.20.0.0/20
• 3000 hosts
• 2000 hosts
• 1000 hosts
• 2 hosts
29
Number of hosts= 212 Mask =1111111.11111111.11110000.00000000/20
a) 256< 212 = 4096 / 256 = 16 => + 15.255
b) From MASK 256-240 = 16 0r by bit -> 16
host mask Net ID FA LA BC
3000 212 255.255.240.0 140.20.0.0 140.20.0.1 140.20.15.254 140.20.15.255
Number of hosts= 211 Mask =1111111.11111111.11111000.00000000/21
a) 256< 211 = 2048 / 256 = 8 => + 7.255
b) From MASK 256-248 = 8
host mask Net ID FA LA BC
2000 211 255.255.248.0 140.20.16.0 140.20.16.1 140.20.23.254 140.20.23.255
Number of hosts= 210 Mask =1111111.11111111.11111100.00000000/22
a) 256< 210 = 1024 / 256 = 4 => + 3.255
b) From MASK 256-252 = 4
host mask Net ID FA LA BC
1000 210 255.255.252.0 140.20.24.0 140.20.24.1 140.20.23.254 140.20.27.255
30
15
host mask Net ID FA LA BC
1000 210 255.255.252.0 140.20.24.0 140.20.16.1 140.20.23.254 140.20.27.255
Number of hosts= 22 Mask =1111111.11111111.11111111.11111100/30
host mask Net ID FA LA BC
2 22 255.255.252.0 140.20.28.0 140.20.28.1 140.20.28.2 140.20.28.3
31
VLSM
• 20.0.0.0/10
• 500 hosts
• 100 hosts
• 100 hosts
• 2 hosts
• 2 hosts
32
16
Number of hosts= 29 Mask =1111111.11111111.11111110.00000000/23
a) 256< 29 = 512 / 256 = 2=> + 1.255
b) From MASK 256-254 = 2
host mask Net ID FA LA BC
512 29 255.255.254.0 20.0.0.0 20.0.0.1 20.0.1.254 20.0.1.255
Number of hosts= 27 Mask =1111111.11111111.11111111.10000000/25
a) From MASK 256-128 = => 128
host mask Net ID FA LA BC
100 28 255.255.255.128 20.0.2.0 20.0.2.1 20.0.2.126 20.0.2.127
Number of hosts= 27 Mask =1111111.11111111.11111111.10000000/25
a) From MASK 256-128 = => 128
host mask Net ID FA LA BC
100 28 255.255.255.128 20.0.2.128 20.0.2.129 20.0.2.254 20.0.2.255
33
host mask Net ID FA LA BC
100 28 255.255.255.128 20.0.2.128 20.0.2.129 20.0.2.254 20.0.2.255
Number of hosts= 22 Mask =1111111.11111111.11111111.11111100/30
host mask Net ID FA LA BC
2 22 255.255.252.0 20.0.3.0 20.0.3.1 20.0.3.2 20.0.3.3
Number of hosts= 22 Mask =1111111.11111111.11111111.11111100/30
host mask Net ID FA LA BC
2 22 255.255.252.0 20.0.3.4 20.0.3.5 20.0.3.6 20.0.3.7
34
17
Subnetting
35
Example
• IP=140.40.0.0 /16 Subnet=6
Class B
Num of Subnets 2^3=8 Convert 3 bit from 0 to 1 in Mask
CIDR 16+3=19 (Number of 1 in Subnet Mask)
Default Mask 255.255.0.0
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHH
1111111.11111111.00000000.00000000
Subnet Mask 1111111.11111111.11100000.00000000
255.255.224.0 (128+64+32=224)
NNNNNNNN.NNNNNNNN.SSSHHHHH.HHHHHHH
Num of Hosts 2^13 - 2 (Number of 0 in Subnet Mask)
36
18
Example 1
• IP=140.40.0.0 /16 Subnet=6
Class B
Num of Subnets 2^3=8 Convert 3 bit from 0 to 1 in Mask
CIDR 16+3=19 (Number of 1 in Subnet Mask)
Default Mask 255.255.0.0
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHH
1111111.11111111.00000000.00000000
Subnet Mask 1111111.11111111.11100000.00000000
255.255.224.0 (128+64+32=224)
NNNNNNNN.NNNNNNNN.SSSHHHHH.HHHHHHH
Num of Hosts 2^13 - 2 (Number of 0 in Subnet Mask)
37
Range (IP=140.40.0.0)
The amount of jump per network from SMask =32
1111111.11111111.11100000.00000000
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Range of Range of Host Broadcast
Subnet First Address to Last Address
140.40.0.0 140.40.31.255
+32
140.40.32.0 140.40.63.255
+32
140.40.64.0 140.40.95.255
140.40.224.0 140.40.255.255
38
19
Range (IP=140.40.0.0)
The amount of jump per network from SMask =32
From mask
1111111.11111111.11100000.00000000 256-224=32
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Range of Range of Host Broadcast
Subnet First Address to Last Address
140.40.0.0 140.40.0.1 to 140.40.31.254 140.40.31.255
+32
140.40.32.0 140.40.32.1 to 140.40.63.254 140.40.63.255
+32
140.40.64.0 140.40.64.1 to 140.40.96.254 140.40.96.255
140.40.224.0 140.40.224.1 to 140.40.255.254 140.40.255.255
39
Example 2
• IP=140.40.0.0 /16 Subnet=2000
Class
Num of Subnets
CIDR/
Default Mask
Subnet Mask
Num of Hosts
40
20
Example3
• IP=140.40.0.0 /16 Subnet=2000
Class B
Num of Subnets 2^11=2048
CIDR/ 16+11=27 (Number of 1 in Subnet Mask)
Default Mask 255.255.0.0
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHH
1111111.11111111.00000000.00000000
Subnet Mask 1111111.11111111.11111111.11100000
255.255..255.224
NNNNNNNN.NNNNNNNN.SSSSSSSS.SSSHHHHH
Num of Hosts 2^5 - 2 (Number of 0 in Subnet Mask)
41
Range (IP=140.40.0.0)
The amount of jump per network from SMask =1 in 3Byte 32 in 4Byte
1111111.11111111.11111111.11100000
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
42
21
Range of host
# Subnet From To Broadcast
0 140.40.0.0 140.40.0.1 140.40.0.30 140.40.0.31
1 140.40.0.32 140.40.0.33 140.40.0.62 140.40.0.63
2 140.40.0.64 140.40.0.65 140.40.0.94 140.40.0.95
3 140.40.0.96 140.40.0.97 140.40.0.126 140.40.0.127
4 140.40.0.128 140.40.0.129 140.40.0.158 140.40.0.159
5 140.40.0.160 140.40.0.161 140.40.0.190 140.40.0.191
6 140.40.0.192 140.40.0.193 140.40.0.222 140.40.0.223
7 140.40.0.224 140.40.0.225 140.40.0.254 140.40.0.255
8 140.40.1.0 140.40.1.1 140.40.1.30 140.40.1.31
9 140.40.1.32 140.40.1.33 140.40.1.62 140.40.1.63
2048 140.40.255.224 140.40.255.225 140.40.255.254 140.40.255.255
43
IP=20.0.0.0 /8 Subnets=500
or IP=20.0.0.0/17
Class
Num of Subnets
CIDR
Default Mask
Subnet Mask
Num of Hosts
44
22
IP=20.0.0.0 /8 Subnets=500
Class A
Num of Subnets 2^9=512 Convert 9 bit from 0 to 1 in Mask
CIDR 8+9=17 (Number of 1 in Mask)
Default Mask 255.0.0.0
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHH
1111111.11111111.00000000.00000000
Subnet Mask 1111111.11111111.11111111.10000000
255.255.128.0
NNNNNNNN.NNNNNNNN.SSSSSSSS.SHHHHHH
Num of Hosts 2^7 - 2 (Number of 0 in Subnet Mask)
45
Range (IP=20.0.0.0)
The amount of jump per network from SMask =1 in 3Byte 128 in 4Byte
1111111.11111111.11111111.10000000
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Range of Range of Host Broadcast
Subnet First Address to Last Address
20.0.0.0 20.0.0.1 to 20.0.0.126 20.0.0.127
+32
20.0.0.128 20.0.0.129 to 20.0.0.254 20.0.0.255
20.0.1.0 20.0.1.1 to 20.0.1.126 20.0.1.127
20.0.1.128 20.0.1.129 to 20.0.1.254 20.0.1.255
20.0.255.128 20.0.255.129 20.0.255.254 20.0.255.255
46
23
47
Method1
• Ex1:we have network: 10.0.0.0 /19 and I want to know the
network range of 202 subnet.
• 10.0.0.0/19= 8+11 ---->
NNNNNNNN.SSSSSSSS.SSSHHHHH.HHHHHHHH
• 1st subnet is zero so 202 th is subnet 201 so convert 201 in
binary and prefix with leading zeroes to get 11 bits value.
• the result is 00011001001 --->
NNNNNNNN.00011001.001HHHHH.HHHHHHHH
• in subnet the host bits are zeroes so --> NNNNNNNN.25.32.0
• ---> 10.25.32.0
48
24
Convert 201 to binary by -
128 64 32 16 8 4 2 1
• 201==> 11001001 1 1 0 0 1 0 0 1
201
-
128
73
-
64
9
-
8
1
-
1 49
Another method :
• Nth subnet = (N - 1) / (2^s) = X.Y
•
• where:
N is the subnet you wish to find
S is the number of subnet bits in the "interesting" octet
X = the new number for the 2nd octet
Y * 256 = the number in the interesting octet
•
• Let’s take you first example, 10.0.0.0/19, find the 202th
subnet.
•
• 10.ssssssss.ssshhhhh.hhhhhhhh
50
25
• The "interesting" octet is the third octet.
• From the formula, the new subnet is 10.X.(Y*256).0
•
• (202-1)/2^3 = 25.125 ==> 25 is the number for the second octet
• ==> 10.25.(Y*256).0
•
• take .125 * 256 = 32000 ==> 32 is the number for the third octet
• ==> 10.25.32.0
• The 202th subnet is 10.25.32.0/19
• lets try anothyer one. Try the 15th subnet.
• (15-1)/2^8 = 1.75 ==> 1 is the number for the second octet
• ==> 10.1.(Y*256).0
• take .75 * 256 = 192 ==> 192 is the number for the third octet
• ==> 10.1.192.0
51
Number of subnet from mask
• If ip from class B and Mask =255.255.224.0
• 11111111.11111111.11100000/16+3=19
• Number of subnet=23 =8
• Given the following network mask, how many bits are being
used to represent the network?
• Netmask: 255.192.0.0
• b)/10
52
26
Convert 400 to binary by -
512 256 128 64 32 16 8 4 2 1
1 1 0 0 1 0 0 0 0
• 400==> 110010000
400
-
256
144
-
128
16
-
16
0
53
27