UDP & TCP
Master the fundamental transport layer protocols that power internet communication
Protocol Performance Calculator
Performance Metrics
Protocol Features
Resource Usage
Transport Layer Protocols
TCP and UDP are the fundamental transport layer protocols that enable communication between applications across networks. Understanding their trade-offs is crucial for designing performant distributed systems.
TCP (Transmission Control Protocol)
Reliable, connection-oriented protocol with guaranteed delivery, ordering, and flow control. Higher overhead but ensures data integrity.
UDP (User Datagram Protocol)
Fast, connectionless protocol with minimal overhead. No delivery guarantees but excellent for real-time applications.
TCP: Reliable Communication
Connection Management
Three-Way Handshake
Connection Termination
Flow Control & Congestion Control
Sliding Window
Controls how much data can be sent before receiving acknowledgment.
Congestion Algorithms
TCP Header Structure
UDP: Fast Communication
Connectionless Design
UDP sends data without establishing a connection, making it much faster but less reliable than TCP.
- Low latency (no handshake)
- Minimal protocol overhead
- No connection state
- Multicast/broadcast support
UDP Header Structure
Use Cases for UDP
Gaming
Low latency position updates, some packet loss acceptable
Video Streaming
Real-time media where speed > perfect quality
DNS Queries
Simple request-response, fast lookups
TCP vs UDP Comparison
Feature | TCP | UDP |
---|---|---|
Connection | Connection-oriented | Connectionless |
Reliability | Guaranteed delivery | Best effort |
Ordering | Ordered | No guarantee |
Error Detection | Yes + Correction | Basic checksum |
Flow Control | Yes | No |
Congestion Control | Yes | No |
Header Size | 20-60 bytes | 8 bytes |
Speed | Slower | Faster |
Broadcasting | No | Yes |
Use Cases | Web, Email, File Transfer | Gaming, Video, DNS, IoT |
Real-World Protocol Usage
TCP Applications
HTTP/HTTPS
Web browsing requires reliable delivery of complete pages
Database Connections
SQL queries must be delivered completely and in order
File Transfers
FTP, SFTP ensure every byte is transferred correctly
Email (SMTP)
Message delivery must be guaranteed and complete
UDP Applications
Online Gaming
Player positions updated 60+ times per second
Live Video Streaming
Netflix, YouTube Live prefer current frames over old ones
Voice over IP (VoIP)
Real-time audio where slight drops are acceptable
IoT Sensors
Temperature readings sent frequently, occasional loss OK