Congestion and Forwarding Worksheet — Study Guide

The two questions cover how a TCP sender's rate climbs and halves under AIMD; how the congestion window limits the bytes a sender may have in flight, and how an arriving ACK lets new bytes out; and how a router chooses an output link by longest prefix match, including what changes when an entry is added and what goes wrong when the table is scanned in the wrong order.

Q1AIMD and the congestion window

1 · A sender's rate between losses

0 1 2 3 4 5 6 7 8 9 10 11 12 0 2 4 6 8 10 12 Time (RTTs) Sending rate (MSS per RTT) loss loss +1 MSS every RTT halved: 8 → 4 halved: 8 → 4

The axes are the worksheet's: time along the bottom, counted in round-trip times, and the sender's rate up the side, in maximum-size segments sent per RTT (one MSS is one full-size segment, 1,000 bytes on this sheet). Each dashed line is a moment the sender learns a segment was lost because three duplicate ACKs came back. These are not the worksheet's numbers: this sender starts at 4 MSS and loses at RTT 4 and RTT 8.

Between losses the line climbs one square per RTT. That is additive increase: every RTT that passes without a loss, the sender adds 1 MSS to its rate §3.7.1. At each dashed line the rate drops straight down to half of whatever it had reached. That is multiplicative decrease. Together they make the sawtooth the book calls AIMD. The sender is never told how much the path can carry; it keeps raising its rate until a loss tells it to back off, and then starts raising it again.

The sheet starts the sender in congestion avoidance and uses only duplicate-ACK losses. A real connection begins in slow start, doubling its rate every RTT, and a timeout sends it back there with the rate reset to 1 MSS §3.7.1. Neither appears on the graph you were given.

2 · The congestion window on the sender's byte stream

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ×1,000 cwnd = 6 MSS = 6,000 bytes, measured from LastByteAcked in flight may send now LastByteAcked = 2,000 LastByteSent = 5,000 ACKed sent, not yet ACKed not yet sent

The strip is the sender's sequence-number space: every byte it will send, laid out left to right. Each box is one 1,000-byte segment, and the ticks count bytes in thousands. Black boxes are bytes the receiver has acknowledged; grey boxes are bytes sent but not yet acknowledged, the bytes in flight; white boxes have not been sent. Again these are not the worksheet's numbers: here cwnd is 6 MSS, bytes through 2,000 are ACKed and bytes through 5,000 have been sent.

LastByteAcked is the right edge of the last black box and LastByteSent is the right edge of the last grey box. The congestion window, cwnd, is a span of bytes that starts at LastByteAcked and runs cwnd bytes to the right. The rule is that the grey region may never be longer than that span §3.7.1. Whatever part of the span is still white is what the sender may send right now: here 3,000 bytes, 5,001 to 8,000.

When an ACK arrives, LastByteAcked moves right, the whole window slides with it, and the bytes that just came inside the window may go out. That is what the book means when it says the ACKs clock the sender: each returning ACK releases new bytes.

A TCP Reno sender is in congestion avoidance. At RTT 0 it is sending 8 MSS per RTT, the dot on the graph. It detects a loss by three duplicate ACKs at RTT 6, RTT 11 and RTT 13, the dashed lines. No other losses occur.

  1. 1

    Draw the sender's rate from RTT 0 to RTT 16.

    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 2 4 6 8 10 12 14 16 Time (RTTs) Sending rate (MSS per RTT) loss loss loss

Later, a sender with an MSS of 1,000 bytes has cwnd = 8 MSS. The strip is its sequence-number space: each box is one segment, and the tick labels count bytes in thousands. Bytes 1–4,000 have been ACKed. Bytes 4,001–9,000 have been sent but not ACKed.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ×1,000 ACKed sent, not yet ACKed not yet sent
  1. 2

    Write the rule the sender must obey, using LastByteSent, LastByteAcked and cwnd.

  2. 3

    Draw a bracket above the strip over the bytes cwnd covers right now. How many more bytes may the sender send before it must wait for an ACK?

    bytes

  3. 4

    The sender sends bytes that fill the rest of its window. Then an ACK arrives with ACK number 6,001; cwnd is still 8 MSS. Which byte range can the sender send now?

    Bytes to

  4. 5

    The RTT is 100 ms. Roughly what is this sender's rate, in kbps?

    kbps

Hint
On part 1: what does the sender do to its rate every RTT when nothing is lost, and what does it do the moment it sees three duplicate ACKs?
Bigger hint
Part 1: add 1 to the rate for each RTT until the first dashed line, then halve it and start adding again. Part 3: in flight is LastByteSent − LastByteAcked; the window is cwnd bytes measured from LastByteAcked. Part 4: an ACK number names the next byte expected, so ACK 6,001 moves LastByteAcked to 6,000 — slide the bracket.
Answer

