Sub topic 17
Solving GATE-style problems on these topics
This chapter collects the problem patterns that GATE CS repeats across TCP, DNS, and HTTP. It assumes you know the layered model, the terms bandwidth, propagation delay, transmission delay, and round-trip time (RTT), powers of two, and the TCP, DNS, and HTTP mechanisms covered in earlier chapters. The goal is a repeatable method for each pattern, plus the errors that cost marks.
A general method
Most questions in this area fall into five families. Identify the family first, then apply its method.
| Family | What is asked | Core idea |
|---|---|---|
| Window and throughput | Utilization, maximum throughput, window size needed | Data per RTT = window, capped by bandwidth-delay product |
| Congestion window trace | cwnd after n RTTs, or after a loss | Slow start, congestion avoidance, Tahoe or Reno reaction |
| Sequence numbers | Next sequence or ack number, bytes transferred | Sequence number counts bytes, ack is next byte expected |
| DNS counting | Number of queries, total time with caching | Each iterative step costs one RTT, cache hits cost zero |
| HTTP timing | Total time to fetch a page and its objects | Count TCP setups and request round trips |
Before calculating, write down every given quantity with its unit. Convert bits to bytes, and Mbps to bits per second, before doing anything else. Most wrong answers come from unit slips, not from misunderstanding the protocol.
Pattern 1: window, RTT, and throughput
A sender with window W bytes can send at most W bytes per RTT. The link can carry at most bandwidth times RTT bytes in that time, which is the bandwidth-delay product (BDP).
- Throughput = min(W / RTT, bandwidth)
- Utilization = W / (BDP + the bytes sent in one transmission time) in the stop-and-wait or sliding window model, which equals W × L / (L + B × RTT) when frames of L bits are sent, with B the bandwidth in bits per second.
- The effective window is min(cwnd, rwnd). Both limits apply at once.
Worked example. A link has bandwidth 10 Mbps and RTT 100 ms. The receiver window is 64 KB. What is the maximum throughput?
- W = 64 KB = 65,536 bytes = 524,288 bits.
- W / RTT = 524,288 / 0.1 = 5.24 Mbps.
- This is below 10 Mbps, so the window is the bottleneck. Throughput is about 5.24 Mbps.
To fill the link you would need a window equal to the BDP: 10,000,000 × 0.1 = 1,000,000 bits = 125,000 bytes.
The following program checks such calculations. It is complete and runs as shown.
def throughput_bps(window_bytes, rtt_s, bandwidth_bps):
return min(window_bytes * 8 / rtt_s, bandwidth_bps)
def bdp_bytes(bandwidth_bps, rtt_s):
return bandwidth_bps * rtt_s / 8
print(throughput_bps(64 * 1024, 0.1, 10_000_000)) # 5242880.0
print(bdp_bytes(10_000_000, 0.1)) # 125000.0Another recurring variation asks for the number of bits needed for the sequence number field. In a sliding window protocol the sequence space must cover the window plus the maximum delay. For TCP, the sequence number counts bytes, so wraparound time matters: with a 32-bit field and a line rate R bytes per second, wraparound takes 2^32 / R seconds. This must exceed the maximum segment lifetime, otherwise old segments could be confused with new ones.
Pattern 2: congestion window traces
The standard GATE assumptions are these. cwnd starts at 1 MSS. In slow start, cwnd doubles each RTT. When cwnd reaches ssthresh, congestion avoidance begins and cwnd grows by 1 MSS per RTT. On loss:
| Event | Tahoe | Reno |
|---|---|---|
| Timeout | ssthresh = cwnd / 2, cwnd = 1, slow start | ssthresh = cwnd / 2, cwnd = 1, slow start |
| Triple duplicate ACK | ssthresh = cwnd / 2, cwnd = 1, slow start | ssthresh = cwnd / 2, cwnd = ssthresh, congestion avoidance |
Worked example. ssthresh is 16 MSS initially. A timeout occurs when cwnd is 20. Find cwnd at the next transmissions in Tahoe.
- Slow start: 1, 2, 4, 8, 16. At 16, cwnd equals ssthresh, so growth becomes linear.
- Congestion avoidance: 17, 18, 19, 20.
- Timeout at 20: ssthresh = 10, cwnd = 1.
- Slow start again: 1, 2, 4, 8, then 10 (capped at ssthresh), then 11, 12, and so on.
Some textbooks let cwnd exceed ssthresh in the last doubling step and some cap it. When a question gives a sequence of values, read the convention from its numbers. The cap shown here matches the simplified model in the Topic Spine.
def trace(rounds, ssthresh, loss_at, loss_kind, variant):
cwnd = 1
out = []
for rtt in range(1, rounds + 1):
out.append((rtt, cwnd))
if rtt in loss_at:
ssthresh = max(cwnd // 2, 2)
if loss_kind == "dupack" and variant == "reno":
cwnd = ssthresh
else:
cwnd = 1
elif cwnd < ssthresh:
cwnd = min(cwnd * 2, ssthresh)
else:
cwnd += 1
return out
print(trace(14, 16, {10}, "dupack", "reno"))
print(trace(14, 16, {10}, "dupack", "tahoe"))Common errors:
- Halving the ssthresh instead of cwnd. The new ssthresh is half of the cwnd at the time of loss, not half of the old ssthresh.
- Forgetting that a timeout resets cwnd to 1 in both variants.
- Ignoring rwnd. If the receiver window is smaller than cwnd, the sending window is rwnd.
A diagram of the Reno cycle helps fix the transitions.
Pattern 3: sequence and acknowledgement numbers
Rules to apply without hesitation:
- The sequence number is the number of the first data byte in the segment.
- The acknowledgement number is the next byte the receiver expects, which is the last received byte plus one.
- SYN and FIN each consume one sequence number, even without data.
- A pure ACK consumes none.
Worked example. A client opens with initial sequence number 1000 and the server with 5000. The client then sends 200 bytes. What are the acknowledgement numbers?
- SYN from the client: seq = 1000.
- SYN-ACK from the server: seq = 5000, ack = 1001.
- ACK from the client: seq = 1001, ack = 5001.
- Client sends 200 bytes: seq = 1001, covering bytes 1001 to 1200.
- Server acknowledges with ack = 1201.
If the client's closing FIN follows with seq = 1201, the server's ack is 1202.
Pattern 4: DNS counting
Method: list the servers contacted in order and count a round trip for each query that is not answered from cache.
Worked example. A host asks its local resolver for www.example.com. The resolver cache is empty, and each RTT to any server is 20 ms, with the host to resolver RTT also 20 ms. The resolver uses iterative queries to the root, the .com TLD server, and the authoritative server.
- Host to resolver (recursive): 1 RTT.
- Resolver to root: 1 RTT.
- Resolver to TLD: 1 RTT.
- Resolver to authoritative: 1 RTT.
- Total: 4 × 20 = 80 ms. The host-to-resolver round trip contains the other three.
If the TLD server address is cached, steps 2 and 3 shrink to just the TLD hop being skipped, giving 2 RTT. If the full answer is cached, only the host-to-resolver RTT remains.
Watch for these points:
- In a fully recursive chain, the query passes through every server and the answer returns through each. The count of messages doubles with each hop.
- Iterative resolution places the work on the resolver. The queried servers only return referrals.
- A TTL (time to live) controls how long a record stays cached. Once the TTL expires, the next lookup repeats the full path.
- Lookups usually use UDP port 53. TCP is used for large responses and zone transfers.
Pattern 5: HTTP timing
Method: count TCP setup RTTs, request RTTs, and transmission times separately.
Rules of thumb:
- A non-persistent connection needs 1 RTT for the handshake and 1 RTT for each request and response, so each object costs 2 RTT plus its transmission time.
- A persistent connection without pipelining pays the handshake once, then 1 RTT per object.
- Persistent with pipelining sends all requests back to back, so the objects cost about 1 RTT total plus transmission time.
- DNS lookup time is added once before the first connection, if the address is not cached.
Worked example. A page has a base HTML file and 5 small images, RTT 50 ms, transmission times ignored.
| Mode | RTTs | Time |
|---|---|---|
| Non-persistent, serial | 6 objects × 2 | 600 ms |
| Persistent, no pipelining | 1 + 6 | 350 ms |
| Persistent, pipelining | 1 + 1 (base) + 1 (images) | 150 ms |
For the pipelined case, the base file must arrive first because the images are discovered by parsing it. Therefore the images are requested together after the base file, which costs one more RTT.
Also remember cookies and caching. A conditional GET carries If-Modified-Since, and a 304 Not Modified response has no body, so only the RTT is spent.
Checking answers
- Compare your result with a limit. Throughput cannot exceed the link rate. Utilization cannot exceed 100 percent.
- Check units at the end: bytes versus bits, ms versus s.
- Check that the number of RTTs matches the number of round trips drawn in your timeline.
- For multiple-select questions, test each statement independently against a rule from this chapter.
Exercise
A TCP sender has ssthresh = 8 MSS and starts with cwnd = 1 MSS. Reno is used. A triple duplicate ACK arrives when cwnd = 12 MSS. Assume cwnd grows as in the model of this chapter and the sender is in congestion avoidance at that moment. What are ssthresh and cwnd right after the loss, and what is cwnd one RTT later?
Show answer
ssthresh becomes 12 / 2 = 6 MSS. Reno sets cwnd = ssthresh = 6 MSS and continues in congestion avoidance, so one RTT later cwnd = 7 MSS. Tahoe would have set cwnd = 1 and restarted slow start.
Exercise
A link is 100 Mbps with RTT 40 ms. The sender window is 250,000 bytes. What is the maximum throughput, and is the window or the link the bottleneck?
Show answer
W / RTT = 250,000 × 8 / 0.04 = 50,000,000 bits per second = 50 Mbps. The link carries 100 Mbps, so the window is the bottleneck. The BDP is 100,000,000 × 0.04 / 8 = 500,000 bytes, and the window is half of that.
Exercise
A client with initial sequence number 7000 sends a SYN, and later sends 300 bytes of data after the handshake completes. The server's initial sequence number is 9000. What are the seq and ack in the segment carrying the data, and what ack does the server return?
Show answer
The SYN uses number 7000, so the first data byte has seq = 7001. The data segment has seq = 7001 and ack = 9001. It covers bytes 7001 to 7300, so the server returns ack = 7301.
Exercise
A page has a base HTML file and 9 images. RTT is 30 ms, and transmission times are negligible. The DNS address is already cached. Compute the fetch time with non-persistent serial connections and with persistent connections without pipelining.
Show answer
There are 10 objects. Non-persistent: 10 × 2 × 30 = 600 ms. Persistent without pipelining: 1 RTT for the handshake plus 10 RTT for the objects, so 11 × 30 = 330 ms.