Skip to main content
junior
beginner
Networking

TCP/IP Fundamentals

Question

Explain the difference between TCP and UDP. When would you use each?

Answer

TCP (Transmission Control Protocol) is connection-oriented, ensuring reliable, ordered delivery with error checking and retransmission. UDP (User Datagram Protocol) is connectionless, offering faster but unreliable delivery without guarantees. Use TCP for web traffic (HTTP), file transfers, and email. Use UDP for streaming, gaming, DNS queries, and real-time applications where speed matters more than reliability.

Why This Matters

Understanding TCP vs UDP is fundamental for troubleshooting network issues, configuring firewalls, and designing distributed systems. DevOps engineers must know which protocol applications use to properly monitor, secure, and optimize network traffic.

Code Examples

Check open TCP/UDP ports

bash
Common Mistakes
  • Assuming all network traffic uses TCP
  • Blocking UDP on firewalls without understanding impact on DNS and NTP
  • Not considering TCP overhead for high-throughput applications
Follow-up Questions
Interviewers often ask these as follow-up questions
  • What is the TCP three-way handshake?
  • Why does DNS use UDP by default but can fall back to TCP?
  • What are the common TCP states and what do they mean?
Tags
networking
tcp
udp
protocols
fundamentals