Professional Documents
Culture Documents
(Flipped Classroom)
An IP address is a 32 bits (4 bytes, also called octets, because 1 byte = 8 bits) number, so it ranges
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
Each octet ranges from 0 ( 00000000 in binary format) to 255 ( 11111111 in binary format)
IP CLASSES
IP addresses are grouped into 5 classes: A, B, C, D, E
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: addresses from 10.0.0.0 to 10.255.255.255 are special addresses, used for LANs (private networks)
NOTICE: addresses from 172.16.0.0 to 172.31.255.255 are special addresses, used for LANs (private
networks)
NOTICE: addresses from 192.168.0.0 to 192.168.255.255 are special addresses, used for LANs (private
networks)
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 ….
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
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
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
An IP address is unique all over the world: it identifies a specific host in the Internet.
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. ]
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:
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:
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 10) 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).
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:
***
Solution item a)
Therefore, both are class B addresses because the first 2 bits are 10.
Solution item b)
21 bits
Network addr.1 10110100.10011101.01101000.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.
b) Determine the subnet mask, the actual number of subnets and the maximum number of host for
each subnet.
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).
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: