Skip to content

Computer Systems and Networks

AP Computer Science PrinciplesTopic 4

Video lesson for this topic Open the video page
7:46

Computer Systems and Networks

People call it the cloud. It is not a cloud. This box sits in somebody's home: a router, taking data from your phone and passing it on. This plug is the other…

English narration · English and 中文 subtitles you can switch

4.1

The Internet

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CSN-1
Computer systems and networks facilitate the transfer of data.

CSN-1.A
Explain how computing devices work together in a network. [Skill 5.A]

  • CSN-1.A.1 A computing device is a physical artifact that can run a program. Some examples include computers, tablets, servers, routers, and smart sensors.
  • CSN-1.A.2 A computing system is a group of computing devices and programs working together for a common purpose.
  • CSN-1.A.3 A computer network is a group of interconnected computing devices capable of sending or receiving data.
  • CSN-1.A.4 A computer network is a type of computing system.
  • CSN-1.A.5 A path between two computing devices on a computer network (a sender and a receiver) is a sequence of directly connected computing devices that begins at the sender and ends at the receiver.
  • CSN-1.A.6 Routing is the process of finding a path from sender to receiver.
  • CSN-1.A.7 The bandwidth of a computer network is the maximum amount of data that can be sent in a fixed amount of time.
  • CSN-1.A.8 Bandwidth is usually measured in bits per second.

CSN-1.B
Explain how the Internet works. [Skill 5.A]

  • CSN-1.B.1 The Internet is a computer network consisting of interconnected networks that use standardized, open (nonproprietary) communication protocols.
  • CSN-1.B.2 Access to the Internet depends on the ability to connect a computing device to an Internet-connected device.
  • CSN-1.B.3 A protocol is an agreed-upon set of rules that specify the behavior of a system.
  • CSN-1.B.4 The protocols used in the Internet are open, which allows users to easily connect additional computing devices to the Internet.
  • CSN-1.B.5 Routing on the Internet is usually dynamic; it is not specified in advance.
  • CSN-1.B.6 The scalability of a system is the capacity for the system to change in size and scale to meet new demands.
  • CSN-1.B.7 The Internet was designed to be scalable.

CSN-1.C
Explain how data are sent through the Internet via packets. [Skill 5.A]

  • CSN-1.C.1 Information is passed through the Internet as a data stream. Data streams contain chunks of data, which are encapsulated in packets.
  • CSN-1.C.2 Packets contain a chunk of data and metadata used for routing the packet between the origin and the destination on the Internet, as well as for data reassembly.
  • CSN-1.C.3 Packets may arrive at the destination in order, out of order, or not at all.
  • CSN-1.C.4 IP, TCP, and UDP are common protocols used on the Internet.

CSN-1.D
Describe the differences between the Internet and the World Wide Web. [Skill 5.A]

  • CSN-1.D.1 The World Wide Web is a system of linked pages, programs, and files.
  • CSN-1.D.2 HTTP is a protocol used by the World Wide Web.
  • CSN-1.D.3 The World Wide Web uses the Internet.

Source: College Board AP Course and Exam Description

An RJ45 Ethernet connector — physical links carry packets across the Internet
An RJ45 Ethernet connector — physical links carry packets across the Internet

In January 2008 two undersea cables near Alexandria, Egypt, were cut. Internet service across Egypt, the Gulf and India became very slow for millions of people, yet the Internet did not stop: traffic found other routes around the break. No person chose those new routes. The network was built to do this by itself, and this unit explains how.

The Internet 互联网 is a global network 网络 of networks. Data travels as packets 数据包 – small chunks that are sent separately and reassembled at the destination 目的地. Two ideas make it work at scale:

  • Protocols 协议 are agreed rules for communication. IP (Internet Protocol) addresses and routes 路由 packets; TCP reassembles them in order and re-requests lost ones; HTTP carries web pages; DNS translates a name like example.com into an IP address IP地址.
  • Redundancy 冗余 and routing: there are many possible paths between two points, so if one path fails, packets take another. This makes the Internet fault-tolerant 容错.
The internet is the worldwide network; the web is one service running on it
The internet is the worldwide network; the web is one service running on it

The Internet is designed to be open 开放的 and scalable 可扩展的 – built on standards 标准 anyone can use, so it keeps working as billions of devices 设备 join. Bandwidth 带宽 is the amount of data a connection can carry per second.

