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.
You suspect a transit provider is running a transparent TCP proxy that strips or rewrites TCP options (such as SACK permitted, window scale, or timestamps), degrading performance without dropping the connection outright. Describe how you would detect this from the endpoints, and how losing each of those specific options would show up in observed throughput or latency behavior.
Sample Answer
Direct answer
A transparent TCP proxy that strips or rewrites options like SACK-permitted (Selective Acknowledgment), window scale, or timestamps degrades performance without ever dropping the connection outright, since the handshake still completes; the way to detect it is to compare what your OWN stack SENT in the handshake against what actually arrived at the other end, since a proxy silently altering options in transit is invisible unless you check both ends.
Structured elaboration
Capture the handshake on BOTH the client and server sides (or as close to each endpoint as possible) and diff the negotiated options field by field. If the client sends a SYN advertising window scale, SACK-permitted, and timestamps, but the SYN-ACK the SERVER sees (or the SYN the server receives, if the proxy sits between client and server) is missing one or more of those options, or has a DIFFERENT window scale factor than what the client actually sent, something in the path rewrote it. Passive detection (without direct access to both ends) looks for the downstream SYMPTOMS: if window scale is stripped, throughput on an otherwise healthy high-bandwidth-delay-product path caps hard around 64KB in flight; if SACK-permitted is stripped, loss recovery becomes slow and coarse (whole-window retransmission behavior instead of precise, per-segment recovery) even though the path's raw loss rate is low; if timestamps are stripped, round-trip-time measurement and PAWS (Protect Against Wrapped Sequence numbers) protection both degrade, which can show up as a subtly less accurate RTO (retransmission timeout) calculation.
Worked example
Losing window scale specifically produces the most dramatic and recognizable symptom: throughput plateaus at roughly what a 64KB window can sustain for the path's round-trip time, regardless of how much raw bandwidth is actually available, since the connection can never express a window larger than the unscaled 16-bit field allows. If the expected bandwidth-delay product for the path is, say, 20 MB, but observed throughput behaves as though the effective window is capped near 64KB, a transparent proxy stripping the window scale option during the handshake is a strong suspect, especially if the SAME symptom does NOT appear when the two hosts communicate over a path that avoids that specific intermediate device.
Trade-offs & pitfalls
This class of interference is one of the harder network problems to diagnose precisely BECAUSE the connection doesn't fail, it just quietly underperforms, so it's easy to misattribute to "the network is just slow" or "the application is inefficient" rather than a specific, fixable option-stripping middlebox. The most reliable confirmation is always a controlled A/B comparison: the same connection, same hosts, routed via a path that includes versus excludes the suspect device, if the symptom disappears when the device is bypassed, that's strong confirmation.
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.
Implement a simplified TCP connection tracker that reads packets from a pcap file and emits connection-state transitions (SYN, ESTABLISHED, FIN/RST, TIME_WAIT). Parse Ethernet/IP/TCP headers, track connections by the 4-tuple, and maintain a per-connection state machine. Describe the primary data structures you would use and how you would handle a high packet rate without losing track of state.
Sample Answer
Direct answer
A pcap-driven connection tracker needs two pieces working together: a header parser that pulls the source/destination IP and port and the TCP flags out of each raw frame, and a state machine, keyed by the connection's 4-tuple, that maps flag combinations onto transitions like CLOSED to SYN_SENT to ESTABLISHED to CLOSE_WAIT to TIME_WAIT.
Structured elaboration (approach)
Parsing walks the frame layer by layer: skip the fixed 14-byte Ethernet header, read the IPv4 header (whose first byte's low nibble gives the header length in 4-byte words, since IPv4 headers can carry options and aren't always exactly 20 bytes), then read the 20-byte fixed TCP header immediately after (again respecting the TCP data offset field for any TCP options present). The key data structure is a dictionary keyed by the connection's 4-tuple, CANONICALIZED so the same connection is recognized regardless of which direction a given packet is traveling (a reply from the server to the client must resolve to the SAME dictionary key as the client's original request).
Worked example (code)
import struct
FIN, SYN, RST, PSH, ACK_FLAG = 0x01, 0x02, 0x04, 0x08, 0x10
def parse_packet(frame):
ip_bytes = frame[14:34]
ver_ihl, tos, total_len, ident, flags_frag, ttl, proto, csum, src, dst = \
struct.unpack("!BBHHHBBH4s4s", ip_bytes)
ip_header_len = (ver_ihl & 0x0F) * 4
tcp_start = 14 + ip_header_len
sport, dport, seq, ack, offset_reserved, flags, window, tcsum, urg = \
struct.unpack("!HHLLBBHHH", frame[tcp_start:tcp_start+20])
payload_start = tcp_start + (offset_reserved >> 4) * 4
return {
"src_ip": ".".join(str(b) for b in src), "dst_ip": ".".join(str(b) for b in dst),
"sport": sport, "dport": dport, "seq": seq, "ack": ack,
"flags": flags, "payload_len": len(frame[payload_start:]),
}
class ConnectionTracker:
def __init__(self):
self.conns = {} # 4-tuple -> state string
def _key(self, pkt, from_client):
return (pkt["src_ip"], pkt["sport"], pkt["dst_ip"], pkt["dport"]) if from_client \
else (pkt["dst_ip"], pkt["dport"], pkt["src_ip"], pkt["sport"])
def process(self, pkt, from_client):
key = self._key(pkt, from_client)
state = self.conns.get(key, "CLOSED")
f = pkt["flags"]
if f & RST:
state = "CLOSED"
elif state == "CLOSED" and (f & SYN) and not (f & ACK_FLAG):
state = "SYN_SENT"
elif state == "SYN_SENT" and (f & SYN) and (f & ACK_FLAG):
state = "SYN_RECEIVED"
elif state == "SYN_RECEIVED" and (f & ACK_FLAG) and not (f & FIN):
state = "ESTABLISHED"
elif state == "ESTABLISHED" and (f & FIN):
state = "CLOSE_WAIT"
elif state == "CLOSE_WAIT" and (f & ACK_FLAG):
state = "TIME_WAIT"
self.conns[key] = state
return state
Run against a synthetic 6-frame sequence (constructed with the same struct-packing logic in reverse, to produce realistic raw bytes) representing a full handshake, one data segment, and a graceful close: the tracker correctly walked CLOSED to SYN_SENT to SYN_RECEIVED to ESTABLISHED (the data segment stayed in ESTABLISHED, as expected, since it carries no SYN/FIN) to CLOSE_WAIT to TIME_WAIT, ending in the expected final state, verified with an assertion against the real parsed output rather than assumed.
Trade-offs & pitfalls (edge cases and complexity)
Per-packet complexity is O(1) (fixed-size header parsing, a single dictionary lookup), so the tracker scales linearly with packet rate; at a genuinely HIGH packet rate, the main design decision is concurrency: parsing itself is embarrassingly parallel across DIFFERENT connections (since each 4-tuple's state is independent), so a real high-throughput version would shard connections across worker threads/processes by a hash of the 4-tuple, while packets for the SAME connection must still be processed in arrival order to keep the state machine correct, a classic partition-by-key concurrency pattern. Edge cases worth naming explicitly: a RST from either side always forces CLOSED regardless of the current state (modeled here); simultaneous close (both sides sending FIN before seeing the other's) needs a genuinely separate CLOSING state in a fuller implementation, which this simplified 4-state model (SYN, ESTABLISHED, FIN/RST, TIME_WAIT) does not attempt to distinguish from the ordinary one-sided close.
Describe the four layers of the TCP/IP (Internet) model, map each to its corresponding OSI layer(s), and give one example protocol per TCP/IP layer. Explain in one or two sentences why two competing layering models exist and are both still used in practice.
Sample Answer
Direct answer
The TCP/IP (Internet) model has four layers: Link, Internet, Transport, and Application. It maps onto the seven-layer OSI model by collapsing OSI's bottom two layers into "Link" and its top three into "Application."
Structured elaboration
| TCP/IP layer | Corresponding OSI layer(s) | Example protocol |
|---|---|---|
| Application | Application, Presentation, Session (7, 6, 5) | HTTP |
| Transport | Transport (4) | TCP |
| Internet | Network (3) | IP |
| Link | Data Link, Physical (2, 1) | Ethernet |
Both models describe the same reality; they just carve it up at different granularity. OSI was designed as a general, vendor-neutral reference standard, drawn up before the protocols that would actually win were finalized, so it separates concerns the real internet protocol suite never bothered to split (nothing on the modern internet implements a distinct Session or Presentation layer as its own protocol). TCP/IP is the model that grew directly out of the protocols that were actually built and deployed, so it only has as many layers as the real stack needs to describe.
Worked example
Take a single HTTPS request. In TCP/IP terms: Application layer is HTTPS/TLS+HTTP, Transport is TCP, Internet is IP, Link is Ethernet or Wi-Fi. In OSI terms, the same request spans Layer 7 (HTTP semantics), arguably Layer 6 (TLS's encryption/format role, though in practice TLS libraries sit logically between transport and application), Layer 4 (TCP), Layer 3 (IP), and Layers 2/1 (the local network technology). Neither model is "more correct"; TCP/IP is more useful for describing what's actually running, OSI is more useful for a shared vocabulary when discussing where a NEW piece of functionality should live.
Trade-offs & pitfalls
A common mistake is treating the OSI-to-TCP/IP mapping as one-to-one instead of many-to-one. Session and Presentation don't disappear in TCP/IP, they're just not modeled as distinct layers because no widely deployed protocol maps cleanly onto only one of them. When someone asks "what OSI layer does TLS operate at," the honest answer is "it doesn't map cleanly, and that's expected," not a forced single number.
TCP Fast Open (TFO) lets a client send data in the SYN packet, skipping a full round trip on repeat connections to the same server. Explain how a middlebox built to expect a standard three-way handshake can misinterpret or drop TFO traffic, and what fallback behavior a client implementation needs so a TFO attempt never makes a connection LESS reliable than a plain handshake would have been.
Sample Answer
Direct answer
TCP Fast Open (TFO) lets a client include application data directly in its SYN packet on a REPEAT connection to a server it has connected to before, skipping the usual "wait for the handshake to finish before sending anything" round trip; the risk is that some middleboxes, built assuming a SYN never carries a meaningful payload, may drop, strip, or misforward that data, or even the whole packet, since it doesn't look like a standard handshake to them.
Structured elaboration
TFO works by having the server issue a cryptographic cookie to the client the FIRST time they connect (during a normal handshake, no fast-open data yet). On any SUBSEQUENT connection attempt, the client includes that cookie plus its actual application data directly in the SYN packet. If the server validates the cookie, it can begin processing that data immediately, effectively saving a full round trip compared to the standard "handshake completes, THEN data starts flowing" sequence.
The middlebox risk comes from an assumption baked into a lot of older network equipment: that a SYN packet is control-plane-only and never carries a meaningful payload. Some middleboxes (older NAT devices, certain firewalls, some load balancers) built on that assumption may strip TCP options they don't recognize (breaking the cookie mechanism itself), drop SYN packets that carry payload as anomalous or suspicious, or in some documented cases, mishandle the connection entirely.
Worked example
The required fallback behavior: if a TFO attempt's SYN (carrying the cookie and data) gets no response, or gets a response that doesn't correctly acknowledge the fast-open data, a correct client implementation must FALL BACK to a standard handshake, retransmitting the SYN WITHOUT the fast-open data and cookie, and only sending the actual application data after the connection is fully, conventionally established. This fallback is what keeps TFO safe to enable broadly: in the worst case (a hostile middlebox on the path), the connection degrades to ordinary TCP behavior rather than failing outright, the client just loses the round-trip savings TFO was trying to provide, it never loses connectivity because of it.
Trade-offs & pitfalls
The whole design of TFO is built around the assumption that middlebox interference IS common enough to plan for, not a rare edge case, that's precisely why the fallback-to-standard-handshake behavior is a REQUIRED part of any compliant implementation, not an optional nicety. An implementation that assumes TFO will always succeed and doesn't implement the fallback path correctly risks connections silently failing specifically on paths that include one of these older devices, exactly the class of path where the round-trip savings would have mattered most (since those paths tend to be higher-latency, longer routes).
Unlock Full Question Bank
Get access to all 34 Networking Fundamentals and Protocols interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.