Computer Networks Interview Questions
Core Concepts
Q: OSI vs TCP/IP model.
OSI (7 layers): Application → Presentation → Session → Transport → Network → Data Link → Physical
TCP/IP (4 layers): Application → Transport → Internet → Network Access
| OSI | TCP/IP | Protocols |
|---|
|---|---|---|
| Application (7) | Application | HTTP, HTTPS, DNS, SMTP, FTP, SSH |
|---|---|---|
| Presentation (6) | Application | SSL/TLS, compression |
| Session (5) | Application | NetBIOS, RPC |
| Transport (4) | Transport | TCP, UDP |
| Network (3) | Internet | IP, ICMP, ARP |
| Data Link (2) | Network Access | Ethernet, WiFi (802.11), MAC |
| Physical (1) | Network Access | Cables, signals |
Q: TCP vs UDP — when to use each.
TCP (Transmission Control Protocol):
•Connection-oriented (3-way handshake: SYN → SYN-ACK → ACK)
•Reliable: acknowledgements, retransmission, in-order delivery
•Flow control, congestion control
•Use for: HTTP/HTTPS, email, file transfer, databases, SSH
UDP (User Datagram Protocol):
•Connectionless, no handshake
•Unreliable: fire-and-forget, no retransmission, no ordering
•Low overhead, low latency
•Use for: DNS, video streaming, gaming, VoIP, DHCP, live broadcasts
Q: HTTP — methods, status codes, versions.
Methods:
•GET: retrieve resource (idempotent, cacheable)
•POST: create resource (not idempotent)
•PUT: replace resource (idempotent)
•PATCH: partial update
•DELETE: remove resource
•HEAD: like GET but headers only
•OPTIONS: describe communication options (used for CORS preflight)
Status codes:
•1xx: Informational (100 Continue)
•2xx: Success (200 OK, 201 Created, 204 No Content)
•3xx: Redirect (301 Permanent, 302 Temporary, 304 Not Modified)
•4xx: Client error (400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests)
•5xx: Server error (500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout)
HTTP versions:
•HTTP/1.1: persistent connections, pipelining (head-of-line blocking)
•HTTP/2: multiplexing (multiple requests/responses in parallel), header compression, server push
•HTTP/3: based on QUIC (UDP), eliminates TCP head-of-line blocking
Q: DNS — how it works.
Q: Subnetting and CIDR.

