You are on page 1of 8

IP ADDRESSING AND SUBNETTING

(Flipped Classroom)

An IP address is a 32 bits (4 bytes, also called octets, because 1 byte = 8 bits) number, so it ranges

from 0 (00000000 00000000 00000000 00000000 in binary format)

to 4294967295 (11111111 11111111 11111111 11111111 in binary format)

DOTTED NOTATION
Traditionally IP addresses are written using a “dotted notation”: the value of each byte (octet) is written in
decimal format, using dotted notation to separate the 4 values.

Examples
1) The address 1847271061 , which is 01101110 00011011 00011110 10010101 in binary format

Is written as: 110 . 27 . 30 . 149

Because: 110 = 011011102 (first byte or Most Significant Byte)

27 = 000110112 (second byte)

30 = 000111102 (third byte)

149 = 100101012 (fourth byte or Least Significant Byte)

NOTICE: 1847271061 = 110 x 224 + 27 x 216 + 30 x 28 + 149 x 20

2) Address 3232237882 is written as: 192 . 168 . 9. 58

Because: 323223788210 = 11000000 . 10101000 . 00001001 . 00111010 2

Each octet ranges from 0 ( 00000000 in binary format) to 255 ( 11111111 in binary format)

So IP addresses range from 0 . 0 . 0 . 0 to 255 . 255 . 255 . 255

IP CLASSES
IP addresses are grouped into 5 classes: A, B, C, D, E

CLASS A: addresses that have first bit = 0


CLASS B: addresses that have first 2 bits = 10
CLASS C: addresses that have first 3 bits = 110
CLASS D: addresses that have first 4 bits = 1110
CLASS E: addresses that have first 5 bits = 11110

Therefore:

 CLASS A: addresses range from 0 . 0 . 0 . 0 to 127 . X . X . X , where “X” means any number between 0
and 255

NOTICE: address 127.0.0.1 is a special address, called “loop-back” address

NOTICE: addresses from 10.0.0.0 to 10.255.255.255 are special addresses, used for LANs (private networks)

 CLASS B: addresses range from 128 . 0 . 0 . 0 to 191 . X . X . X

NOTICE: addresses from 172.16.0.0 to 172.31.255.255 are special addresses, used for LANs (private
networks)

 CLASS C: addresses range from 192 . 0 . 0 . 0 to 223 . X . X . X

NOTICE: addresses from 192.168.0.0 to 192.168.255.255 are special addresses, used for LANs (private
networks)

 CLASS D: addresses range from 224 . 0 . 0 . 0 to 239 . X . X . X

 CLASS E: addresses range from 240 . 0 . 0 . 0 to 255 . X . X . X

Examples
Address 201 . 165 . 13 . 225 is a CLASS C address because 201 = 110010012 ( first 3 bits = 110 )
Address 85 . 41 . 209 . 172 is a CLASS A address because 85 = 010101012 ( first bit = 0 )

***

Furthermore, an IP address is divided into two parts: Network number (first part) and Host number
(second part)
Network number Host number
…. 32 bits ….

Division depends on the class

CLASS A: 8 bits for Network, 24 bits for Host


CLASS B: 16 bits for Network, 16 bits for Host
CLASS C: 24 bits for Network, 8 bits for Host
CLASS D and E: this addresses are not divided, because they are reserved for special applications

This means that:

In CLASS A there are:


 125 possible Networks, since the first octet ranges from 0 to 127, but number 0, 10 and 127 cannot
be used

 16777214 possible Hosts for each network, since 24 bits allow 224=16777216 combinations, but
number 0.0.0 and 255.255.255 cannot be used

In CLASS B there are:

 16368 possible Networks, since 14 bits (remember that first 2 bits are fixed =10) allow 214=16384
combinations, but 16 numbers (between 172.16.X.X and 172.31.X.X) cannot be used

 65534 possible Hosts for each network, since 16 bits allow 216=65536 combinations, but number
0.0 and 255.255 cannot be used

In CLASS C there are:

 2096896 possible Networks, since 21 bits (remember that first 3 bits are fixed =110) allow
221=2097152 combinations, but 256 numbers (between 192.168.0.X and 192.160.255.X) cannot be
used

 254 possible Hosts for each network, since 8 bits allow 28=256 combinations, but number 0 and 255
cannot be used

8 bits 8 bits 8 bits 8 bits


CLASS A 0 Netw (7 bits) Host (24 bits)

CLASS B 10 Network (14 bits) Host (16 bits)

CLASS C 110 Network (21 bits) Host (8 bits)

