Sub topic 2
Flow control with the receiver window
TCP sends a reliable byte stream between two programs. Two limits control how fast a TCP sender can transmit: the receiver's buffer space and the capacity of the network. This chapter covers both, then the DNS lookup that happens before a connection starts.
Flow control with the receiver window
The receiver advertises a window, called rwnd, in every acknowledgement. It is the free space left in the receiver's buffer. The sender may have at most rwnd unacknowledged bytes in flight. When the application reads slowly, rwnd shrinks. When the buffer empties, rwnd grows again.
Congestion control: slow start, congestion avoidance, Tahoe and Reno
The sender also keeps a congestion window, cwnd, which estimates what the network can carry. The effective window is the smaller of cwnd and rwnd.
- Slow start: cwnd doubles each round-trip time (RTT) until it reaches ssthresh.
- Congestion avoidance: cwnd grows by one segment each RTT.
- Tahoe: on any loss, it sets ssthresh to half of cwnd and restarts cwnd at 1.
- Reno: on three duplicate ACKs, it halves cwnd and continues from there. On timeout, it restarts cwnd at 1.
| Event | Tahoe response | Reno response |
|---|---|---|
| Timeout | cwnd = 1, slow start | cwnd = 1, slow start |
| Three duplicate ACKs | cwnd = 1, slow start | cwnd = ssthresh, congestion avoidance |
Window, RTT, and throughput calculations
Throughput is at most the window divided by the RTT. Use the smaller of cwnd and rwnd:
window_bytes = 16 * 1024
rtt_seconds = 0.05
throughput_bps = window_bytes * 8 / rtt_seconds
print(f"{throughput_bps / 1e6:.2f} Mbps")The program prints 2.62 Mbps.
The DNS hierarchy: root, TLD, and authoritative servers
DNS maps names to addresses through a tree of servers. Root servers point to top-level domain (TLD) servers, such as the servers for .com. Each TLD server points to the authoritative server for a domain, which holds the final answer.
Resolving a name: iterative versus recursive queries and caching
In a recursive query, the client asks one server, and that server does the full lookup for it. In an iterative query, each server returns a referral, and the client asks the next server itself. Resolvers cache answers for the record's TTL (time to live), so repeated lookups skip most of the tree.
Exercise
A receiver advertises a 64 KB window, the RTT is 100 ms, and cwnd is not a limit. What is the maximum throughput in bits per second?
Show answer
65536 × 8 / 0.1 = 5,242,880 bit/s, about 5.24 Mbps.