Devices, systems, networks and paths

These terms are defined exactly on the exam, each building on the last:

  • A computing device 计算设备 is a physical thing that can run a program: a computer, tablet, server, router or smart sensor.
  • A computing system 计算系统 is a group of devices and programs working together for a common purpose.
  • A computer network 计算机网络 is a group of connected devices that can send or receive data. It is one type of computing system.
  • A path 路径 is a sequence of directly connected devices that starts at the sender and ends at the receiver. Routing is finding a path.

How packets travel. A router 路由器 reads each packet's destination IP address and forwards it toward that address. Routing is dynamic: each packet takes whatever path is best at that moment, so packets of one message can take different paths and arrive out of order. TCP puts them back in order using their sequence numbers.

Information travels as a data stream 数据流, split into chunks. Each chunk goes inside a packet together with metadata 元数据, which is used for routing and for putting the chunks back together:

A data stream split into four chunks; one chunk sits in a packet beside its metadata: origin, destination and packet number
A packet holds a chunk of the data plus the metadata needed to deliver it

Packets may arrive in order, out of order, or not at all. Suppose packets 1 to 5 are sent and 2, 1, 5, 3 arrive. TCP notices that 4 is missing, asks for it again, and gives the program all five in order. UDP passes on what arrived and does not ask for packet 4.

  • TCP aims to provide reliable 可靠的, ordered byte-stream delivery by detecting missing data and retransmitting it. A connection can still fail, so delivery is not guaranteed under every network failure.
  • UDP sends datagrams without built-in delivery acknowledgements, ordering or retransmission. It can avoid waiting for retransmission, but it is not always faster. An application may add its own reliability; time-sensitive video and games may prefer a missing update to a late one.
  • Protocols are layered 分层的: for example, HTTP/1.1 uses TCP over IP. Other HTTP versions can use a different transport. Each layer has a role.
  • Bandwidth is the maximum amount of data that can be sent in a fixed time, usually measured in bits per second; latency 延迟 is the delay for one packet to arrive.

Worked example: how many addresses? An IP address is a binary number of fixed length, so $n$ bits give $2^{n}$ different addresses.

  1. IPv4 uses 32 bits 位: $2^{32} \approx 4.3$ billion addresses — too few for every device on Earth.
  2. IPv6 uses 128 bits: $2^{128}$ addresses.
  3. IPv6 has $\dfrac{2^{128}}{2^{32}} = 2^{96}$ times as many addresses as IPv4.
  4. Each extra bit doubles the number of addresses: going from 32 to 33 bits gives $2 \times 2^{32}$ addresses, not $2^{32} + 1$.

Worked example: bandwidth. How long does a 200-megabyte video take to send over a link with a bandwidth of 50 megabits per second?

  1. Change bytes to bits: $200 \times 8 = 1600$ megabits.
  2. Divide by the rate: $\dfrac{1600}{50} = 32$ seconds.

This is the shortest possible time, because bandwidth is a maximum. Common mistake: forgetting the factor of 8. File sizes are usually given in bytes; bandwidth is given in bits.

The Internet is not the Web

The Internet The World Wide Web 万维网
What it is a network of connected networks a system of linked pages, programs and files
Protocols IP, TCP, UDP and others HTTP
Relationship carries the Web and much else, such as email runs on top of the Internet

So "the Web is down" and "the Internet is down" are different claims. A video call or an email can work with no web page involved.

Why the Internet can grow

The protocols are open, which means nonproprietary: no one needs to ask permission or pay to use them, so anyone can connect another device. Routing is not fixed in advance. Scalability is the capacity of a system to change in size to meet new demands, and because of these two facts the Internet has grown from a few computers to billions.

Explore

How data crosses the Internet in packets

The Internet breaks a message into numbered packets, each addressed and routed independently (often by different paths), then reassembled at the destination. That design makes it fault-tolerant — if one route fails, packets take another.

