Python · SQL · Web Dev · Java · AI/ML tracks launching soon — your one platform for all of IT

What is a Network?

A beginner-to-PhD journey through computer networks — from why they exist, to how a single click on your phone becomes electrons crossing five continents and back in 300 milliseconds.

45 min May 2026

Chapter 01

You Already Use Networks — Millions of Times a Day

Before we define anything, let's look at what you've already done today.

Real-World Scenario

You woke up this morning and checked Instagram. Your phone sent a request to a server in California, which looked up your account in a database, pulled 20 photos from a storage cluster, compressed them, and sent them back — all in under 2 seconds. Then you opened Google Maps. Your phone asked a GPS satellite for coordinates, sent them to Google's servers in Iowa, which computed your route using live traffic data collected from 2 million other phones at that exact moment, and returned turn-by-turn directions. Then you streamed a YouTube video. 4K video means roughly 25 megabytes per second of data — continuous, uninterrupted, from a data center that might be 10,000 km away.

None of this feels magical anymore. But every single action above required a computer network — a system that lets machines talk to each other across any distance, reliably, at speed. Understanding how networks work means understanding the invisible infrastructure that modern life runs on. Every app you build, every job in tech, every system you design touches networks.

This guide starts at zero. No background required. By the end, you will understand not just what networks are, but why they work the way they do — and what would break if they worked differently.

🌍 The internet in numbers (2025)

  • 5.5 billion internet users — 68% of humanity
  • ~500 billion GB of data transferred every day
  • 600+ undersea fiber optic cables carrying 99% of international internet traffic
  • 4.6 billion websites, ~200 million actively maintained
  • ~1.5 million data centers worldwide, with hyperscale facilities consuming more power than small countries

Chapter 02

What is a Network, Really?

The simplest definition, and why it's not enough.

A computer network is two or more devices connected in a way that allows them to exchange information. That is it. Your phone and laptop connected via Bluetooth — that is a network. Two computers in an office with a cable between them — that is a network. The entire global internet — that is also a network, just one with billions of devices.

The interesting question is not "what is a network" — it is why do we connect devices at all? The answer is resource sharing. Before networks, every computer was an island. Want to print a document? You needed a printer connected directly to your machine. Want to share a file with a colleague? You physically handed them a floppy disk (called "sneakernet" — because you walked the data over on your sneakers). Networks eliminated the island problem.

Three Things Every Network Does

Every network in existence — from your home WiFi to the global internet — does exactly three things:

🔗
1. Connect
Establishes a path between devices — physical cables, WiFi radio waves, fiber optic light pulses, or satellite signals.
📦
2. Transfer
Moves data from one device to another. But not as a single stream — as small packets that can be routed independently.
📋
3. Follow Rules
Uses agreed-upon protocols so that a Samsung phone, an Apple server, and a Windows PC can all talk to each other.

Your Home Network — Up Close

Before we scale up to the global internet, let us look at the smallest network most people interact with: their home network. Every device in your home that connects to the internet is part of this network — your phone, laptop, smart TV, thermostat, and even your printer.

Interactive — Home Network

Click any device to learn what it does and what its IP address means.

Notice that your router has two different IP addresses. One faces inward (your home network) — like 192.168.1.1. One faces outward (the internet) — your actual public IP like 103.74.52.18. This is because there are not enough public IP addresses for every device in every home. Your router uses a technique called NAT (Network Address Translation) to let all your devices share one public IP. We will explore this in detail in Chapter 5.

Chapter 03

How Data Actually Travels — The Packet Revolution

The internet doesn't work the way most people assume. Here's the surprising reality.

Real-World Scenario

Imagine you need to mail a 500-page manuscript to a publisher in another city. You could stuff all 500 pages in one enormous box — but if that box gets lost or damaged in transit, you lose everything. Or you could send 50 smaller packages, each with 10 pages and a label saying "Package 3 of 50, pages 21-30." If package 12 gets lost, only that package needs to be re-sent. The publisher waits for all 50 packages, reassembles them in order, and reads the complete manuscript. This is exactly how the internet works.

The internet uses packet switching — data is broken into small chunks called packets (typically 1,500 bytes each), sent independently, and reassembled at the destination. This was a radical idea in the 1960s. Before packet switching, telephone networks used circuit switching — when you made a call, a dedicated physical circuit was reserved between you and the other person for the entire duration of the call, even when neither of you was speaking. Wasteful.

Why Packets Changed Everything

🛡️
Fault Tolerant
If one router fails, packets reroute around it automatically. The internet was originally designed to survive nuclear strikes by the US military (ARPANET, 1969).
Efficient
Multiple packets from different users share the same physical wire simultaneously. One slow download doesn't block someone else's video call.
📈
Scalable
Billions of devices can join the internet without reserving circuits in advance. Capacity is shared dynamically.
🔄
Resilient
Packets can take different paths. One packet might go Ashburn → Singapore → Google, the next might go Ashburn → London → Google.

Anatomy of a Packet

Every packet has two parts: a header (the label on the envelope — who it is from, who it is going to, what number this packet is) and a payload (the actual data inside). Multiple headers can be stacked — one for each layer of the network stack.

Simplified packet structure
[Ethernet Header  | IP Header         | TCP Header        | HTTP Data      ]
 src MAC           src IP: 192.168.1.5  seq: 1001          GET / HTTP/1.1
 dst MAC           dst IP: 142.250.182.4 ack: 0             Host: google.com
 type: IPv4        protocol: TCP         port: 443           ...

 ← 14 bytes →    ← 20 bytes →          ← 20 bytes →       ← up to ~1460 bytes →

 Total packet = 1500 bytes (MTU = Maximum Transmission Unit)

The MTU (Maximum Transmission Unit) of 1,500 bytes is not arbitrary — it is the maximum payload size that Ethernet (the most common link-layer protocol) defined in the 1980s. If your data is larger, it gets fragmented into multiple packets automatically.

3D Visualization — TCP/IP Encapsulation

