CS445: IPv4 Addresses In-class activity Names: Part 1: Address Classes Original three classes of IPv4 addresses: A: 0 network (7 bits) host (24 bits) B: 10 network (14 bits) host (16 bits) C: 110 network (21 bits) host (8 bits) 1. How many unique network IDs are there in class A addresses? # of unique hosts? 2. How many unique network IDs are there in class B addresses? # of unique hosts? 3. How many unique network IDs are there in class C addresses? # of unique hosts? 4. Which type of address do you think is the most popular? Why? IP addresses are often written not in the binary form, but in decimal form as one number per byte. For example, here is an IP address written in decimal: 171.69.210.245 5. The 171 corresponds to the first byte, interpreted as the most significant bit being on the left. 171 (decimal) is what number in binary? 6. To which address class does this IP address belong? 7. Now you know about the IP address classes. You can quickly identify the address s class by looking at the first byte of the IP address. a. What is the numerical decimal range of the first byte for class A addresses? b. Range for class B? c. Range for class C? Now, let s consider the job of routers in the Internet. From prior lectures, you know that the routers do fragmentation and forwarding. Each IP packet has an IP address for the sender and another for the destination. Forwarding for routers becomes:
Router Forwarding Procedure If network address of destination is a network on one of my interfaces, deliver packet to that interface. Else If network address of destination is in my forwarding table, Deliver to next hop router Else Deliver packet to default router Part 2: Subnetting Ok, let s go back to discussing addresses. It seems that class B addresses would be most popular, yet there are not enough of these to satisfy everyone who wants a class B address. Recall that the class B address looks like: 10 network (14 bits) Host (16 bits) Hmmm, perhaps two or more companies/organizations could share a single class B address. This leads to subnetting. 8. What are advantages of using subnetting (think about scalability and effective use of address space)? Mechanics of subnetting: Create a mask (usually consecutive ones) to indicate the subnet ID. 10 network (14 bits) Host (16 bits) //original IP address 111111 1111 (20 bits) Host (12 bits) //subnet mask This creates a 3-part IP address: 10 network (14 bits) subnet (4 bits) host (12 bits) The size of the subnet portion of the address depends on the length of the subnet mask. In the case above, the mask is 20 bits long, carrying over 4 bits past the network portion of the class B address space. So, this subnet is 4 bits long. But, the subnet mask can be shorter or longer than 4 bits, depending on how much room each subnet wants to keep for the host IDs. Example Suppose we want to share an IP class B network address among several corporations. We could create the subnet mask: 255.255.255.128 (25 ones, 7 zeros)
This would create two subnets, each that could support 128 hosts. Corp A has subnet: 128.96.79.128 [so, it would have addresses 128.96.79.128 128.96.79.255] Corp B has subnet: 128.96.79.0 [so, it would have addresses 128.96.79.0 128.96.79.127] Suppose an IP packet arrives with IP address 128.96.79.89. The router needs to determine to which subnet to forward the packet. To determine the subnet, use the bit AND operator between IP address and the subnet mask: 128.96.79.89 & 255.255.255.128 = 128.96.79.0 (so, this is on Corp B) 9. Now, suppose a packet arrives with IP address 128.96.79.200. To which subnet should the packet be delivered (corp A or corp B)? Now, forwarding just got a little more complicated. Each router needs to have in its tables: Subnet Number Subnet Mask Next Hop 128.96.79.0 255.255.255.128 Interface 1 128.96.79.128 255.255.255.128 Interface 2 128.96.85.0 255.255.255.0 Router 2 Forwarding Algorithm with Subnets: If host, D = subnet mask of host & destination address If D = subnet # of host, deliver locally Else send to router for forwarding If router, For each entry in forwarding table: D = subnet mask of host & destination address If D == subnet # in table, deliver to next hop If no entry found, deliver to default router Part 3: Classless Addressing (CIDR) Perhaps we should just get rid of classes completely and use the address space more efficiently and more flexibly. This is what CIDR (classless interdomain routing) tries to do. In part 2, we created subnets of class B addresses. Now, classless addressing effectively creates supernets, too.
Another advantage of classless addressing is reducing the size of forwarding tables, if we can have one aggregate entry for several networks located at the same corporation. The idea of CIDR is to generalize IP addresses so the network part is any length. Then, we can give out several class C addresses to a single corporation (now that class B addresses are exhausted). For example, we might give one corporation the a chunk of network addresses with network portions 192.4.16 through 192.4.31 (remember, class C addresses have 110 and then 21 bits for the network portion). It would be a shame to put all 16 entries into a forwarding table for this single corporation (which is what we would do in the original class-based scheme). We could be smarter and just put the network value and its length in the forwarding table. Now, this corporation basically has an address with a network portion of 20 bits: 192.4.16 = 11000000 00000100 00010000 192.4.31 = 11000000 00000100 00011111 (So, the first 20 bits are the same and just these first 20 bits can be stored as a single entry in a forwarding table. Nice routing aggregation. But, this only works if the addresses are handed out in consecutive blocks.) The network address would now be written as: 192.4.16/20 //first 20 bits are the same CIDR addresses can also be written in hexadecimal (each 4-bit chunk is written with a single digit in hex). So, 192 (decimal) is 11000000 (binary). 192 in hex is C0 (C for 1100 and 0 for 0000). Note that standard class C addresses are referred to as slash 24 since the first 24 bits denote the network address. The one above would be called a slash 20 address. Impacts to forwarding Now, the router might have several addresses that share a common prefix. When determining where to forward packets, the router uses the longest match in the forwarding table to determine the next hop. 10. Suppose the table below is the forwarding table for a router and the addresses use CIDR. Addresses are written in hex. Suppose six packets arrive with destination addresses shown below. For each destination address, state the next hop for the packet. In the forwarding table, if there is a single entry between the dots, it means that there are leading zeros for this portion of the address. C4.5E.2.0 means C4.5E.02.00.
Forwarding table: Net/Length NextHop C4.5E.2.0/23 A C4.5E.4.0/22 B C4.5E.C0.0/19 C C4.5E.40.0/18 D C4.4C.0.0/14 E C0.0.0.0/2 F 80.0.0.0/1 G Determine the next hop for the following addresses: Destination Address C4.4B.31.2E C4.5E.05.09 C4.4D.31.2E C4.5E.03.87 C4.5E.7E.12 C4.5E.D1.02 Next Hop F The first entry above is done for you. C4.4B.31.2E has the longest match with C0.0.0.0/2 (just the first four bits match, but it matches at least the first 2, as given by the slash 2), so the router forwards it to next hop F. It might be tempting to forward it to E, since the address matches the first 12 bits. But, it needs to match at least 14 bits to have a match with C4.4C.0.0. Part 4: Summary IPv4 started with class-based addresses. Then, the Internet got too big and class B addresses were too popular. So, subnetting and CIDR are also used to create more addresses that make more effective use of the limited 32 bits by sharing class B addresses (subnetting) and aggregating class C addresses (CIDR, or supernetting ). IPv6 uses 128-bit addresses, so there are a whole lot more unique addresses. We will look at IPv6 in a future lecture. Part 5: Optional (if time) 11. Determine what the router will do with packets with IP addresses shown below. Assume the router has a forwarding table that uses subnetting: SubnetNumber SubnetMask NextHop 128.96.170.0 255.255.254.0 Interface 0 (directly connected network)
128.96.168.0 255.255.254.0 Interface 1 (directly connected network) 128.96.166.0 255.255.254.0 R2 128.96.164.0 255.255.252.0 R3 (default) R4 Determine the next hop for the following addresses: Destination Address Next Hop 128.96.171.92 Interface 0 128.96.167.151 128.96.163.151 128.96.169.192 128.96.165.121 The first entry is done for you. Applying the mask 255.255.254.0 to 128.96.171.92 gives us 128.96.170.0, so we use interface 0 for forwarding.