Lecture10

advertisement
ECE 4110 –
Internetwork Programming
Subnetting, Supernetting,
and Classless Addressing
IP Addresses



IP address is 32 bits long.
Conceptually the address is the pair
(NETID, HOSTID).
IP domain name and addresses managed:


Formerly, by IANA (Internet Assigned Numbers
Authority)
Now by ICANN (Internet Corporation for
Assigned Names and Numbers)
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
2
Classful Addressing (revisited)
3
Classful Addressing




(cont’d)
Historically, a class A address was
assigned to networks with > 216
(65,536) hosts.
Class B to networks with 28 (256) to
216 hosts.
Class C to networks with < 218 hosts.
Class E was reserved for future use.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
4
Classful Addressing

(cont’d)
Scaling issues:




Eventual exhaustion of the IPv4 address space.
Ability to route traffic between ever increasing
number of networks that comprise the internet.
IPv4 uses 32 bit address 232  4.3 billion
addresses, and six billion lives on earth at
present.
CIDR (Classless Inter-Domain Routing) slowed
down address exhaustion.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
5
Classful Addressing

Class A all 0s network number is used to represent
the “default” route (0.0.0.0).




A routing table entry that means any destination not
matching any other table entry should be sent to the
default route.
Class A all 1s network number is loopback.


(cont’d)
Packet never leaves the machine.
Used for testing the protocol stack or accesing processes
on the same machine.
Another block (netid 10) in Class A address space is
reserved for private use.
27 - 3 = 125 class A networks.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
6
Classful Addressing




(cont’d)
16 class B blocks are reserved for
private addresses.
214 - 16 = 16,368 class B blocks.
256 Class C blocks are used for private
addresses.
221-256 = 2,096,896 class C networks.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
7
Classful Addressing



(cont’d)
Most of class E is wasted.
Nobody wants class C.
In the beginning:



IP addresses were assigned based on request,
not need.
32-bit address was thought to be plenty.
Classful addressing is easy to understand and
implement, but not efficient. Class C blocks are
too small, class B blocks are too large.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
8
Subnetting




Makes the subnet structure of a network
invisible outside the organization’s private
network.
External Internet does not need to know
internal subnet structure.
To reach any host, external routers only
need to know the path to the “gateway”
router for the entire subnetwork.
Subnetting reduces the size of routing
tables.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
9
Subnetting



(cont’d)
At boot time, a machine gets its own IP
address (E.g., stored on disk).
Host also needs to know how many bits are
used for subnet ID and how many for host
ID. This is the subnet mask.
Subnet mask is 32 bit value containing “one
bits” for the network ID and subnet ID,
“zero valued bits” for host ID.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
10
Subnetting

(cont’d)
When a host is given its own IP address
and its subnetwork mask it can then figure
out:

Am I class A, B, or C address?


Where is the boundary between the network ID
and the subnet ID?


Look at higher order bits.
Defined by class definition.
Where is the boundary between the subnet ID
and the host ID?

Spring 2003
Tuna Tugcu
Host ID is 0s in mask.
ECE 4110 – Internetwork Programming
11
Subnetting



(cont’d)
All 0’s host number is used to identify the
base network (or subnetwork).
All 1’s host number represents broadcast
address for the network (or subnetwork).
It is also possible to deploy network
numbers from the private address space for
internal connectivity (RFC 1918).

A Network Address Translator (NAT) must be
used to provide external internet access.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
12
A Network with Two Levels of
Hierarchy (not subnetted)
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
13
A Network with Three Levels of
Hierarchy (subnetted)
14
Addresses in a Network with
and without Subnetting

“Site+Subnet id” is called extended network prefix.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
15
Analogy from the Telephone
Network
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
16
Default Mask vs Subnet Mask
17
Finding the Subnet Address:
Straight Method

11001000 00101101 00100010 00111000
11111111 11111111 11110000 00000000
11001000 00101101 00100000 00000000

