01

How Networks Work

A visual guide to the invisible infrastructure that connects the modern world - from electrons on a wire to the global routing fabric across continents.

OSI ModelTCP/IPDNSBGPTLSCDN
01

How Networks Work at a Fundamental Level

Every interaction on the internet relies on a stack of protocols built over decades. The diagrams below show how data is structured, layered, and routed across networks.

1.1

The OSI Model vs TCP/IP

The OSI model (7 layers) is a conceptual framework. The TCP/IP model (4 layers) is what the internet actually uses. Each layer encapsulates data from the layer above.

Data Transport Network LinkHeaders wrap payload at each layer
OSI Model (7 layers)TCP/IP Model (4 layers)ApplicationHTTP, DNS, SMTP, TLSTransportTCP, UDP, QUICInternetIP, ICMP, ARPLinkEthernet, Wi-Fi7ApplicationHTTP, DNS, SMTP, TLSUser-facing network services6PresentationTLS, JPEG, ASCIIData translation, encryption5SessionRPC, NetBIOSSession management4TransportTCP, UDP, QUICReliable end-to-end delivery3NetworkIP, ICMP, BGPLogical addressing, routing2Data LinkEthernet, Wi-FiNode-to-node delivery1Physical10BASE-T, RS-232Raw bit transmission5-7→4→3→1-2→Conceptual framework (ISO 1984)What the internet actually uses
1.2

Packets, Frames, and Encapsulation

Data is broken into packets (layer 3) and wrapped in frames (layer 2). Each layer adds its own header - this is encapsulation. The animated visualization below shows packets traversing OSI layers through a router.

Header metadata AddressesTotal: 20 bytes (160 bits) header + payload
Ver44b VersionIHL54b Header lengthDSCPEF6b Traffic classECN02b CongestionTotal Length150016b Total bytesID0x4A2F16b Fragment IDFlags0103b DF/MF bitsFrag Offset013b Fragment posTTL648b Max hopsProtocolTCP(6)8b Upper protoChecksum0x1A2B16b Header CRCSrc IP10.0.0.132b Source addrDst IP93.184.216.3432b Dest addrHow Data Wraps at Each Layer (Encapsulation)ApplicationHTTP Request / JSON PayloadTransportTCP Hdr (20b) | Application DataNetworkIP Hdr (20b) | TCP Hdr | App DataData LinkMAC Hdr (14b) | IP Hdr | TCP Hdr | App Data | FCS (4b)PhysicalPreamble (7b) | MAC Hdr | ... | FCS | IFGSender adds headers layer-by-layerReceiver strips in reverse order
SOURCEROUTERRIB / FIBDESTApplicationTransportNetworkData LinkPhysicalP1P2P3P4P5P6P7P8Packets traverse OSI layers through router forwarding plane
1.3

Routing, Switching, and Path Selection

Switches (layer 2) forward by MAC address. Routers (layer 3) forward by IP using Dijkstra's shortest-path algorithm (OSPF, IS-IS) or path-vector (BGP). Select source and destination below to trace a packet through the network.

→Hops: 6 | Total: 46ms
1G/10ms1G/20ms10G/5ms1G/25ms10G/10ms10G/8ms1G/12ms1G/20ms10G/6ms1G/18ms10G/7ms1G/14ms10G/9ms10G/5ms1G/15ms10G/6ms1G/12ms1G/10msPACKET (hop 1)SrcR1R2R3R4R5R6R7R8R9R10R11R12Dst
Path:Src→R1→R3→R6→R10→R12→Dst
Network topology: devices, connections, and roles
1Gbps10Gbps10Gbps1Gbps1Gbps1Gbps10Gbps10GbpsClientEnd deviceSwitchLayer 2 forwardingRouterLayer 3 routingFirewallAccess controlLoad BalancerTraffic distributionWeb Server 1App hostWeb Server 2App hostDatabasePersistent storageLANWAN / InternetServer Farm
1.4

TCP: The Three-Way Handshake

TCP provides reliable, connection-oriented delivery using sequence numbers, acknowledgements, and a three-way handshake (SYN, SYN-ACK, ACK). Sliding window flow control and AIMD congestion control manage throughput.

CLIENTSERVERCLOSEDSYN-SENTESTABLISHEDLISTENSYN-RCVDESTABLISHEDseq = sequence number, ack = acknowledgement number
1.5

Sockets and Ports

Ports 0-1023

