Computer Networks: TCP/IP Stack, 3-Way Handshake & Congestion Control
Networking is a cornerstone topic for NIC Scientific/Technical roles and PSU telecom interviews. Learn packet flows, congestion algorithms, and socket states.
In-Depth Interview Questions & Model Solutions
Q1Describe the complete step-by-step TCP 3-Way Handshake and 4-Way Connection Teardown.
Handshake: (1) Client sends `SYN` (seq=x), state becomes `SYN_SENT`. (2) Server replies with `SYN-ACK` (seq=y, ack=x+1), state becomes `SYN_RCVD`. (3) Client responds with `ACK` (ack=y+1), state becomes `ESTABLISHED`. Server enters `ESTABLISHED` upon receiving ACK. Teardown: (1) Client sends `FIN`, enters `FIN_WAIT_1`. (2) Server sends `ACK`, enters `CLOSE_WAIT`; Client enters `FIN_WAIT_2`. (3) Server sends `FIN`, enters `LAST_ACK`. (4) Client sends `ACK`, enters `TIME_WAIT` (waits 2*MSL to ensure late packets are cleared), then closes.
- SYN and FIN consume 1 sequence number each; standalone ACKs consume 0.
- TIME_WAIT prevents old duplicate packets from interfering with new socket sessions.
- TCP SYN cookies mitigate SYN flood DoS attacks.
Q2How do TCP Tahoe and TCP Reno handle Congestion Avoidance and Fast Recovery?
Both begin with Slow Start (exponential window growth: `cwnd` doubles each RTT until `ssthresh`). Upon reaching `ssthresh`, Congestion Avoidance activates (`cwnd` increases by 1 MSS per RTT - Additive Increase). On receiving 3 Duplicate ACKs (indicating packet loss): TCP Tahoe resets `cwnd=1` and enters Slow Start. TCP Reno implements Fast Retransmit & Fast Recovery: it halves `cwnd` (`cwnd = ssthresh = cwnd/2`) and continues linear increase without dropping back to 1 MSS.
- Slow Start: Exponential growth until ssthresh.
- Congestion Avoidance: AIMD (Additive Increase Multiplicative Decrease).
- Fast Retransmit triggered by 3 Duplicate ACKs.
Technical Panel Interview Strategy Tips
- Practice calculating subnet masks (VLSM / CIDR notations like /27, /29) mentally for screening tests.
- Understand the role of ARP, ICMP, and BGP routing protocols.