TCP and UDP Protocols
Overview
Section titled âOverviewâTCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are the two primary transport layer protocols used in network communication. They operate at Layer 4 of the OSI model and determine how data is transmitted between devices.
TCP (Transmission Control Protocol)
Section titled âTCP (Transmission Control Protocol)âTCP is a connection-oriented protocol that ensures reliable, ordered delivery of data. It establishes a connection before transmitting data and verifies that all packets arrive successfully.
TCP Characteristics
Section titled âTCP Characteristicsâ- Connection-oriented: Establishes connection via three-way handshake
- Reliable delivery: Guaranteed data delivery with error checking
- Ordered delivery: Packets arrive in the order sent
- Flow control: Manages data transmission rate
- Slower: Higher overhead due to reliability features
- Acknowledgment: Receiver acknowledges receipt of data
Common TCP Ports
Section titled âCommon TCP Portsâ| Port | Service | Description |
|---|---|---|
| 20 | FTP-DATA | File Transfer Protocol (data) |
| 21 | FTP | File Transfer Protocol (control) |
| 22 | SSH | Secure Shell |
| 23 | Telnet | Remote login (unencrypted) |
| 25 | SMTP | Simple Mail Transfer Protocol |
| 53 | DNS | Domain Name System |
| 80 | HTTP | HyperText Transfer Protocol |
| 110 | POP3 | Post Office Protocol 3 |
| 143 | IMAP | Internet Message Access Protocol |
| 443 | HTTPS | HTTP Secure (SSL/TLS) |
| 445 | SMB | Server Message Block |
| 3306 | MySQL | MySQL Database |
| 3389 | RDP | Remote Desktop Protocol |
| 5432 | PostgreSQL | PostgreSQL Database |
| 8080 | HTTP-ALT | HTTP Alternative |
UDP (User Datagram Protocol)
Section titled âUDP (User Datagram Protocol)âUDP is a connectionless protocol that provides fast, unreliable delivery of data. It does not establish a connection or verify delivery, making it suitable for applications where speed is prioritized over accuracy.
UDP Characteristics
Section titled âUDP Characteristicsâ- Connectionless: No connection establishment required
- Unreliable delivery: No guarantee packets arrive
- Unordered delivery: Packets may arrive out of sequence
- No flow control: Sends data at applicationâs pace
- Faster: Lower overhead due to minimal features
- No acknowledgment: Receiver does not confirm receipt
Common UDP Ports
Section titled âCommon UDP Portsâ| Port | Service | Description |
|---|---|---|
| 53 | DNS | Domain Name System queries |
| 67 | DHCP | Dynamic Host Configuration Protocol (server) |
| 68 | DHCP | Dynamic Host Configuration Protocol (client) |
| 123 | NTP | Network Time Protocol |
| 161 | SNMP | Simple Network Management Protocol |
| 162 | SNMP-TRAP | SNMP Traps |
| 389 | LDAP | Lightweight Directory Access Protocol |
| 500 | ISAKMP | Internet Key Exchange (IPSec) |
| 514 | Syslog | System Logging Protocol |
| 1900 | SSDP | Simple Service Discovery Protocol |
| 5353 | mDNS | Multicast DNS |
| 5355 | LLMNR | Link-Local Multicast Name Resolution |
Comparison Table
Section titled âComparison Tableâ| Feature | TCP | UDP |
|---|---|---|
| Connection Type | Connection-oriented | Connectionless |
| Reliability | Reliable | Unreliable |
| Ordering | Ordered | Unordered |
| Speed | Slower | Faster |
| Error Checking | Yes | Yes (checksum only) |
| Flow Control | Yes | No |
| Use Cases | Email, Web, FTP, SSH | DNS, VoIP, Gaming, Streaming |
| Header Size | 20-60 bytes | 8 bytes |
When to Use TCP vs UDP
Section titled âWhen to Use TCP vs UDPâUse TCP when:
- Data integrity is critical
- You need ordered delivery
- Connection management is important
- Examples: Email, file transfers, web browsing
Use UDP when:
- Speed is more important than reliability
- Real-time communication is needed
- Loss of some packets is acceptable
- Examples: Video streaming, online gaming, VoIP