Data Plane Quiz — Study Guide

The two questions cover longest prefix match on a forwarding table written in CIDR (sizing a block, matching destinations, and adding an entry) and a DHCP exchange between a laptop and two servers drawn on a timeline.

Q1Longest Prefix Match in CIDR

1 · Reading a block from its prefix

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 172.20.0.0/16 covers all 256 third-byte values 172.20.96.0/20 covers 96 to 111 172.20.104.0/22 covers 104 to 107 172.20.105.0/24 covers 105

Each box on the axis is one value of the third byte of the address, from 96 to 111. Each bar is one block, written as a prefix, and the bar covers the third-byte values that block contains. All four addresses start 172.20. The /16 bar runs off both ends because it covers every third-byte value, 0 to 255.

The bars are nested: each shorter block contains every longer block drawn inside it. A longer prefix leaves fewer free bits, so it covers fewer values §4.3.2.

A block starts at the third byte written in its prefix and covers a fixed number of values, which the block-size table gives. 172.20.96.0/20 covers 16 values starting at 96, so it runs from 172.20.96.0 to 172.20.111.255. A destination matches an entry when its first two bytes agree and its third byte falls inside the entry's range. When several entries match, the router forwards on the one with the longest prefix, because it is the most specific §4.2.1.

A router uses longest prefix match with this forwarding table. The block-size table beside it says how far each prefix reaches: a block starts at the third byte in its prefix and covers that many third-byte values. For example, 10.1.16.0/20 covers 16 values, so it runs from 10.1.16.0 to 10.1.31.255.

Prefix lengthThird-byte values coveredAddresses
/16256 (all)65,536
/20164,096
/2182,048
/2241,024
/232512
/241256
Destination prefixLink interface
128.64.0.0/160
128.64.32.0/201
128.64.40.0/232
128.64.41.0/243
otherwise4
  1. 1

    How many addresses does 128.64.40.0/23 cover? What are its first and last addresses?

    Addresses:  First:  Last:

  2. 2

    For each destination, list the interfaces whose entries match, then give the interface the datagram leaves on. Row a is filled in as an example.

    Destination addressEntries that matchInterface
    a128.64.41.2000, 1, 2, 33
    b128.64.40.9
    c128.64.43.5
    d128.64.48.3
    e128.65.41.200
  3. 3

    The operator wants every address from 128.64.48.0 to 128.64.48.255 to leave on interface 5. Write the entry to add, in CIDR form.

    Entry: → 5

Hint
Part 1: the last address is in the last third byte the block covers, with fourth byte 255. Part 2: every entry agrees on the first two bytes, 128.64, so start there. Then use the block-size table to turn each entry into a range of third bytes, and check whether the destination's third byte falls inside it.
Bigger hint
128.64.32.0/20 covers 16 third-byte values starting at 32: third bytes 32 to 47. 128.64.40.0/23 covers 2 starting at 40: 40 to 41.
Answer

1512 addresses: 128.64.40.0 to 128.64.41.255

The block-size table's /23 row gives 2 third-byte values and 512 addresses. The block starts at the third byte written in its prefix, 40, so it covers third bytes 40 and 41, with every fourth byte in each §4.3.2.

If you answered 256, or a last address of 128.64.40.255, you read the block as a /24, which covers one third-byte value. A /23 leaves one more bit free, so it is twice as large.

2b → 2, c → 1, d → 0, e → 4

Destination addressEntries that matchInterface
a128.64.41.2000, 1, 2, 33
b128.64.40.90, 1, 22
c128.64.43.50, 11
d128.64.48.300
e128.65.41.200none (otherwise)4
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 128.64.0.0/16 covers all 256 third-byte values (interface 0) 128.64.32.0/20 covers 32 to 47 (interface 1) 128.64.40.0/23 covers 40 to 41 (interface 2) 128.64.41.0/24 covers 41 (interface 3) added in part 3: 128.64.48.0/24 covers 48 (interface 5) a b c d

The axis is the third byte, from 32 to 48. Each bar is one entry of the forwarding table over the third-byte values its block covers, with the interface it sends to. The dots mark the destinations by their third byte: a is 41, b is 40, c is 43 and d is 48. The dashed bar is the entry added in part 3. Destination e is not on the axis, because its second byte is 65 and every entry starts 128.64.

A destination matches every bar above its dot, and the longest of those bars gives the interface. Ignore the dashed bar for part 2: it does not exist until part 3.

Destination b has third byte 40, inside the /20 (32 to 47) and the /23 (40 to 41) but not the /24, which covers only 41, so it matches 0, 1 and 2 and the /23 is the longest. Destination c has third byte 43, inside the /20 but just past the /23, so it matches 0 and 1. Destination d has third byte 48, just past the /20's last value, 47, so only the /16 matches. Destination e's second byte is 65, so it fails every entry. The table leaves the "otherwise" row out of the matching lists, as in row a; it is used only when no other entry matches, and that is the case for e §4.2.1.

If you gave interface 0 for b or c, you took the first match in the table, or the /16 because it matched. The order of the table does not matter: of all the entries that match, the longest prefix wins.

If you gave interface 2 for c or interface 1 for d, you stretched a block one value too far. The /23 starting at 40 ends at 41, and the /20 starting at 32 ends at 47, so the next value is outside it.

If you gave interface 0 for e, you compared only the first byte. Every entry fixes the first two bytes, 128.64, and e starts 128.65.

3128.64.48.0/24 → 5

The range 128.64.48.0 to 128.64.48.255 is exactly one third-byte value, 48, with every fourth byte. In the block-size table that is a /24. A /23 starting at 48 would also take 128.64.49.x, and a /20 starting at 48 would take third bytes 48 to 63, so the /24 is the only entry that covers just the range asked for. In the figure, only d changes: it matches both the /16 and the new /24, the /24 is longer, and d now leaves on 5. No other destination in part 2 starts 128.64.48, so b, c and e are unchanged.

