# How packets find their way

> IP addresses, routers that only know the next step, how networks share directions, and the cables on the seabed.

Lesson 3 of 6 in [How the internet actually works](https://learnfold.app/learn/internet/), a free course from Learnfold.

Every device on the internet needs an address so packets can reach it. That's its IP address. The classic kind, IPv4, is four numbers with dots between them, like 203.0.113.7. There are only about 4.3 billion possible IPv4 addresses, fewer than there are people, and the supply of new ones ran out years ago. The newer kind, IPv6, has so many addresses that running out isn't a real concern. The two run side by side.

So how do far more than 4.3 billion devices get online? Mostly by sharing. Your home router has one public address and hands every device in your house a private one. When your phone's packets leave the house, the router swaps in its public address and keeps a note, so it can pass the replies back to the right device. This trick is called network address translation, or NAT.

### Routers only know the next step

A router is a computer whose whole job is forwarding packets. It reads the destination address, checks a table, and sends the packet out whichever connection brings it closer. Then it moves on to the next packet. A big router does this many millions of times a second.

No router knows the full route. Picture asking for directions in a city where each person only knows which street to take next. A packet from your phone to a server on another continent might pass through somewhere around 10 to 20 routers, each making one small decision.



Play the route, then fail the link and play again. The small network is illustrative; route updates take time on a real network.

### How networks share directions

The internet is made of tens of thousands of separate networks, run by internet providers, universities, big companies, and cloud platforms. Each runs its own routers. To fill their tables, networks tell their neighbors which blocks of addresses they can reach, using a protocol called BGP, the Border Gateway Protocol. Neighbors pass the news along, and before long every network has a path to everywhere.

BGP runs largely on trust. If a network announces a route it shouldn't, others may believe it. In 2008 a provider in Pakistan tried to block YouTube inside the country by announcing a route to YouTube's addresses. The announcement leaked to the rest of the world, a large share of YouTube's traffic headed to Pakistan, and the site was unreachable for many people for about two hours. Networks have better ways to check announcements now, but smaller versions of this mistake still happen.

### Under the sea

When your packets cross an ocean, they almost certainly travel through a cable on the seabed, not a satellite. Several hundred of these cables wrap the planet. In the deep ocean one is roughly as thick as a garden hose, and most of that is protective layers around hair-thin glass fibers that carry pulses of light.

Light in glass moves at about two thirds of its speed in empty space. That sets a floor no upgrade can beat. A round trip between New York and London takes about 65 milliseconds, however fast your plan is. That's why big websites keep copies of themselves on several continents.



Drag the globe sideways or tap Turn to see the ocean path from another angle. The route is illustrative; real cables follow the seabed and use landing stations.

### Rabbit holes

> How does a ship lay a cable across the ocean floor, and what happens when one breaks?

> Why did we run out of IPv4 addresses, and why is the move to IPv6 taking so long?

> How does a router choose between two paths to the same place?

Read online: https://learnfold.app/learn/internet/routing/