The subnetwork address is 200.45.32.0.


Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
18
Finding the Subnet Address:
Short-Cut Method
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
19
Comparison of a Default
Mask and a Subnet Mask

The number of subnets must be a power of 2.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
20
Example

A company is granted the site address
201.70.64.0 (class C). The company
needs six subnets.

Design the subnets.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
21
Example (Sol’n)

The number of 1s in the default
mask is 24 (class C).





6 is not a power of 2.
The next number that is a power of 2 is 8.
We need 3 more 1s in the subnet mask.
The total number of 1s in the subnet mask is 27
(24 + 3).
Subnet mask:


11111111 11111111 11111111 11100000, or
255.255.255.224
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
22
Example (Sol’n)
23
Variable Length Subnet
Masks (VLSM)



IP network is subdivided in unequal
pieces.
Each subnetwork has its own mask
thus “extended-network-prefixes”
have different lengths.
Allows size of subnets to reflect the
number of required host addresses in
each subdivision.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
24
VLSM

We want to use:



Smaller subnets (longer masks) where we have fewer
nodes.
Larger subnets (shorter masks) where we have more
nodes.
Routing protocols must carry extended-networkprefix information with each route advertisement.


(cont’d)
OK to use: OSPF, RIPV2, IS-IS, CISCO’s E–IGRP they are
all classless
Routers must use a forwarding algorithm based on
longest match.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
25
VLSM
Spring 2003
Tuna Tugcu
(cont’d)
ECE 4110 – Internetwork Programming
26
VLSM: Example 1


Destination: 10.1.2.5 =
00001010.00000001.00000010.00000101
Routing table has entries for:

Route #1: 10.1.0.0/ 24
10.1.0.0/24 = [00001010.00000001.00000000].00000000

Route #2: 10.1.2.0/ 24
10.1.2.0/24 = [00001010.00000001.00000010].00000000

Route #3: 10.1.0.0/ 16
10.1.0.0/16 = [00001010.00000001].00000000.00000000

Route #2 has the longest matching prefix.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
27
Sidenote: Private Networks

IANA has reserved the following addresses as
private networks (RFC – 1918).

10.0.0.0 - 10.255.255.255
(10.0.0.0/8 prefix)

172.16.0.0 - 172.31.255.255
(172.16.0.0/12 prefix)

192.168.0.0 - 192.168.255.255
(192.168.0.0/16 prefix)


Private networks are not routable on the Internet.
They can be used simultaneously by many
organizations.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
28
VLSM: Example 2


An organization has the “private” network prefix
192.168.0.0/16 and plans to deploy VLSM.
Here is their plan:
192.168.0.0/16
0
1
0
1
Spring 2003
Tuna Tugcu
…
2
30
3
31
…
12
13
0
14
1
…
0
1

15
14
…
16 Equal size
blocks => 4 bits
15
6
ECE 4110 – Internetwork Programming
7
29
VLSM: Example 2


(cont’d)
To have 16 equal size blocks 24 =16 =>4 bits are
needed beyond /16 => 20 extended-networkprefix.
Each of these blocks has 212=4096 addresses
inside.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
30
VLSM: Example 2









(cont’d)
Base Prefix:
11000000.10101000.00000000.00000000 = 192.168.0.0/16
Subnet
Subnet
Subnet
Subnet
Subnet
……
Subnet
Subnet
Subnet
11000000.10101000.00000000.00000000
11000000.10101000.00010000.00000000
11000000.10101000.00100000.00000000
11000000.10101000.00110000.00000000
11000000.10101000.01000000.00000000
Spring 2003
Tuna Tugcu
#
#
#
#
#
0:
1:
2:
3:
4:
=
=
=
=
=
192.168.0.0/20
192.168.16.0/20
192.168.32.0/20
192.168.48.0/20
192.168.64.0/20
# 13: 11000000.10101000.11010000.00000000 = 192.168.208.0/20
# 14: 11000000.10101000.11100000.00000000 = 192.168.224.0/20
# 15: 11000000.10101000.11110000.00000000 = 192.168.240.0/20
ECE 4110 – Internetwork Programming
31
VLSM: Example 3


