Portmint Lighthouse

Routers and a Packet's Journey

A packet almost never travels straight from your laptop to its destination. It hops from one machine to the next, getting handed forward a little closer each time, until it arrives. The machines doing that handing-off are called routers.

Think of a letter you mail across the country. It doesn't fly in a straight line. It goes to your local post office, then a regional sorting center, then another, then the city near its destination, then the local carrier. At each stop, a sorter reads the address and decides which truck it goes on next. A router is that sorter. 🔦

What a router actually does

A router sits at a junction where networks meet. When a packet arrives, the router looks at the destination IP address written on it, checks a kind of map called a routing table, and picks the best next step. Then it passes the packet along and forgets about it. Its whole job is one decision: "Given where this is headed, who should I hand it to next?"

No single router knows the entire path. Your home router doesn't know the route to a server in Tokyo. It only knows "send anything that isn't local out to my internet provider." The provider's router knows a bit more, the next one more still. Each one only needs to know the next step, not the whole trip. The path emerges from many small, local decisions stacked end to end.

Finding a path, and rerouting around trouble

Routers are constantly chatting with their neighbors, sharing notes about which connections are up and how busy they are. That's how the map stays current. When you send a packet, the routers along the way each apply their freshest map to choose the next hop.

This is also what makes the internet sturdy. Suppose a cable gets cut or a sorting center goes dark. The routers near the blockage notice the road is gone, update their maps, and start sending packets a different way. Your letter still arrives; it just took a detour. Because each packet is routed fresh, two postcards from the same message can even travel different roads and still meet up at the end.

There's a quiet safety rule too. Every packet carries a hop limit, a small countdown that drops by one at each router. If a packet ever gets stuck looping between sorters, the count hits zero and the packet is dropped instead of circling forever. It's the post office throwing out a letter that's been bouncing between two towns for a week.

Your turn

On most computers you can watch the hops yourself. Open a terminal and run tracert example.com on Windows, or traceroute example.com on Mac or Linux. You'll see a numbered list appear, one line per router the packet passed through, often with city names hidden in the addresses. Count the hops. Run it again to a faraway site and notice the list gets longer. That list is the real journey, sorter by sorter.

Next we follow the packet all the way to the end of its trip and ask: what is the machine waiting there? That's "What a Server Actually Is." 🐙

Stuck or curious?

Ask Pip about this lesson — tap the porthole bottom-right.