Vocabulary Train
English
Internet/ˈɪntənet/
network/ˈnetwɜːk/
packets/ˈpækɪts/
destination/ˌdestɪˈneɪʃn/
Protocols/ˈprəʊtəkɒlz/
routes/ruːts/
Redundancy/rɪˈdʌndənsi/
fault-tolerant/fɒlt ˈtɒlərənt/
open/ˈəʊpən/
scalable/ˈskeɪləbl/
standards/ˈstændədz/
devices/dɪˈvaɪsɪz/
Bandwidth/ˈbændwɪdθ/
computing device/kəmˈpjuːtɪŋ dɪˈvaɪs/
computing system/kəmˈpjuːtɪŋ ˈsɪstəm/
computer network/kəmˈpjuːtə ˈnetwɜːk/
path/pæθ/
router/ˈruːtə/
data stream/ˈdeɪtə striːm/
metadata/ˌmetəˈdeɪtə/
reliable/rɪˈlaɪəbl/
layered/ˈleɪəd/
latency/ˈleɪtənsi/
bits/bɪts/
World Wide Web/wɜːld waɪd web/
IP address/ˌaɪ ˈpiː əˈdres/
Watch lesson
4.2

Fault Tolerance

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CSN-1
Computer systems and networks facilitate the transfer of data.

CSN-1.E
For fault-tolerant systems, like the Internet:
a. Describe the benefits of fault tolerance. [Skill 1.D]
b. Explain how a given system is fault-tolerant. [Skill 5.A]
c. Identify vulnerabilities to failure in a system. [Skill 1.D]

  • CSN-1.E.1 The Internet has been engineered to be fault-tolerant, with abstractions for routing and transmitting data.
  • CSN-1.E.2 Redundancy is the inclusion of extra components that can be used to mitigate failure of a system if other components fail.
  • CSN-1.E.3 One way to accomplish network redundancy is by having more than one path between any two connected devices.
  • CSN-1.E.4 If a particular device or connection on the Internet fails, subsequent data will be sent via a different route, if possible.
  • CSN-1.E.5 When a system can support failures and still continue to function, it is called fault-tolerant. This is important because elements of complex systems fail at unexpected times, often in groups, and fault tolerance allows users to continue to use the network.
  • CSN-1.E.6 Redundancy within a system often requires additional resources but can provide the benefit of fault tolerance.
  • CSN-1.E.7 The redundancy of routing options between two points increases the reliability of the Internet and helps it scale to more devices and more people.

Source: College Board AP Course and Exam Description

A Wi-Fi router: the local gateway that forwards packets toward the wider Internet
A Wi-Fi router: the local gateway that forwards packets toward the wider Internet

A system is fault-tolerant if it keeps working even when part of it fails. The Internet achieves this through redundant connections: because packets can be routed along multiple paths, the failure of one router or cable does not stop communication – traffic simply reroutes. Fault tolerance costs extra resources (the redundant paths) but greatly improves reliability 可靠性. A single path with no backup is not fault-tolerant.

Why it matters: parts of a large system fail at unexpected times, often several together. Fault tolerance lets people keep using the network while repairs happen. Having more than one path between any two connected devices is the usual form of redundancy, and it also helps the Internet grow, because new devices need not depend on any single link.

Worked example: which failures break the network? In the network below, the lines are connections between computers.

A network of seven computers: A connects to B and C; B connects to C and D; C connects to E; D connects to E and F; E connects to F; F connects to G by a single line
  1. Can A still reach F if one connection fails? Yes. Every connection on one route has a backup route 备用路由: if A–B fails, A–C–E–F still works.

  2. Smallest number of failures that cut A off from F? Two: for example A–B and A–C, because those are A's only two connections.

  3. Is G fault-tolerant? No. G has one connection, F–G. If it fails, G cannot reach anyone, so F–G is a single point of failure 单点故障.

  4. How would you fix that? Add one more connection to G, for example E–G. Now G has two paths, and a single failure cannot cut it off.

Exam skill: to find whether a failure disconnects two computers, cross out the failed connections and look for any remaining path between them.

Worked example: what redundancy costs. Five computers are joined in three ways.

Layout Connections Failures it can always survive
A line, each joined to the next 4 0
A ring 5 1
Every computer joined to every other 10 3

The ring costs one extra connection and survives any single failure. The full layout survives more but needs twice as many connections. Redundancy always trades extra resources for reliability.

