TCP/IP Basics Cheat Sheet

Core TCP/IP concepts: OSI model layers, TCP vs UDP comparison, common ports, and IP addressing fundamentals every developer should know.

Last Updated: May 1, 2025

OSI Model Layers

LayerNameProtocol/FunctionPDU
7ApplicationHTTP, DNS, SMTP, FTPData
6PresentationTLS/SSL, ASCII, JPEGData
5SessionNetBIOS, RPC, SocketsData
4TransportTCP, UDPSegment/Datagram
3NetworkIP, ICMP, OSPFPacket
2Data LinkEthernet, ARP, MACFrame
1PhysicalCables, Radio, FiberBits

TCP vs UDP

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryBest-effort (no guarantee)
OrderingIn-order deliveryNo ordering guarantee
OverheadHigher (20-byte header)Lower (8-byte header)
Flow ControlYes (sliding window)None
Use CasesWeb, email, file transferStreaming, VoIP, DNS, gaming
Handshake3-way (SYN, SYN-ACK, ACK)None

Common Ports

ItemDescription
20/21FTP (File Transfer Protocol) — data/control
22SSH (Secure Shell) — encrypted remote access
23Telnet — unencrypted remote access (avoid!)
25SMTP — email sending between servers
53DNS — domain name resolution
80HTTP — unencrypted web traffic
110POP3 — email retrieval
143IMAP — email retrieval with server-side folders
443HTTPS — encrypted web traffic (TLS)
3306MySQL/MariaDB database default port
5432PostgreSQL database default port
6379Redis in-memory data store
27017MongoDB database default port

IP Addressing Basics

ItemDescription
IPv432-bit address (4 octets), e.g., 192.168.1.1
Subnet MaskDefines network vs host portion, e.g., 255.255.255.0
CIDRClassless Inter-Domain Routing, e.g., 192.168.1.0/24
Private IPv410.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
Loopback127.0.0.1 (localhost) — always points to self
APIPA169.254.0.0/16 — auto-assigned when DHCP fails
Default GatewayRouter that connects local network to other networks
Broadcast255.255.255.255 — sends to all hosts on LAN
Pro Tip: Remember the OSI mnemonic: 'Please Do Not Throw Sausage Pizza Away' — Physical, Data Link, Network, Transport, Session, Presentation, Application.