Click any layer to inspect its header fields. Outer layers wrap inner ones — like envelopes inside envelopes.

L2Ethernet Frame14-byte header
L3IP Packet20-byte header
L4TCP Segment20-byte header
L7HTTP Payloadup to 1,460 bytes

Each layer's header is added by the sender's OS and stripped by the receiver at the matching layer.

Interactive — Packet Journey

Follow a single request from your keyboard to Google and back.

⌨️Step 1 — You press Enter

You type "google.com" and press Enter. Your browser breaks your HTTP request into small chunks called packets. Each packet is roughly 1,500 bytes (about 1,500 characters). Why not send everything at once? Because smaller chunks can be rerouted around failures, and multiple packets can travel different paths simultaneously.

[Your Device]
→ Breaks request into packets
→ Packets: #1, #2, #3, #4...

1 / 4

Common misconception: packets always take the same path

Many people imagine the internet as a series of tubes where their data flows in a straight line. In reality, packets from the same TCP connection can take entirely different physical paths — one might go through London, another through Singapore — and arrive out of order. TCP's job is to reorder them correctly.

Chapter 04

Protocols — The Rules Everyone Must Follow

Without protocols, a Google server and an Apple iPhone would have nothing to say to each other.

Real-World Scenario

Imagine landing at an airport in Japan when you do not speak Japanese. You go to the information desk and the agent speaks only Japanese. You speak only English. Neither of you can help the other. Now imagine both of you speak French — a common language. That is what protocols are: agreed-upon communication rules that let completely different devices understand each other.

A protocol is a set of rules that defines: how to start a conversation, what format messages must be in, how to handle errors, and how to end the conversation. Without protocols, a Samsung phone could not load a page from an Apple server in a Google data center.

The Protocol Stack — Layers of Responsibility

Networking is organized in layers. Each layer handles one job and passes work up or down to the next layer. You do not need to memorize this yet — but understanding the concept is crucial.

7 — Application
HTTP, HTTPS, DNS, SMTP, FTP
What are you asking for? (A webpage, an email, a file)
4 — Transport
TCP, UDP
How reliably? Port numbers. Splitting data into segments.
3 — Network
IP (IPv4/IPv6), ICMP
Where does it go? IP addresses. Routing across the internet.
2 — Data Link
Ethernet, WiFi (802.11)
How does it move on the local link? MAC addresses.
1 — Physical
Fiber, copper, radio
Actual electrons, photons, or radio waves.

When you send a request, each layer wraps the data with its own header (called encapsulation). When data arrives, each layer unwraps the header it understands (called decapsulation). Your web browser never knows about MAC addresses. The Ethernet hardware never knows about HTTP. Each layer only speaks to the layer above and below it.

The Two Great Transport Protocols: TCP and UDP

At the Transport layer (Layer 4), two protocols divide the world between them: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). The choice between them is one of the most important decisions in network application design.

Interactive — TCP vs UDP

Toggle between the two to understand when each protocol is used and why.

TCP — Reliable Delivery

Analogy

Like sending a registered letter via post — you get a delivery confirmation for every letter, and if one gets lost, it's resent automatically.

How it works:

  • 3-way handshake before any data flows (SYN → SYN-ACK → ACK)
  • Every packet gets a sequence number and must be acknowledged
  • Lost packets are automatically retransmitted
  • Flow control prevents the sender from overwhelming the receiver
  • Congestion control slows down when the network is busy

Used for:

Web browsing (HTTP/HTTPS)Email (SMTP, IMAP)File transfers (FTP, SCP)Database queriesSSH remote access

The Trade-off

The overhead of acknowledgments adds latency. A typical TCP connection takes 1–3 round trips just to establish before data flows.

Modern protocols often blur this line. QUIC (used by HTTP/3) implements reliability on top of UDP at the application layer — gaining the benefits of UDP's speed while adding its own congestion control and stream multiplexing. When you watch YouTube, there is a good chance you are using QUIC right now.

Chapter 05

Addresses — How the Internet Knows Where to Send Your Data

The internet needs to find your device among 5.5 billion users. Here's how.

Real-World Scenario

Think about your home. It has a postal address — say, "42 Main Street, Austin, TX 78701." That address gets a letter from anywhere in the world to your building. But inside your building, you also have an apartment number — "Flat 3B." The postal system uses the building address. Once the letter arrives, your building's internal system uses the apartment number. IP addresses work the same way: public IPs route traffic across the internet, private IPs route traffic within your home network.

IP Addresses — Your Device's Mailing Address

An IP address (Internet Protocol address) is a unique identifier for a device on a network. Every packet on the internet carries a source IP (where it came from) and a destination IP (where it is going). Routers use destination IPs to decide where to forward each packet.

There are two versions of IP addresses in use today:

IPv4 — The Old Standard
192.168.1.1
  • 32-bit address (4 groups of 0–255)
  • ~4.3 billion possible addresses
  • We ran out in 2011 — NAT is the workaround
  • Still 95%+ of internet traffic today
IPv6 — The Future
2001:0db8:85a3::8a2e:0370:7334
  • 128-bit address (8 groups of hex)
  • 340 undecillion addresses (3.4 × 10³⁸)
  • Enough for every atom on Earth's surface
  • No need for NAT — every device gets a public IP

Private vs Public IP Addresses

Not all IP addresses are visible on the internet. Three ranges are reserved as private — they can only exist on local networks (your home, office, etc.) and are never routed on the public internet:

RFC 1918 Private Address Ranges
10.0.0.0    to  10.255.255.255    # 10.x.x.x  — Class A (16M addresses)
172.16.0.0  to  172.31.255.255    # 172.16-31.x.x — Class B (1M addresses)
192.168.0.0 to  192.168.255.255   # 192.168.x.x — Class C (65K addresses)

Your home router gives devices addresses in 192.168.x.x range (most common).
Enterprise networks often use 10.x.x.x for scale.

NAT — How Millions of Devices Share One IP Address

