Skip to content

TCP/IP Deep Dive


TCP/IP Model Overview

TCP/IP Protocol Stack


TCP Header Structure

TCP Header Structure


TCP Connection States

TCP Connection State Machine


TCP Flow Control

TCP Sliding Window Protocol


TCP Congestion Control

TCP Congestion Control


TCP Congestion Control Algorithms

Modern Congestion Control Algorithms


IP Addressing

IPv4 Addressing


NAT (Network Address Translation)

Network Address Translation

NAT Types

  • SNAT: Source NAT (outbound, changes source IP)
  • DNAT: Destination NAT (inbound, port forwarding)
  • PAT: Port Address Translation (many-to-one)

NAT Traversal Techniques

  • STUN: Session Traversal Utilities for NAT
  • TURN: Traversal Using Relays around NAT
  • ICE: Interactive Connectivity Establishment

Socket Programming

Socket Lifecycle


Socket Options

Important Socket Options


Common TCP Issues

Common TCP Problems


TCP Tuning Parameters

Linux TCP Tuning Parameters


UDP Characteristics

UDP Characteristics


Interview Questions

  1. Explain TCP three-way handshake
  2. SYN → SYN-ACK → ACK
  3. Establishes sequence numbers both directions
  4. Takes 1.5 RTT

  5. Why does TIME_WAIT exist?

  6. Ensures delayed packets don't corrupt new connections
  7. Allows final ACK to be retransmitted if lost
  8. Duration: 2 × MSL (Maximum Segment Lifetime)

  9. How does TCP handle packet loss?

  10. Timeout-based retransmission
  11. Fast retransmit (3 duplicate ACKs)
  12. Selective acknowledgments (SACK)

  13. What is TCP slow start?

  14. Initial congestion window = 1 MSS
  15. Doubles every RTT until ssthresh or loss
  16. Avoids flooding network initially

  17. TCP vs UDP: When to use each?

  18. TCP: Reliability needed (HTTP, databases)
  19. UDP: Low latency, loss tolerant (gaming, video)

  • *