05 Computer Networks
05 Computer Networks
Overview
Networking fundamentals — the OSI/TCP-IP model, protocols, and addressing — underpin how web applications
(like the MERN apps you've built) actually communicate over the wire.
Key Concepts
• OSI Model (7 Layers): Physical, Data Link, Network, Transport, Session, Presentation, Application — a
conceptual framework for how data moves from one device to another.
• TCP/IP Model: A practical 4-layer model (Link, Internet, Transport, Application) that the modern internet
actually runs on; TCP/IP consolidates several OSI layers.
• TCP vs UDP: TCP is connection-oriented, reliable, ordered, with flow/congestion control (used for HTTP,
email); UDP is connectionless, faster, no delivery guarantee (used for video streaming, DNS, gaming).
• Three-Way Handshake: TCP connection setup: SYN → SYN-ACK → ACK, establishing sequence numbers and
confirming both sides are ready to communicate.
• HTTP vs HTTPS: HTTPS is HTTP layered over TLS/SSL, encrypting traffic and authenticating the server via
certificates to prevent eavesdropping and tampering.
• DNS Resolution: Translates human-readable domain names into IP addresses via a hierarchical lookup:
browser cache → OS cache → resolver → root, TLD, and authoritative name servers.
• IP Addressing & Subnetting: IPv4 addresses are 32-bit, divided into network and host portions via a subnet
mask; CIDR notation (e.g., /24) specifies the network prefix length.
• Sockets: An endpoint for sending/receiving data across a network, identified by an IP address and port
number, forming the basis of client-server communication.
• Load Balancing: Distributing incoming requests across multiple servers to improve availability and
throughput, using strategies like round robin, least connections, or IP hash.
• CDN (Content Delivery Network): A geographically distributed network of caching servers that serve static
content from a location close to the user, reducing latency.
Common Interview Questions
Q1. What happens when you type a URL into a browser?
DNS resolves the domain to an IP, the browser establishes a TCP connection (and TLS handshake for HTTPS),
sends an HTTP request, the server processes it and returns a response, and the browser renders the
received HTML/CSS/JS.
Q3. What is the difference between a forward proxy and a reverse proxy?
A forward proxy sits in front of clients and forwards their requests to the internet (hiding the client); a
reverse proxy sits in front of servers and forwards client requests to the appropriate backend (hiding the
server).
Q5. What is CORS and why does it matter for a MERN app?
Cross-Origin Resource Sharing is a browser security mechanism that restricts web pages from making
requests to a different origin unless the server explicitly allows it via response headers — relevant whenever
your React frontend and Node backend run on different ports/domains.
Q6. What's the difference between a 401 and 403 HTTP status code?
401 Unauthorized means authentication is required or has failed; 403 Forbidden means the server
understood the request and identified the client, but refuses to authorize it regardless of credentials.