CSCI 3500: Studio 23

Network Layer


The network layer is responsible for routing messages between separate physical machines. The most common network-layer protocol is the famous Internet Protocol (IP). The familiar IP address imposes a structure on how to route packets through an IP network.

In this studio, you will:

  1. Learn to split an IP address into a network address and host identifier
  2. Use the CIDR system to specify groups of IP addresses called subnets
  3. Compute IP address / subnet inclusion
  4. Route packets based on the longest matching network address rule

Please complete the required exercises below, as well as any optional enrichment exercises that you wish to complete.

As you work through these exercises, please record your answers in a text file. When finished, submit your work via the git repository.

Make sure that the name of each person who worked on these exercises is listed in the first answer, and make sure you number each of your responses so it is easy to match your responses with each exercise.


Required Exercises

  1. As the answer to the first exercise, list the names of the people who worked together on this studio.

  2. In IP routing it is useful to subdivide the IP address space into logical subdivisions called subnets. An example of a subnet might be the set of all addresses from 152.221.54.0 to 152.221.54.255, which specifies a subnet containing 256 addresses. Recall that an IPv4 address is a 32-bit number comprised of four 8-bit integers. Which bits are constant and which bits vary in the above subnet range?

  3. A compact way of specifying subnets (called CIDR notation or slash notation) is to specify the number of bits that are fixed and the number of bits that are allowed to vary. For example, 63.48.0.0/12 specifies a subnet defined by the twelve most significant bits of the address. These twelve leftmost bits (0011 0011 0011) are called the network address and the remaining twenty bits are called the host identifier, meaning they specify a particular host in the subnet.

    Specify the subnet from Exercise 2 using CIDR notation.

  4. Write the network address and the host identifier, in binary, for the IP address 152.78.101.35/20.

  5. Subnets are also how the IANA (Internet Assigned Numbers Authority) allocates blocks of IP addresses to businesses and organizations. St. Louis University has its own allocation. Give the CIDR notation for SLU's IPv4 allocation given on this webpage.

  6. How many bits are in SLU's host identifier? How many IP addresses have been assigned to SLU?

  7. Subnets are extremely useful for routing because they allow you to route packets to a whole subnet rather than to a specific computer. This way, a router in New York doesn't have to keep track of each individual computer in a subnet in Los Angeles. It only needs to keep track of how to route a packet to their aggregate network address. To make this kind of routing decision you need to be able to tell whether a desired IP address belongs to a subnet. Which of the IP addresses below belong to the subnet 38.191.208.0/20? (Hint: You need to compare the binary representations of the network addresses, not the decimal.).

    A) 38.191.240.22
    B) 38.191.222.47
    C) 38.181.210.128
    D) 38.191.207.255
    

  8. Notice that a single IP address can match multiple network addresses. For example, the IP address 165.35.124.22 matches 165.35.124.0/24 as well as 165.35.0.0/16 and 165.32.0.0/12. Which of the following subnets match the IP address 200.100.50.25? (Hint: You need to compare the binary representations of the network addresses, not the decimal.)
    A) 200.0.0.0/8
    B) 200.96.0.0/12
    C) 200.64.0.0/16
    D) 200.100.48.0/22
    

  9. As above, subnets are useful because they allow us to make routing decisions easily. Recall that a router makes routing decisions by comparing the destination IP address of a waiting packet with all of possible destinations in its routing table and selecting the "closest" matching destination. We can now specify exactly what is meant by finding the "closest" matching router table entry: the closest entry is the one with the longest matching network address. For example, the IP address 20.40.80.160 matches both 20.40.0.0/16 and 20.40.80.0/24. Which subnet is the longer match?

  10. Suppose a router has the following routing table:

    Destination Interface Cost
    192.168.1.0/24 Ethernet0 300
    192.168.0.0/16 Ethernet1 600
    192.168.1.47/32 Ethernet2 1
    192.168.1.156/32 Ethernet3 1
    0.0.0.0/0 Ethernet5 1000

    Suppose some packets come into the router with the following destination IP addresses. Which interface are they sent out on? (Which router table entry has the longest matching network address?)

    A) 192.168.1.102
    B) 192.168.24.94
    C) 192.168.1.47
    D) 165.134.107.80
    
    

Optional Enrichment Exercises

  1. An alternative system to using CIDR addresses is to use a network mask. This system allows you to specify which individual bits of an IP address should be considered the network address rather than the host specifier. A network mask is given as a 32-bit number in IP address format, and each bit that is a one in the binary representation is considered part of the network address. For example, the CIDR address 192.168.0.0/16 is equivalent to the address 192.168.0.0 with a network mask of 255.255.0.0. In this case, the network mask would be:

    11111111 11111111 00000000 00000000

    The network address approach is strictly more flexible and allows you to specify some truly complex routing rules. For example, the CIDR system is incapable of specifying the mask 255.0.255.0, which would give a mask of:

    11111111 00000000 11111111 00000000

    However, such network rules are typically not used in practice.

    >