While at this level in the hierarchical addressing
plan, let’s look at the resulting host addresses
available for Subnet #3.
Define the host addresses for Subnet #34
(192.168.48.0/20).
192.168.0.0/16
0
1
0
Spring 2003
Tuna Tugcu
1
…
2
30
3
31
…
12
13
0
14
1
…
0
1
15
14
15
…
ECE 4110 – Internetwork Programming
6
7
32
VLSM: Example 3







(cont’d)
Subnet #3:
11000000.10101000.00110000.00000000 = 192.168.48.0 /20
Host
Host
Host
……
……
Host
Host
11000000.10101000.00110000.00000001 = 192.168.48.1
11000000.10101000.00110000.00000010 = 192.168.48.2
11000000.10101000.00110000.00000011 = 192.168.48.3
#1:
#2:
#3:
#4093: 11000000.10101000.00111111.11111101 = 192.168.63.253
#4094: 11000000.10101000.00111111.11111110 = 192.168.63.254
The broadcast address for Subnet #34 is found by setting the host-number field to
all 1s.

Broadcast : 11000000.1010100.00111111.11111111 = 192.168.63.255
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
33
VLSM: Example (Notation)

We are working with a /16 base address



Subnet #144-#144 is Sub-subnet #14 under
Subnet #14.


Subnet #34 is the subnet with value 3
20-bit extended network prefix
(a 4-bit field has been added to the /16 base
address)
Both subnet and sub-subnet fields are 4 bits.
Thus, the extended network prefix is now 24
bits long.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
34
VLSM: Example 4
While still at the same level, let’s look at the
16 subnets we have under Subnet #144
(192.168.224.0/20).

192.168.0.0/16
0
1
0
1
…
Spring 2003
Tuna Tugcu
2
30
3
31
…
12
13
0
14
1
…
0
1
15
14
…
15
6
7
ECE 4110 – Internetwork Programming
35
VLSM: Example 4








(cont’d)
Subnet # 14:
11000000.10101000.11100000.00000000 = 192.168.224.0/20
Subnet
Subnet
Subnet
Subnet
Subnet
……
……
Subnet
Subnet
11000000.10101000.11100000.00000000
11000000.10101000.11100001.00000000
11000000.10101000.11100010.00000000
11000000.10101000.11100011.00000000
11000000.10101000.11100100.00000000
#
#
#
#
#
14-0:
14-1:
14-2:
14-3:
14-4:
=
=
=
=
=
192.168.224.0/24
192.168.225.0/24
192.168.226.0/24
192.168.227.0/24
192.168.228.0/24
# 14-14: 11000000.10101000.11101110.00000000 = 192.168.238.0/24
# 14-15: 11000000.10101000.11101111.00000000 = 192.168.239.0/24
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
36
VLSM: Example 5

Still at the same level, let’s look at the host
addresses on one of these new sub – subnets,
Sub-subnet #144-#34 (192.168.227.0/24).
192.168.0.0/16
0
1
0
1
…
2
30
3
31
…
12
13
14
…
0 1 2 3
0
Spring 2003
Tuna Tugcu
15
14 15
1
…
ECE 4110 – Internetwork Programming
6
7
37
VLSM: Example 5









(cont’d)
Subnet #144-#34: 11000000.10101000.11100011.00000000 = 192.168.227.0/24
Host
Host
Host
Host
Host
……
……
Host
Host
#1:
#2:
#3:
#4:
#5:
11000000.10101000.11100011.00000001
11000000.10101000.11100011.00000010
11000000.10101000.11100011.00000011
11000000.10101000.11100011.00000100
11000000.10101000.11100011.00000101
=
=
=
=
=
192.168.227.1
192.168.227.2
192.168.227.3
192.168.227.4
192.168.227.5
#253:
#254:
11000000.10101000.11100011.11111101 = 192.168.227.253
11000000.10101000.11100011.11111110 = 192.168.227.254
The broadcast address for Subnet # 144–#34 is determined by setting all the bits in
the host number field to 1:

Broadcast:
11000000.10101000.11100011.11111111 = 192.168.227.255
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
38
VLSM: Example 6
Let’s go down one more level, and look at
sub-subnet #144–#144 (192.168.238.0/24).

192.168.0.0/16
0
1
0
1
…
Spring 2003
Tuna Tugcu
2
30
3
31
…
12
13
0
14
1
…
0
1
15
14
…
15
6
7
ECE 4110 – Internetwork Programming
39
VLSM: Example 6










(cont’d)
Since 8 = 23 , 3 more bits are required to identify each of eight subnets.

Extended-network-prefix length will be /27.
Subnet #14-14:
11000000.10101000.11101110.00000000 = 192.168.238.0/24
Subnet
Subnet
Subnet
Subnet
Subnet
Subnet
Subnet
Subnet
11000000.10101000.11101110.00000000
11000000.10101000.11101110.00100000
11000000.10101000.11101110.01000000
11000000.10101000.11101110.01100000
11000000.10101000.11101110.10000000
11000000.10101000.11101110.10100000
11000000.10101000.11101110.11000000
11000000.10101000.11101110.11100000
#14-14-0:
#14-14-1:
#14-14-2:
#14-14-3:
#14-14-4:
#14-14-5:
#14-14-6:
#14-14-7:
Spring 2003
Tuna Tugcu
=
=
=
=
=
=
=
=
192.168.238.0/27
192.168.238.32/27
192.168.238.64/27
192.168.238.96/27
192.168.238.128/27
192.168.238.160/27
192.168.238.192/27
192.168.238.224/27
ECE 4110 – Internetwork Programming
40
Going the Other Way:
Supernetting


Several class C blocks combined to create
larger blocks.
Two methods:

Pick the blocks to be merged randomly.


Routers outside the organization treat each block
separately.
Pick them according to a set of rules:



Spring 2003
Tuna Tugcu
Number of blocks must be a power of 2.
Blocks must be contiguous.
If number of blocks is N, third byte of the first address
must be divisible by N.
ECE 4110 – Internetwork Programming
41
Supernetting
Spring 2003
Tuna Tugcu
(cont’d)
ECE 4110 – Internetwork Programming
42
Comparison of Subnet, Sefault,
and Supernet Masks
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
43
Supernetting:
Example 1

Question:


We need to make a supernetwork out of 16
class C blocks. What is the supernet mask?
Solution:

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
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
44
Supernetting:
Example 2

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?
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
45
Supernetting:
Example 2 (sol’n)

Apply the supernet mask to see if we can
find the beginning address.




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.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
46
Supernetting:
Example 3


A supernet has a first address of
205.16.32.0 and a supernet mask of
255.255.248.0.
How many blocks are in this supernet
and what is the range of addresses?
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
47
Supernetting:
Example 3 (sol’n)


Supernet mask has 21 1s.
Default mask has 24 1s.
(difference of 3 bits)
 23 or 8 blocks in this supernet.



Blocks are 205.16.32.0 to
205.16.39.0.
First address is 205.16.32.0.
Last address is 205.16.39.255.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
48
CIDR: Classless InterDomain
Routing




CIDR removes concept of class A, B, C
network addresses.
Instead, uses concept of network prefix.
CIDR supports arbitrary sized networks.
Routers use network prefix instead of first 3
bits of IP address to determine dividing
point between network number and host
number.
Spring 2003
Tuna Tugcu
ECE 4110 – Internetwork Programming
49
CIDR

(cont’d)
Constraints:


Block size must be a power of 2.
Beginning address must be divisible by block
size.
E.g.: If the block contains 4 addresses, the starting
address cannot be 193.140.196.2, because:
11000001
11000001
11000001
11000001
Spring 2003
Tuna Tugcu
10001100
10001100
10001100
10001100
11000100
11000100
11000100
11000100
00000010
00000011
00000100
00000101
ECE 4110 – Internetwork Programming
50
Download