Learning LibrarySecurity LibraryTeens

How networks work: a request's journey

When you load a page, your request doesn't teleport — it hops across a chain of machines to reach the server and back. Understanding that journey is the map you need before thinking about security.

The big idea

Data crosses a network in packets that hop from machine to machine — your device, routers, and finally the server — each forwarding it toward the destination.

See it in code

1The basics

At its simplest, a network is two machines talking directly — a source and a destination. Data leaves one and arrives at the other:

python
# The simplest network: two machines connected directly.
source = "your laptop"
destination = "server"
print(f"{source} -> {destination}")
print("The message travels from source to destination.")
Run it — data going straight from one machine to another:
your laptop -> server
The message travels from source to destination.

Two machines, one direct line. Real networks are rarely this short — the data almost always passes through machines in between.

2A step further

Add a machine in the middle. A router sits between you and the server and forwards the data one step closer — so now the message passes through something on the way:

python
# Real networks add machines in between - here a router in the middle.
path = ["your laptop", "home router", "server"]
for machine in path:
    print(f"passes through: {machine}")
Run it — the data passes through each machine on the path:
passes through: your laptop
passes through: home router
passes through: server

Three machines now, and the data touches every one. Each machine it passes through is a place data can be seen — hold that thought.

3In our world

A real request takes far more than three hops. We model the full path as a list — each hop a machine with an address that forwards the packet one step closer — and the loop walks that route from your laptop to the server:

python
# A request hops across machines to reach a server. (Conceptual model.)
route = ["your laptop", "home router", "ISP", "backbone", "server"]

packet = "GET /index.html"
for i, hop in enumerate(route):
    print(f"hop {i}: {hop} forwards the packet")

print("Delivered:", packet, "to", route[-1])
Run it — the packet's path from your device to the server:
hop 0: your laptop forwards the packet
hop 1: home router forwards the packet
hop 2: ISP forwards the packet
hop 3: backbone forwards the packet
hop 4: server forwards the packet
Delivered: GET /index.html to server

Every hop is a machine that could see, delay, or misroute the packet — which is exactly why the web moved to HTTPS, so data is encrypted along the whole journey. Knowing the route is the first step to reasoning about where things can go wrong.

The same idea, everywhere

'Data passing through intermediaries' is a model that recurs constantly: a letter through the postal system, a message through app servers, a function call through layers of software. Seeing the full path — and every point that touches the data — is how you reason about both performance and trust.

Try it yourself

Add more hops to the route and watch the path grow (real requests can take a dozen or more). Then imagine which hops you control (your laptop, your router) versus which you don't — a key security distinction.

The common mistake

Assuming data is private just because it reached its destination. Without encryption, every hop along the way can read the packet. Understanding the route is what makes clear why encryption matters — the data is exposed at each machine it passes through.

What it unlocks

The network map leads into ports and protocols, vulnerabilities, and ultimately the security mindset.