Course contents · Lesson 1 of 22

How Does the Internet Work? A Beginner's Guide

How the Internet Works · Lesson 1 of 22 · 8 min Foundations

A friend on another continent shares a holiday photo, and a second later it is on your phone, though the file sits on a computer thousands of kilometres away. So how does the internet work? This lesson follows that photo: what the internet is made of, why data travels in small pieces called packets, and how each piece finds its way.

Why data travels as small packets

A packet is a small piece of data that crosses a network on its own. On most home and office networks, a packet holds at most 1,500 bytes (a byte is about one letter of English text), so a 3-megabyte (MB) photo travels as roughly 2,000 packets.

Why not send the photo in one piece? Because links are shared. Packets from many people take turns on the same cables, so your photo and someone's video call can share a link at once, and nobody reserves a line first, as old telephone calls did. This is called packet switching. And if one packet is lost, only it is sent again.

What the internet is physically made of

The internet is a network of networks: tens of thousands of separately run networks that agree to carry each other's traffic. Your home has one; your Internet Service Provider (ISP), the company you pay for access, runs another, as do mobile operators and cloud providers.

Real hardware joins them. Your phone reaches your home router, the box linking your home to your ISP, over Wi-Fi, a short-range radio link. From there a fibre-optic line (glass strands carrying pulses of light), a cable-TV line or a phone line runs to the ISP. On mobile data, a phone mast takes the router's place, and the mobile operator is your ISP.

ISPs connect to the backbone, the big long-distance networks between cities and countries, by direct links or at internet exchange points, buildings where many networks meet. Fibre cables on the sea bed carry almost all traffic between continents. In the map, notice that one request crosses several networks, each separately run.

Layered map of six boxes. Your phone connects over Wi-Fi radio to your home router, which joins your home to your ISP over a fibre, cable or phone line. Your ISP connects to the backbone of big carriers by a direct link or at an exchange point, and the backbone includes undersea cables that cross oceans. The backbone links over fibre to the server's ISP or cloud network, which links through the data centre to the server that stores the photo. A note says every arrow is real hardware, cable or radio
No single company owns the path from you to the server.

What a packet carries

Every packet has a header, a short label at the front, and a payload, the slice of your data behind it. The network reads only the header, as a sorting office reads only the front of a card.

The header holds the sender's and receiver's IP addresses (Internet Protocol addresses), numbers such as 203.0.113.7 that identify devices on the internet; lesson 2 covers them. It also carries a sequence number that says where this piece fits, like a page number. Strictly, that number sits in a second header added by TCP, the rules that keep data complete and in order (lesson 5), and it counts bytes, not pages.

The header also has a time to live (TTL), a counter lowered by one at each stop. At zero the packet is thrown away, so a looping packet cannot circle forever. In the diagram, notice that each postcard line has a matching packet field.

Side-by-side comparison. A postcard lists From: Asha, Mumbai; To: Ben, London; Page: 2 of 40; and the text, then we caught the train. A packet's header lists source IP 203.0.113.7, the server, destination IP 198.51.100.23, you, and sequence number 1461, which counts bytes, followed by a payload of about 1,400 bytes, a slice of the photo. Arrows pair each postcard line with its packet field. A note says these are example values and real headers hold a few more fields
The header does the job of a postcard's addresses and page number.

Routers choose only the next hop

A router is a device that passes packets from one network towards the next, like a sorting office. Each step along the path is called a hop.

When a packet arrives, the router looks up its destination in a routing table, a list of which neighbour is the best next step for each range of addresses, and sends it on. That is the whole decision: no router knows the full route. Lesson 12 looks inside these tables.

Routers learn these routes from their neighbours, using the Border Gateway Protocol (BGP) between big networks, so when a link fails they switch to another next hop.

Different paths, one complete message

Because each router decides for itself, packets of one photo can take different paths, for example when a link fails or routers learn a new route mid-transfer. Routers try to keep one conversation on one path, since that avoids reordering, but nothing guarantees it.

So packets can arrive late, out of order, twice, or not at all: an overloaded router simply drops packets, and the network promises nothing. Your device puts things right. It uses the sequence numbers to restore the order and drop duplicates, and the sender resends anything the receiver never confirmed.

In the flowchart, packets 3 and 4 take a quieter path through Router C and overtake packet 2.

Flowchart in four steps. Step 1: the sender cuts the photo into four numbered packets, 1 to 4, which all go to Router A. Step 2: each router picks only the next hop. Router A sends packets 1 and 2 to Router B, whose link is busy so packets wait, and packets 3 and 4 to Router C, whose link is quiet and faster. Step 3: the packets arrive at the receiver, your phone, in the order 1, 3, 4, 2. Step 4: the receiver sorts them back into the order 1, 2, 3, 4. A callout says packets 3 and 4 overtake packet 2, and the numbers let the receiver sort them
Packets may arrive out of order; their numbers let the receiver rebuild the message.

Putting it together: loading a faraway photo

In plain words:

  1. Your app finds the server's IP address using DNS, the internet's directory of names (lesson 3).
  2. It sends a short request, which hops router by router to the server.
  3. The server sends the photo back as about 2,000 numbered packets.
  4. They cross the server's network, the backbone, your ISP and your home router: for example, 15 hops.
  5. Your phone puts them in order, has missing ones resent, and shows the photo.

Distance adds delay. Light in fibre covers about 200 kilometres per millisecond (ms), a thousandth of a second, so with a server 10,000 km away, a request and its reply need at least a tenth of a second.

Check yourself

Why can a video call and a big download share one home connection at the same time?

Both are cut into small packets that take turns on the same link, so neither holds the line for the whole transfer.

A router in Singapore gets a packet bound for London. Must it know the whole route?

No. It looks up the destination in its routing table and picks only the next hop; each router after it does the same.

A photo's packets arrive as 1, 3, 2, and packet 4 never arrives. Is the photo lost?

No. The receiver reorders 1, 2 and 3 by their sequence numbers, and the sender resends packet 4 because the receiver never confirmed it.