Since IPv4 only has 4.3 billion addresses and there are 5.5 billion internet users (plus multiple devices each), we would have run out long ago without a workaround. The solution is NAT (Network Address Translation). Your router has one public IP from your ISP. Every device in your home gets a private IP from the router. When your phone (192.168.1.101) sends a request to Google, the router translates: "This packet is really from me (103.74.52.18), and when the reply comes, send it back to 192.168.1.101:54321." This translation table is maintained in memory.

NAT translation table (simplified)
Private IP:Port          Public IP:Port          Destination
192.168.1.101:54321  →   103.74.52.18:1024  →   142.250.182.4:443 (Google)
192.168.1.102:55001  →   103.74.52.18:1025  →   31.13.79.70:443   (Facebook)
192.168.1.110:56789  →   103.74.52.18:1026  →   52.84.17.99:443   (Netflix)

When Google replies to 103.74.52.18:1024, NAT routes it to 192.168.1.101:54321

MAC Addresses — The Hardware Identity

Every network interface (WiFi card, Ethernet port) has a MAC address (Media Access Control address) burned into its hardware at the factory. Unlike IP addresses (which are logical and can change), MAC addresses are permanent hardware identifiers.

MAC addresses are used for local delivery only. When your laptop sends a packet to your router, it uses the router's MAC address as the destination. When the router forwards that packet to the next router on the internet, the MAC addresses change — but the IP addresses stay the same. MAC addresses are replaced at every hop; IP addresses travel end-to-end.

MAC address format
A4:C3:F0:11:22:33

First 3 bytes (A4:C3:F0) = OUI (Organizationally Unique Identifier)
  → Assigned to a manufacturer (Apple, Intel, Qualcomm, etc.)
  → You can look up who made the card from the first 3 bytes

Last 3 bytes (11:22:33) = Device-specific unique identifier
  → Assigned by manufacturer at factory

Total: 48-bit = ~281 trillion possible addresses

DNS — The Internet's Phone Book

You type "google.com." Your computer needs an IP address to connect to. But you are not going to type "142.250.182.4" into your browser — you need a translation service. That is DNS (Domain Name System): the distributed database that maps human-readable names to IP addresses.

DNS is not a single server — it is a hierarchical tree of servers distributed across the world. No single server knows all domain names. Instead, servers delegate responsibility downward: root servers know about TLDs (.com, .org, .in), TLD servers know about domains (google.com, amazon.com), and authoritative servers know the actual IPs.

Interactive — DNS Resolution

Follow a DNS query from "google.com" to an IP address, step by step.

🔎

You type google.com in your browser. What happens next?

DNS is faster than you think

A DNS query typically completes in 5–50ms for cached responses, and 100–300ms for a full recursive resolution. Google's 8.8.8.8 and Cloudflare's 1.1.1.1 are public DNS resolvers with servers on every continent — they cache billions of records and can often answer in under 10ms. The first time you visit a site, DNS takes a round trip. Every time after (within the TTL window), it is instant from cache.

Chapter 06

Bandwidth, Latency, and Why Your Fast Connection Sometimes Feels Slow

The two most misunderstood concepts in networking — and why they matter for every application you build.

Real-World Scenario

You have a 200 Mbps fiber connection at home — blazing fast. But when you join a video call, there is a half-second delay on everything you say. Your colleague's WiFi is only 20 Mbps, but her video call is crisp and instant. How? Because bandwidth and latency are completely different things — and for interactive applications, latency is far more important.

People often confuse "fast internet" with "high bandwidth." They are not the same. These are the four metrics that actually describe a network connection:

Bandwidth
Mbps / Gbps
The width of a pipe — how much data can flow through per second.
A 1 Gbps connection can transfer 1,000 Megabits (125 Megabytes) per second. Relevant for large file transfers and streaming — not for interactive apps.
Latency
milliseconds (ms)
How long it takes for one bit to travel from A to B and back (round-trip time / RTT).
Governed by the speed of light (~200,000 km/s in fiber) and the number of router hops. New York to Singapore is ~200ms minimum — physics, not technology.
Throughput
Mbps (actual)
What you actually get — bandwidth minus overhead, congestion, and retransmissions.
Bandwidth is the ceiling. Throughput is what reaches your application after TCP overhead, packet loss, and congestion control. Often 60–80% of bandwidth.
Jitter
ms (variation)
Inconsistency in latency — packets arriving with varying delays.
Video calls hate jitter. If packet 1 arrives in 30ms and packet 2 arrives in 90ms, you get audio/video stuttering. High jitter = poor call quality even with low average latency.

Interactive — Bandwidth vs Latency

Move the sliders and see how each metric affects different tasks differently.

50 Mbps
1 Mbps (2G-ish)100 Mbps (fiber)1 Gbps
30 ms
1ms (LAN)30ms (good fiber)300ms (satellite)
🌐 Load Google.com (1 MB page)280 ms

120ms for TCP + DNS handshakes, 160ms data transfer

💿 Download Ubuntu ISO (4 GB)11m 55s

For downloads, latency barely matters — it's almost pure bandwidth

📹 Video Call (Zoom)30ms RTT

Excellent — conversations feel natural

Key insight: For large downloads, bandwidth is everything. For interactive use (web pages, video calls, gaming), latency is everything. A 1 Gbps connection with 300ms latency will feel slower for web browsing than a 10 Mbps connection with 10ms latency.

The Bandwidth-Delay Product — Why "Fast" Networks Can Still Feel Slow

The Bandwidth-Delay Product (BDP) tells you how much data can be "in flight" in the network at any moment — like water filling a long hose:

Bandwidth-Delay Product
BDP = Bandwidth × RTT

Example: 1 Gbps connection with 100ms RTT
BDP = 1,000,000,000 bits/sec × 0.1 sec = 100,000,000 bits = 12.5 MB

This means 12.5 MB of data can be "in flight" simultaneously.
TCP's congestion window must be large enough to fill this pipe.
If the window is too small, TCP sits idle waiting for acknowledgments
instead of sending more data — wasting your bandwidth.

