Networking Crash Course#

Table of Contents#

  1. 1. How the Internet Works: Packets & Routers
  2. 2. OSI vs TCP/IP Layer Models
  3. 3. MAC Addresses, Ethernet & ARP
  4. 4. IPv4, IPv6, CIDR & NAT
  5. 5. Transport Layer: TCP vs UDP
  6. 6. TCP 3-Way Handshake & Teardown
  7. 7. DNS: Domain Name System
  8. 8. HTTP Evolution: HTTP/1.1, HTTP/2 & HTTP/3
  9. 9. TLS 1.3 Handshake & HTTPS
  10. 10. Load Balancing: Layer 4 vs Layer 7
  11. 11. AWS Cloud Networking: VPC, Security Groups & NACLs
  12. 12. Essential Network Diagnostics CLI
  13. 13. Networking Quick Reference

1. How the Internet Works: Packets & Routers#

The modern Internet is a packet-switched network. When you stream a 4K video or load a web page, data is sliced into discrete chunks called packets (typically ~1500 bytes each, bounded by the MTU — Maximum Transmission Unit).

Each packet contains:

Packet Switching vs Circuit Switching: Traditional telephone calls used dedicated physical circuits (if a line went quiet, bandwidth was wasted). Packet switching allows billions of devices to share the exact same optical fiber and copper wires by interleaving packets dynamically.

2. OSI vs TCP/IP Layer Models#

Network communication is organized into modular abstraction layers. While the OSI 7-layer model is the theoretical reference standard, the practical Internet runs on the TCP/IP 4-layer stack:

  1. Application Layer (OSI 7, 6, 5): User-facing protocols (HTTP, DNS, SSH, WebSockets, SMTP). Data unit: Message / Stream.
  2. Transport Layer (OSI 4): End-to-end process-to-process communication, port numbers, reliability, and flow control (TCP, UDP, QUIC). Data unit: Segment (TCP) / Datagram (UDP).
  3. Network Layer (OSI 3): Host-to-host logical routing across multiple interconnected networks (IPv4, IPv6, ICMP, BGP). Data unit: Packet.
  4. Link / Physical Layer (OSI 2, 1): Hop-to-hop physical delivery between directly connected hardware on the same local subnet (Ethernet, Wi-Fi, MAC addresses, fiber optics). Data unit: Frame / Bits.

3. MAC Addresses, Ethernet & ARP#

Within a Local Area Network (LAN), devices communicate using their globally unique 48-bit MAC (Media Access Control) Address (e.g. 52:54:00:12:34:56) burned into the Network Interface Card (NIC).

4. IPv4, IPv6, CIDR & NAT#

IP addresses route packets across heterogeneous networks globally:

5. Transport Layer: TCP vs UDP#

Operating systems provide two fundamental transport protocols over IP:

  1. TCP (Transmission Control Protocol):
    • Connection-oriented: Requires a 3-way handshake before data transfer.
    • Reliable & Ordered: Every byte is acknowledged; lost packets are retransmitted; packets arriving out-of-order are reassembled seamlessly.
    • Congestion & Flow Control: Automatically throttles sending rate to avoid saturating network buffers.
    • Used by: HTTP/1.1, HTTP/2, SSH, PostgreSQL, Redis, SMTP.
  2. UDP (User Datagram Protocol):
    • Connectionless: Sends packets ("fire and forget") with zero setup delay.
    • Unreliable & Unordered: No acknowledgments, no retransmissions, no packet reordering.
    • Used by: DNS queries, live video streaming, multiplayer games, VoIP, and modern HTTP/3 (via QUIC).

6. TCP 3-Way Handshake & Teardown#

Before any data can flow over a TCP connection, client and server synchronize sequence numbers:

Client                                          Server
  |                                               |
  | -------- SYN (seq = X) -------------------->  |  1. Client requests connection
  |                                               |
  | <------- SYN-ACK (seq = Y, ack = X + 1) ----  |  2. Server acknowledges and responds
  |                                               |
  | -------- ACK (seq = X + 1, ack = Y + 1) ----> |  3. Connection ESTABLISHED
  |                                               |
  | ================= Data Transfer ============= |
  |                                               |
  | -------- FIN (I'm done sending) ------------> |  4. Graceful Teardown
  | <------- ACK -------------------------------- |
  | <------- FIN -------------------------------- |
  | -------- ACK -------------------------------> |  (Client enters TIME_WAIT)

7. DNS: Domain Name System#

DNS is the decentralized phonebook of the Internet, translating human-friendly names (techtoday.click) into machine-routable IP addresses (44.193.134.238):

  1. Browser / OS Cache: Checks local memory and /etc/hosts.
  2. Recursive Resolver (e.g. 8.8.8.8, 1.1.1.1): If not cached, the resolver queries the root name servers (.).
  3. Root Server: Directs query to the .click Top-Level Domain (TLD) server.
  4. TLD Server: Directs query to the Authoritative Name Server hosting records for techtoday.click.
  5. Authoritative Server: Returns the final A record (IPv4) or AAAA record (IPv6).

8. HTTP Evolution: HTTP/1.1, HTTP/2 & HTTP/3#

9. TLS 1.3 Handshake & HTTPS#

HTTPS secures plain HTTP traffic using Transport Layer Security (TLS 1.3):

  1. Confidentiality: Symmetric AES-256-GCM / ChaCha20 encryption ensures eavesdroppers only see scrambled ciphertext.
  2. Integrity: Cryptographic hashes prevent data tampering in flight.
  3. Authentication: X.509 certificates signed by trusted Certificate Authorities (CAs) prove the server owns the domain name.
  4. 1-RTT Handshake: TLS 1.3 negotiates symmetric session keys using Elliptic Curve Diffie-Hellman (ECDHE) in just a single round-trip before application data flows.

10. Load Balancing: Layer 4 vs Layer 7#

  1. Layer 4 Load Balancers (Transport Layer • AWS NLB, HAProxy TCP mode, IPVS):
    • Operates at the transport layer (IP and Port only, 4-tuple: source IP, source port, dest IP, dest port).
    • Does not decrypt TLS or parse HTTP headers; passes raw TCP/UDP streams through.
    • Delivers millions of packets per second with ultra-low latency and minimal memory/CPU overhead.
  2. Layer 7 Load Balancers (Application Layer • AWS ALB, Nginx, Envoy, Traefik):
    • Operates at the application layer (terminates TLS, parses HTTP headers, cookies, URL paths).
    • Can route /api/* to Service A and /static/* to S3/CDN.
    • Supports intelligent retry policies, gRPC stream routing, sticky sessions, and rate-limiting.

Mental Model: Layer 4 vs Layer 7

  • Layer 4 Analogy: A mail dispatcher who reads only the postal code and building number on the outside envelope, forwarding letters instantly without opening them.
  • Layer 7 Analogy: An executive assistant who opens the letter, reads the actual text, and routes the invoice to billing, the contract to legal, and the feedback to product.

11. AWS Cloud Networking: VPC, Security Groups & NACLs#

Cloud networking in AWS provides a virtualized software-defined network that isolates resources, controls traffic flow, and secures communication boundaries:

1. VPC & Subnets: The Foundation

2. Security Groups (Instance-Level Firewall • Stateful)

A Security Group acts as a virtual firewall controlling traffic directly at the Elastic Network Interface (ENI) level of an EC2 instance or container:

3. Network ACLs (Subnet-Level Firewall • Stateless)

A Network Access Control List (NACL) acts as an outer perimeter firewall controlling traffic entering and exiting an entire subnet:

Mental Model: Security Groups vs Network ACLs

  • Analogy: The NACL is the security guard stationed at the building entrance checking the visitor log (subnet perimeter). The Security Group is the deadbolt lock on your personal apartment door (instance level).
  • Order of Traffic Flow: Inbound: Internet → Route Table → NACL (Subnet) → Security Group (Instance) → Application.
  • State: Security Groups track connection state automatically (stateful); NACLs evaluate every packet from scratch in both directions (stateless).

4. Secure Access: AWS VPN & Bastion Hosts

How developers and operators securely connect into private subnets without exposing servers to the public Internet:

12. Essential Network Diagnostics CLI#

# Test end-to-end connectivity and latency
ping -c 4 8.8.8.8

# Inspect DNS resolution flow and records
dig techtoday.click +trace
nslookup google.com

# Trace intermediate router hops
traceroute 1.1.1.1

# Inspect active TCP sockets and listening server ports
ss -tulpn
netstat -tuln

# Inspect HTTP requests, response headers, and timings
curl -Iv https://techtoday.click

# Capture live network packets on eth0 interface
sudo tcpdump -i eth0 -n port 80 or port 443

13. Networking Quick Reference#

Key Mental Models & Standard Ports

  • Port 22: SSH (Secure Shell)
  • Port 53: DNS (Domain Name System, UDP/TCP)
  • Port 80: HTTP (Unencrypted Web)
  • Port 443: HTTPS / QUIC (Encrypted Web, TCP/UDP)
  • Port 5432: PostgreSQL
  • Port 6379: Redis
  • Security Group vs NACL: SGs are stateful instance firewalls (allow-only); NACLs are stateless subnet perimeters (allow + deny, requires ephemeral return ports 1024–65535).
  • MTU: Maximum Transmission Unit (default 1500 bytes on Ethernet).
  • TTL: Time-to-Live counter decremented by each router hop to prevent infinite loops.

Next Steps: Advance to enterprise routing, BGP, TCP congestion algorithms, and kernel sysctl tuning in the Networking Detailed Course. Return to the TechToday Homepage.