510 likes | 682 Views
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)
E N D
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) ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
Classful Addressing (cont’d) • 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. • 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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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? • Look at higher order bits. • Where is the boundary between the network ID and the subnet ID? • Defined by class definition. • Where is the boundary between the subnet ID and the host ID? • Host ID is 0s in mask. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
A Network with Two Levels ofHierarchy (not subnetted) ECE 4110 – Internetwork Programming
Addresses in a Network withand without Subnetting • “Site+Subnet id” is called extended network prefix. ECE 4110 – Internetwork Programming
Analogy from the Telephone Network ECE 4110 – Internetwork Programming
Finding the Subnet Address: Straight Method • 11001000 00101101 00100010 00111000 • 11111111 11111111 1111000000000000 • 11001000 00101101 0010000000000000 • The subnetwork address is 200.45.32.0. ECE 4110 – Internetwork Programming
Finding the Subnet Address: Short-Cut Method ECE 4110 – Internetwork Programming
Comparison of a Default Mask and a Subnet Mask • The number of subnets must be a power of 2. ECE 4110 – Internetwork Programming
Example • A company is granted the site address 201.70.64.0 (class C). The company needs six subnets. • Design the subnets. ECE 4110 – Internetwork Programming
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 ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
VLSM (cont’d) • 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-network-prefix information with each route advertisement. • 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. ECE 4110 – Internetwork Programming
VLSM (cont’d) ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
192.168.0.0/16 16 Equal size blocks => 4 bits 0 1 2 3 … 12 13 14 15 0 1 … 14 15 0 1 … 30 31 0 1 … 6 7 VLSM: Example 2 • An organization has the “private” network prefix 192.168.0.0/16 and plans to deploy VLSM. • Here is their plan: ECE 4110 – Internetwork Programming
VLSM: Example 2 (cont’d) • To have 16 equal size blocks 24 =16 =>4 bits are needed beyond /16 => 20 extended-network-prefix. • Each of these blocks has 212=4096 addresses inside. ECE 4110 – Internetwork Programming
VLSM: Example 2 (cont’d) • Base Prefix: 11000000.10101000.00000000.00000000 = 192.168.0.0/16 • Subnet # 0: 11000000.10101000.00000000.00000000 = 192.168.0.0/20 • Subnet # 1: 11000000.10101000.00010000.00000000 = 192.168.16.0/20 • Subnet # 2: 11000000.10101000.00100000.00000000 = 192.168.32.0/20 • Subnet # 3: 11000000.10101000.00110000.00000000 = 192.168.48.0/20 • Subnet # 4: 11000000.10101000.01000000.00000000 = 192.168.64.0/20 …… • Subnet # 13: 11000000.10101000.11010000.00000000 = 192.168.208.0/20 • Subnet # 14: 11000000.10101000.11100000.00000000 = 192.168.224.0/20 • Subnet # 15: 11000000.10101000.11110000.00000000 = 192.168.240.0/20 ECE 4110 – Internetwork Programming
192.168.0.0/16 0 1 2 3… 12 13 14 15 0 1 … 14 15 0 1 … 30 31 0 1 … 6 7 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). ECE 4110 – Internetwork Programming
VLSM: Example 3 (cont’d) • Subnet #3: 11000000.10101000.00110000.00000000 = 192.168.48.0 /20 • Host #1: 11000000.10101000.00110000.00000001 = 192.168.48.1 • Host #2: 11000000.10101000.00110000.00000010 = 192.168.48.2 • Host #3: 11000000.10101000.00110000.00000011 = 192.168.48.3 …… …… • Host #4093: 11000000.10101000.00111111.11111101 = 192.168.63.253 • Host #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 ECE 4110 – Internetwork Programming
VLSM: Example (Notation) • We are working with a /16 base address • 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) • Subnet #144-#144 is Sub-subnet #14 under Subnet #14. • Both subnet and sub-subnet fields are 4 bits. • Thus, the extended network prefix is now 24 bits long. ECE 4110 – Internetwork Programming
192.168.0.0/16 0 1 2 3 … 12 13 14 15 0 1 … 14 15 0 1 … 30 31 0 1 … 6 7 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). ECE 4110 – Internetwork Programming
VLSM: Example 4 (cont’d) • Subnet # 14: 11000000.10101000.11100000.00000000 = 192.168.224.0/20 • Subnet # 14-0: 11000000.10101000.11100000.00000000 = 192.168.224.0/24 • Subnet # 14-1: 11000000.10101000.11100001.00000000 = 192.168.225.0/24 • Subnet # 14-2: 11000000.10101000.11100010.00000000 = 192.168.226.0/24 • Subnet # 14-3: 11000000.10101000.11100011.00000000 = 192.168.227.0/24 • Subnet # 14-4: 11000000.10101000.11100100.00000000 = 192.168.228.0/24 …… …… • Subnet # 14-14: 11000000.10101000.11101110.00000000 = 192.168.238.0/24 • Subnet # 14-15: 11000000.10101000.11101111.00000000 = 192.168.239.0/24 ECE 4110 – Internetwork Programming
192.168.0.0/16 0 1 2 3 … 12 13 14 15 0 1 2 3 … 14 15 0 1 … 30 31 0 1 … 6 7 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). ECE 4110 – Internetwork Programming
VLSM: Example 5 (cont’d) • Subnet #144-#34: 11000000.10101000.11100011.00000000 = 192.168.227.0/24 • Host #1: 11000000.10101000.11100011.00000001 = 192.168.227.1 • Host #2: 11000000.10101000.11100011.00000010 = 192.168.227.2 • Host #3: 11000000.10101000.11100011.00000011 = 192.168.227.3 • Host #4: 11000000.10101000.11100011.00000100 = 192.168.227.4 • Host #5: 11000000.10101000.11100011.00000101 = 192.168.227.5 …… …… • Host #253: 11000000.10101000.11100011.11111101 = 192.168.227.253 • Host #254: 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 ECE 4110 – Internetwork Programming
192.168.0.0/16 0 1 2 3 … 12 13 14 15 0 1 … 14 15 0 1 … 30 31 0 1 … 6 7 VLSM: Example 6 • Let’s go down one more level, and look at sub-subnet #144–#144 (192.168.238.0/24). ECE 4110 – Internetwork Programming
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 #14-14-0: 11000000.10101000.11101110.00000000 = 192.168.238.0/27 • Subnet #14-14-1: 11000000.10101000.11101110.00100000 = 192.168.238.32/27 • Subnet #14-14-2: 11000000.10101000.11101110.01000000 = 192.168.238.64/27 • Subnet #14-14-3: 11000000.10101000.11101110.01100000 = 192.168.238.96/27 • Subnet #14-14-4: 11000000.10101000.11101110.10000000 = 192.168.238.128/27 • Subnet #14-14-5: 11000000.10101000.11101110.10100000 = 192.168.238.160/27 • Subnet #14-14-6: 11000000.10101000.11101110.11000000 = 192.168.238.192/27 • Subnet #14-14-7: 11000000.10101000.11101110.11100000 = 192.168.238.224/27 ECE 4110 – Internetwork Programming
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: • 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
Supernetting (cont’d) ECE 4110 – Internetwork Programming
Comparison of Subnet, Sefault, and Supernet Masks ECE 4110 – Internetwork Programming
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 ECE 4110 – Internetwork Programming
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? ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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? ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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. ECE 4110 – Internetwork Programming
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 10001100 11000100 00000010 11000001 10001100 11000100 00000011 11000001 10001100 11000100 00000100 11000001 10001100 11000100 00000101 ECE 4110 – Internetwork Programming