This is why downloading a large file from a server 20ms away is much faster than from a server 200ms away, even if both have 10 Gbps connections. TCP cannot fill the pipe if it has to wait 200ms for every acknowledgment before sending more.

Bufferbloat — The Hidden Problem in Your Router

Modern routers have large buffers (queues) to hold packets when they are congested. Sounds good? It causes a problem called bufferbloat: when someone in your house starts a large download, the router fills its buffer with download packets, and all your other traffic (video calls, gaming) has to wait in line — adding hundreds of milliseconds of latency. You can test this at fast.com or dslreports.com/speedtest.

The solution is CoDel (Controlled Delay) — a queue management algorithm built into modern Linux kernels and routers like those running OpenWRT. CoDel deliberately drops packets that have been waiting too long, forcing senders to slow down before the buffer fills, keeping latency consistently low. Most consumer routers do not implement this properly — it is why enterprise-grade routers (from Ubiquiti, MikroTik) often feel noticeably better for real-time use.

Chapter 07

The Physical Internet — What It Actually Looks Like

The internet is real, physical, and surprisingly fragile in some ways.

Real-World Scenario

In March 2013, someone in Egypt dug into the seabed with an anchor and accidentally cut an undersea fiber optic cable. Internet speeds across South Asia and the Middle East dropped by 60% for three days. In 2022, a volcanic eruption near Tonga severed the undersea cable connecting the island nation, cutting it off from the internet for weeks. The internet feels invisible, but it runs on physical infrastructure that can be cut, flooded, or destroyed.

Undersea Cables — The Backbone of Global Communication

Forget satellites for a moment. 99% of international internet traffic travels through undersea fiber optic cables. There are 600+ of these cables crisscrossing the ocean floor, each one about as thick as a garden hose, carrying thousands of fiber strands. Each fiber can carry terabits per second using wavelength-division multiplexing (sending dozens of different colors of light through one fiber simultaneously).

The cable connecting Virginia Beach, USA to Bilbao, Spain (the MAREA cable) is about 6,600 km long. A photon travels through glass at about 2/3 the speed of light (200,000 km/s), so the theoretical minimum latency Virginia to Bilbao is about 33ms one way. Real-world latency is ~60-70ms round-trip due to router processing, signal amplification at repeaters, and routing overhead.

🔦 How fiber optic cables work

Fiber optic cables transmit data as pulses of light through thin glass fibers (thinner than a human hair). Light bounces along the fiber via total internal reflection — it never touches the cable walls because the glass core is denser than the cladding around it, causing light to reflect back inward at the boundary. Undersea cables have electronic "repeaters" every 50–100 km that receive the optical signal, convert it to electricity, amplify it, convert back to light, and retransmit — all underwater, running on power sent through the copper core of the cable from shore.

Data Centers — Where the Internet Lives

When you access any website, app, or service, your request ultimately reaches a data center — a facility housing thousands of servers. Hyperscale data centers (Google, Amazon, Meta, Microsoft) can contain 100,000+ servers and consume 100+ megawatts of power (enough for a small city). They are typically located near renewable energy sources, cool climates (for natural cooling), and major fiber optic networks.

Google has 35+ data center campuses worldwide. A request from Seattle to google.com typically hits a data center in The Dalles, Oregon; a request from New York typically hits one in Berkeley County, South Carolina — rarely one on the opposite coast. This is by design: keeping servers close to users reduces latency.

CDNs — The Internet's Distributed Cache

A CDN (Content Delivery Network) is a globally distributed network of servers that cache and serve content from locations close to end users. When Netflix has a new show, they do not stream it from a central server to 100 million viewers simultaneously. Instead, they push copies of the content to CDN servers in hundreds of cities worldwide. When you hit play, you are streaming from a server 20ms away, not 200ms away from a central location.

Cloudflare, Akamai, Fastly, and AWS CloudFront are major CDN providers. They serve images, videos, static HTML/CSS/JS, and sometimes entire dynamic applications from edge nodes. A website using a CDN correctly will serve the same content 10x faster to users worldwide compared to a single-region server.

Chapter 08

Security — How HTTPS Protects Everything You Send

Without encryption, every packet you send is readable by anyone between you and the server.

Real-World Scenario

Imagine sending a postcard vs. a sealed letter. A postcard (plain HTTP) — anyone who handles it can read everything. A sealed, tamper-evident letter with a wax seal (HTTPS) — your postman can see the destination address, but not the contents. Even if they intercept it, they cannot read it without breaking the seal (and you would know if they did). HTTPS is that sealed letter — encrypted so that only you and the server can read the contents.

Why HTTP Alone Is Dangerous

Plain HTTP sends everything in cleartext. If you are on public WiFi at a coffee shop and you log into a site using HTTP, anyone on the same network running Wireshark can capture your username and password as plaintext. This is called a man-in-the-middle attack. As recently as 2010, the tool "Firesheep" let anyone on public WiFi steal Facebook session cookies in one click, because Facebook was still serving login pages over HTTP.

HTTPS and TLS — The Full Story

HTTPS = HTTP + TLS (Transport Layer Security). TLS does three things:

1
Authentication
Proves you're talking to the real server (google.com) and not an impostor. Servers have digital certificates signed by a Certificate Authority (CA) like DigiCert or Let's Encrypt. Your browser trusts ~150 root CAs pre-installed by the OS.
2
Encryption
All data is encrypted using symmetric keys (AES-256 or ChaCha20) that are negotiated during the handshake. Even if someone captures every packet, they cannot decrypt the contents without the session key.
3
Integrity
Each message includes a cryptographic MAC (Message Authentication Code). If any bit of the data is modified in transit, the MAC check fails and the connection is terminated immediately.
TLS 1.3 Handshake (simplified)
Client → Server:  ClientHello  (supported TLS versions, cipher suites, random nonce)
Server → Client:  ServerHello  (chosen cipher, server certificate, server public key)
                  Certificate  (signed by DigiCert, proving server identity)