1Peaks 14, 12, 8 · troughs 7, 6, 4 · ends at 7

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 2 4 6 8 10 12 14 16 Time (RTTs) Sending rate (MSS per RTT) loss loss loss 14 7 12 6 8 4 7
RTT06just after 611just after 1113just after 1316
Rate (MSS/RTT)8147126847

From 8 at RTT 0 the rate climbs 1 MSS per RTT, so it reaches 14 at RTT 6, where the first loss halves it to 7. Five more RTTs take it to 12 at RTT 11, halved to 6. Two more take it to 8 at RTT 13, halved to 4. Three more end it at 7 at RTT 16. Each rise is a straight line and each drop is vertical (Figure 1); a drop drawn across one RTT is fine, since the sheet does not say how quickly the sender reacts.

If your line doubled each RTT, you drew slow start. Slow start is what a connection does when it opens, or after a timeout; this sender is already in congestion avoidance, where the increase is one MSS per RTT, not a doubling.

If your line fell to 1 MSS at each dashed line, you treated the loss as a timeout. Three duplicate ACKs are the milder signal: later segments are still getting through, so TCP Reno halves the rate rather than restarting it §3.7.1. Only a timeout drops it to 1 MSS.

If every trough is 4, you halved the starting rate instead of the rate at the moment of loss. The drop is from the peak the line has just reached, so the troughs fall as the peaks fall: 7, then 6, then 4.

2LastByteSent − LastByteAcked ≤ cwnd

The left side is the number of bytes in flight: sent, but not yet acknowledged. The rule says that number may never exceed the window §3.7.1. The sender is not limited in how much it has sent in total, only in how much it has sent whose fate it does not yet know.

3Bracket over 4,001–12,000 · 3,000 more bytes

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ×1,000 cwnd = 8,000 bytes, from byte 4,000 3,000 more: 9,001–12,000

The window starts at LastByteAcked, byte 4,000, and runs 8 × 1,000 = 8,000 bytes, so it ends at byte 12,000. The grey boxes already use 9,000 − 4,000 = 5,000 of those bytes. That leaves 12,000 − 9,000 = 3,000 bytes the sender may send before it has to wait: bytes 9,001 to 12,000.

If you answered 8,000, you took the whole window as available and ignored the 5,000 bytes already in flight. The window limits the bytes in flight, not the bytes still to send.

4Bytes 12,001–14,000

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ×1,000 cwnd = 8,000 bytes, now from byte 6,000 12,001–14,000 may go out

After part 3 the sender has sent everything through byte 12,000. ACK 6,001 says the receiver now has everything through byte 6,000, so LastByteAcked moves from 4,000 to 6,000. The window slides with it and now ends at 6,000 + 8,000 = 14,000. Bytes 12,001 to 14,000 are inside the window and not yet sent, so those 2,000 bytes go out. The ACK freed two segments' worth of window, and two new segments leave: that is the ACK clock from Figure 2.

If you ended the window at 14,001, or started it at 6,001, you read the ACK number as the last byte received. An ACK number names the next byte the receiver expects, so ACK 6,001 means bytes through 6,000 have arrived. This is the same slip as on the Week 5 TCP worksheet.

5≈ 640 kbps

In one RTT the sender can put at most one window of bytes on the wire, so its rate is roughly cwnd divided by the RTT §3.7.1: 8,000 bytes per 0.1 s is 80,000 bytes per second, and eight bits to the byte makes 640,000 bits per second. It is only "roughly" because the ACKs that open the window arrive spread across the RTT rather than all at once.

§3.7 TCP Congestion Control · video · knowledge checks · practice problems · §3.6 Principles of Congestion Control · video

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

Q2Longest prefix match

3 · Comparing one address with the entries in a forwarding table

destination 11001000 00010111 00011000 10101010 entry → link 0 11001000 00010111 00010*** ******** fails at bit 21 entry → link 1 11001000 00010111 00011000 ******** matches · 24 fixed bits · longest entry → link 2 11001000 00010111 00011*** ******** matches · 21 fixed bits shaded: the entry's fixed bits, the ones the destination must agree with · * matches either bit

Each row is a 32-bit address written as four groups of eight bits. The top row is the destination address of an arriving datagram; the three rows below it are entries from a forwarding table, using the book's own example rather than the worksheet's table. In an entry, a 1 or 0 is a fixed bit the destination must agree with, and a * is a bit the entry does not care about. An entry's prefix is its run of fixed bits, and its length is how many there are: 21, 24 and 21 here.

To test one entry, compare it with the destination from the left and stop at the first fixed bit that disagrees. The entry for link 0 fails at its 21st bit, where it needs a 0 and the destination has a 1. The entries for links 1 and 2 agree on every fixed bit, so both match. Longest prefix match picks the matching entry with the most fixed bits §4.2.1, link 1 with 24, and the datagram leaves there. The shorter entry covers a wider range of addresses; the longer one carves a narrower range out of it, and wins inside that range.

