CSCI 3500: Studio 23
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:
- Learn to split an IP address into a network address and host identifier
- Use the CIDR system to specify groups of IP addresses called subnets
- Compute IP address / subnet inclusion
- 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 by sending your text file and
source code to firstname.lastname@example.org
with the phrase
in the subject line.
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.
- As the answer to the first exercise, list the names of the people who
worked together on this studio.
- 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 184.108.40.206
to 220.127.116.11, 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?
- 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, 18.104.22.168/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.
- Write the network address and the host identifier, in binary,
for the IP address 22.214.171.124/20.
- 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.
- How many bits are in SLU's host identifier? How many IP addresses have been assigned to SLU?
- 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 126.96.36.199/20? (Hint: You need to compare
the binary representations of the network addresses, not the decimal.).
- Notice that a single IP address can match multiple network addresses. For example, the
IP address 188.8.131.52 matches 184.108.40.206/24 as well as 220.127.116.11/16 and
18.104.22.168/12. Which of the following subnets match the IP address 22.214.171.124?
(Hint: You need to compare the binary representations of the network addresses, not the decimal.)
- 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
126.96.36.199 matches both 188.8.131.52/16 and 184.108.40.206/24. Which subnet
is the longer match?
- Suppose a router has the following routing table:
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?)
Optional Enrichment Exercises
- 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.>