Networking Fundamentals and Protocols Questions
The core model of how networks move data: the OSI and TCP/IP layers, the Internet Protocol suite, transport protocols (TCP versus UDP), encapsulation, and TCP behavior including congestion control. Covers the protocol foundations every networking and infrastructure discussion builds on, from link layer through transport. The conceptual bedrock beneath addressing, routing, and switching.
Explain the TCP state transitions for a graceful close (the FIN handshake) versus an abrupt close (RST). Discuss simultaneous close and RST-during-handshake edge cases, and how asymmetric routing or race conditions can produce half-open sockets that neither side recognizes as dead.
Sample Answer
Direct answer
A graceful close is a symmetric exchange where each direction of the connection is shut down independently with its own FIN/ACK pair; an abrupt close (RST) tears down both directions immediately and without acknowledgment, discarding any data still in flight.
Structured elaboration
Graceful close, the normal case: the side that's done sending data sends a FIN. The other side ACKs it and moves to CLOSE_WAIT (it can still send its own data; only ONE direction has closed so far). When that side is also done, it sends its own FIN, the original side ACKs it, and both directions are now closed. Because it takes a FIN and an ACK in EACH direction, a full graceful close is normally four messages (though the middle ACK and FIN are frequently combined into one segment in practice), and the side that sent the last ACK enters TIME_WAIT.
Abrupt close via RST: either side can send a RST at any point to say "this connection is invalid, stop immediately," with no ACK expected and no guarantee that data already sent (or in flight) will be delivered or acknowledged. A RST is what you see when a process crashes and the OS cleans up its sockets, when data arrives for a port nothing is listening on, or when an application deliberately aborts a connection instead of finishing a clean handshake-of-goodbyes.
Simultaneous close is the edge case where BOTH sides send a FIN before either has received the other's FIN. Both sides transition through a CLOSING state (rather than one going through FIN_WAIT and the other CLOSE_WAIT) before eventually reaching TIME_WAIT once both FINs are acknowledged. It's rare, but it's why the TCP state machine has a CLOSING state at all: it exists specifically for this race.
Worked example
A RST during the handshake itself, before a connection is even established, means something different from a RST on an established connection: it almost always means nothing is listening on that port (or a firewall/security-group is actively rejecting rather than silently dropping). This is one of the fastest network diagnostics available, a connection refused instantly (RST) tells you the path and host are reachable but the service isn't there, whereas a connection that hangs and eventually times out with no RST tells you the packet may be silently dropped somewhere in the path, a materially different failure to chase down.
Trade-offs & pitfalls
Asymmetric routing can produce a half-open connection that looks alive on one side even after the other side has actually closed: if the FIN from one side never arrives (dropped along an asymmetric or otherwise broken return path), that side can sit in FIN_WAIT or the other side in ESTABLISHED indefinitely from its own perspective, believing the connection is fine when it's not. Keepalive probes exist specifically to eventually detect and clear out this class of half-open zombie connection, since neither side's own state machine will notice on its own.
Describe the TCP three-way handshake in detail: which flags are set in each packet (SYN, SYN-ACK, ACK), how sequence and acknowledgment numbers are used, and what state each endpoint moves into after each step. Explain what problem the handshake actually solves.
Sample Answer
Direct answer
The TCP three-way handshake establishes a reliable connection before any data flows: the client sends a SYN, the server replies with a combined SYN-ACK, and the client finishes with an ACK. Its job is to let both sides agree on starting sequence numbers and confirm that both directions of the path actually work before committing application data to the wire.
Structured elaboration
- SYN: the client picks an initial sequence number (ISN, essentially a large pseudo-random 32-bit number) and sends a segment with the SYN flag set and that sequence number. The client moves to the
SYN-SENTstate. - SYN-ACK: the server, if it's listening on that port, picks its OWN initial sequence number, and replies with a segment that has both the SYN flag set (announcing the server's own sequence number) AND the ACK flag set (acknowledging the client's sequence number + 1). The server moves to the
SYN-RECEIVEDstate. - ACK: the client acknowledges the server's sequence number + 1 with a plain ACK segment. Both sides now move to
ESTABLISHED, and either side may now send data.
Why three steps rather than two: TCP needs BOTH sides' sequence numbers acknowledged, since TCP is full-duplex (both directions need independent sequence tracking). A two-way handshake could confirm only one direction; the third message is what confirms the client's original SYN actually arrived, closing the loop for the client's own sequence space.
Worked example
Suppose a client opens a TCP connection to a web server on port 443. The client sends SYN, seq=1000. The server responds SYN, ACK, seq=5000, ack=1001 (acknowledging the client's SYN by number+1). The client responds ACK, seq=1001, ack=5001. From this point, the client's next data byte will carry sequence number 1001, and the server's next data byte will carry sequence number 5001; each side tracks the OTHER side's sequence space independently via the ACK field of every following segment.
Trade-offs & pitfalls
A frequent mistake is describing the handshake as three round trips; it's actually one and a half round trips of latency, because the SYN-ACK piggybacks the server's SYN onto its ACK of the client's SYN. This is also exactly why TCP always incurs at least one round trip of setup latency before any data can flow, which is the whole motivation behind newer mechanisms like TCP Fast Open that try to send data alongside the very first SYN.
Define bandwidth, throughput, and goodput, and explain at least four distinct reasons an application might observe lower throughput or goodput than the link's rated bandwidth. For a given slow transfer, what is the fastest way to tell which of your reasons is the actual cause?
Sample Answer
Direct answer
Bandwidth is the link's raw theoretical capacity; throughput is what's actually achieved end-to-end, which is always less than or equal to bandwidth; and goodput is throughput minus any overhead that isn't USEFUL application data (protocol headers, retransmissions of data that eventually succeeds anyway). An application commonly sees less than the rated bandwidth for several genuinely distinct reasons, and telling them apart is the fast path to the right fix.
Structured elaboration
Four common, distinct reasons throughput or goodput falls short of bandwidth:
- Retransmissions: any lost segment that has to be resent consumes bandwidth without contributing new useful data, so a lossy path shows lower goodput even at unchanged raw throughput.
- Protocol overhead: every layer's headers (Ethernet, IP, TCP) consume bytes that count toward raw throughput but never toward the application's actual USEFUL payload, goodput specifically excludes them.
- Congestion-window or flow-control limits: if the connection's congestion window or receive window is smaller than the path's bandwidth-delay product, the sender is idle waiting for ACKs rather than continuously filling the pipe, capping achieved throughput well below the link's rated bandwidth regardless of loss.
- Application-level inefficiency: an application that reads/writes in small chunks, adds its own serialization overhead, or simply isn't pipelining requests efficiently can bottleneck well below what the transport layer itself is capable of moving.
Worked example
The fastest way to localize which of these applies to a specific slow transfer: check retransmission counters first (ss -i's retrans field), if they're elevated, loss/retransmission is a real contributor. If retransmissions are low but the window (cwnd/rwnd from the same tool) is small relative to the path's bandwidth-delay product, the connection is window-limited rather than loss-limited, and no amount of "fixing loss" will help. If BOTH retransmissions are low and the window is comfortably larger than the bandwidth-delay product, yet throughput is still poor, suspect application-level inefficiency (measure CPU usage and how the application is actually issuing reads/writes) rather than anything at the transport layer at all.
Trade-offs & pitfalls
The most common diagnostic mistake is assuming a throughput shortfall is automatically a "network problem" and reaching straight for network-level tuning; a genuinely application-bound bottleneck (small, unbuffered writes; serialized rather than pipelined requests) is common and invisible to any amount of TCP-level tuning, wasting real effort until the actual bottleneck is correctly localized first.
Walk through how TCP congestion control evolves during a long-lived connection: slow start, congestion avoidance, fast retransmit, and fast recovery. State which sender-side variable changes at each stage and what event triggers the transition to the next stage.
Sample Answer
Direct answer
Over the life of a connection, TCP's congestion window grows exponentially in slow start, switches to growing linearly in congestion avoidance once it approaches a known safe ceiling, and reacts to loss with fast retransmit and fast recovery rather than always restarting from scratch.
Structured elaboration
- Slow start: the connection begins with a small congestion window (historically 1 segment; modern stacks start higher, commonly around 10 segments per RFC 6928) and roughly DOUBLES the window every round trip, since each of the ACKs for the previous batch triggers sending two new segments. This continues until either loss occurs, or the window reaches a threshold called
ssthresh(slow start threshold), at which point the sender switches strategies. - Congestion avoidance: once at or above
ssthresh, growth switches from exponential to roughly linear (classically, additive increase of about one segment per round trip), a much more cautious probe for additional capacity. - Fast retransmit: if the sender sees three duplicate ACKs (the receiver repeatedly acknowledging the same byte, implying a specific segment is missing but LATER data did arrive), it retransmits the missing segment immediately, without waiting for the retransmission timer to expire, since three duplicate ACKs is strong, specific evidence of loss rather than simple reordering.
- Fast recovery: after a fast retransmit, rather than collapsing all the way back to slow start,
ssthreshis set to about half the current window, and the window itself is set near that halved value, so the sender doesn't have to re-earn all its previous progress from a window of one segment; it resumes near where it estimates the path can actually sustain.
Worked example
Picture a connection whose window has grown to 64 segments in flight when a single segment is lost and detected via three duplicate ACKs (not a full timeout). Fast retransmit resends the missing segment immediately. Fast recovery sets ssthresh to roughly 32 (half of 64) and the window to near that value, then resumes congestion avoidance's linear growth from there, rather than collapsing to slow start's small initial window and doubling all the way back up. Contrast this with a RETRANSMISSION TIMEOUT (no duplicate ACKs arrived at all, meaning the loss was severe enough that the whole flight of data went missing): that's a much stronger loss signal, and the sender resets ssthresh to half the current window but drops the actual window all the way back to slow start's minimum, since a timeout implies the path may be far more broken than a few duplicate ACKs would suggest.
Trade-offs & pitfalls
It's a common mistake to say TCP always halves its window on any loss and moves on; a full retransmission timeout is treated far more conservatively (full reset to slow start) than a fast-retransmit-detected loss (a much gentler recovery), because the ABSENCE of any duplicate ACKs at all is itself informative: it suggests either a much larger loss event or a badly congested/broken path, not just one unlucky dropped segment.
Explain bufferbloat: why excessive buffering in network devices increases latency and jitter under load even though it reduces packet loss, and how Active Queue Management algorithms such as fq_codel counteract it. Why does bufferbloat specifically interfere with TCP's own congestion signals?
Sample Answer
Direct answer
Bufferbloat happens when routers or switches along a path have excessively large buffers that queue packets during congestion instead of dropping them, which keeps loss low but lets queuing delay grow essentially unbounded, adding latency and jitter that TCP's own congestion control never gets a clear enough signal to react to. Active Queue Management algorithms like fq_codel counteract it by proactively dropping or marking packets BEFORE the queue grows large, restoring a timely loss signal.
Structured elaboration
A classic loss-based congestion-control algorithm relies on packet loss (or an explicit congestion mark) as its primary "back off" signal. If a device's buffer is very large, it can absorb a burst of excess traffic by queuing it rather than dropping it, so loss never actually happens, but every packet sitting in that oversized queue now experiences extra delay waiting its turn. Ironically, a device built to be MORE forgiving (bigger buffer, less loss) ends up making the user experience WORSE (much higher and more variable latency) precisely because it hides the congestion signal the sender needs to slow down.
fq_codel (Fair Queuing with Controlled Delay) attacks this from two angles: "fair queuing" gives each active flow its own small queue so one bulk-transfer flow can't monopolize the buffer and starve a latency-sensitive flow (like a video call) sharing the same link; "controlled delay" tracks how long packets are actually sitting in the queue, and once a packet has been queued longer than a target delay (commonly around 5ms), it starts dropping packets to force the responsible flow's congestion control to back off, well before the queue grows large enough to cause serious latency.
Worked example
On a home internet connection with a large, un-managed buffer at the router, a single large upload (like a cloud backup) can push queuing delay from a normal few milliseconds up to several hundred milliseconds or more, which is directly noticeable as a video call over the same connection becoming choppy or laggy, even though no packets for the video call are actually being dropped, they're just sitting in a queue behind the bulk upload's traffic for hundreds of milliseconds. Enabling fq_codel on that router's egress queue caps how long any packet can wait, keeping the video call's latency low even while the bulk upload continues in the background.
Trade-offs & pitfalls
Bufferbloat is easy to misdiagnose as "the link doesn't have enough bandwidth" when the real problem is excess, unmanaged queuing delay on a link that has PLENTY of bandwidth; the fix (AQM, not more bandwidth) is the opposite of what a naive read of "things feel slow" would suggest. A useful diagnostic: latency under load (with a saturating background transfer running) that's dramatically higher than idle-latency is the signature of bufferbloat, not a raw throughput problem.
Unlock Full Question Bank
Get access to all 36 Networking Fundamentals and Protocols interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.