An IP address is unique all over the world: it identifies a specific host in the Internet.

Private IP addresses ( LANs )


Special addresses must be used to build up a private LAN (Local Area Network):

These addresses are:

From To

10.0.0.0 10.255.255.255

172.16.0.0 172.31.255.255

192.168.0.0 192.168.255.255
The most commonly used addresses for LANs are: 192.168.X.X

Such addresses are not public: it means that they cannot be directly “seen” in Internet.

If a big Company needs public IP addresses (i.e. addresses that can be directly “seen” in Internet) it must
ask ICANN (Internet Corporation for Assigned Names and Numbers – www.icann.org ) [ up to 1998 the
Authority in charge of that was IANA - Internet Assigned Numbers Authority - http://www.iana.org ]

[ To tell the truth IP addresses are exhausted: on 31 January 2011 IANA assigned the last address, but just
to understand, let’s suppose that there are some more addresses available. ]

Now, it’s important to understand a key concept concerning IP assignment.

When ICANN assigns IP addresses, it never assigns a single IP address; it actually provides a Network
number; it implies that the Company applying for addresses gets a group of addresses.

Examples
1) ICANN doesn’t assign the single address 160.75.34.236 (which is a Class B address); instead it
assigns the Network number 160.75.X.X; in this way the Company gets 65534 addresses (host
addresses)

2) ICANN doesn’t assign the single address 205.198.120.46 (which is a Class C address); instead it
assigns the Network number 205.198.120.X; in this way the Company gets a group of 254 addresses
(host addresses): from 205.198.120.X

Of course Class C Network numbers are very expensive, while the Class C ones are the cheapest.

SUBNETTING
Once the Company gets the group of addresses, it can divide hosts in Subnets. This can be done by dividing
further the Host number into two parts: Subnet number and Host number:

Subnet number Host number


Class xxx Network number number
Class xxx Host number

IP address ( 32 bit )

Examples
1) The Company buys the Network Number 205.198.120.X (Class C). Let’s suppose that the Host
number (last octet) is divided like that: 3 bits for the Subnet number and 5 bits for the Host
number; such configuration allows 8 class C subnets (23=8) ; each subnet can have up to 30 hosts
(25=32 but number 0 and 31 cannot be used)
2) The Company buys the Network Number 135.215.X.X (Class B). Let’s suppose that the Host number
(last 2 octets) is divided like that: 10 bits for the Subnet number and 6 bits for the Host number;
such configuration allows 1024 class B subnets (210=1024) ; each subnet can have up to 62 hosts
(26=64 but number 0 and 63 cannot be used)

SUBNET MASK
The Subnet Mask is a simple method to express how an IP address is divided. The subnet mask is a 32 bits
number, written in dotted notation such that:

 Bit corresponding to the Network number or to the Subnet Number are = 1;

 Bit corresponding to the final Host number are = 0;

Examples
1) The subnet mask 255.255.255.192 ( = 11111111. 11111111. 11111111.11000000 in binary format)
indicates that the last 6 bits are the host number.

2) Let’s consider the Network number 153.71.X.X (class B) and let’s suppose that the Host number
(last 2 octets) is divided like that: 12 bits for the Subnet number and 4 bits for the Host number;
then the applied subnet mask is: 255.255.255.240 ( = 11111111. 11111111. 11111111.11110000 in
binary format)

If the host number is not divided, then the subnet mask has the minimum numbers of “ones” and it is
called default subnet mask. These are the default subnet mask:

Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0

Recently a more concise notation has been introduced to indicate the subnet mask: it is the “slash
notation”. Using this notation the numbers of “ones” in the subnet mask is written in decimal format at
the end of an IP address, preceded by “/”.

Examples
1) 153.71.50.123 /27 means that the applied subnet mask is 255.255.255.224 ( = 11111111.
11111111. 11111111.11100000 in binary format): in effect there are 27 bits = 1 in the mask.

2) 153.71.50.123 /14 is wrong because it is a class B address and therefore the minimum number of
bits = 1 is 16 ( = 11111111. 11111111. 00000000.00000000 in binary format)
NETWORK ADDRESS and BROADCAST ADDRESS
Given an IP address, the Network Address is obtained by zeroing the Host number and leaving the Network
number and the Subnet number unchanged.

In other words the Network Address is obtained leaving unchanged those bits that correspond to a “1” in
the subnet mask and changing to “0” those bits that correspond to a “0” in the subnet mask.

Thus, given an IP address, a simple way to determine the Network address is to perform a bit-wise AND
operation between the IP address and the Subnet Mask.

***

