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.
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 length | Third-byte values covered | Addresses |
|---|---|---|
| /16 | 256 (all) | 65,536 |
| /20 | 16 | 4,096 |
| /21 | 8 | 2,048 |
| /22 | 4 | 1,024 |
| /23 | 2 | 512 |
| /24 | 1 | 256 |
| Destination prefix | Link interface |
|---|---|
| 128.64.0.0/16 | 0 |
| 128.64.32.0/20 | 1 |
| 128.64.40.0/23 | 2 |
| 128.64.41.0/24 | 3 |
| otherwise | 4 |
How many addresses does 128.64.40.0/23 cover? What are its first and last addresses?
Addresses: First: Last:
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 address | Entries that match | Interface | |
|---|---|---|---|
| a | 128.64.41.200 | 0, 1, 2, 3 | 3 |
| b | 128.64.40.9 | ||
| c | 128.64.43.5 | ||
| d | 128.64.48.3 | ||
| e | 128.65.41.200 |
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
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 address | Entries that match | Interface | |
|---|---|---|---|
| a | 128.64.41.200 | 0, 1, 2, 3 | 3 |
| b | 128.64.40.9 | 0, 1, 2 | 2 |
| c | 128.64.43.5 | 0, 1 | 1 |
| d | 128.64.48.3 | 0 | 0 |
| e | 128.65.41.200 | none (otherwise) | 4 |
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
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
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".
Fill in the addresses.
| Message | Source IP : port | Destination IP : port |
|---|---|---|
| A's OFFER | ||
| REQUEST | ||
| ACK |
When can the laptop first send a datagram from 10.0.0.57?
1Five messages, seven arrows
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
| Message | Source IP : port | Destination IP : port |
|---|---|---|
| A's OFFER | 10.0.0.1 : 67 | 255.255.255.255 : 68 |
| REQUEST | 0.0.0.0 : 68 | 255.255.255.255 : 67 |
| ACK | 10.0.0.1 : 67 | 255.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