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.
Walk me through everything that happens, network-wise, between typing https://api.example.com/orders into a browser and the browser receiving the first byte of the HTTP response. Don't worry about page rendering, just get me to the response.
Sample Answer
Direct answer
The browser resolves the hostname to an IP via DNS, opens a TCP connection on port 443, negotiates TLS on top of that connection, then sends the HTTP request. Each step can cost a round trip unless cached, so the wait before the first response byte is roughly DNS time plus TCP handshake time plus TLS handshake time plus one HTTP round trip.
Structured elaboration
DNS: the OS asks a resolver to translate the hostname to an IP, one round trip if cached anywhere in the chain, more if it walks root to TLD to authoritative server.
TCP: SYN, SYN-ACK, ACK, one round trip before any data moves.
TLS: client and server agree on a cipher suite, the server presents a certificate the browser validates against a trusted CA, and both derive a shared symmetric key. TLS 1.3 takes one round trip; TLS 1.2 typically needs two.
HTTP: only now does the request go out over the encrypted channel, and the response returns on the same connection.
Worked example
Assume a 50ms one-way trip (100ms round trip). Cold cache, TLS 1.3: DNS (100ms) plus TCP (100ms) plus TLS (100ms) plus HTTP (100ms) equals 400ms before the first byte. With DNS cached and a warm keep-alive connection reused, that same request costs just 100ms, a 4x difference, the whole argument for connection reuse.
Trade-offs and pitfalls
- Assuming HTTPS costs the same as plain HTTP is wrong; a cold-cache HTTPS request costs 3 to 4 times the round trips.
- Reuse (HTTP/1.1 keep-alive, HTTP/2 multiplexing) skips TCP and TLS setup for later requests to the same host; TLS session resumption skips most of a fresh handshake too.
What the interviewer probes next
Expect a follow-up on what changes when the connection is already warm, and what TLS session resumption specifically skips.
Explain the difference between a port, a socket, and a connection (the 4-tuple / 5-tuple). What distinguishes well-known, registered, and ephemeral port ranges, and why can many different clients share the same server port on one host without their traffic getting mixed up? Briefly note how NAT changes what a receiver actually observes on the wire.
Sample Answer
Direct answer
A port is a 16-bit number identifying an endpoint on a host; a socket is the (IP address, port, protocol) combination that uniquely names one endpoint; and a connection (the 4-tuple, or 5-tuple if you count the protocol) is the full pairing of BOTH endpoints' sockets, source IP, source port, destination IP, destination port. Many clients can share the same server port because what actually distinguishes their traffic is the FULL 4-tuple, not the destination port alone.
Structured elaboration
Port ranges are conventionally split three ways: well-known ports (0-1023, traditionally requiring elevated privilege to bind on Unix-like systems, and reserved by convention for standard services like 443 for HTTPS), registered ports (1024-49151, registered with IANA for specific applications but not privileged), and ephemeral (or dynamic/private) ports (49152-65535 by IANA convention, though many OSes use a wider practical range), which the OS assigns automatically to the CLIENT side of an outgoing connection.
| Term | Common port table |
|---|---|
| 22 | SSH |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 3306 | MySQL |
| 3389 | RDP |
A server listening on port 443 can serve thousands of simultaneous clients because the SERVER's port (443) is only ONE piece of what identifies each connection; every incoming connection also carries a distinct client IP and, typically, a distinct client-side ephemeral port, so the full 4-tuple (client IP, client port, server IP, server port) is what the OS actually uses to demultiplex incoming packets to the right connection, even though the server-side half of that tuple (server IP and port) is identical across all of them.
Worked example
Two different clients, 203.0.113.5 and 203.0.113.9, can both have simultaneous connections to a web server at 198.51.100.1:443. Client A's connection might use ephemeral port 51000 and client B's might use 51000 too (a coincidence, since each client picks its own ephemeral ports independently), yet the server has no trouble distinguishing them, because the full 4-tuples are different: (203.0.113.5, 51000, 198.51.100.1, 443) versus (203.0.113.9, 51000, 198.51.100.1, 443). If client A instead opens a SECOND connection to the same server, its OS will typically pick a DIFFERENT ephemeral port for that second connection (since a client can't have two identical 4-tuples open at once to the same destination), giving something like (203.0.113.5, 51001, 198.51.100.1, 443).
Trade-offs & pitfalls
NAT changes what a receiver actually observes on the wire: a device behind a NAT gateway sharing one public IP will have its ephemeral port REWRITTEN by the NAT device (Port Address Translation) so that multiple internal hosts sharing the same public IP can still be distinguished by the server, meaning the source port a server sees is often not the port the ORIGINAL client actually used, a common source of confusion when correlating server-side logs against client-side application behavior.
Explain the seven layers of the OSI model. For each layer, state its primary responsibility, the name of its protocol data unit (PDU), and one or two protocols or technologies that commonly operate there. Then explain why identifying which layer a failure sits at is useful before you jump to a fix.
Sample Answer
Direct answer
The OSI model splits network communication into seven layers, each handing off a well-defined unit of work to the layer above and below it: Physical, Data Link, Network, Transport, Session, Presentation, and Application. Knowing which layer a protocol or symptom belongs to lets you reason about failures systematically instead of guessing.
Structured elaboration
| Layer | Responsibility | PDU (protocol data unit) | Common protocols/tech |
|---|---|---|---|
| 7. Application | Provides the interface applications use to talk over the network | Data | HTTP, DNS |
| 6. Presentation | Translates, encrypts, and compresses data into a form the application layer can use | Data | TLS, character encoding |
| 5. Session | Establishes, manages, and tears down a logical session between two hosts | Data | RPC session handling |
| 4. Transport | End-to-end delivery between processes: reliability, ordering, flow control | Segment (TCP) / Datagram (UDP) | TCP, UDP |
| 3. Network | Logical addressing and routing across networks | Packet | IP, ICMP |
| 2. Data Link | Framing and addressing on a single link (same broadcast domain) | Frame | Ethernet, ARP |
| 1. Physical | Raw bit transmission over a physical medium | Bit | Ethernet PHY, fiber, radio (Wi-Fi) |
The mnemonic that matters more than memorizing names is the DIRECTION of responsibility: each layer only needs to trust the layer directly below it to deliver its unit of data, and it only exposes a clean interface to the layer above. That's what lets a Transport-layer protocol like TCP work identically over Ethernet, Wi-Fi, or a VPN tunnel: it never needs to know which Layer 1/2 technology is underneath.
Worked example
Say a user reports "the site is down." Layer-by-layer reasoning turns that vague complaint into a specific hypothesis:
- Physical/Data Link symptom: the NIC shows no link light, or
ip linkreports the interface asDOWNa cable or switch-port problem. - Network layer symptom:
pingto the server's IP times out but the local gateway responds a routing problem somewhere between here and there. - Transport layer symptom:
pingsucceeds but a TCP connection to the port hangs or resets a firewall, a service that isn't listening, or a transport-level issue. - Application layer symptom: the TCP connection completes but the HTTP response is an error or garbage the service is up but misbehaving.
Each of these is a different team, a different fix, and a different urgency. That's the actual payoff of the model: it turns "the site is down" into "which layer, which evidence."
Trade-offs & pitfalls
The OSI model is a teaching and troubleshooting framework, not how real stacks are literally implemented. Session and Presentation are rarely separate pieces of code in modern systems; TLS, for instance, is commonly described as "sits between Transport and Application" rather than cleanly as Layer 6. Don't over-fit a real symptom to exactly one layer: a firewall dropping SYN packets looks like a Transport-layer symptom (connection never establishes) but the actual cause and fix live at a security-policy layer that OSI doesn't model at all.
Explain how encapsulation works when an HTTP request travels from a browser to a web server across the internet. Describe, header by header, what gets added at the transport, network, and data-link layers, and what happens in reverse (decapsulation) at the server.
Sample Answer
Direct answer
Encapsulation is the process of wrapping data in a new header (and sometimes trailer) as it moves down the protocol stack, and stripping those headers back off as it moves up the stack on the receiving side. Each layer only understands its own header; it treats everything handed to it by the layer above as an opaque payload.
Structured elaboration
Follow a browser's HTTP request to a web server, header by header, going down the sender's stack:
- Application layer: the browser produces an HTTP request (method, path, headers, body).
- Transport layer: TCP wraps that request in a TCP segment, adding a header with source port, destination port, sequence number, acknowledgment number, and flags. The whole HTTP request becomes the segment's payload.
- Network layer: IP wraps the TCP segment in an IP packet, adding a header with the source IP address and destination IP address. The TCP segment becomes the packet's payload.
- Data link layer: Ethernet wraps the IP packet in a frame, adding a header with the source MAC address and destination MAC address (and a trailer with a frame check sequence for error detection). The IP packet becomes the frame's payload.
- Physical layer: the frame is converted to bits and transmitted as electrical, optical, or radio signals.
On the receiving side, decapsulation runs in exactly the reverse order: the physical layer recovers bits into a frame, the data link layer strips the Ethernet header/trailer and hands the IP packet up, the network layer strips the IP header and hands the TCP segment up, the transport layer strips the TCP header and hands the HTTP request up, and the application layer finally sees the original request.
Worked example
Concretely, by the time the original HTTP request bytes reach the wire, they are surrounded by four layers of header (ignoring the physical layer, which isn't a header at all): [Ethernet header][IP header][TCP header][HTTP request bytes][Ethernet trailer]. Each intermediate device on the path (a switch, a router) only needs to look at the headers relevant to its own layer: a switch reads the Ethernet header to decide which port to forward the frame out of; a router strips the Ethernet framing entirely, reads the IP header to decide the next hop, and re-wraps the same IP packet in a NEW Ethernet frame addressed to the next hop's MAC address. The TCP header and the HTTP payload never change as the packet crosses the network; only the Layer 2 framing gets rewritten at each hop.
Trade-offs & pitfalls
The most common confusion is expecting the MAC addresses in the Ethernet header to stay constant end-to-end, they don't. Only the IP addresses (Network layer) stay constant from source to destination; the MAC addresses (Data Link layer) change at every hop, because Ethernet framing is only meaningful on a single link, not across the whole path.
Explain the differences between TCP and UDP in terms of connection model, reliability, ordering, and flow/congestion control. For each protocol, name two real-world services that should use it and explain why. Then describe a scenario where you would build a custom reliable protocol on top of UDP rather than simply using TCP.
Sample Answer
Direct answer
TCP is connection-oriented and guarantees reliable, in-order delivery with built-in flow and congestion control, at the cost of handshake setup latency and head-of-line blocking; UDP is connectionless, with no delivery guarantees, ordering, or congestion control, trading reliability for minimal overhead and lower latency. The right choice depends on whether the application can tolerate loss and reordering itself, or needs the transport layer to handle it.
Structured elaboration
| Property | TCP | UDP |
|---|---|---|
| Connection model | Connection-oriented (handshake required) | Connectionless (no setup) |
| Reliability | Guaranteed delivery via retransmission | Best-effort, no retransmission |
| Ordering | In-order delivery guaranteed | No ordering guarantee |
| Flow control | Yes (receive window) | None |
| Congestion control | Yes (built into the protocol) | None (must be built by the application, if needed at all) |
| Overhead | Higher (handshake, ACKs, header size) | Lower (no handshake, smaller header) |
Two examples per protocol: TCP is the right choice for a database connection or a file transfer, where losing or reordering even one byte silently would corrupt the result, and the application has no interest in reimplementing reliability itself. UDP is the right choice for live video/voice calls or DNS queries, where a single lost or late packet is better DISCARDED and moved past (an old, out-of-order audio frame is useless once its playback moment has passed) than retransmitted at the cost of added latency that would make the whole stream feel laggy.
Worked example
A scenario where building custom reliability ON TOP of UDP beats plain TCP: a real-time multiplayer game sending frequent position updates. TCP's strict in-order delivery means a single lost packet blocks EVERY later packet from being delivered to the application until the lost one is retransmitted and received (head-of-line blocking), even if those later packets contain fresher, more relevant position data. Building a thin reliability layer over UDP lets the application decide per-message whether it's worth retransmitting (a player's current position, three updates old, usually isn't worth retransmitting, a newer update has probably already superseded it) rather than being forced into strict in-order delivery for data where "newest wins" matters more than "nothing lost."
Trade-offs & pitfalls
A common mistake is treating "TCP is reliable, UDP isn't" as the END of the analysis; the real question is whether your application's OWN definition of correctness matches TCP's specific guarantees (strict ordering, full reliability) or would be better served by a custom scheme that's more permissive in exactly the ways TCP is rigid. Building your own reliability on UDP is real engineering work (implementing retransmission, sequencing, and congestion awareness yourself), not a shortcut, it's justified specifically when TCP's guarantees don't match what the application actually needs.
Unlock Full Question Bank
Get access to all 10 Networking Fundamentals and Protocols interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.