Well-known: HTTP(80), HTTPS(443), SSH(22), DNS(53)

Ports 1024-49151

Registered: assigned by IANA for specific services

Ports 49152-65535

Ephemeral: dynamically assigned to client connections

A socket is identified by the tuple (protocol, local IP, local port, remote IP, remote port). The OS demultiplexes incoming traffic using the destination port number.

02

How You Connect to the World

DNS translates names to IPs. IP addressing provides unique identifiers. BGP routes traffic between the 70,000+ autonomous systems that make up the internet.

2.1

The World Wide Web

The web (invented at CERN, 1989) is built on URLs, HTTP, and HTML. A URL decomposes as: scheme://host[:port][/path][?query][#fragment].

Client → Server request lifecycle with round-trip costs
BrowserURL: https://example.comDNS Resolve93.184.216.34TCP ConnectSYN/ACK to :443TLS HandshakeClientHello -> FinishedHTTP RequestGET / HTTP/2Edge CDNReverse ProxyWeb Servernginx / ApacheApp ServerDjango / ExpressDatabasePostgreSQL / RedisResponseHTML + Assets0-RTT1-RTT1-RTT1-RTT0.5-RTTTotal new-connection latency: ~3.5 RTTs | HTTP/2 multiplexing eliminates reconnect cost | HTTP/3 (QUIC): 0-RTT for return visits
2.2

DNS Resolution

The DNS is a hierarchical database. Queries flow from stub resolver through recursive resolvers, root servers, TLD servers, and authoritative nameservers. The interactive simulator below traces each step.

Domain:
BrowserClientStub Resolverlibc / OSRecursive Resolver8.8.8.8Root Servera.root-servers.netTLD Server.comAuthoritativens1.example.comCacheRecursive Cache

Enter a domain and click Resolve to trace the DNS lookup path

Resolution complete: example.com → 93.184.216.34

Cached by recursive resolver for 300s TTL

2.3

IP Addressing and Subnets

192Network (8 bits)168Network (8 bits)1Host (8 bits)0Host (8 bits)192.168.1.0/24 = 256 addresses (254 usable)
IPv4

32-bit address. ~4.3B unique addresses. Exhausted - NAT mitigates. RFC 1918 private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.

IPv6

128-bit address. 340 undecillion addresses. No NAT needed. Native dual-stack deployment growing. Format: 2001:db8::/32.

2.4

BGP and Inter-Domain Routing

BGP is the glue that holds the internet together. Over 70,000 ASes exchange reachability info via path-vector routing. The AS_PATH attribute prevents loops and enables traffic engineering.

BGP Best Path Selection (ordered priority)1. Highest WeightCisco proprietary, local to router2. Highest Local PrefPropagated within the AS3. Locally OriginatedRoutes originated by this router4. Shortest AS_PATHFewest AS hops to destination5. Lowest OriginIGP < EGP < INCOMPLETE6. Lowest MEDMulti-Exit Discriminator between peers
03

How Servers and Websites Communicate

Loading a website triggers a sequence of DNS lookups, TCP handshakes, TLS negotiations, and HTTP exchanges. Each stage is shown below.

3.1

HTTP: Request-Response Protocol

HTTP is a request-response protocol. Each request has a method (GET, POST, PUT, etc.), URI, version, headers, and optional body. Below is an interactive builder to construct raw HTTP requests.

Headers
:
:
:
:
GET /v1/users HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <token>
User-Agent: Mozilla/5.0 (compatible; NetworksGuide/1.0)

Active headers: 4Content-Length: 0Raw size: 172 bytes
3.2

HTTPS and TLS 1.3

TLS provides confidentiality (encryption), integrity (no tampering), and authentication (server identity via certificates). TLS 1.3 reduced the handshake from 2-RTT to 1-RTT using ECDHE key exchange. Step through each phase below.

CLIENT
Cipher SuitesTLS_AES_256_GCM_SHA384
Key ExchangeECDHE (X25519)
SERVER
Random32-byte nonce
ExtensionsSNI, ALPN, key_share
Cipher Suites
TLS_AES_256_GCM_SHA384
Key Exchange
ECDHE (X25519)
Random
32-byte nonce
Extensions
SNI, ALPN, key_share
Step 1/5ClientHelloOffered parameters

Client sends supported TLS version (1.3), cipher suites (TLS_AES_256_GCM_SHA384), key share (X25519 public key), and random nonce.

3.3