Client:           Verifies certificate chain → Root CA in browser trust store ✓
                  Generates pre-master secret, encrypts with server's public key
Client → Server:  ClientKeyExchange (encrypted pre-master secret)
                  ChangeCipherSpec (switching to symmetric encryption now)
                  Finished (HMAC of entire handshake, proving integrity)

Server:           Decrypts pre-master secret using its private key
                  Both sides derive the same symmetric session key
Server → Client:  ChangeCipherSpec + Finished

→ From here, all communication is AES-256-GCM encrypted.
→ TLS 1.3 optimized this from TLS 1.2's 3+ round trips down to 1-2.

Modern HTTPS uses forward secrecy — the session keys are ephemeral and never stored. Even if a server's private key is stolen years later, past encrypted sessions cannot be decrypted. This is achieved using Diffie-Hellman Ephemeral (DHE) or Elliptic Curve DHE key exchange.

Chapter 09

Putting It All Together — The Full Journey of a Web Request

Every concept from the previous chapters comes together when you click a link.

You have learned about packets, TCP, IP addresses, DNS, latency, and HTTPS separately. Now watch them all work together in real time — this is what happens when you click a link on any website.

Interactive — Full HTTP Request

The complete lifecycle of visiting a webpage — from keypress to pixels. Total: ~276ms

🌐

Watch the complete journey of a single webpage request.

Notice the single most surprising insight: the actual HTTP request is trivial compared to the setup. DNS + TCP + TLS take 3–5 round trips before a single byte of your actual content is transferred. This is why connection reuse matters so much — HTTP/1.1 introduced keep-alive, HTTP/2 introduced multiplexing (multiple requests on one connection), and HTTP/3 (QUIC) starts transferring data in the very first packet.

🚀 HTTP/3 and QUIC — the next generation

HTTP/3 runs on QUIC instead of TCP. QUIC is built on UDP but implements its own reliability, congestion control, and stream multiplexing. The key innovation: QUIC integrates TLS 1.3 into the transport handshake — so you go from connection establishment to encrypted data in just 1 round trip (or even 0 round trips for returning connections via session resumption). YouTube, Google Search, and Cloudflare-protected sites already use HTTP/3 for most connections.

Chapter 10

Hands-On — Network Tools Every Developer Must Know

These commands are available on every Mac, Linux, and most Windows machines. Run them yourself right now.

Understanding networks in theory is one thing. Being able to observe and debug them in practice is what separates good engineers from great ones. Here are the essential tools:

ping — Is the host reachable?

ping sends ICMP Echo Request packets to a host and measures the round-trip time. It tells you: is the host alive, and how far away is it in milliseconds?

ping examples
$ ping google.com
PING google.com (142.250.182.4): 56 data bytes
64 bytes from 142.250.182.4: icmp_seq=0 ttl=57 time=12.847 ms
64 bytes from 142.250.182.4: icmp_seq=1 ttl=57 time=13.201 ms
64 bytes from 142.250.182.4: icmp_seq=2 ttl=57 time=12.953 ms

# time= is your round-trip latency
# ttl= (Time To Live) starts at 64/128 and decrements at each router hop
# 57 means it passed through 64-57=7 routers to reach you

$ ping -c 100 8.8.8.8 | tail -5
--- 8.8.8.8 ping statistics ---
100 packets transmitted, 99 received, 1% packet loss
round-trip min/avg/max/stddev = 11.2/13.4/45.2/3.1 ms
# stddev = jitter. 3.1ms = good. 30ms = bad for video calls.

traceroute / tracert — Every router on the path

traceroute (macOS/Linux) or tracert (Windows) shows every router hop between you and a destination, and the latency to each hop. It exploits the TTL field — sends packets with TTL=1 (dies at first router), then TTL=2 (dies at second), and so on, collecting the IP and latency of each hop.

traceroute example
$ traceroute google.com
traceroute to google.com (142.250.182.4)
 1  192.168.1.1          1.2 ms   # Your home router
 2  10.8.32.1            5.1 ms   # Your ISP's first router
 3  125.16.8.17          8.3 ms   # ISP backbone
 4  72.14.204.85         15.2 ms  # Google's network (AS15169 = Google)
 5  142.250.182.4        16.1 ms  # Google's edge server

 * * * means the router didn't reply (firewalled) but packets pass through

dig — DNS debugging

dig (Domain Information Groper) queries DNS servers and shows you the raw response, including TTL, record type, and which server answered. Every backend developer should know this command.

dig examples
$ dig google.com
;; ANSWER SECTION:
google.com.    300  IN  A  142.250.182.4
# TTL=300s, A record (IPv4), IP address

$ dig google.com MX        # Mail servers for google.com
$ dig google.com NS        # Authoritative name servers
$ dig @8.8.8.8 google.com  # Use Google's DNS instead of default
$ dig +trace google.com    # Full resolution chain (root → TLD → authoritative)
$ dig -x 142.250.182.4     # Reverse lookup: IP → domain name

curl — Making HTTP requests from the command line

curl is the Swiss Army knife of HTTP — you can make any kind of request, set headers, inspect responses, measure timing, and test APIs.

curl examples
# Basic GET request
$ curl https://httpbin.org/get

# See response headers only
$ curl -I https://google.com

# Detailed timing breakdown (invaluable for debugging)
$ curl -w "DNS: %{time_namelookup}s | TCP: %{time_connect}s | TLS: %{time_appconnect}s | Total: %{time_total}s
" -o /dev/null -s https://google.com
DNS: 0.012s | TCP: 0.024s | TLS: 0.056s | Total: 0.089s

# POST with JSON body
$ curl -X POST https://api.example.com/data \
  -H "Content-Type: application/json" \
  -d '{"key": "value"}'

# Follow redirects and show all verbose headers
$ curl -L -v https://google.com 2>&1 | head -50

ss / netstat — What's happening on your machine right now

