Transcript Subnet Mask

Network Protocols
Chapter 5 (TCP/IP Suite Book):
IP Addressing: Subnets and Supernets
Copyright © Lopamudra Roychoudhuri
1
Agenda

Topic 1: IP Addresses: classful addressing

Subnets and Supernets
2
Subnetting and Supernetting
 Network addresses available for
assignment to organizations are close to
depletion
 This is coupled with the ever-increasing
demand for addresses from
organizations that want connection to
the Internet
 Two solutions: subnetting and
supernetting
3
A network with two levels of
hierarchy (not subnetted)
IP addresses are designed with two levels of hierarchy
Netid
hostid
4
A network with three levels of
hierarchy (subnetted)
3rd level:
host
2nd level:
subnet
1st level:
site
5
IP Address Subnetting

Subnetting imposes another level of
hierarchy to IP addresses.

A Network Manager is given a block of IP
addresses by ICAAN or an ISP

He/she can then create multiple IP subnets
from this block of IP addresses using IP
address subnetting
6
IP Address Subnetting

Subnetting splits the bits of the IP address
into three address fields:

IP Network – identifies network prefix
assigned by the ICAAN

IP Subnet – identifies internal subnet number
determined by local network administrator

IP Host – identifies individual machine
7
IP Packet Delivery

IP routers deliver data packets as follows:

Internet routers only look at IP Network address to
determine destination network

Once inside destination network, local routers look at
IP Subnet address to determine destination subnet

The last router attached to the destination subnet
looks at IP Host address to determine particular
destination machine.
8
Routing/Addressing Rules

Consider PC A and PC B with IP addresses
IP-A and IP-B.


If PC A and PC B can reach each other without
going through a router, then IP-A and IP-B
must have identical netid and subnetid.
If IP-A and IP-B have different netid or
subnetid, then data packets must go through
at least one router to get from PC A to PC B.
9
Router Ports Must be
Different Subnets

Each port of a router must connect to a
different subnet (i.e. different netid
and/or subnetid fields in addresses)
10
Addresses in a network with and
without subnetting
e.g. hierarchy in
a telephone number
11
Subnet Masks


How do Host machines and routers know which
bits are Subnet Bits?
A Subnet Mask is entered into every Host
machine and every router to tell them: Out of
each 32-bit IP address:

How many bits are Network bits?

How many bits are Subnet bits?

How many bits are Host bits?
12
Subnet Masks

An IP subnet mask is a 32-bit value defined as
follows:



Every IP address bit position that should be a Network
bit or a Subnet bit position is marked with a 1 bit
Every IP address bit position that should be a Host bit
is marked with a 0 bit
Subnet masks are written in dotted decimal
notation (0 – 255), just like IP addresses – but
they are not IP addresses.
13
Default Mask and subnet mask
11111111 11111111 00000000 00000000
10001101 00001110 01001000 00011000
10001101 00001110 00000000 00000000
11111111 11111111 11000000 00000000
10001101 00001110 01001000 00011000
10001101 00001110 01000000 00000000
14
Another Example
What is the subnetwork address if the destination address
is 145.45.34.56 and the subnet mask is 255.255.240.0?
Solution
We apply the AND operation on the address and the
subnet mask.
Address
➡ 10010001 00101101 00100010 00111000
Subnet Mask
➡ 11111111 11111111 11110000 00000000
Subnetwork Address ➡ 10010001 00101101 00100000 00000000
The subnet address is 145.45.32.0
15
Comparison of a default
mask and a subnet mask
16
Figure 5.25
Network mask and subnetwork mask
c bits
h bits
Number of subnets possible? 2c = 2ni-n
Number of addresses per subnet?
2h = 232-ni
h
32-ni - 2
Number of hosts supported per subnet? 2 - 2 = 2
If I want s subnets, what is c?
Find c so that 2c ≥ s
17
Subnet Sizes

Network Manager chooses number of subnet
bits, c, to use based on organization needs.


If we need s subnets, we choose c such that 2c ≥ s
If we have

n network bits, where n is determined by address
class (A, B or C),

c subnet bits and
h host bits (n+c+h = 32), then this allows

2c subnets on our network

2h – 2 host machines on each subnet

18
A Subnet Example
An organization with a class B address 141.14.0.0 needs 4
subnets without subnet restriction. What’s the mask?
22
4=
Or, s=2
2 bits
14 bits
11111111.11111111.11000000.00000000
Or
255.
255.
192.
0
How many hosts can there be in each subnet?
214-2
What are the subnet addresses of each of the 4 subnets?
Next slide
19
A network with three levels of hierarchy (subnetted)
141.14. 00111111 11111110
141.14. 00000000 00000001
141.14. 11000000 00000001
141.14. 01111111 11111110
141.14. 01000000 00000001
141.14. 11111111 11111110
141.14. 10111111 11111110
141.14. 10000000 00000001
20
Restriction on Subnet IDs

If the restriction is imposed, you cannot use all 0’s and all
1’s in the subnet ID portion of an IP address.



If the restriction is relaxed, you can use all 0’s and all 1’s in
the subnet ID portion of an IP address. In other words you
will have two more useable subnet IDs than if the
restriction is not relaxed.




“Using subnet zero for addressing was discouraged because of the
confusion inherent in having a network and a subnet with
indistinguishable addresses.”
http://www.cisco.com/en/US/tech/tk648/tk361/technologies_tech_
note09186a0080093f18.shtml
For Cisco IOS releases prior to 12.0, you would turn the option on
a Cisco router by “ip subnet-zero” command
But As of Cisco IOS Software Release 12.0, Cisco routers now have
ip subnet-zero enabled by default
But you can turn it off if you want by “no ip subnet-zero” command
In either case, you CANNOT use all 0’s and all 1’s in the
host ID portion of the IP address.
21
Subnet Example

A business with a class B address (X.Y.0.0) has
12 internal departments and would like to place
each one on a separate subnet. They follow
subnet restriction. How many subnet bits should
they choose?




We know that n = 16 (Class B address)
We need at least 14 subnets (12 plus 2 special
subnets)
So, s must be at least 4, since 23 < 14 < 24
Thus, we choose n=16, s=4, h=12, which allows



Up to 24-2= 14 user subnets
Up to 212-2 = 4094 user host addresses in each subnet
Subnet Mask = 255.255.240.0
22
Subnetting Example – Class B
23
Example – Range of Subnets
(with restriction)
24
Subnet Example cont.
25
Supernetting




Supernetting allows us to combine adjacent class C
addresses together into larger networks
(supernets).
A supernet mask is the reverse of a subnet mask.
Example: A site needs 1000 IP addresses, but their
ISP only has class C addresses available.
Solution: ISP assigns them 4 adjacent Class C
networks: (for example, 201.60.32.0, 201.60.33.0,
201.60.34.0, 201.60.35.0)
26
A supernet
• 4 networks are combined together to form the supernet
• We will borrow bits from the network part.
• How many bits do we need to borrow?
27
Supernetting

The corporate site routers consider these 4 Class C
networks to be a single network by specifying this
network and mask:
 Network 201.60.32.0, Mask 255.255.252.0


By converting last 2 1-bits in the Class C default mask to
0-bits, we form a mask that defines 1022 (210 – 2) hosts
in a single network.
Routers outside the corporate site still consider
these to be 4 separate Class C networks (but all 4
point to the same destination).
28
Comparing subnetting and
supernetting
Default mask 255.255.255.0
Subnet mask 255.255.255.192
Default mask 255.255.255.0
Supernet mask 255.255.252.0
29
Supernetting Rules
1. The number of blocks must be a power of 2 (1, 2,
4, 8, 16, . . .).
2. The blocks must be contiguous in the address
space (no gaps between the blocks).
3. The third byte of the first address in the superblock
must be evenly divisible by the number of blocks.
In other words, if the number of blocks is N, the
third byte must be divisible by N.
30
Example
A company needs 600 addresses. Which of the following set of class C
blocks can be used to form a supernet for this company?
198.47.32.0
198.47.33.0
198.47.34.0
No, there are only three blocks. Violates rule 1
198.47.32.0
198.47.42.0
198.47.52.0
198.47.62.0
No, Blocks are not contiguous. Violates rule 2
198.47.31.0
198.47.32.0
198.47.33.0
198.47.34.0
No, 31 in 1st block is is not divisible by 4, (no of blocks). Violates rule 3
198.47.32.0
198.47.33.0
198.47.34.0
198.47.35.0
Yes, Satisfies all rules
31
Example
We need to make a supernetwork out of 16 class C blocks.
What is the supernet mask?
Solution
We need 16 blocks. For 16 blocks we need to change
four 1s to 0s in the default mask. So the mask is
11111111 11111111 11110000 00000000
or
255.255.240.0
32
Example
We need to make a supernetwork out of 8 class C blocks.
What is the supernet mask?
Solution
We need 16 blocks. For 16 blocks we need to change
four 1s to 0s in the default mask. So the mask is
11111111 11111111 11111000 00000000
or
255.255.248.0
33
Example
A supernet has a first address of 205.16.32.0 and a
supernet mask of 255.255.248.0. A router receives
three packets with the following destination
addresses:
205.16.37.44
205.16.42.56
205.17.33.76
Which packet belongs to the supernet?
34
Solution
We apply the supernet mask to see if we can find the
beginning address.
11111111 11111111 11111000 00000000
205.16.37.44 AND 255.255.248.0
 205.16.32.0
205.16.42.56 AND 255.255.248.0
 205.16.40.0
205.17.33.76 AND 255.255.248.0
 205.17.32.0
•Only the first address belongs to this supernet.
35
Example
A supernet has a first address of 195.6.16.0 and a
supernet mask of 255.255.240.0. A router receives
three packets with the following destination
addresses:
195.6.63.100
195.6.27.55
195.6.31.250
Which packet belongs to the supernet?
36
Solution
We apply the supernet mask to see if we can find the
beginning address. 11111111 11111111 11110000 00000000
195.6.63.100 AND 255.255.240.0
 195.6.48.0
195.6.27.55 AND 255.255.240.0
 195.6.16.0
195.6.31.250 AND 255.255.240.0
 195.6.16.0
•Only the last two addresses belong to this supernet.
37