Interview Q&A / Computer Networks
Computer Networks interview questions
What happens when you open a website, TCP vs UDP, DNS and HTTP.
Prefer rapid revision? Practise Computer Networks short interview answers →
- How does DNS resolution work, step by step?
Your device asks a recursive resolver, which checks its cache and, if needed, asks a root server, then the TLD server (like .com), then the domain's authoritative server, which returns the IP address. Every answer carries a TTL, so resolvers and devices cache it and skip most of these steps next time.
IntermediateIn-depth4 min read - What is an IP address, a subnet and CIDR notation like /24?
An IPv4 address is a 32-bit number that identifies a device on a network. CIDR notation such as 192.168.1.0/24 says how many leading bits are the network part; the rest identify hosts. A /24 has 256 addresses (254 usable), a /16 has 65,536, and each extra bit halves the size of the subnet.
IntermediateIn-depth4 min read - At which OSI layer does TLS work?
TLS has no clean place in OSI. It runs on top of TCP and below HTTP, so it is usually described as layer 6 (presentation) or between layers 4 and 7. In the TCP/IP model it simply sits inside the application layer.
IntermediateQuick answer1 min read - How do Cache-Control and ETag let a browser reuse a response?
Cache-Control: max-age tells the browser how long it may reuse a response without asking. After that, the browser can revalidate with If-None-Match and the ETag; if nothing changed, the server replies 304 Not Modified with no body.
IntermediateQuick answer1 min read - How do TCP slow start and congestion avoidance work? Trace cwnd over time.
Slow start doubles the congestion window every round trip from a small start until it reaches a threshold (ssthresh). After that, congestion avoidance grows it by about one segment per round trip. On a timeout, ssthresh becomes half the window and cwnd restarts small.
IntermediateQuick answer1 min read - How does a router choose between several matching routes? Explain longest prefix match.
The router picks, among all table entries that contain the destination address, the one with the longest prefix (most specific). A /24 beats a /16, which beats a /8, and 0.0.0.0/0 is the last-resort default route.
IntermediateQuick answer1 min read - How does TCP detect and recover from a lost packet?
The sender retransmits when its timer expires without an ACK, or sooner if it receives three duplicate ACKs, which signal that later segments arrived but one is missing. That second path is called fast retransmit.
IntermediateQuick answer1 min read - How does the TCP sliding window work? Give a small example.
The receiver advertises how many bytes it can accept. The sender may keep that many bytes in flight without waiting for ACKs, and as each ACK arrives the window slides forward so new data can be sent. This keeps the link busy instead of stop-and-wait.
IntermediateQuick answer1 min read - How does traceroute discover the path to a server?
It sends packets with TTL set to 1, then 2, then 3 and so on. Each router that drops a packet at TTL 0 replies with an ICMP Time Exceeded message, revealing its address, until the destination itself replies.
IntermediateQuick answer1 min read - How is a TCP connection closed, and what is the TIME_WAIT state?
Each side closes its own direction with FIN and the other side ACKs it, so teardown takes four segments. The side that closes first then waits in TIME_WAIT, about twice the maximum segment lifetime (60 seconds on Linux), to catch late packets and to resend the last ACK if lost.
IntermediateQuick answer1 min read - What are DNS over HTTPS and DNS over TLS, and what problem do they solve?
Plain DNS is unencrypted, so anyone on the path can read and alter your lookups. DNS over TLS (port 853) and DNS over HTTPS (port 443) encrypt the query between you and the resolver, hiding what names you look up from the local network.
IntermediateQuick answer1 min read - What are the main differences between HTTP/1.1 and HTTP/2?
HTTP/2 uses a binary format, multiplexes many requests over a single TCP connection, compresses headers with HPACK and allows prioritisation. HTTP/1.1 is plain text and handles one request at a time per connection, so browsers open several connections instead.
IntermediateQuick answer1 min read - What are unicast, broadcast and multicast, and why can TCP not use the last two?
Unicast sends to one receiver, broadcast to every host on the local network, and multicast to a group that has joined. TCP needs a two-way connection with one peer, so it only supports unicast; broadcast and multicast use UDP.
IntermediateQuick answer1 min read - What changes in a packet as it passes through routers?
The IP source and destination stay the same (without NAT), but each router decrements the TTL by 1 and the Ethernet frame is rebuilt with new source and destination MAC addresses for the next link.
IntermediateQuick answer1 min read - What is a socket, and how can one server handle thousands of clients on port 443?
A socket is one endpoint of a connection: an IP address plus a port plus a protocol. A TCP connection is identified by the four-tuple of source IP, source port, destination IP and destination port, so many clients can share the server's port 443 because each tuple is unique.
IntermediateQuick answer1 min read - What is MTU, and what happens when a packet is bigger than it?
MTU is the largest packet a link can carry; Ethernet's is usually 1500 bytes. IPv4 routers may split a bigger packet into fragments, or drop it and send an ICMP message if the Don't Fragment bit is set. IPv6 routers never fragment.
IntermediateQuick answer1 min read - What is route summarization? Summarize 192.168.0.0/24 and 192.168.1.0/24.
Summarization replaces several contiguous routes with one shorter-prefix route. 192.168.0.0/24 and 192.168.1.0/24 combine into 192.168.0.0/23, which covers 192.168.0.0 to 192.168.1.255, so routers keep one entry instead of two.
IntermediateQuick answer1 min read - What is the difference between a recursive and an iterative DNS query?
In a recursive query, the client asks a resolver to do all the work and return a final answer. In an iterative query, the server replies with its best referral and the asker follows it to the next server. Your device asks recursively; the resolver then asks iteratively.
IntermediateQuick answer1 min read - What is the difference between distance vector and link state routing protocols?
Distance vector protocols like RIP share their routing table with neighbours and trust what they hear (routing by rumour). Link state protocols like OSPF flood the full network map to everyone, and each router computes shortest paths itself with Dijkstra's algorithm.
IntermediateQuick answer1 min read - What is the difference between TCP flow control and congestion control?
Flow control stops a fast sender from overwhelming a slow receiver, using the receiver's advertised window. Congestion control stops senders from overwhelming the network in between, using a congestion window the sender maintains itself. The sender obeys the smaller of the two.
IntermediateQuick answer1 min read - What is VLSM? Allocate subnets for 100, 50 and 20 hosts from 192.168.5.0/24.
VLSM (variable length subnet masking) lets each subnet use the mask that fits its size instead of one size for all. Allocate largest first: /25 for 100 hosts, /26 for 50, /27 for 20, and a /30 for a router link.
IntermediateQuick answer1 min read - Why does DNS mostly use UDP, and when does it switch to TCP?
A DNS lookup is one small question and one small answer, so UDP avoids the cost of a handshake. DNS falls back to TCP when the answer is too large for a UDP response (truncated flag set), for zone transfers, and for DNS over TLS.
IntermediateQuick answer1 min read