ss examples (macOS: use netstat -an)
$ ss -tuln
# -t TCP, -u UDP, -l listening, -n don't resolve hostnames
Netid  State   Recv-Q  Send-Q  Local Address:Port  Peer Address:Port
tcp    LISTEN  0       128     0.0.0.0:22           0.0.0.0:*     # SSH server
tcp    LISTEN  0       511     0.0.0.0:80           0.0.0.0:*     # HTTP server
tcp    LISTEN  0       511     0.0.0.0:443          0.0.0.0:*     # HTTPS server

$ ss -tnp    # Show which process owns each connection
$ ss -s      # Summary statistics (established, time-wait, etc.)

Chapter 11

Troubleshooting — How to Systematically Debug Any Network Problem

The OSI model isn't just theory — it's a debugging framework used by every network engineer.

Real-World Scenario

A developer at 2 AM: "The website is down!" But why? Is the server off? Is DNS broken? Is the network unreachable? Did a certificate expire? Is there a firewall rule? Is the application crashing? Without a systematic approach, you would guess randomly and waste hours. The OSI model gives you a bottom-up debugging methodology.

When something does not work, always start at Layer 1 (Physical) and work your way up. Confirming each layer is working before checking the next prevents you from debugging application code when the problem is actually a bad ethernet cable.

