PlacementPrep

Networking Basics Questions Placement

27 min read
Topics & Practice
Advertisement 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):

LayerNameFunctionExamples
7ApplicationUser interface, network appsHTTP, FTP, SMTP, DNS
6PresentationData format, encryptionSSL/TLS, JPEG, ASCII
5SessionSession managementNetBIOS, PPTP
4TransportEnd-to-end deliveryTCP, UDP
3NetworkRouting, logical addressingIP, ICMP, OSPF
2Data LinkPhysical addressing, framingEthernet, MAC, PPP
1PhysicalBits on wireCables, Hubs, Signals

TCP/IP Model (4 Layers):

LayerOSI EquivalentProtocols
Application5-7HTTP, FTP, SMTP, DNS
Transport4TCP, UDP
Internet3IP, ICMP, ARP
Network Access1-2Ethernet, Wi-Fi

Mnemonic for OSI: "Please Do Not Throw Sausage Pizza Away"

TCP vs UDP

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityReliable (acknowledgments)Unreliable
OrderOrdered deliveryNo ordering
SpeedSlower (overhead)Fast
Use CaseWeb, Email, File TransferStreaming, Gaming, DNS
Header Size20-60 bytes8 bytes
Flow ControlYesNo
Congestion ControlYesNo

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]

FeatureHTTPHTTPS
SecurityUnencryptedEncrypted with SSL/TLS
Port80443
CertificateNot requiredSSL certificate required
PerformanceFasterSlower (encryption overhead)
URLhttp://https://
SEOLower rankingPreferred 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:

RecordPurposeExample
AIPv4 addressexample.com → 93.184.216.34
AAAAIPv6 addressexample.com → 2606:2800:220:1:248:1893:25c8:1946
CNAMECanonical name (alias)www.example.com → example.com
MXMail exchangeexample.com → mail.example.com
NSName serverexample.com → ns1.example.com
TXTText recordSPF, DKIM verification
SOAStart of authorityZone 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]

FeatureGETPOST
PurposeRetrieve dataSubmit data
VisibilityData in URLData in body
CachingCan be cachedNot cached
BookmarkableYesNo
Length LimitLimited by URL (2048 chars)Unlimited
SecurityNot for sensitive dataSafer for sensitive data
IdempotentYesNo
HistoryStored in browser historyNot 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:

AlgorithmDescriptionUse Case
Round RobinSequential distributionEqual capacity servers
Least ConnectionsTo server with fewest connectionsVariable request duration
Least Response TimeTo fastest responding serverPerformance critical
IP HashBased on client IPSession persistence
WeightedBased on server capacityDifferent 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:

CodeMeaningExample
200OKSuccessful GET, PUT
201CreatedSuccessful POST
204No ContentSuccessful DELETE
400Bad RequestInvalid input
401UnauthorizedMissing auth
403ForbiddenNo permission
404Not FoundResource doesn't exist
500Server ErrorException 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:

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:

FeatureHTTPWebSocket
CommunicationHalf-duplexFull-duplex
ConnectionShort-livedPersistent
OverheadHigh (headers every request)Low (after handshake)
Server PushNot supported (polling needed)Native support
Real-timePolling/WebSocket neededNative
Protocolhttp:// 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:

  1. Reduced Latency: Serve from nearest edge server
  2. Lower Bandwidth Costs: Origin serves less data
  3. High Availability: Multiple servers, automatic failover
  4. DDoS Protection: Absorb and distribute attack traffic
  5. 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

  1. "What happens when you type google.com in browser?" → DNS → TCP handshake → TLS → HTTP request → Server processing → Response → Rendering
  2. "Difference between router and switch?" → Router (Layer 3, between networks), Switch (Layer 2, within network)
  3. "What is NAT?" → Network Address Translation, maps private IPs to public IP
  4. "How does traceroute work?" → Uses TTL increment, ICMP time exceeded or port unreachable
  5. "Explain SYN flood attack?" → Attacker sends SYN without completing handshake, exhausting server resources

Companies Asking Networking Questions

CompanyFrequencyFocus Areas
AmazonVery HighLoad balancing, AWS networking
GoogleVery HighProtocol design, Performance
CloudflareVery HighDNS, CDN, Security
AkamaiVery HighCDN, Edge computing
CiscoVery HighRouting, Switching, Protocols
NetflixHighCDN, Video streaming
UberHighMicroservices networking

Preparation Tips

  1. Understand Packet Flow: From application to wire and back
  2. Practice Wireshark: See real protocols in action
  3. Learn Cloud Networking: VPCs, subnets, security groups
  4. Know Trade-offs: TCP vs UDP, REST vs gRPC
  5. Security Focus: HTTPS, TLS, certificates
  6. Scalability: Load balancing, CDNs, caching
  7. 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! 🌐

Advertisement Placement

Share this article: