igrigorik/hpbn.co

Formula mistake for "Time to reach the cwnd size of size N"

Closed this issue · 0 comments

Copying feedback from an email—courtesy of Jon Wong. Great catch...


There’s a small mistake in your formula for “time to download 45 packets”. Let N = 45.
(We consider the unit RTT, round-trip time, assuming that the data transfer is latency-bound.)

The number of round-trip times (RTTs), n, taken is a “sum of n geometric terms”, not just a “geometric nth term”.
Specifically, we want to know “how many geometric growths (of the cwnd) will bring the cumulative cwnd’s up to at least N”, rather than to know “how many geometric growths will bring the cwnd to N”.

(cwnd described by you here: https://hpbn.co/building-blocks-of-tcp/)

Deriving from “sum of geometric progression”, your formula on Udacity should have a “+ 1” inside the base-2 log. That is,

log-base-2 ([N / initial cwnd] + 1).

To save you time, here’s a quick illustration (rather than full proof):
If N is 70 and initial cwnd is 10, the cwnd’s grow thus: 10 + 20 + 40 = 70. Plugging those numbers into the above formula, you get log(7 + 1) which is exactly 3 RTTs.
If N is 75 instead, your original formula gives: log(7.5) which will be 3 (wrong answer) instead of 4 RTTs.