AP Computer Science Principles · Study guide

The Internet

AP® Computer Science Principles · Big Idea 4 · Computer Systems and Networks

The Internet

What devices, systems, and networks are, how paths and bandwidth work, how packets and open protocols move data, and how the Internet differs from the Web.

1Devices, systems, networks

Three words nest inside each other:

WordMeaningExamples
Computing deviceA physical thing that can run a programLaptops, phones, tablets, servers, routers, smart sensors
Computing systemA group of devices and programs working together for a common purposeA school's laptops, its Wi-Fi, and its grade-book app
Computer networkA group of connected devices that can send or receive dataYour home Wi-Fi with everything joined to it

A network is devices working together, so a computer network is a type of computing system. A router counts as a computing device: it runs a program that decides where data goes next.

2Paths and routing

Figure 1. Devices joined by links form a network. A path is a chain of directly connected devices from sender to receiver; this network has four of them.

A path between two devices (a sender and a receiver) is a sequence of directly connected devices that starts at the sender and ends at the receiver. Routing is the process of finding a path. In the network above, laptop A can reach server B four ways:

PathLinks usedSlowest link
A → R1 → R2 → R4 → B450 Mbps
A → R1 → R3 → R4 → B430 Mbps
A → R1 → R2 → R3 → R4 → B520 Mbps
A → R1 → R3 → R2 → R4 → B520 Mbps

To check a path, make sure every neighboring pair shares a link, and that no device repeats. A → R1 → R4 → B is not a path here, because R1 and R4 have no link between them.

3Bandwidth

The bandwidth of a network is the most data it can send in a fixed amount of time. It is usually measured in bits per second: 1 kbps is a thousand bits per second, 1 Mbps a million, 1 Gbps a billion.

Think of the width of a pipe, not its length. A wider pipe moves more water each second. Two things follow:

  • The slowest link sets the pace. Data on a path moves no faster than its narrowest link. The best path above is A → R1 → R2 → R4 → B, limited to 50 Mbps by the R1 to R2 link, even though its other links are faster.
  • Time = size ÷ bandwidth, once the units match. File sizes are in bytes (MB, capital B) and bandwidth in bits (Mbps, small b); one byte is 8 bits. A 90 MB album is 720 megabits, so at 30 Mbps it takes 24 seconds, and at 60 Mbps 12 seconds.

Bandwidth is not the same as latency, the delay before a piece of data arrives. A connection can move lots of data per second and still have a noticeable delay, like a wide but very long pipe. A video call needs low latency; a big download mostly needs high bandwidth. More bandwidth also does not make data more secure or stop errors; it only lets more data through each second.

4Networks of networks

The Internet is a computer network made of many connected networks, owned by different people and companies, that all use standardized, open communication protocols.

  • A protocol is an agreed-upon set of rules that say how a system behaves: how addresses look, how data is packaged, what a reply looks like. Devices made by different companies can talk because they follow the same rules.
  • The Internet's protocols are open: anyone can read them and build a device that follows them, without asking permission. That makes it easy to connect new devices. (Open describes the rules, not the price: you still pay for an Internet connection.)
  • Getting access means connecting your device to a device that is already on the Internet, such as a home router that connects to an Internet service provider.
  • Routing on the Internet is usually dynamic: no one plans the route in advance. Each router forwards data based on where it is going and the state of its links right now, so the same trip can take a different path a minute later.
  • Scalability is a system's ability to change in size to meet new demands. The Internet was designed to be scalable: open protocols let new networks join, and dynamic routing uses new links as soon as they exist.

