TCP/IP
TCP/IP model and protocols
TCP/IP
TCP/IP is the fundamental protocol suite that powers the modern internet.
What is TCP/IP?
TCP/IP is a four-layer model:
Application Layer: HTTP, HTTPS, FTP, SSH, DNS, SMTP
Transport Layer: TCP, UDP
Internet Layer: IP (IPv4, IPv6), ICMP
Link Layer: Ethernet, WiFiIP (Internet Protocol)
Handles routing and addressing
IPv4
- 32-bit addresses
- Format: 192.168.1.1
- Approximately 4.3 billion addresses
- Most common today
IPv6
- 128-bit addresses
- Format: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
- Virtually unlimited addresses
- Future standard
TCP (Transmission Control Protocol)
Reliable, connection-oriented transmission
Connection Establishment (Three-Way Handshake)
1. Client sends SYN
2. Server responds with SYN-ACK
3. Client sends ACK
→ Connection establishedCharacteristics
- Reliable delivery
- In-order delivery
- Flow control
- Error checking
- Connection-oriented
When to Use TCP
- Email (SMTP, POP3)
- Web (HTTP, HTTPS)
- File transfer (FTP, SFTP)
- Remote access (SSH, Telnet)
- Database connections
UDP (User Datagram Protocol)
Fast, connectionless transmission
Characteristics
- No guarantee of delivery
- May arrive out of order
- Low overhead
- Fast transmission
- Connectionless
When to Use UDP
- Video streaming
- Audio streaming
- Online gaming
- DNS queries
- DHCP
- Real-time applications
TCP vs UDP
TCP: UDP:
Reliable Unreliable
Ordered Unordered
Slower Faster
Connectionful Connectionless
Error checking Minimal checkingICMP (Internet Control Message Protocol)
Used for diagnostics and error reporting
Common Uses
# Ping (ICMP Echo)
ping example.com
# Traceroute (ICMP Time Exceeded)
traceroute example.com
# Check connectivity
ping -c 4 8.8.8.8Network Tools
# View network configuration
ifconfig
ip addr
# Check connectivity
ping 8.8.8.8
nslookup example.com
# View routing table
route -n
ip route
# View active connections
ss -tuln
netstat -tuln
# Trace route to destination
traceroute example.com
mtr example.com
# Monitor network traffic
tcpdump
wiresharkBest Practices
- Use TCP for data integrity
- Use UDP for speed where loss acceptable
- Monitor network performance
- Understand your protocol needs
- Test connectivity regularly
- Keep router/firewall updated
- Monitor bandwidth usage