Cryptographic Primitives in Network Security

Symmetric

AES-256-GCM: bulk encryption

ChaCha20-Poly1305: mobile-optimized

Key: same for encrypt/decrypt

Asymmetric

RSA-2048 / ECDSA P-256

Ed25519: modern & fast

Key: public + private pair

Hash Functions

SHA-256: 256-bit digest

SHA-3: Keccak standard

BLAKE2b: high performance

TLS 1.3 combines all three: ECDHE (asymmetric) for key exchange, HKDF (hash) for key derivation, AES-256-GCM (symmetric) for bulk encryption.

3.4

Complete Request/Response Flow

The complete sequence from URL entry to pixels on screen, with estimated round-trip costs.

StepComponentActionRTT Cost
1BrowserURL Parsing + HSTS check0
2DNSRecursive resolution chain1 RTT
3TCPSYN -> SYN-ACK -> ACK1 RTT
4TLSClientHello -> ServerHello -> KeyExchange -> Finished1 RTT (TLS 1.3)
5HTTPGET / HTTP/2 (multiplexed streams)1 RTT
6Servernginx -> Express/Django -> handler -> response~50ms processing
7BrowserHTML parse, CSSOM, layout, paint, composite0 (parallel)

Total new-connection latency: 3-4 RTTs + processing. HTTP/2 reuse eliminates subsequent connection overhead. HTTP/3 (QUIC) further reduces to 0-RTT for returning visitors.

04

Edge Networks, CDNs, and Modern Infrastructure

Content is cached at thousands of edge locations worldwide. Traffic is shaped by peering agreements. Applications run at the network edge for minimal latency.

4.1

Content Delivery Networks

CDNs use geographically distributed edge servers and anycast routing to serve content from the nearest POP. Cache hits skip the origin entirely, delivering sub-20ms response times globally.

Edge POP OriginAnycast routes user to closest POP
Origin ServerPrimary infrastructureDeployed onceUS WestLos Angeles~75% cache hitUS EastNew York~75% cache hitEU WestLondon~75% cache hitEU CentralFrankfurt~75% cache hitAsiaSingapore~75% cache hitOceaniaSydney~75% cache hitUserSan FranciscoNearest POP (anycast)TTL: 300s cache at edgeRevalidation: stale-while-revalidate
70%

Average cache hit ratio for static assets

50%

Latency reduction (RTT) for global users

95%

DDoS mitigation at the edge

4.2

Edge Computing

Edge computing runs application logic directly at CDN POPs. Instead of all requests traveling to a central data center, code executes close to the user. Platforms: Cloudflare Workers, Fastly Compute@Edge, AWS Lambda@Edge. Use cases: real-time personalization, A/B testing, image optimization, bot detection, SSR at the edge.

Edge-First Architecture

As much logic as possible runs at the CDN edge; the origin is treated as a fallback database. This pattern enables sub-50ms time-to-first-byte globally.

4.3

Peering and Transit

The internet is a web of interconnection agreements. Transit (paying an upstream for full internet access), Peering (direct exchange, usually at an IXP), and Tier 1 networks (no transit providers) form the hierarchy. The world's largest IXPs: DE-CIX Frankfurt (10Tbps+), AMS-IX Amsterdam, LINX London.

Transit

Network pays upstream ISP for full internet reachability. Tier 1 networks (AT&T, Lumen, NTT) have no transit - they reach everyone via peering.

Peering

Two networks exchange traffic directly at an IXP. Settlement-free if balanced; paid peering if traffic ratio is skewed.

4.4

The Modern Internet Ecosystem

574+

Submarine cable systems

1.4M km fiber

1.3M+

ASNs in global table

IPv4 + IPv6 prefixes

20Tbps+

Peak IXP throughput

DE-CIX Frankfurt

400+

Global edge POP count

Cloudflare alone

65%

Traffic from CDN edge

Up from 20% in 2015

40%+

Traffic encrypted

HTTPS: 3% in 2014

5.3B+

Internet users

~66% of population

~250ms

Max Earth RTT

Fiber: 2/3 light speed

HTTP/2 introduced multiplexed streams and HPACK compression. HTTP/3 replaces TCP with QUIC (over UDP), eliminating head-of-line blocking and providing 0-RTT reconnect. Modern security follows Zero Trust Architecture: never trust, always verify, with mTLS and service meshes.

How Networks Work - A visual technical reference on internet infrastructure.