IP Address Subnetting¶
Slides: http://www.cs.put.poznan.pl/ksiek/naps/subnets/

Problem:
- A company has a single IP network address (public).
- A company has several buildings, each with a LAN network.
- How to design the networks within the company?
- How to allocate addresses?
- How to separate networks?
Division of networks into equal-sized subnetworks¶
Given a network IP address:
- the network part has of length \(s\) bits (mask is
/s
)- the computer part is of length \(k\) bits (\(k = 32-s\))
Division of a network into \(p\) (equal-sized) subnets, subnetwork address derivation:
- “borrow” from the computer part of the address as many bits, as are needed to count \(p\) networks: \(\lceil \log_2(p) \rceil\)
- use the “borrowed” bits to assign numbers to subnetworks
- extend the network mask by \(\lceil \log_2(p) \rceil\)
We get \(\lceil \log_2(p) \rceil\) subnetworks, where each subnetwork has a (correct) IP address:
- each subnet has its own network and broadcast addresss
- each network can have \(2^{k - \lceil \log_2(p) \rceil} - 2\) computers in it
- each network mask is longer than the mask of the original network (\(s + \lceil \log_2(p) \rceil\))
Vocabulary: subnetwork = subnet.
Example¶
Divide 150.10.0.0/16
into 4
subnets.
- in order to assign addresses to 4 subnets we need \(\lceil \log_2(4) \rceil = 2\) bits
subnet numbering:
00
– first subnet01
– second subnet10
– third subnet11
– fourth subnet
Fist subnet¶
- 16 most significant bits without change
- in the “borrowed” part goes the number assigned to the first subnet:
00
- 14 least significant bits of the computer part are zeroed.
- first subnet network address:
150.10.0.0
- new mask must also hide the “borrowed” bits, so new length: \(16+2 = 18\)
- first subnet mask:
255.255.192.0
–/18
full address of first subnet:
150.10.0.0/18
range of computers in the first subnet:
10010110 10010110 00000000 00000000
150.150.0.0
network address 10010110 10010110 00000000 00000001
150.150.0.1
first computer address 10010110 10010110 00000000 00000010
150.150.0.2
second computer address ... ... 10010110 10010110 00111111 11111110
150.150.63.254
last computer address 10010110 10010110 00111111 11111111
150.150.63.255
broadcast address - computer address range:
150.150.0.1
–150.150.63.254
- no of computers in first subnet: \(2^{14} - 2\)
- computer address range:
broadcast address:
150.150.63.255
All subnets¶
Subnet no. Subnet address Subnet mask Subnet mask Computer address range Broadcast address 00
150.10.0.0
255.255.192.0
/18
150.10.0.1
–150.10.63.254
150.10.63.255
01
150.10.64.0
255.255.192.0
/18
150.10.64.1
–150.10.127.254
150.10.127.255
10
150.10.128.0
255.255.192.0
/18
150.10.128.1
–150.10.191.254
150.10.191.255
11
150.10.192.0
255.255.192.0
/18
150.10.192.1
–150.10.255.254
150.10.255.255
Network design¶

Division of networks into different-sized subnetworks¶

Problem:
- a company has several buildings containing differing numbers of computers
Variable Length Subnet Masking (VLSM):
dividing a network into subnets that are described by different masks (with different address ranges)
- modus operandi:
- division into equal-sized network
- division of one of the subnets into smaller subnets
Divide the network 150.10.0.0/16
into:
- 3 subnets containing 15 000 computers each, and
- 4 additional subnets containing 4000 computers
Dividing 150.10.0.0/16
into 4 subnets with mask /18
¶
Subnet no. Subnet address Subnet mask Subnet mask Computer address range Broadcast address 00
150.10.0.0
255.255.192.0
/18
150.10.0.1
–150.10.63.254
150.10.63.255
01
150.10.64.0
255.255.192.0
/18
150.10.64.1
–150.10.127.254
150.10.127.255
10
150.10.128.0
255.255.192.0
/18
150.10.128.1
–150.10.191.254
150.10.191.255
11
150.10.192.0
255.255.192.0
/18
150.10.192.1
–150.10.255.254
150.10.255.255
Dividing 150.10.64.0/18
into 4 subnets with mask /20
¶
Subnet no. Subnet address Subnet mask Subnet mask Computer address range Broadcast address 00
150.10.64.0
255.255.240.0
/20
150.10.64.1
–150.10.79.254
150.10.79.255
01
150.10.80.0
255.255.240.0
/20
150.10.80.1
–150.10.95.254
150.10.95.255
10
150.10.96.0
255.255.240.0
/20
150.10.96.1
–150.10.111.254
150.10.111.255
11
150.10.112.0
255.255.240.0
/20
150.10.112.1
–150.10.127.254
150.10.127.255
Subnets¶
- All subnets:
150.10.0.0/18
150.10.128.0/18
150.10.192.0/18
150.10.64.0/20
150.10.80.0/20
150.10.96.0/20
150.10.112.0/20
- Routers located outside the network only maintain one row in their routing table: the row contains only
150.10.0.0/16
- Routes to subnets have to be remembered within all routers within the network
150.10.0.0/16
Applicability condition¶
Given a network 100.0.0.0/8
that contains routers R1
and R2
that find routes based on a dynamic routing protocol (eg. RIP)