Packet switching sends packets by independent routes, so the network tolerates a failed link
Packet switching sends packets by independent routes, so the network tolerates a failed link
Vocabulary Train
English
reliability/rɪˌlaɪəˈbɪlɪti/
backup route/ˈbækʌp ruːt/
single point of failure/ˈsɪŋɡl pɔɪnt ɒv ˈfeɪlɪə/
4.3

Parallel and Distributed Computing

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CSN-2
Parallel and distributed computing leverage multiple computers to more quickly solve complex problems or process large data sets.

CSN-2.A
For sequential, parallel, and distributed computing:
a. Compare problem solutions. [Skill 1.D]
b. Determine the efficiency of solutions. [Skill 1.D]

  • CSN-2.A.1 Sequential computing is a computational model in which operations are performed in order one at a time.
  • CSN-2.A.2 Parallel computing is a computational model where the program is broken into multiple smaller sequential computing operations, some of which are performed simultaneously.
  • CSN-2.A.3 Distributed computing is a computational model in which multiple devices are used to run a program.
  • CSN-2.A.4 Comparing efficiency of solutions can be done by comparing the time it takes them to perform the same task.
  • CSN-2.A.5 A sequential solution takes as long as the sum of all of its steps.
  • CSN-2.A.6 A parallel computing solution takes as long as its sequential tasks plus the longest of its parallel tasks.
  • CSN-2.A.7 The "speedup" of a parallel solution is measured in the time it took to complete the task sequentially divided by the time it took to complete the task when done in parallel.

CSN-2.B
Describe benefits and challenges of parallel and distributed computing. [Skill 1.D]

  • CSN-2.B.1 Parallel computing consists of a parallel portion and a sequential portion.
  • CSN-2.B.2 Solutions that use parallel computing can scale more effectively than solutions that use sequential computing.
  • CSN-2.B.3 Distributed computing allows problems to be solved that could not be solved on a single computer because of either the processing time or storage needs involved.
  • CSN-2.B.4 Distributed computing allows much larger problems to be solved quicker than they could be solved using a single computer.
  • CSN-2.B.5 When increasing the use of parallel computing in a solution, the efficiency of the solution is still limited by the sequential portion. This means that at some point, adding parallel portions will no longer meaningfully increase efficiency.

Source: College Board AP Course and Exam Description

Data-centre server racks: distributed computing spreads work across many machines
Data-centre server racks: distributed computing spreads work across many machines
  • Sequential computing 顺序计算 runs one operation at a time.
  • Parallel computing 并行计算 splits a task into parts that run at the same time on multiple processors 处理器, finishing faster.
  • Distributed computing 分布式计算 uses many computers connected by a network to work on one problem – essential for problems too big for a single machine.
Parallel computing: many processors work at the same time
Parallel computing: many processors work at the same time

A parallel solution's speedup 加速比 is the sequential time divided by the parallel time. Speedup is limited: parts that must run in sequence cannot be sped up by adding processors, so doubling the processors rarely doubles the speed.

Two rules give almost every answer:

  • A sequential solution takes as long as the sum of all its steps.
  • A parallel solution takes as long as its sequential steps plus the longest of the steps that run at the same time.

Worked example. A task has a part that must run sequentially, taking $40$ seconds, plus a parallelizable part that takes $60$ seconds on one processor – so on a single processor the whole task takes $40+60=100$ seconds. Spread the parallel part across $3$ processors and it takes $\tfrac{60}{3}=20$ seconds, so the total parallel time is $40+20=60$ seconds and the speedup is $\tfrac{100}{60}\approx1.67$. The $40$-second sequential part is a floor: even with infinitely many processors the task can never finish in under $40$ seconds.

Bars of total time for 1 to 12 processors: 100, 70, 60 and on down to 45 seconds, never below a dashed line at 40 seconds
Each extra processor helps less: the sequential part sets a floor

So at some point adding processors no longer helps in any useful way. The first extra processor saves 30 seconds; going from 6 to 12 processors saves only 5. The speedup here can never reach $\tfrac{100}{40}=2.5$.

Worked example: two processors, three independent processes. Processes P, Q and R take $50$, $40$ and $30$ seconds and do not depend on each other. Each processor runs one process at a time.

  1. Sequentially (one processor): $50 + 40 + 30 = 120$ seconds.
  2. With two processors, try each split and take the longer processor's time: $\{50\}, \{40, 30\} \to 70$; $\{50, 30\}, \{40\} \to 80$; $\{50, 40\}, \{30\} \to 90$.
  3. The best split finishes in 70 seconds: one processor runs P while the other runs Q then R.
  4. Speedup $= \dfrac{120}{70} \approx 1.71$.

