HxHippy

TCP/IP Fundamentals

Understanding the TCP/IP protocol stack, layers, and how data flows across networks.

Last updated: 2025-01-15

TCP/IP Protocol Suite

The TCP/IP model is the foundation of modern networking, defining how data is transmitted across networks.

The Four Layers

Application Layer

  • HTTP, HTTPS, FTP, SSH, DNS, SMTP
  • User-facing protocols
  • Data formatting and presentation

Transport Layer

  • TCP - Reliable, connection-oriented
  • UDP - Fast, connectionless
  • Port numbers and segmentation

Internet Layer

  • IP - Addressing and routing
  • ICMP - Error reporting and diagnostics
  • Packet fragmentation

Network Access Layer

  • Ethernet, Wi-Fi
  • MAC addressing
  • Physical transmission

TCP vs UDP

Feature TCP UDP
Connection Connection-oriented Connectionless
Reliability Guaranteed delivery Best effort
Ordering In-order delivery No ordering
Speed Slower Faster
Use Cases HTTP, SSH, FTP DNS, Streaming, Gaming

TCP Three-Way Handshake

Client              Server
  |                   |
  |------- SYN ------>|
  |                   |
  |<--- SYN + ACK ----|
  |                   |
  |------- ACK ------>|
  |                   |
  |   Connection      |
  |   Established     |

IP Addressing

IPv4 Structure

  • 32-bit address
  • Dotted decimal notation (192.168.1.1)
  • Network and host portions

IPv6 Structure

  • 128-bit address
  • Hexadecimal notation (2001:db8::1)
  • Built-in security features

Common Ports

Port    Protocol    Service
20-21   TCP         FTP
22      TCP         SSH
23      TCP         Telnet
25      TCP         SMTP
53      TCP/UDP     DNS
80      TCP         HTTP
443     TCP         HTTPS
3306    TCP         MySQL
5432    TCP         PostgreSQL
6379    TCP         Redis

Packet Flow Example

# Trace packet path
traceroute google.com

# Capture packets
tcpdump -i eth0 -n port 80

# Analyze with tshark
tshark -i eth0 -f "tcp port 443"

Best Practices

  1. Understand layers - Know which protocol operates where
  2. Use TCP for reliability - When data integrity matters
  3. Use UDP for speed - Real-time applications
  4. Monitor traffic - Regular packet analysis
  5. Secure ports - Close unnecessary services
beginner Fundamentals Updated 2025-01-15
  • tcp
  • ip
  • networking
  • osi model
  • protocol
  • packets
  • layers