Sub topic 17
Solving GATE-Style Problems on TCP, Sockets, DNS, and HTTP
Assume you know the layered network model, encapsulation, bandwidth, latency, round-trip time (RTT), binary arithmetic, and basic Python or C. This chapter gives a method for solving common numerical and conceptual questions.
A reliable order for protocol questions
First identify the layer and the object being counted.
- A socket endpoint is identified by an IP address and a port number.
- A TCP connection is identified by the four-tuple
(source IP, source port, destination IP, destination port). - TCP sequence numbers count bytes, not segments.
- A SYN or FIN consumes one sequence-number position.
- A TCP acknowledgement gives the next byte expected.
For example, suppose host A sends SYN, seq=100. Host B replies with SYN-ACK, seq=500, ack=101. Host A completes the handshake with ACK, ack=501. The acknowledgement values increase because SYN consumes one sequence number.
A TCP close uses FIN and ACK messages. If a FIN has sequence number 900, the acknowledgement for it is 901. TCP can close the two directions separately, so four messages are common, although some ACK and FIN messages can be combined.
Window and throughput calculations
The receiver window, rwnd, protects the receiver from buffer overflow. The congestion window, cwnd, protects the network from overload. The usable sender window is:
W = min(rwnd, cwnd)
If the window is W bytes and the RTT is R seconds, the window-limited throughput is:
throughput = W / R
The actual throughput cannot exceed the bottleneck link rate:
actual throughput = min(W / R, link rate)
For example, with rwnd = 12 KB, cwnd = 20 KB, and RTT = 40 ms, the usable window is 12 KB. Therefore:
throughput = 12,000 / 0.04 = 300,000 bytes/s
Use consistent units. Convert milliseconds to seconds before dividing.
| Quantity | Meaning | Common mistake |
|---|---|---|
| `rwnd` | Receiver buffer space advertised to sender | Treating it as a network limit |
| `cwnd` | Sender’s estimate of safe network capacity | Confusing it with receiver buffer space |
| `RTT` | Time for a packet and its acknowledgement | Using one-way delay |
| `W / RTT` | Window-limited sending rate | Ignoring the link-rate limit |
Congestion-window traces
During slow start, cwnd approximately doubles once per RTT. During congestion avoidance, it increases by about one maximum-segment size (MSS) per RTT.
For a simplified TCP trace:
- Start with
cwnd = 1 MSS. - Double it during slow start until reaching
ssthresh. - Increase linearly during congestion avoidance.
- On a timeout, Tahoe sets
ssthreshto half the oldcwndand resetscwndto1 MSS. - On triple duplicate ACKs, Reno roughly halves
cwndand retransmits without waiting for a timeout.
DNS and HTTP question patterns
For DNS, distinguish the resolver’s work from the name server’s work. A recursive query asks a server to return the final answer. An iterative query returns a referral, such as a root or .com name server. Check the TTL before deciding whether another lookup is needed.
For HTTP, identify the request method, status-code class, and connection behavior. 2xx means success, 3xx redirection, 4xx client error, and 5xx server error. HTTP/1.1 normally supports persistent connections, while HTTP/2 multiplexes streams over one TCP connection.
Exercise
A sender has rwnd = 8 KB, cwnd = 20 KB, RTT = 20 ms, and a link rate of 1 MB/s. What is the maximum window-limited throughput?
Show answer
The usable window is min(8, 20) KB = 8 KB. The window rate is 8,000 / 0.02 = 400,000 bytes/s, which is below 1 MB/s. Therefore, the maximum throughput is 400,000 bytes/s.