OSI vs TCP/IP Model
TCP/IP is the model actually used on the internet — it collapses OSI's 7 layers into 4:
Key Concepts Per Layer
Encapsulation Flow
When you send data, each layer wraps it with a header (encapsulation). On arrival, each layer unwraps it (de-encapsulation).
[ L4 SEGMENT | DATA ]
[ L3 PACKET | SEG | DATA ]
[ L2 FRAME | PKT | SEG | DATA ]
[ L1: 010101 raw bits on wire ]
Methods: GET POST PUT DELETE PATCH
Status: 200 OK / 404 Not Found / 500 Error
Record types: A, AAAA, CNAME, MX, TXT
Uses UDP (fast) or TCP (large responses)
Assigns: IP, subnet mask, gateway, DNS
Lease time: addresses are temporary
Uses: server admin, git, tunneling
ssh user@192.168.1.10
IMAP: syncs mailbox (server-side)
POP3: downloads and deletes (local)
SFTP: runs over SSH, fully encrypted
Active vs Passive mode for firewalls
Flow control: receiver controls send rate
Used by: HTTP, SSH, FTP, SMTP
Used by: DNS, VoIP, video streaming, gaming
Lower latency — critical for real-time apps
Certificate: proves server identity (CA-signed)
Provides: confidentiality + integrity + auth
IPv6: 128-bit address (virtually unlimited)
Connectionless: no state, no guarantee
traceroute: maps hops to destination
Errors: "Destination Unreachable", "TTL Exceeded"
OSPF: Open Shortest Path First (intra-network)
RIP: older, hop-count based routing
Frame: [Dest MAC | Src MAC | Type | Data | FCS]
Standards: 802.3 (wired)
802.11ax (Wi-Fi 6): up to 9.6Gbps, better density
Bands: 2.4GHz (range) vs 5GHz (speed)
Responds: "I do — MAC: AA:BB:CC:DD:EE:FF"
Stored in ARP cache (arp -a to view)
IPv4
IPv6
CIDR (Classless Inter-Domain Routing) notation expresses a network as an IP address followed by a prefix length (e.g., /24). This defines how many bits belong to the network vs. the hosts.
How Subnet Masks Work
MASK: 255.255.255.0 = 11111111.11111111.11111111.00000000
──────────────────────────────────────────────────
NET: 192.168.1 = Network portion (fixed)
HOST: 0–255 = Host portion (variable)
| CIDR | SUBNET MASK | HOSTS | USE CASE |
|---|---|---|---|
| /8 | 255.0.0.0 | 16M | Large ISP / enterprise |
| /16 | 255.255.0.0 | 65,534 | Large org network |
| /24 | 255.255.255.0 | 254 | Standard office LAN |
| /25 | 255.255.255.128 | 126 | Half a /24 |
| /26 | 255.255.255.192 | 62 | Small dept network |
| /28 | 255.255.255.240 | 14 | Small server segment |
| /30 | 255.255.255.252 | 2 | Point-to-point links |
| /32 | 255.255.255.255 | 1 | Single host route |
NAT (Network Address Translation)
VLSM (Variable Length)
VLAN (Virtual LAN)
TCP vs UDP: When to Use Which
Common Port Numbers
A DMZ (Demilitarized Zone) is a network segment that sits between the internet and the internal network. Public-facing services (web servers, email) live here so that a compromise doesn't directly expose internal systems.
// Traffic flows left→right. Return traffic is allowed by stateful firewall rules. Internal systems never directly exposed to internet.