L1 Physical
Is the cable plugged in? Is WiFi enabled? Any link lights?
ip link show / ifconfig / Check indicator LEDs
L2 Data Link
Can I see my own IP? Is the network interface up?
ip addr show / ifconfig / ipconfig /all
L3 Network
Can I reach the default gateway (router)?
ping 192.168.1.1 (your router's IP)
L3 Internet
Can I reach a public IP (bypass DNS)?
ping 8.8.8.8 (if this works, it is a DNS issue)
L7 DNS
Can I resolve domain names?
dig google.com / nslookup google.com
L7 Application
Can I make an HTTP connection?
curl -v https://google.com / curl -I https://yoursite.com

Common Failures and Their Signatures

🔴 Browser says 'site can't be reached'
Likely cause: DNS failure OR no network connectivity
Fix: Try ping 8.8.8.8 (network OK?) then dig domain (DNS OK?)
🔴 SSL certificate error
Likely cause: Expired cert, wrong domain, or self-signed
Fix: openssl s_client -connect host:443 to see the cert details
🔴 Connection refused
Likely cause: Server is up, but nothing is listening on that port
Fix: ss -tuln on server to see what ports are open
🔴 Connection timed out
Likely cause: Firewall dropping packets silently (vs. rejecting them)
Fix: traceroute to see where packets stop. Check iptables/security groups.
🔴 502 Bad Gateway
Likely cause: Nginx/load balancer can't reach the upstream app server
Fix: Check if app server is running (systemctl status), check app logs
🔴 High latency to server
Likely cause: Congestion, bufferbloat, or wrong CDN region serving you
Fix: traceroute to find the slow hop. curl --timing to isolate DNS/TCP/TLS

Chapter 12

Advanced Topics — Where Networking Gets Fascinating

For those ready to go deeper — the mechanisms that make the internet at scale possible.

BGP — How the Internet Routes Between Networks

The internet is not one network — it is ~80,000 Autonomous Systems (ASes), each one managed by an organization: your ISP, Google, Cloudflare, universities, etc. Each AS has its own internal routing. Between ASes, they use BGP (Border Gateway Protocol) to announce which IP prefixes they can reach.

BGP is a path vector protocol — each AS announces "I can reach X, and the path is through these ASes." This is why the internet is sometimes called "a network of networks." BGP is also notoriously fragile: in 2010, Pakistan Telecom accidentally announced it could reach YouTube's IP space, and BGP propagated this lie globally — causing YouTube to be unreachable worldwide for two hours. This is called a BGP hijack.

Subnetting — Dividing Networks Efficiently

A subnet is a logical subdivision of an IP network. Instead of one flat network where all 65,000 devices in a company can talk to each other directly, subnetting divides them into smaller groups. 192.168.1.0/24 means "all IPs from 192.168.1.0 to 192.168.1.255" — the /24 is the CIDR notation for "the first 24 bits are the network portion."

CIDR subnetting
Notation   Subnet Mask       # of hosts   Example range
/24        255.255.255.0     254          192.168.1.1 - 192.168.1.254
/25        255.255.255.128   126          192.168.1.1 - 192.168.1.126
/16        255.255.0.0       65,534       10.0.0.1 - 10.0.255.254
/8         255.0.0.0         16M          10.0.0.1 - 10.255.255.254

Rule: /X means the first X bits are fixed (network address).
The remaining 32-X bits are host addresses.
First and last IPs in a subnet are reserved (network + broadcast).

Load Balancing — Distributing Traffic Across Servers

No single server can handle millions of requests per second. Load balancers distribute incoming traffic across a pool of servers. They check server health continuously and remove failed servers automatically. Common strategies:

Round RobinRequest 1 → Server 1, Request 2 → Server 2, Request 3 → Server 3, back to Server 1. Simple, equal distribution. Does not account for server load.
Least ConnectionsRoutes each new request to the server with fewest active connections. Better for requests with variable processing time.
IP Hash / Sticky SessionsAlways routes the same client IP to the same server. Required for stateful applications that store session data locally.
WeightedDifferent servers get different proportions of traffic based on their capacity. A server with 4x the RAM might get 4x the traffic.

WebSockets — Real-Time Bidirectional Communication

Regular HTTP is request-response: you ask, the server answers, connection closes. For real-time apps (chat, live dashboards, multiplayer games), you need the server to push data to you without you asking. WebSockets solve this by upgrading an HTTP connection to a persistent, bidirectional channel. Both sides can send messages at any time.

WebSocket upgrade handshake
Client → Server (HTTP):
GET /chat HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==

Server → Client:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

→ Now both sides can send frames at any time. No more polling.
→ Used by: Slack, Discord, WhatsApp Web, trading platforms, live sports scores

Chapter 13

Common Misconceptions That Will Get You in Trouble

These are the beliefs that sound right, feel right, and are wrong. Internalise these before your next interview or production incident.

Common Mistake — More bandwidth = faster internet

Bandwidth is the pipe width. Latency is the pipe length. For interactive applications — web pages, video calls, online gaming, SSH — latency dominates the experience. A 1 Gbps connection with 200ms latency will feel slower for web browsing than a 20 Mbps connection with 10ms latency. The first page load involves DNS (1 round trip), TCP handshake (1 round trip), TLS handshake (1–2 round trips), and the actual HTTP request (1 round trip) — at 200ms RTT, that is 800ms before you see anything. At 10ms RTT, it is 40ms. Bandwidth matters for large file transfers; latency matters for everything interactive.

Common Mistake — HTTPS means the website is safe and trustworthy

HTTPS means the connection between your browser and the server is encrypted and authenticated. It says nothing about what the server does with your data, whether the site is legitimate, or whether the owner has good intentions. Phishing sites, scam stores, and malware distribution sites all use HTTPS. The padlock icon means "your connection to this site is private" — not "this site is trustworthy." Certificate Authorities verify that the certificate belongs to the domain name (DV certificates) or the organization (EV certificates), but even DV certs are trivially available for any domain, including paypa1.com.

Common Mistake — WiFi and the internet are the same thing

WiFi is your Local Area Network — the radio network connecting your devices to your router. The internet is the global network your router connects to via your ISP. You can have WiFi with no internet (your router is on, but your ISP connection is down — devices can still talk to each other and to your router). You can have internet with no WiFi (an Ethernet cable directly to your router). When your "internet is down," the first diagnostic step is exactly this: can you ping your router (192.168.1.1)? If yes, the WiFi LAN is working and the problem is the ISP's WAN connection. If no, the problem is your local network.

Common Mistake — Packets always take the same path from A to B

Packet switching routes each packet independently. Two consecutive packets in the same TCP connection can travel entirely different paths — one via Singapore, one via London — and arrive at the destination out of order. TCP uses sequence numbers to reassemble them in the correct order regardless of arrival order. This is by design: if one path becomes congested or fails, individual packets reroute without the entire connection needing to restart. It also means that adding more hops (traceroute shows longer paths) doesn't necessarily mean higher latency — a longer path through faster routers can beat a shorter path through congested ones.

Common Mistake — DNS is just a lookup — it doesn't affect performance or security

DNS is on the critical path of every network connection. Slow DNS adds directly to page load time (every uncached hostname = one DNS round trip before any connection can begin). DNS failures make everything unreachable even if the network and servers are perfectly healthy — Facebook's 2021 outage was primarily a DNS problem. DNS is also a major attack vector: DNS hijacking (redirecting queries to malicious servers), DNS cache poisoning (Kaminsky attack), and DNS-based DDoS amplification (open resolvers used to flood targets). Use DNSSEC to sign your zones, DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) to prevent interception, and a reputable recursive resolver (1.1.1.1, 8.8.8.8) rather than your ISP's default which may be slow and logged.

Common Mistake — TCP is always reliable — it never loses data

TCP guarantees delivery of data to the application, but this reliability is achieved through retransmission — which takes time. In high-packet-loss environments (satellite, mobile on poor signal), TCP's retransmission timeouts can cause seconds of latency per lost packet, making it feel completely broken even though it is technically "working." TCP also does not protect against data corruption that passes CRC checks. And at the application level, TCP only guarantees ordered, reliable delivery to the socket buffer — if your application crashes before reading the buffer, the data is lost. "TCP is reliable" means "lost packets are retransmitted," not "your application always receives all data."

Chapter 14

Interview Questions — Test Your Understanding

From entry-level to research-level. Each answer reveals a deeper layer of how networks actually work.

BeginnerQ: What is the difference between a switch and a router?
A switch operates at Layer 2 (Data Link) and connects devices within the same network using MAC addresses. When your laptop sends data to your printer on the same WiFi, the switch handles it locally — no routing needed. A router operates at Layer 3 (Network) and connects different networks using IP addresses. It routes traffic between your home network and the internet. Most home "routers" are actually router + switch + WiFi access point combined in one box.
BeginnerQ: What happens when you type google.com in a browser and press Enter?
The complete sequence: (1) Browser checks DNS cache for google.com's IP. If not found, queries the OS cache, then your router/ISP's resolver, then performs a full recursive DNS lookup through root → TLD → Google's authoritative DNS. (2) Browser initiates a TCP connection to port 443 (3-way handshake: SYN, SYN-ACK, ACK). (3) TLS handshake: browser verifies Google's certificate, negotiates encryption keys. (4) Browser sends HTTP GET request. (5) Google's servers process it and return an HTTP response with HTML. (6) Browser parses HTML, discovers additional resources (CSS, JS, images), makes additional requests for each. (7) Browser executes JS, applies styles, renders pixels. Total time: 200–500ms for a first visit.
BeginnerQ: What's the difference between TCP and UDP? When would you use each?
TCP provides reliable, ordered delivery with flow control and congestion control — every packet is acknowledged, and lost packets are retransmitted. UDP provides fast, connectionless transmission with no guarantees — packets may be lost, reordered, or duplicated. Use TCP for anything that needs completeness and accuracy: web pages, email, file transfers, database connections, SSH. Use UDP for anything where speed matters more than perfection: video calls (a lost packet means a glitch, not a freeze), DNS queries (small, fast, retried at the application layer if needed), online gaming, live streaming, and QUIC (HTTP/3).
IntermediateQ: What is NAT and why was it invented?
NAT (Network Address Translation) allows multiple devices with private IP addresses to share a single public IP address. It was invented as a stopgap solution to IPv4 address exhaustion (only 4.3 billion addresses for billions of devices). The router maintains a translation table mapping private IP:port pairs to public IP:port pairs. When a private device sends a packet, NAT rewrites the source IP/port to the public address and records the mapping. When the response arrives, NAT looks up the mapping and rewrites the destination back to the private address. NAT has side effects: it breaks some protocols (like FTP active mode, SIP, IPsec) that embed IP addresses in the payload, complicates peer-to-peer connections, and requires techniques like STUN/TURN/ICE for WebRTC to work behind NAT.
IntermediateQ: Explain DNS resolution in detail. What is a TTL and what happens when it expires?
DNS resolution follows a hierarchical tree: Recursive resolver (your ISP or 8.8.8.8) → Root nameservers (13 logical roots, ~1,000 anycast instances) → TLD nameservers (.com, .org, .in) → Authoritative nameservers (the domain owner's DNS). Each DNS record has a TTL (Time To Live) in seconds. Resolvers cache records for their TTL duration — if TTL=300, the record is cached for 5 minutes and then discarded. After expiration, the next query triggers a fresh lookup. Short TTLs (60s) enable faster DNS changes during migrations. Long TTLs (3600s) reduce DNS query load and improve performance. Propagation delay: when you change a DNS record, old TTL-cached records persist until they expire — this is why "DNS propagation" can take hours if you had a long TTL.
SeniorQ: What is the Bandwidth-Delay Product and how does it affect TCP throughput?
The Bandwidth-Delay Product (BDP) = bandwidth × round-trip time. It represents the amount of data "in flight" in the network at any moment — the pipeline capacity. TCP's congestion window limits how much unacknowledged data can be in flight simultaneously. If the congestion window is smaller than the BDP, TCP is underutilizing the available bandwidth — it transmits, then sits idle waiting for ACKs before sending more. To saturate a 10 Gbps link with 100ms RTT, the congestion window must be at least 10Gbps × 0.1s = 125 MB. TCP's slow start begins with a small window and grows exponentially until it detects congestion. For long-distance, high-bandwidth links (satellite, transoceanic fiber), this slow start phase can significantly limit throughput. Solutions include BBR (Bottleneck Bandwidth and RTT) congestion control used by Google, TCP window scaling (RFC 7323), and QUIC which can be more aggressively tuned.
SeniorQ: How does TLS 1.3 differ from TLS 1.2, and what are the security implications of forward secrecy?
TLS 1.3 made three major improvements over TLS 1.2: (1) Handshake reduced from 2 round trips to 1 (0-RTT for session resumption). TLS 1.3 removes non-forward-secret cipher suites (RSA key exchange) and mandates ECDHE/DHE. (2) Forward secrecy (Perfect Forward Secrecy / PFS) is mandatory. In TLS 1.2 with RSA key exchange, the client encrypted the pre-master secret with the server's long-term RSA key — if that key is compromised later, all past sessions can be decrypted. TLS 1.3 uses ephemeral Diffie-Hellman: fresh key pairs are generated per-session, and private keys are immediately discarded after use. Compromising the server's certificate key doesn't decrypt any past sessions. (3) Removed weak algorithms: RC4, 3DES, MD5, SHA-1, RSA key exchange. Only AES-128-GCM, AES-256-GCM, and ChaCha20-Poly1305 are allowed. Security implication: large-scale passive surveillance becomes infeasible even if an attacker records all encrypted traffic today hoping to break it later.
PhDQ: Describe the QUIC protocol architecture. What problems does it solve that TCP + TLS could not?
QUIC (originally Google QUIC, now IETF RFC 9000) is a general-purpose transport protocol built on UDP that reimplements and improves upon TCP + TLS. Core problems it solves: (1) Head-of-line blocking: HTTP/2 multiplexes multiple streams over one TCP connection, but a single lost packet stalls all streams (TCP must deliver data in order). QUIC implements stream multiplexing at the transport layer — a lost packet only blocks the affected stream, not others. (2) Connection migration: TCP connections are identified by the 4-tuple (src IP, src port, dst IP, dst port). If your IP changes (switching from WiFi to LTE), the TCP connection breaks. QUIC uses connection IDs independent of IP — connections survive network transitions. (3) 0-RTT resumption: returning clients can send application data in the first packet (no handshake delay). (4) Integrated TLS: QUIC integrates TLS 1.3 into the handshake — connection establishment and key exchange happen simultaneously. (5) Loss detection improvements: QUIC uses explicit packet numbers (not sequence numbers) and separate ACK streams, enabling more precise RTT measurement and faster loss detection. (6) Congestion control flexibility: QUIC makes it easier to deploy new congestion control algorithms (BBR, CUBIC) without OS-level kernel changes. Deployed in: Google Search, YouTube, Cloudflare, Meta, and HTTP/3.

🎯 Key Takeaways

  • A network is two or more devices that can exchange data — from Bluetooth earphones to the global internet. All networks connect, transfer, and follow protocols.
  • Packet switching breaks data into small chunks that travel independently and are reassembled at the destination — enabling the internet's fault tolerance, efficiency, and scale.
  • TCP provides reliable, ordered delivery (used for web, email, files). UDP is fast but unreliable (used for video calls, gaming, DNS). HTTP/3 (QUIC) combines UDP's speed with application-layer reliability.
  • Every IP packet carries source and destination IPs end-to-end. MAC addresses handle local delivery and change at every router hop. NAT lets millions of private IPs share one public IP.
  • DNS translates domain names to IP addresses through a hierarchy: root → TLD → authoritative. Responses are cached by TTL. DNS is critical infrastructure — broken DNS equals broken internet.
  • Bandwidth = how much data per second (pipe width). Latency = how long data takes to travel (pipe length). For downloads, maximize bandwidth. For interactive apps, minimize latency.
  • HTTPS = HTTP + TLS. TLS authenticates the server via certificates, encrypts all data with AES-256, and ensures integrity via HMAC. TLS 1.3 mandates forward secrecy — past sessions cannot be decrypted even if keys are stolen later.
  • Troubleshoot network issues bottom-up: Physical → Link → Network (ping router) → Internet (ping 8.8.8.8) → DNS (dig) → Application (curl). Confirm each layer works before checking the next.
Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...