Networking · Lesson 4 of 14

How the internet works

Follow one click from your device to a website and back: packets, IP addresses, routers, ports and protocols explained simply, with an interactive packet journey.

⏱ 16 min🎯 Beginner🧪 Hands-on practice🎬 Video

By the end, you’ll be able to…

  • Describe what happens between typing a web address and seeing the page
  • Explain what packets, routers and protocols do
  • Use the layer idea to tell which part of the trip a problem is in

Key words

Packet
A small chunk of data with a header that says where it’s from and where it’s going.
Router
A device that forwards packets toward their destination, one hop at a time.
IP address
The address used to deliver packets to a device on a network.
Protocol
An agreed set of rules for how devices talk, like HTTP or DNS.
ISP
Internet service provider: the company that connects your home to the internet.
TCP
A protocol that makes sure data arrives complete and in order.

The internet is a network of networks

Your home Wi-Fi is a small network. Your school has a network. Cloudflare, Google and your ISP run giant networks. The internet is what you get when all of these agree to pass each other’s data along using shared rules called protocols.

There’s no single “internet computer”. It’s more like a postal system: lots of independent post offices that all understand the same address format.

Data travels in packets

When you load a page, the data isn’t sent as one big blob. It’s split into packets, small pieces with a header that holds the source address, destination address and other details. Packets can take different paths and arrive out of order. TCP puts them back together and asks for any missing ones again.

What happens when you open a website

  1. Your device joins the network. DHCP on your router hands it an IP address, like 192.168.1.23.
  2. DNS lookup. Your device asks a DNS resolver, “what’s the IP address for example.com?” (Full lesson on DNS.)
  3. Connection. Your device opens a TCP connection to that IP on port 443, the HTTPS port.
  4. Encryption. A TLS handshake sets up encryption and checks the site’s certificate. (See HTTPS & TLS.)
  5. Request and response. Your browser sends an HTTP request (“GET / please”), and the server replies with HTML.
  6. More requests. The HTML mentions images, styles and scripts, so the browser repeats this many times.

Along the way, packets pass through your router, your ISP and several other networks. Each router reads the destination IP and forwards the packet one hop closer. You can see those hops with traceroute (macOS/Linux) or tracert (Windows).

Layers: a map for troubleshooting

Networking is split into layers, each doing one job and trusting the layer below. The simple four-layer version:

LayerJobExamples
ApplicationWhat the app is sayingHTTP, DNS, SSH
TransportWhich program, and reliable or fastTCP, UDP, ports
InternetWhich device, across networksIP addresses, routers
LinkThe local hopWi-Fi, Ethernet, MAC addresses

When something breaks, layers help you ask good questions. No Wi-Fi bars? Link problem. Can reach 1.1.1.1 but not example.com? Probably DNS. Page loads but says “403 Forbidden”? That’s the application talking.

Try it on your own computer

# See the route your packets take (safe, read-only)
traceroute example.com      # macOS / Linux
tracert example.com         # Windows

example.com is a domain reserved for documentation and examples, so it’s a polite target for practice.

🧪 Hands-on

Practice

Step through the journey of a single click. Press Next hop and watch where the request goes.

🎬 Watch

Video: The Internet: Packets, Routing & Reliability

NetworkingThe Internet: Packets, Routing & ReliabilityCode.org · Watch on YouTube

Video by Code.org, hosted on YouTube. It loads only when you press play.

✅ Check yourself

Quick quiz

Q1. What does a router mainly look at to decide where to send a packet?
Q2. You can ping 1.1.1.1 but example.com won’t load anywhere. What’s the most likely culprit?
Q3. Which protocol re-sends lost packets and keeps data in order?