The question's table holds only prefixes from /16 to /24, so a block is always whole third-byte values. A longer prefix such as a /26 splits the fourth byte instead, and the same rule, longest matching prefix wins, applies §4.3.2.

If you wrote 128.64.48.0/23 or /20, you picked a block that includes addresses outside 128.64.48.0 to 128.64.48.255, and those addresses would leave on interface 5 too.

§4.3.2 IPv4 Addressing; §4.2.1 Input Port Processing and Destination-Based Forwarding · video · knowledge checks · practice problems

Figures after the authors' Chapter 4 slides, copyright © 1996–2025 J.F. Kurose and K.W. Ross.

GW CSCI 4431/6431 Computer Networks · Week 10 Data Plane Quiz

Q2DHCP on a Timeline

A laptop joins a LAN that has two DHCP servers: server A at 10.0.0.1 and server B at 10.0.0.2. Both answer the laptop. A offers 10.0.0.57 and B offers 10.0.0.99. A's offer reaches the laptop first, and the laptop takes it.

DHCP reference, alphabetical

  1. 1

    Draw the whole exchange. Draw each message as an arrow from its sender to every machine whose DHCP program receives it. Number the arrows in the order they are sent and label each with its message name, e.g. "1 DISCOVER".

    Server A 10.0.0.1 Laptop no address yet Server B 10.0.0.2 time
  2. 2

    Fill in the addresses.

    MessageSource IP : portDestination IP : port
    A's OFFER
    REQUEST
    ACK
  3. 3

    When can the laptop first send a datagram from 10.0.0.57?

Hint
Part 1: what does the laptop have to do before any server knows it exists? Part 2: what IP address does the laptop own when each message is sent?
Bigger hint
Part 1: a datagram to port 67 is received by both servers' DHCP programs; a datagram to port 68 only by the laptop's. Part 2: the laptop does not own 10.0.0.57 until the ACK arrives, so nothing before that can be addressed to it.
Answer

1Five messages, seven arrows

Server A 10.0.0.1 Laptop no address yet Server B 10.0.0.2 time 1 DISCOVER 1 DISCOVER 2 OFFER 10.0.0.57 3 OFFER 10.0.0.99 4 REQUEST (names A) 4 REQUEST (names A) 5 ACK 10.0.0.57 owns 10.0.0.57

Each vertical line is one machine, with time running downward. Each arrow is one message, drawn from its sender to a machine whose DHCP program receives it, and it slopes down because the message takes time to arrive. The number gives the order the messages are sent in, and the name says which message it is. DISCOVER and REQUEST are each drawn as two arrows because each is one message that reaches both servers.

The OFFERs and the ACK each have a single arrow, to the laptop. No arrow runs between the two servers.

The laptop starts with no address, so it first has to find out which servers exist. The DISCOVER goes to port 67, where both servers' DHCP programs listen, so both receive it and each answers with an OFFER: A proposes 10.0.0.57 and B proposes 10.0.0.99. A's reaches the laptop first, and the laptop takes it. The laptop sends one REQUEST that names A. It goes to port 67, so B receives it too, sees that it names A, and takes no further part. Only A sends the ACK. The OFFERs and ACK go to port 68, where only DHCP clients listen, so a server never receives another server's OFFER §4.3.2. You may accept messages 2 and 3 in either order, as long as A's OFFER arrives first.

If you drew one DISCOVER arrow, only one server heard the laptop, and there would be no second offer to choose between. Both servers listen on port 67, so a message to port 67 reaches both.

If you drew arrows between A and B, you treated the servers as sharing what they hear. An OFFER goes to port 68, which is a client's port, so the other server's DHCP program does not receive it. The servers do not coordinate with each other.

If you drew the REQUEST to A only, B never learns that its offer was not taken. The REQUEST is a broadcast to port 67, so both servers receive it, and it is the message's contents, not its delivery, that name A.

2Every message is a broadcast

MessageSource IP : portDestination IP : port
A's OFFER10.0.0.1 : 67255.255.255.255 : 68
REQUEST0.0.0.0 : 68255.255.255.255 : 67
ACK10.0.0.1 : 67255.255.255.255 : 68

The laptop owns no address until the ACK, so it sends from 0.0.0.0, and the servers cannot address it as 10.0.0.57. Every message therefore goes to the broadcast address 255.255.255.255, and the port decides who receives it: 67 for messages from the client and 68 for messages from a server. A server sends from its own address, 10.0.0.1, and its own port, 67. This question leaves out the other information the ACK carries, such as the subnet mask, the first-hop router and the DNS server, and the lease time that says how long the address is the laptop's §4.3.2.

If you wrote 10.0.0.57 as the destination of the OFFER or the ACK, or as the source of the REQUEST, you used an address the laptop does not own yet. A machine accepts a datagram sent to a specific IP address only if that address is its own, so the laptop would discard it.

If you swapped the ports, you read the port as belonging to the message instead of to the program. The server always sends from its own port, 67, to the client's port, 68, and the client does the reverse.

3After it receives the ACK (message 5)

An OFFER is only a proposal, and the REQUEST is only the laptop's choice. A could still refuse, for example if it had given the address to someone else in the meantime. The address becomes the laptop's when A's ACK arrives.

If you answered after the OFFER, you treated a proposal as an assignment. If you answered after the REQUEST, you treated the laptop's own message as the server's decision; only the ACK confirms that the address now belongs to the laptop.

§4.3.2 IPv4 Addressing (Obtaining a Host Address: DHCP) · video · knowledge checks · practice problems

GW CSCI 4431/6431 Computer Networks · Week 10 Data Plane Quiz

1 / 2