TCP
Handshake, byte sequencing with sliding windows, and congestion control turn lossy IP packets into an ordered stream. Interviewers lean on it because slow or stalled connections trace back here.
on this pageshowhide
explore
- Segment Header and Options5 questions
- Connection Establishment6 questions
- Sequencing and Acknowledgment5 questions
- Flow Control4 questions
- Congestion Control5 questions
- Retransmission and Timeouts5 questions
- Nagle, Delayed ACK & Keepalive5 questions
- Connection Teardown5 questions
- Sockets & Ports6 questions
questions
page 2 of 2In a TCP SYN flood from spoofed source addresses, what server state fills up, why do those entries linger, and why do legitimate clients fail to connect?
basics
~20 sEach SYN leaves a half-open connection in SYN-RECEIVED, held in a limited per-port backlog. Spoofed sources never answer, so entries wait out the server's SYN-ACK retries; with the backlog full, new SYNs are ignored or evict others, and real clients' connects stall.
Why does a long-lived TCP connection through a stateful firewall hang and fail on the first request after an idle period, and should you fix it with TCP keepalive or an application heartbeat?
basics
~20 sThe firewall's idle timer expired and it deleted the connection's state without telling either endpoint, so later segments are dropped or reset. Send traffic more often than that timer: TCP keepalive with a short idle time, or an application heartbeat.
After a TCP sender retransmits a segment and an ACK covering it arrives, why must it not take an RTT sample from that ACK, and what keeps the timeout sane instead?
basics
~20 sThe ACK cannot say which copy it acknowledges, so the RTT is ambiguous; Karn's algorithm discards such samples. The RTO, doubled on each timeout, is kept until new data is acknowledged without retransmission. The timestamp option removes the ambiguity.
Why does losing the last segment of a TCP response often stall it for a whole RTO, while a mid-stream loss recovers in about one round trip?
basics
~20 sFast retransmit needs later segments to produce duplicate ACKs; a tail loss has too few behind it, so only the RTO, normally at least 1 s (RFC 6298), recovers it. RACK-TLP (RFC 8985) instead probes after about 2 x SRTT.
Over a site-to-site tunnel, TCP handshakes and small requests succeed but large downloads stall; why does clamping the MSS in passing SYNs fix it?
basics
~20 sEndpoints derive MSS from their own 1500-byte links, but tunnel encapsulation shrinks the path MTU, so full-sized segments are dropped and, with ICMP feedback filtered, never shrink. Rewriting passing SYNs' MSS to fit the tunnel stops oversized segments being built.
What problem does TCP selective acknowledgment (SACK) solve that cumulative ACKs cannot, and why must a sender still keep data a SACK block reported?
basics
~20 sCumulative ACKs report only the contiguous prefix, so several losses in one window surface about one per round trip. SACK blocks describe data held beyond the gap but are advisory, so data is freed only once the cumulative ACK passes.
A TCP client opens short-lived connections to one server IP and port and closes each one first; what caps its sustained new-connection rate, and how do you compute it?
basics
~20 sToward one server socket only the client port varies, and the client, closing first, holds each port in TIME-WAIT for 2×MSL. Ceiling: usable ports divided by that time — 16,384 ports over RFC 9293's 240 s is about 68 per second.
When a TCP server shows thousands of connections stuck in CLOSE-WAIT while the clients calling it show thousands in TIME-WAIT, what does each pile mean, and which one is a bug?
basics
~20 sCLOSE-WAIT piles up where the peer has closed but the local application never calls close: almost always a connection leak. TIME-WAIT piles up on the active closer under high connection churn: normal, and it clears itself after 2×MSL.
What happens in TCP when two endpoints send each other a SYN at the same time, and how many segments does that simultaneous open take?
basics
~20 sEach side, in SYN-SENT, receives a SYN without an ACK, moves to SYN-RECEIVED and sends a SYN-ACK repeating its own ISN. Each SYN-ACK moves its receiver to ESTABLISHED: four segments, one connection. RFC 9293 requires every TCP to support it.
What is silly window syndrome in TCP, and how do the sender and the receiver each avoid it?
basics
~20 sSilly window syndrome is a stable TCP pattern of tiny window openings filled by tiny segments. RFC 9293 requires both sides to avoid it: receivers withhold small window increases, senders wait for a worthwhile amount to send.
How does a UDP socket differ from a TCP socket in the socket API, and what does calling connect() on a UDP socket actually do?
basics
~20 sA UDP socket never listens or accepts: one bound socket trades datagrams with any peer, sendto naming the destination and recvfrom returning one whole datagram and its sender. connect() on UDP sends nothing; it sets a default peer and filters locally.
Why does a TCP Reno flow take minutes to regain its window on a 1 Gbps, 100 ms path after one loss, and how does CUBIC's growth change that?
basics
~20 sA 1 Gbps, 100 ms path needs about 8,333 full-sized packets in flight; after halving, Reno adds one segment per round trip, so it needs about 4,167 round trips, roughly 7 minutes. CUBIC cuts less and regrows along a time-based cubic curve.
When a TCP path's round-trip time suddenly jumps from 80 ms to about 2 seconds, why does the sender retransmit data that was never lost, and how can it tell afterwards?
basics
~20 sAn RTO built from 80 ms samples sits at the 1 s floor, so a 2 s delay fires it while the originals are merely late. An ACK echoing the original's TSval, or a D-SACK for the duplicate, exposes the spurious timeout.
Why are TCP's window scale, SACK-permitted and timestamps options confined to SYN segments, and what breaks if a middlebox strips one from the SYN-ACK?
basics
~20 sThese options change how the whole connection behaves, so they are offered in the SYN before data flows. Window scale and timestamps apply only if both SYN and SYN-ACK carry them; stripping one from the SYN-ACK leaves the two ends disagreeing.
A TCP bulk transfer across per-packet load-balanced parallel links shows frequent fast retransmits although the path drops almost nothing: what in TCP's acknowledgment behaviour explains this?
basics
~20 sA TCP receiver sends an immediate duplicate ACK for each segment arriving above a gap, and a reordered segment leaves the same gap as a lost one. Overtaken by three or more segments, it triggers fast retransmit of data that was only late.
In TCP, what is TIME-WAIT assassination as described in RFC 1337, and why does it undermine the protection TIME-WAIT is meant to give?
basics
~20 sAn old duplicate segment reaches an endpoint in TIME-WAIT; its ACK reaches a peer with no record of the connection, which answers RST, and the reset ends TIME-WAIT early, exposing a reopened connection to stale segments.
showing 31–46 of 46