Worked example: steps that must wait. Steps X (20 s) and Y (30 s) can run at the same time, but step Z (10 s) needs both results first. Two processors are available.

  1. Sequentially: $20 + 30 + 10 = 60$ seconds.
  2. In parallel: X and Y run together and finish after the longer one, 30 seconds. Then Z runs: $30 + 10 = 40$ seconds.
  3. Speedup $= \dfrac{60}{40} = 1.5$.

Common mistake: adding every step in the parallel case, or dividing the total by the number of processors. Neither follows the rule, unless the work really does split evenly with no sequential part.

Why distributed computing? Some problems cannot be solved on one computer at all, because they would take too long or need too much storage. Search engines and weather forecasts are examples. Spreading the work over many devices solves much larger problems more quickly. Parallel solutions also scale better than sequential ones: when the data grow, you can add processors. The cost is that the parts must be coordinated, and any part that must run in sequence still limits the speed.

Exam skill: given the times for the sequential and parallel portions of a task, be able to calculate the total parallel time and the speedup.

Vocabulary Train
English
Sequential computing/siːˈkwenʃl kəmˈpjuːtɪŋ/
Parallel computing/ˈpærəlel kəmˈpjuːtɪŋ/
processors/ˈprəʊsesəz/
Distributed computing/ˈdɪstrɪbjuːtɪd kəmˈpjuːtɪŋ/
speedup/ˈspiːdʌp/
4.3

Practice

Answer each before reading the answers below.

  1. Explain how a file is sent across the Internet in packets, and why the packets may arrive out of order.
  2. Name the protocol that does each job: gives devices addresses and routes packets; makes sure all packets arrive and are reassembled; turns domain names into IP addresses.
  3. Devices A, B and C are connected in a line: A–B–C. Is the network fault-tolerant? How could you make it so?
  4. Three tasks take $40$, $30$ and $50$ s. Find the time on one processor, the shortest time on two processors running in parallel, and the speedup.
  5. How many bits are in an IPv4 address and an IPv6 address? Why was IPv6 introduced?
  6. Explain the difference between the Internet and the World Wide Web.
4.3

Answers

  1. The file is split into packets, each with a source address, destination address and sequence information. Packets can take different routes, so they may arrive out of order; the receiver reassembles them.
  2. IP; TCP; DNS.
  3. No: if B fails, A cannot reach C. Adding a direct link from A to C gives a redundant path.
  4. One processor: $40 + 30 + 50 = 120$ s. Two: $50$ s on one and $40 + 30 = 70$ s on the other, so $70$ s. Speedup $= 120 \div 70 \approx 1.7$.
  5. IPv4 has $32$ bits ($2^{32}$, about $4.3$ billion addresses); IPv6 has $128$ bits. IPv4 addresses were running out.
  6. The Internet is the network of connected devices and the protocols that carry data. The Web is one service that runs on it: linked pages accessed with HTTP.
4.3

Exam tips

  • Describe how data travels in packets over a redundant, fault-tolerant network of independent routers.
  • Know that protocols (IP, TCP, HTTP) are agreed rules, and that open standards let different systems interoperate 互操作.
  • Explain scalability 可扩展性 and how the Internet grows without central control 集中控制.
  • Contrast bandwidth (rate) with latency (delay), and describe the DNS name-to-address lookup.
  • Discuss the digital divide 数字鸿沟 and security basics (encryption 加密, authentication 身份验证) in plain terms.
Vocabulary Train
English
interoperate/ˌɪntəˈrɒpəreɪt/
scalability/ˌskeɪləˈbɪlɪti/
central control/ˈsentrəl kənˈtrəʊl/
digital divide/ˈdɪdʒɪtl dɪˈvaɪd/
encryption/enˈkrɪpʃn/
authentication/ɔːˌθentɪˈkeɪʃn/

Interactive lessons on this topic

Work through it step by step, with instant-check exercises.

Past Papers

More topics in AP Computer Science Principles

Log in or create account

IGCSE, A-Level & AP