Networking Basics Questions Placement
Networking Basics Interview Questions and Answers for Placements
Last Updated: March 2026
Introduction to Computer Networks
Computer networking forms the backbone of modern computing, enabling communication between devices across the globe. Understanding networking fundamentals is essential for software engineers, as virtually every application today communicates over a network. From TCP/IP protocols to HTTP/HTTPS, DNS, and security - networking knowledge is tested in virtually every technical interview.
Why Networking is Essential for Placements
- Universal Requirement: Every application uses network communication
- System Design Foundation: Can't design scalable systems without networking knowledge
- DevOps/SRE Roles: Network troubleshooting is core skill
- Security Focus: Network security critical in modern applications
- Cloud Native: Microservices communicate via networks
Key Concepts and Theory
OSI Model vs TCP/IP Model
OSI Model (7 Layers):
| Layer | Name | Function | Examples |
|---|---|---|---|
| 7 | Application | User interface, network apps | HTTP, FTP, SMTP, DNS |
| 6 | Presentation | Data format, encryption | SSL/TLS, JPEG, ASCII |
| 5 | Session | Session management | NetBIOS, PPTP |
| 4 | Transport | End-to-end delivery | TCP, UDP |
| 3 | Network | Routing, logical addressing | IP, ICMP, OSPF |
| 2 | Data Link | Physical addressing, framing | Ethernet, MAC, PPP |
| 1 | Physical | Bits on wire | Cables, Hubs, Signals |
TCP/IP Model (4 Layers):
| Layer | OSI Equivalent | Protocols |
|---|---|---|
| Application | 5-7 | HTTP, FTP, SMTP, DNS |
| Transport | 4 | TCP, UDP |
| Internet | 3 | IP, ICMP, ARP |
| Network Access | 1-2 | Ethernet, Wi-Fi |
Mnemonic for OSI: "Please Do Not Throw Sausage Pizza Away"
TCP vs UDP
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented | Connectionless |
| Reliability | Reliable (acknowledgments) | Unreliable |
| Order | Ordered delivery | No ordering |
| Speed | Slower (overhead) | Fast |
| Use Case | Web, Email, File Transfer | Streaming, Gaming, DNS |
| Header Size | 20-60 bytes | 8 bytes |
| Flow Control | Yes | No |
| Congestion Control | Yes | No |
TCP Header:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Practice Questions with Solutions
Question 1: Explain TCP 3-Way Handshake. ⭐⭐ [Medium]
The 3-way handshake establishes a TCP connection between client and server.
Process:
Client Server
| |
|-------- SYN (seq=x) ----------->| Step 1: Client sends SYN
| | "I want to connect"
| |
|<-- SYN-ACK (seq=y, ack=x+1) ----| Step 2: Server responds
| | "I got it, you there?"
| |
|-------- ACK (ack=y+1) --------->| Step 3: Client confirms
| | "I'm here, let's talk"
| |
|<========= DATA TRANSFER =========>|
Why 3-way?
- SYN: Client sends initial sequence number (ISN)
- SYN-ACK: Server acknowledges and sends its ISN
- ACK: Client acknowledges server's ISN
- Ensures both sides can send and receive
Sequence Numbers:
- Protect against delayed duplicate packets
- Provide reliability through acknowledgment
Python Socket Example:
# Server
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('localhost', 8080))
server.listen(5)
conn, addr = server.accept() # Completes 3-way handshake
# Client
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('localhost', 8080)) # Initiates 3-way handshake
Question 2: What is the Difference between HTTP and HTTPS? ⭐ [Easy]
| Feature | HTTP | HTTPS |
|---|---|---|
| Security | Unencrypted | Encrypted with SSL/TLS |
| Port | 80 | 443 |
| Certificate | Not required | SSL certificate required |
| Performance | Faster | Slower (encryption overhead) |
| URL | http:// | https:// |
| SEO | Lower ranking | Preferred by search engines |
HTTPS Handshake (TLS 1.2):
1. Client Hello
- Supported TLS versions
- Cipher suites supported
- Random bytes (client_random)
2. Server Hello
- Chosen TLS version
- Chosen cipher suite
- Random bytes (server_random)
- SSL Certificate (public key)
3. Client Verification
- Verify certificate (CA, expiry, domain)
- Generate pre-master secret
- Encrypt with server's public key
4. Key Generation
- Both generate session keys from:
client_random + server_random + pre-master
5. Finished
- Exchange encrypted "finished" messages
- Secure channel established
Why HTTPS matters:
- Confidentiality: Data encrypted in transit
- Integrity: Data can't be modified
- Authentication: Verify server identity
- Trust: Padlock icon builds user confidence
Question 3: Explain DNS Resolution Process. ⭐⭐ [Medium]
DNS (Domain Name System) translates human-readable domain names to IP addresses.
Resolution Process:
User types: www.example.com
1. Browser Cache
- Check if recently resolved
2. OS Cache (hosts file, DNS client)
- Check local DNS cache
3. Router Cache
- Check router's DNS cache
4. ISP DNS Server (Recursive Resolver)
- If not cached, start recursive query
5. Root Name Server
- "I don't know, ask .com servers"
- Returns TLD server address
6. TLD Server (.com)
- "I don't know, ask example.com servers"
- Returns authoritative server
7. Authoritative DNS Server
- "www.example.com is at 93.184.216.34"
8. Return to Client
- Cache the result (TTL duration)
- Connect to IP address
DNS Record Types:
| Record | Purpose | Example |
|---|---|---|
| A | IPv4 address | example.com → 93.184.216.34 |
| AAAA | IPv6 address | example.com → 2606:2800:220:1:248:1893:25c8:1946 |
| CNAME | Canonical name (alias) | www.example.com → example.com |
| MX | Mail exchange | example.com → mail.example.com |
| NS | Name server | example.com → ns1.example.com |
| TXT | Text record | SPF, DKIM verification |
| SOA | Start of authority | Zone information |
DNS Caching:
- Browser cache: Few minutes
- OS cache: Configurable (usually hours)
- TTL in DNS record: Set by domain owner
Question 4: What is the Difference between GET and POST? ⭐ [Easy]
| Feature | GET | POST |
|---|---|---|
| Purpose | Retrieve data | Submit data |
| Visibility | Data in URL | Data in body |
| Caching | Can be cached | Not cached |
| Bookmarkable | Yes | No |
| Length Limit | Limited by URL (2048 chars) | Unlimited |
| Security | Not for sensitive data | Safer for sensitive data |
| Idempotent | Yes | No |
| History | Stored in browser history | Not stored |
GET Request:
GET /users?id=123 HTTP/1.1
Host: api.example.com
POST Request:
POST /users HTTP/1.1
Host: api.example.com
Content-Type: application/json
{
"name": "John",
"email": "john@example.com"
}
When to Use:
- GET: Search, filter, retrieve data, bookmarkable pages
- POST: Create resources, submit forms, sensitive data
Other HTTP Methods:
- PUT: Update entire resource (idempotent)
- PATCH: Partial update
- DELETE: Remove resource
- HEAD: Get headers only
- OPTIONS: Get supported methods
Question 5: Explain TCP Congestion Control. ⭐⭐⭐ [Hard]
Congestion Control prevents network overload by regulating data flow.
Key Mechanisms:
1. Slow Start:
- Start with small congestion window (cwnd = 1 MSS)
- Double cwnd every RTT (exponential growth)
- Continues until threshold (ssthresh) or packet loss
2. Congestion Avoidance:
- After reaching ssthresh, linear growth
- Add 1 MSS per RTT
- More conservative than slow start
3. Fast Retransmit:
- On 3 duplicate ACKs, retransmit immediately
- Don't wait for timeout
4. Fast Recovery:
- After fast retransmit, don't go to slow start
- Set cwnd = ssthresh + 3 MSS
- Continue in congestion avoidance
TCP Tahoe vs Reno:
- Tahoe: On loss, cwnd = 1, slow start
- Reno: Fast recovery, better performance
Modern Algorithms:
- CUBIC: Used in Linux default
- BBR: Google's bottleneck bandwidth approach
Visualization:
Congestion Window
│
│ ╱‾‾‾‾‾‾‾‾‾‾‾‾‾‾╲
│ ╱ ╲___ Slow Start
│ ╱ then Congestion Avoidance
│ ╱ Packet Loss → Drop
│╱ Fast Recovery
└────────────────────────────── Time
Question 6: What is a Load Balancer? Explain Types. ⭐⭐⭐ [Hard]
Load Balancer distributes incoming network traffic across multiple servers to ensure high availability and reliability.
Why Load Balancing:
- High availability (no single point of failure)
- Scalability (add/remove servers)
- Better performance (distribute load)
- Health monitoring (remove failed servers)
Types of Load Balancers:
1. Layer 4 (Transport Layer):
- Based on IP address and port
- Faster, less processing
- Doesn't inspect content
- Examples: HAProxy (L4 mode), AWS NLB
2. Layer 7 (Application Layer):
- Based on HTTP headers, URL, cookies
- Content-aware routing
- SSL termination
- Examples: Nginx, AWS ALB, HAProxy (L7 mode)
Load Balancing Algorithms:
| Algorithm | Description | Use Case |
|---|---|---|
| Round Robin | Sequential distribution | Equal capacity servers |
| Least Connections | To server with fewest connections | Variable request duration |
| Least Response Time | To fastest responding server | Performance critical |
| IP Hash | Based on client IP | Session persistence |
| Weighted | Based on server capacity | Different server specs |
Session Persistence (Sticky Sessions):
- Route same client to same server
- Methods: IP hash, cookies, session ID
Health Checks:
Load Balancer → Server A: /health (OK)
Load Balancer → Server B: /health (FAIL)
↓
Remove B from pool
Question 7: Explain REST API Principles. ⭐⭐ [Medium]
REST (Representational State Transfer) is an architectural style for designing networked applications.
Six Constraints:
1. Client-Server:
- Separation of concerns
- Client handles UI, server handles data
- Independent evolution
2. Stateless:
- No client context stored on server
- Each request contains all necessary information
- Server doesn't remember previous requests
3. Cacheable:
- Responses must define themselves as cacheable
- Improves scalability and performance
4. Uniform Interface:
- Resource identification (URLs)
- Resource manipulation through representations
- Self-descriptive messages
- Hypermedia as engine of application state (HATEOAS)
5. Layered System:
- Client can't tell if connected directly to server or intermediary
- Load balancers, caches, proxies transparent
6. Code on Demand (Optional):
- Server can extend client functionality (JavaScript)
RESTful URL Design:
GET /users # List all users
GET /users/123 # Get user 123
POST /users # Create new user
PUT /users/123 # Update user 123 (full)
PATCH /users/123 # Partial update user 123
DELETE /users/123 # Delete user 123
GET /users/123/orders # Get user's orders
HTTP Status Codes:
| Code | Meaning | Example |
|---|---|---|
| 200 | OK | Successful GET, PUT |
| 201 | Created | Successful POST |
| 204 | No Content | Successful DELETE |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Missing auth |
| 403 | Forbidden | No permission |
| 404 | Not Found | Resource doesn't exist |
| 500 | Server Error | Exception occurred |
Question 8: What is CORS and How to Handle It? ⭐⭐ [Medium]
CORS (Cross-Origin Resource Sharing) is a security mechanism that restricts web pages from making requests to a different domain than the one serving the web page.
Same-Origin Policy:
- Protocol + Host + Port must match
- http://example.com:80 vs https://example.com:443 → Different!
CORS Headers:
Request Headers:
Origin: http://example.com
Access-Control-Request-Method: POST
Access-Control-Request-Headers: X-Custom-Header
Response Headers:
Access-Control-Allow-Origin: http://example.com
Access-Control-Allow-Methods: GET, POST, PUT
Access-Control-Allow-Headers: Content-Type, X-Custom-Header
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 86400
Types of CORS Requests:
1. Simple Requests:
- GET, HEAD, POST
- Standard headers only
- Content-Type: application/x-www-form-urlencoded, multipart/form-data, text/plain
- No preflight
2. Preflight Requests:
- Non-simple requests trigger OPTIONS preflight
- Browser checks if actual request is safe
- Server must respond to OPTIONS
Preflight Flow:
Browser → OPTIONS /api/data
Origin: http://example.com
Access-Control-Request-Method: DELETE
Server ← 204 No Content
Access-Control-Allow-Origin: http://example.com
Access-Control-Allow-Methods: GET, POST, DELETE
Browser → DELETE /api/data (actual request)
Handling CORS:
Server-side (Express.js):
const cors = require('cors');
app.use(cors({
origin: 'http://example.com',
methods: ['GET', 'POST'],
credentials: true
}));
Proxy (Development):
// React development server proxy
"proxy": "http://localhost:3001"
Never use * with credentials!
Question 9: Explain WebSockets and Difference from HTTP. ⭐⭐⭐ [Hard]
WebSocket provides full-duplex communication over a single TCP connection.
HTTP vs WebSocket:
| Feature | HTTP | WebSocket |
|---|---|---|
| Communication | Half-duplex | Full-duplex |
| Connection | Short-lived | Persistent |
| Overhead | High (headers every request) | Low (after handshake) |
| Server Push | Not supported (polling needed) | Native support |
| Real-time | Polling/WebSocket needed | Native |
| Protocol | http:// or https:// | ws:// or wss:// |
WebSocket Handshake:
Client Request:
GET /chat HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
Server Response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Python WebSocket Example:
# Server (using websockets library)
import asyncio
import websockets
async def handler(websocket, path):
async for message in websocket:
print(f"Received: {message}")
await websocket.send(f"Echo: {message}")
start_server = websockets.serve(handler, "localhost", 8765)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
# Client
import asyncio
import websockets
async def client():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
await websocket.send("Hello!")
response = await websocket.recv()
print(response)
asyncio.get_event_loop().run_until_complete(client())
Use Cases:
- Real-time chat
- Live notifications
- Gaming
- Stock tickers
- Collaborative editing
Alternatives:
- SSE (Server-Sent Events): One-way server push over HTTP
- Long Polling: HTTP workaround for server push
- WebRTC: Peer-to-peer, good for video/voice
Question 10: What is a CDN and How Does It Work? ⭐⭐ [Medium]
CDN (Content Delivery Network) is a distributed network of servers that delivers content to users based on their geographic location.
How CDN Works:
Without CDN: With CDN:
User in India User in India
│ │
│ Request │ Request
▼ ▼
Server in US Edge Server in Mumbai
(200ms latency) (20ms latency)
│ │
│ Response │ Cached Response
│ (Slow) │ (Fast)
▼ ▼
User User
CDN Benefits:
- Reduced Latency: Serve from nearest edge server
- Lower Bandwidth Costs: Origin serves less data
- High Availability: Multiple servers, automatic failover
- DDoS Protection: Absorb and distribute attack traffic
- SSL/TLS Optimization: Terminate SSL at edge
CDN Caching:
First Request:
User → Edge Server → Origin Server
↓
Cache content at edge
Subsequent Requests:
User → Edge Server (cached)
↓
Serve directly (faster)
Cache Invalidation:
- TTL (Time To Live): Auto-expire after set time
- Purge: Manually clear cache
- Versioning: Change filename (style.v1.css → style.v2.css)
Popular CDNs:
- Cloudflare
- AWS CloudFront
- Google Cloud CDN
- Akamai
- Fastly
CDN for Dynamic Content:
- Route optimization (not caching)
- TCP connection reuse
- Keep-alive with origin
- Smart routing (avoid congested paths)
Common Interview Follow-Up Questions
- "What happens when you type google.com in browser?" → DNS → TCP handshake → TLS → HTTP request → Server processing → Response → Rendering
- "Difference between router and switch?" → Router (Layer 3, between networks), Switch (Layer 2, within network)
- "What is NAT?" → Network Address Translation, maps private IPs to public IP
- "How does traceroute work?" → Uses TTL increment, ICMP time exceeded or port unreachable
- "Explain SYN flood attack?" → Attacker sends SYN without completing handshake, exhausting server resources
Companies Asking Networking Questions
| Company | Frequency | Focus Areas |
|---|---|---|
| Amazon | Very High | Load balancing, AWS networking |
| Very High | Protocol design, Performance | |
| Cloudflare | Very High | DNS, CDN, Security |
| Akamai | Very High | CDN, Edge computing |
| Cisco | Very High | Routing, Switching, Protocols |
| Netflix | High | CDN, Video streaming |
| Uber | High | Microservices networking |
Preparation Tips
- Understand Packet Flow: From application to wire and back
- Practice Wireshark: See real protocols in action
- Learn Cloud Networking: VPCs, subnets, security groups
- Know Trade-offs: TCP vs UDP, REST vs gRPC
- Security Focus: HTTPS, TLS, certificates
- Scalability: Load balancing, CDNs, caching
- Troubleshooting: ping, traceroute, netstat, curl
FAQ
Q: What's the difference between a hub, switch, and router?
A: Hub (Layer 1, broadcasts to all), Switch (Layer 2, MAC-based forwarding), Router (Layer 3, IP-based forwarding between networks).
Q: Explain ARP (Address Resolution Protocol).
A: Maps IP addresses to MAC addresses on local network. "Who has IP 192.168.1.1? Tell MAC address."
Q: What is MTU and why does it matter?
A: Maximum Transmission Unit. Largest packet size. If exceeded, fragmentation occurs (performance impact).
Q: Difference between symmetric and asymmetric encryption?
A: Symmetric uses same key for encrypt/decrypt (fast). Asymmetric uses public/private key pair (secure key exchange).
Q: What is a reverse proxy?
A: Sits in front of servers, forwarding client requests. Used for load balancing, SSL termination, caching.
Strong networking knowledge is the foundation of distributed systems! 🌐