The sheet writes every entry in binary. The book writes the same 21 fixed bits as 200.23.16.0/21, and Week 9 covers that notation and why addresses are grouped this way §4.3. Where the entries come from, the routing that fills the table, is Chapter 5 §4.1.

A router's forwarding table matches the leading bits of a datagram's 32-bit destination address; each * matches either bit. The router uses longest prefix match.

Destination address rangeLink interface
11000000 10101000 ******** ********0
11000000 10101000 0001**** ********1
11000000 10101000 00011*** ********2
11000000 10101000 00011010 ********3
otherwise4
  1. 1

    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
    a11000000 10101000 00010110 101000010, 11
    b11000000 10101000 00011010 01100100
    c11000000 10101000 00011100 00000001
    d11000000 10101000 11110000 00001111
    e11000001 10101000 00011010 01100100
  2. 2

    The operator adds one entry: 11000000 10101000 00011100 0000**** → interface 5. Which of a–e now leave on a different interface? Why are the others unaffected?

  3. 3

    Go back to the original table. Suppose the router checked entries top to bottom and used the first one that matched. Which of a–e would leave on the wrong interface? How could you reorder the table so the first match is always the longest?

Hint
Compare one destination with one entry, bit by bit, stopping where the stars begin. Does every bit before the stars agree?
Bigger hint
Every entry starts with the same 16 bits, so check those first: a mismatch there leaves only "otherwise". Then look at the third byte only. Count each entry's fixed bits (16, 20, 21, 24); of the entries that match, the one with the most fixed bits wins. For part 3, ask which entry first-match hits for any address starting 11000000 10101000.
Answer

1b → 3 · c → 2 · d → 0 · e → 4

Destination addressEntries that matchInterface
a11000000 10101000 00010110 101000010, 11
b11000000 10101000 00011010 011001000, 1, 2, 33
c11000000 10101000 00011100 000000010, 1, 22
d11000000 10101000 11110000 0000111100
e11000001 10101000 00011010 01100100none (otherwise)4

Every entry except "otherwise" begins with the same 16 bits, 11000000 10101000, so for b, c and d the comparison is decided by the third byte, and for e it is over before it gets there. Entries 0 to 3 fix 16, 20, 21 and 24 bits, and each is nested inside the one before it: anything that matches entry 3 also matches 2, 1 and 0. For b, the third byte 00011010 agrees with all four, so the longest, entry 3, wins. For c, 00011100 agrees with 0001**** and 00011*** but not with 00011010, so entry 2 is its longest match. For d, 11110000 agrees only with the all-star third byte of entry 0. For e, the first byte is 11000001: its eighth bit is a 1 where every entry needs a 0, so nothing matches and the datagram takes the "otherwise" row, interface 4.

If you sent e to 3, you compared only the third byte. e's third and fourth bytes are identical to b's, which is the trap: the comparison starts at the first bit (Figure 3), and e already disagrees at bit 8.

If you sent c to 3, you let a wrong bit through. Entry 3 fixes the whole third byte, and c's 00011100 differs from 00011010 in two places. One disagreeing fixed bit is enough to rule an entry out.

If you sent b and c to 0, you took the first row that matched instead of the longest. That is exactly the mistake part 3 asks about: the first row is the shortest prefix, so it matches almost everything.

2Only c, from 2 to 5

The new entry fixes 28 bits, more than any existing entry, so wherever it matches it wins. But it matches only addresses whose third byte is 00011100 and whose fourth byte starts 0000. Of a to e, only c has both, so only c moves. The others still match exactly the entries they matched before, and the longest of those has not changed. A longer entry carves a narrower range out of a wider one without touching the rest §4.2.1.

3a, b, c → 0 · sort 3, 2, 1, 0, otherwise

Entry 0 sits at the top and matches every address that begins 11000000 10101000, so a first-match router never looks past it for a, b or c: all three leave on interface 0 instead of 1, 3 and 2. d really does belong to entry 0, and e matches nothing but "otherwise", so those two come out right either way. Reordering fixes it: put the longest entry first, 3, then 2, 1 and 0, with "otherwise" last. When the longest entries are checked first, the first match is the longest match.

A real router does not scan the list at all. Its lookup memory returns the longest matching entry in a single step, so the order of the entries never matters there §4.2.1; the scan in part 3 is a thought experiment about what "longest" means.

§4.2 What's Inside a Router? · video (part 1) · knowledge checks · practice problems · §4.1 Network Layer Overview · video · knowledge checks

GW CSCI 4431/6431 Computer Networks · Week 08 Congestion and Forwarding Worksheet

1 / 2