Given an IP address, the Broadcast Address is obtained by changing to “1” all bits of the Host number and
leaving the Network number and the Subnet number unchanged.

In other words the Broadcast Address is obtained by leaving unchanged those bits that correspond to a “1”
in the subnet mask and changing to “1” those bits that correspond to a “0” in the subnet mask.

Thus, given an IP address, a simple way to determine the Network address is to invert the subnet mask (0
1 and 10) and perform a bit-wise OR operation between the IP address and the inverted Subnet Mask.

Examples
Given the IP address 74.180.30.7 /14 , let’s determine the Network address and the Broadcast address
74. 180. 30. 7
IP address 01001010.10110100.00011110.00000111
Subnet mask 11111111.11111100.00000000.00000000

14 bits
Network addr. 01001010.10110100.00000000.00000000
Broadcast addr. 01001010.10110111.11111111.11111111

Exercise 1
Let’s consider a Class B network using the subnet mask 255.255.252.0

Determine the number of Subnets and the maximum number of hosts that each subnet can have.

***

The subnet mask has 22 bits = 1; the subnet number is therefore composed by 6 bits ( = 22 – 16 ) and the
final host number is composed by 10 bits ( = 32 – 22 ). Thus the number of possible subnets is 64 ( = 26 ) and
the maximum number of Hosts of each subnet is 1022 ( 210 = 1024 but we must subtract the Network
address and the Broadcast address, that cannot be used).

255. 255. 252. 0


Subnet mask 11111111.11111111.11111100.00000000

22 bits
Subnet Final host
number number
Class B network number
( 16 bits )
Class B Host number ( 16 bits )
Exercise 2
Given two IP addresses, 180.157.106.18 /21 and 180.157.124.195 /21, determine:

a) the class of the addresses

b) whether they belong to the same subnet or not

***

Solution item a)

Converting first octet into binary format: 18010 = 101101012

Therefore, both are class B addresses because the first 2 bits are 10.

Solution item b)

180. 157. 106. 18


IP address 1 10110100.10011101.01101010.00010010
Subnet mask 11111111.11111111.11111000.00000000

21 bits
Network addr.1 10110100.10011101.01101000.00000000

180. 157. 124. 195


IP address 2 10110100.10011101.01111100.11000011
Subnet mask 11111111.11111111.11111000.00000000

21 bits
Network addr.2 10110100.10011101.01111000.00000000

Comparing the two Network addresses we can conclude that the addresses belong to different subnets.

Exercise 3
A company wants to build up a public network , connecting 500 hosts; the network will be divided into 5
subnet of 100 hosts each.

a) Which class of addresses is needed?

b) Determine the subnet mask, the actual number of subnets and the maximum number of host for
each subnet.

c) List all subnet addresses that can be obtained


***

Solution item a)

As a class C network address allows up to 254 hosts, a class B address is needed, which allows up to 65534
hosts.

Solution item b)

In order to have 5 subnets, the subnet number must be composed at least by 3 bits; the actual number of
subnets will be 8 ( 23 = 8) ; then 13 bit are devoted to hosts ( 13 = 16 – 3 ) ; so, the maximum number of
hosts for each subnet is 8190 ( 213 = 8192 but we must subtract the Network address and the Broadcast
address, that cannot be used).

The subnet mask is: 255.255.224.0

255. 255. 224. 0


Subnet mask 11111111.11111111.11100000.00000000

19 bits
Subnet Final host
number number
Class B network number
( 16 bits )
Class B Host number ( 16 bits )

Solution item c)

Supposing that the class B Network number bought by the company is X.Y.0.0, these are all possible subnet
addresses:

Subnet #0: X.Y.0.0 (in binary format: xxxxxxxx.yyyyyyyy.00000000.00000000


Subnet #1: X.Y.32.0 (in binary format: xxxxxxxx.yyyyyyyy.00100000.00000000
Subnet #2: X.Y.64.0 (in binary format: xxxxxxxx.yyyyyyyy.01000000.00000000
Subnet #3: X.Y.96.0 (in binary format: xxxxxxxx.yyyyyyyy.01100000.00000000
Subnet #4: X.Y.128.0 (in binary format: xxxxxxxx.yyyyyyyy.10000000.00000000
Subnet #5: X.Y.160.0 (in binary format: xxxxxxxx.yyyyyyyy.10100000.00000000
Subnet #6: X.Y.192.0 (in binary format: xxxxxxxx.yyyyyyyy.11000000.00000000
Subnet #7: X.Y.224.0 (in binary format: xxxxxxxx.yyyyyyyy.11100000.00000000

You might also like