Growth needed room in the rules, too. The older address format, IPv4, uses 32-bit addresses: 232, about 4.3 billion, which is not enough for every device on Earth. IPv6 uses 128-bit addresses, a number so large that running out is not a concern. Over the same decades, the number of transistors on a chip roughly doubled every two years (an observation called Moore's law), which made devices faster, smaller, and cheaper and helped the Internet grow.

5Packets

Information crosses the Internet as a data stream. The stream is cut into chunks, and each chunk is wrapped in a packet. A packet holds a chunk of data plus metadata (data about the data): the source and destination addresses used for routing, and a sequence number used to put the chunks back together.

Figure 2. Packets that take different routes can arrive out of order. The number in each packet's label lets the receiver rebuild the message.

Each packet is routed on its own, so packets from one message can take different paths. As a result, packets may arrive in order, out of order, or not at all. In Figure 2, packets 2 and 4 took faster routes and arrived first; the receiver still rebuilt MEETATNOON!! by sorting on the numbers.

6IP, TCP, and UDP

Three common Internet protocols split the work:

ProtocolJobGood for
IP (Internet Protocol)Gives devices addresses and moves each packet toward its destination. Makes no promise about order or arrival.Every packet uses it
TCP (Transmission Control Protocol)Numbers the packets, has the receiver confirm what arrived, re-sends missing ones, and delivers everything in orderWeb pages, email, file downloads: anything that must be complete
UDP (User Datagram Protocol)Sends packets without waiting for confirmation; a lost packet stays lostLive video, voice calls, games: late data is useless data

Two more names come up constantly. HTTP (and its encrypted form, HTTPS) is how a browser asks a server for a page and how the server sends it back. DNS turns a name like example.com into the numeric IP address that routers use.

The key idea

The Internet is a network of networks that follow open protocols, so anyone can connect and it can grow. Data travels as packets with metadata for routing and reassembly; packets may arrive in order, out of order, or not at all. IP moves packets, TCP makes delivery complete and ordered, and UDP trades reliability for speed.

7The Internet and the Web

The World Wide Web is a system of linked pages, programs, and files. It uses the protocol HTTP, and it runs on the Internet. The Internet is the network underneath; the Web is one service on top of it.

Figure 3. The Web uses the Internet, but so do email, calls, and games. That is why the two words do not mean the same thing.

Web pages are named by URLs. Each part of https://blog.example.com/articles/2024/tips.html means something:

PartIn this URLMeaning
Protocolhttps://How to talk to the server (HTTPS: encrypted HTTP)
SubdomainblogAn optional section of the site
Domain nameexampleThe site's main name; DNS turns it into an IP address
Top-level domain.comThe ending: .com, .org, .edu, .gov, or a country code such as .uk
Path/articles/2024/tips.htmlWhich page or file on the server

8Worked examples

Worked Example 1 Check a path

Is it a path?

In the network of Figure 1, which of these are paths from A to B? (a) A → R1 → R3 → R4 → B (b) A → R1 → R4 → B (c) A → R1 → R2 → R3 → R4 → B

  1. 1
    (a) Every neighboring pair shares a link: A–R1, R1–R3, R3–R4, R4–B. It is a path.
  2. 2
    (b) R1 and R4 have no direct link, so the chain breaks. Not a path.
  3. 3
    (c) A–R1, R1–R2, R2–R3, R3–R4, R4–B are all links, and nothing repeats. It is a path, just a longer one.
Answer: (a) and (c).
Worked Example 2 Use bandwidth

Download time

A 45 MB video downloads over a 15 Mbps connection. How long does it take? What if the bandwidth doubles?

  1. 1
    Convert to bits: 45 MB × 8 = 360 megabits.
  2. 2
    Time = 360 ÷ 15 = 24 seconds.
  3. 3
    Double the bandwidth: 360 ÷ 30 = 12 seconds.
Answer: 24 seconds, then 12 seconds. Twice the bandwidth, half the time.
Worked Example 3 Explain packets

The photo arrived fine

A student sends a photo. Its packets arrive in the order 3, 1, 4, 2. Explain why, and how the photo still appears correctly.

  1. 1
    Each packet is routed separately and can take a different path, so some arrive sooner than others.
  2. 2
    Each packet's metadata includes its sequence number.
  3. 3
    The receiver (using TCP) waits for all of them and puts them in number order before showing the photo.
Answer: Different paths give different arrival times; sequence numbers in the metadata let the receiver reassemble the photo.
Worked Example 4 Choose a protocol

Stream or download?

Which protocol fits each: (a) downloading a software update, (b) a live video call?

  1. 1
    (a) A file with a missing piece will not install. It must be complete, so use TCP.
  2. 2
    (b) A late video frame is useless; waiting for a re-sent one would freeze the call. Use UDP and keep going.
Answer: (a) TCP, (b) UDP.
Worked Example 5 Internet or Web?

Sort the activities

Which of these use the World Wide Web: (a) clicking a link on a news site, (b) sending an email from a mail app, (c) a router forwarding a packet, (d) a browser loading a page by HTTP?

  1. 1
    (a) and (d) involve linked pages and HTTP: the Web.
  2. 2
    (b) Email uses the Internet but not the Web.
  3. 3
    (c) Forwarding packets is the Internet itself.
Answer: (a) and (d). All four use the Internet.

9Common mistakes

Common Mistake 1 · Calling the Web the Internet

The Web is one service that uses the Internet. Email, games, and calls use the Internet without being part of the Web.

Common Mistake 2 · Saying a packet holds only data

Every packet also carries metadata: addresses for routing and a number for reassembly.

Common Mistake 3 · Mixing up bits and bytes

Bandwidth is in bits per second; file sizes are in bytes. Multiply megabytes by 8 before dividing.

Common Mistake 4 · Thinking open means insecure or free

Open protocols are public rules that anyone may follow. Security comes from encryption, and access still costs money.

Explain how the Internet works like this

“The message is split into packets. Each packet carries part of the data plus metadata, including the destination address and a sequence number. Routers forward each packet along whatever path is available, so packets can arrive out of order; the receiver uses the sequence numbers to reassemble them.”

Name the packets, the metadata and what it is for, and what the receiver does.