Key Takeaways
- TCP/IP is the foundational protocol suite of the Internet.
- Understanding layers helps troubleshoot problems systematically.
- IP addressing and subnetting are essential skills.
- TCP provides reliable, ordered delivery; UDP is faster but unreliable.
- Ports identify applications on a host.
- Command-line tools are essential for network troubleshooting.
Table of Contents
1. Introduction to TCP/IP
TCP/IP (Transmission Control Protocol/Internet Protocol) is the suite of communication protocols that power the Internet. It defines how data is packaged, addressed, transmitted, and received. Understanding TCP/IP is fundamental for network administrators, security professionals, and developers alike.
The model is often compared to the theoretical OSI model, but TCP/IP is the practical implementation used globally.
2. Network Layers
2.1 TCP/IP vs OSI Model
| OSI Layer | TCP/IP Layer | Protocols/Examples |
|---|---|---|
| 7. Application | Application | HTTP, HTTPS, FTP, SMTP, DNS |
| 6. Presentation | SSL/TLS, JPEG, ASCII | |
| 5. Session | NetBIOS, RPC | |
| 4. Transport | Transport | TCP, UDP |
| 3. Network | Internet | IP, ICMP, ARP |
| 2. Data Link | Network Access | Ethernet, WiFi (MAC addresses) |
| 1. Physical | Cables, radio waves |
Encapsulation
Data is wrapped in headers as it passes down layers. Application data → TCP segment → IP packet → Ethernet frame. Each layer adds its own header with relevant addressing and control information.
3. IP Addressing & Subnetting
3.1 IPv4 Addresses
# IPv4 address structure
192.168.1.100 = 32 bits (4 octets)
# Private IP ranges (RFC 1918)
10.0.0.0 - 10.255.255.255 (/8)
172.16.0.0 - 172.31.255.255 (/12)
192.168.0.0 - 192.168.255.255 (/16)
# Special addresses
127.0.0.1 = Localhost (loopback)
0.0.0.0 = All interfaces / default route
255.255.255.255 = Broadcast
3.2 Subnetting
# Subnet mask and CIDR notation
255.255.255.0 = /24 = 256 addresses (254 usable)
255.255.255.128 = /25 = 128 addresses (126 usable)
255.255.255.192 = /26 = 64 addresses (62 usable)
# Example: 192.168.1.0/24
Network: 192.168.1.0
First host: 192.168.1.1
Last host: 192.168.1.254
Broadcast: 192.168.1.255
3.3 IPv6
# IPv6 address structure
2001:0db8:85a3:0000:0000:8a2e:0370:7334 = 128 bits
# Shortened form
2001:db8:85a3::8a2e:370:7334
# Special addresses
::1 = Localhost
fe80::/10 = Link-local addresses
4. TCP vs UDP
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented (3-way handshake) | Connectionless |
| Reliability | Guaranteed delivery, retransmission | No guarantee |
| Ordering | Ordered delivery | No ordering |
| Speed | Slower (overhead) | Faster |
| Use Cases | HTTP, HTTPS, SSH, FTP | DNS, VoIP, gaming, streaming |
4.1 TCP 3-Way Handshake
# TCP connection establishment
Client → Server: SYN (seq=x)
Server → Client: SYN-ACK (seq=y, ack=x+1)
Client → Server: ACK (ack=y+1)
# Connection closed with FIN handshake
5. Ports & Protocols
5.1 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 |
| 3389 | TCP | RDP |
6. Routing Fundamentals
# View routing table (Windows)
route print
netstat -rn
# View routing table (Linux)
ip route
route -n
# Default route example
0.0.0.0/0 via 192.168.1.1 (gateway)
NAT (Network Address Translation)
NAT allows multiple devices on a private network to share a single public IP. The router translates private IPs to the public IP for outbound traffic and reverses for responses. This is why your home devices have 192.168.x.x addresses but appear as one IP on the internet.
7. Troubleshooting
7.1 Essential Commands
# Test connectivity
ping hostname/IP
# Trace route
tracert hostname (Windows)
traceroute hostname (Linux)
# DNS lookup
nslookup hostname
dig hostname
# Show connections and listening ports
netstat -an
ss -tuln (Linux)
# Show network configuration
ipconfig /all (Windows)
ip addr show (Linux)
7.2 Troubleshooting Methodology
- Check physical connectivity
- Verify IP configuration (correct IP, subnet, gateway)
- Ping localhost (127.0.0.1) - test TCP/IP stack
- Ping gateway - test local connectivity
- Ping external IP - test routing
- Ping hostname - test DNS
Wireshark
For deep packet analysis, Wireshark is essential. Capture traffic to see exactly what's happening on the wire—protocol issues, malformed packets, connection problems, and security issues become visible.
8. Frequently Asked Questions
Conclusion
TCP/IP knowledge is foundational for IT and security professionals. Understanding how data flows through layers, how addressing works, and how to troubleshoot systematically are skills that apply across networking, system administration, and security. Master these fundamentals and you'll have a solid base for advanced networking and security topics.
Continue Learning:
DNS Guide
Network Monitoring