Networking Tutorial · Networking Basics · Lesson 2 of 28

How the Internet Works

Packets, routers, and the trip a request takes from your browser to a server and back.

Create a free account to save this page, take notes and track your progress. Sign in

Packets

Data on a network travels in small chunks called packets. A 2 MB image is split into well over a thousand packets. Each packet has a header (source address, destination address, protocol and more) and a payload (a piece of your data).

Sending small packets lets many conversations share the same cables fairly, and if one packet is lost only that packet needs to be sent again.

Routers and hops

Your packets go from your device to your home router, to your internet provider, across several provider networks and finally to the server. Each router looks at the destination address and forwards the packet one hop closer. No router knows the whole path; each only knows where to send packets next.

$ traceroute example.com
 1  192.168.1.1      1.2 ms    home router
 2  100.64.0.1       8.4 ms    internet provider (carrier-grade NAT)
 3  203.0.113.9     12.1 ms    provider core
 4  198.51.100.17   14.9 ms    exchange / transit provider
 5  93.184.215.14   15.3 ms    destination

Latency and bandwidth

  • Latency is how long one packet takes to arrive, measured as round-trip time (RTT) with ping. Light in fibre covers about 200 km per millisecond, so London to New York (about 5,600 km) can never be faster than about 56 ms round trip.
  • Bandwidth is how much data per second the path can carry.

Many small requests are limited by latency, not bandwidth. That is why connection reuse, fewer round trips and CDNs close to users matter so much.

The speed-of-light limit on latencyTry it yourself
FIBRE_KM_PER_MS = 200      # light in glass travels about 200 km per millisecond

routes = {"London - Paris": 340, "London - New York": 5570, "Sydney - Frankfurt": 16500}
for name, km in routes.items():
    rtt = 2 * km / FIBRE_KM_PER_MS
    print(f"{name:20} {km:>6} km  best possible RTT {rtt:5.1f} ms")

Output

London - Paris          340 km  best possible RTT   3.4 ms
London - New York      5570 km  best possible RTT  55.7 ms
Sydney - Frankfurt    16500 km  best possible RTT 165.0 ms

Test yourself

A page makes 20 requests one after another to a server 80 ms away (round trip). Roughly how long do the round trips alone take?

  1. 80 ms
  2. 160 ms
  3. 1.6 seconds
  4. 20 seconds
Show answer

Answer: 1.6 seconds

20 sequential round trips of 80 ms each is 1,600 ms. Fewer round trips or parallel requests help more than extra bandwidth.

Was this page helpful?