- Problem:
- router
R2
sends toR1
the information about network100.192.0.0
; what mask isR1
supposed to assume for this network? - solution: (warunek stosowalności) – network communication using IP must also contain the network mask
- router
Support for VLSM¶
- Protocols without VLSM support:
- RIP v1 (IETF)
- IGRP (Cisco)
- Protocols with VLSM support:
- RIP v2 (IETF)
- OSPF (IETF)
- EIGRP (Cisco)
Classless Inter-Domain Routing¶
Classless Inter-Domain Routing:
- abandoning the classful approach (a mask can be shorter than the shortest mask allowed by the classful approach),
- allows for shorter routing tables — row aggregation,
- enforces allocation of addresses as per necessity — the term “a network of class XX” replaced by the term “CIDR address block,” for which only mask length matters,
- technology used with VLSM,
- technology, according to which Internet Service Providers (ISP) allocate addresses.
- CIDR allows allocation according to real needs
- liczba adresów w bloku CIDR jest dowolną (w ustalonym zakresie) potęgą liczby 2
Classful approach¶
Classful approach:
Network class Mask No. of addresses A 255.0.0.0
(/8
)16 777 216 B 255.255.0.0
(/16
)65 536 C 255.255.255.0
(/24
)256
CIDR approach¶
CIDR approach:
CIDR prefix Mask No. of addresses /32
255.255.255.255
/31
255.255.255.254
2 /30
255.255.255.252
4 ... ... ... /13
255.255.248.0
524 288 ... ... ... /1
128.0.0.0
2 147 483 648
Network address aggregation¶

Routing table at R2:
destination mask gateway 200.1.0.0
/24
R1 200.1.1.0
/24
R1 200.1.2.0
/24
R1 ... ... ... 200.1.15.0
/24
R1 200.1.16.0
/24
R3 200.1.17.0
/24
R3 200.1.18.0
/24
R3 ... ... ... 200.1.31.0
/24
R3
- Given a range of IP addresses:
- find the longest common prefix of their network parts
- shorten the mask and create a common network IP address (called supernet address or a CIDR address)
- attention: a supernet cannot contain addresses from outside a given range
Example – finding the supernet address for router R2:
200.1.0.0/24
11001000.00000001.0000-0000.00000000 200.1.1.0/24
11001000.00000001.0000-0001.00000000 200.1.2.0/24
11001000.00000001.0000-0010.00000000 200.1.3.0/24
11001000.00000001.0000-0011.00000000 200.1.15.0/24
11001000.00000001.0000-1111.00000000 200.1.0.0/24
11001000.00000001.0001-0000.00000000 200.1.1.0/24
11001000.00000001.0001-0001.00000000 200.1.2.0/24
11001000.00000001.0001-0010.00000000 200.1.3.0/24
11001000.00000001.0001-0011.00000000 200.1.15.0/24
11001000.00000001.0001-1111.00000000
- Supernet addresses:
11001000.00000001.00000000.00000000
czyli200.1.0.0/20
.11001000.00000001.00010000.00000000
czyli200.1.0.0/20
.
New routing table for router R2:
destination mask gateway 200.1.0.0
/20
R1 200.1.16.0
/20
R3
Advantage: smaller routing table (faster lookup)
Often addresses cannot be aggregated to a single supernet address.
Example: finding a CIDR address for the following network addresses:
200.1.48.0/24
200.1.49.0/24
- ...
200.1.79.0/24
200.1.48.0/24
11001000.00000001.0-0110000.00000000 200.1.49.0/24
11001000.00000001.0-0110001.00000000 ... ... 200.1.63.0/24
11001000.00000001.0-0111111.00000000 200.1.64.0/24
11001000.00000001.0-1000000.00000000 200.1.65.0/24
11001000.00000001.0-1000001.00000000 ... ... 200.1.79.0/24
11001000.00000001.0-1001111.00000000
Aggregation to a single address 200.1.0.0/17
would include nonexistent network addresses, e.g.: 200.0.127.0/24
. Instead, we aggregate into two supernets:
200.1.48.0/24
11001000.00000001.0011-0000.00000000 200.1.49.0/24
11001000.00000001.0011-0001.00000000 ... ... 200.1.63.0/24
11001000.00000001.0011-1111.00000000
Supernet: 200.1.48.0/20
200.1.64.0/24
11001000.00000001.0100-0000.00000000 200.1.65.0/24
11001000.00000001.0100-0001.00000000 ... ... 200.1.79.0/24
11001000.00000001.0100-1111.00000000
Supernet: 200.1.64.0/20
Exercises¶
Divide the network with an IP address of
200.10.20.0/24
into 8 subnets.Divide one of the subnets from the exercise above into four additional subnets.
Aggregate the following network addresses:
202.1.0.0/24
,202.1.1.0/24
, ...,202.1.63.0/24
202.1.24.0/24
,202.1.25.0/24
, ...,202.1.39.0/24
For the figure below assume as follows:
Service provider R1 (named the same as router R1 for verisimilitude) has a CIDR address of
200.200.50.0/23
. A part of the addresses within R1’s available space is kept for R1’s private use: this part must be sized sufficiently to allocate addresses to 100 devices. The remainder of R1’s address space is given away to subcontrators: R2 and R4. R2 uses a part of the address space it was given to allocate 50 devices, and subcontracts the remainder to service provider R3. R3 uses the remainder of the space to create two separate networks, each containing 30 devices. R4 uses the address space it was given to create two networks containig 120 and 70 devices respectively.Propose an address scheme for all of the resulting subnets.

Extra materials¶
- Cisco: http://www.cisco.com
- Chuck Semeria, Understanding IP Addressing: Everything You Ever Wanted To Know