跳到主要内容

计算机系统与网络

AP 计算机科学原理知识点 4

本主题的视频课程 打开视频页面
7:47

计算机系统与网络

人们称之为云。它不是云。这个盒子放在某人的家里:一个路由器,接收你手机的数据并转发。这个插头是另一端…

英文讲解 · 可切换中英文字幕

4.1

互联网

教学大纲

持久理解 (CSN-1): 计算机系统和网络促进数据的传输。

学习目标 CSN-1.A: 解释计算设备如何在网络中协同工作。[技能 5.A]

  • CSN-1.A.1 计算设备是一种可以运行程序的物理实体。示例包括计算机、平板电脑、服务器、路由器和智能传感器。
  • CSN-1.A.2 计算系统是一组为共同目标而协同工作的计算设备和程序。
  • CSN-1.A.3 计算机网络是一组互联的计算设备,能够发送或接收数据。
  • CSN-1.A.4 计算机网络是计算系统的一种类型。
  • CSN-1.A.5 计算机网络上两个计算设备(发送方和接收方)之间的路径是从发送方开始并以接收方结束的一系列直接相连的计算设备序列。
  • CSN-1.A.6 路由是寻找从发送方到接收方路径的过程。
  • CSN-1.A.7 计算机网络的带宽是指在固定时间内可以发送的最大数据量。
  • CSN-1.A.8 带宽通常以比特每秒为单位进行测量。

学习目标 CSN-1.B: 解释互联网的工作原理。[技能 5.A]

  • CSN-1.B.1 互联网是由使用标准化、开放(非专有)通信协议互联的网络组成的计算机网络。
  • CSN-1.B.2 访问互联网取决于将计算设备连接到已接入互联网的设备的能力。
  • CSN-1.B.3 协议是一套约定好的规则,用于规定系统的行为。
  • CSN-1.B.4 互联网使用的协议是开放的,这允许用户轻松地将额外的计算设备连接到互联网。
  • CSN-1.B.5 互联网上的路由通常是动态的;它不是预先指定的。
  • CSN-1.B.6 系统的可扩展性是指系统改变其大小和规模以满足新需求的能力。
  • CSN-1.B.7 互联网在设计时即考虑了可扩展性。

学习目标 CSN-1.C: 解释数据如何通过数据包经由互联网发送。[技能 5.A]

  • CSN-1.C.1 信息作为数据流在因特网上传递。数据流包含数据块,这些数据块被封装在数据包中。
  • CSN-1.C.2 数据包包含一个数据块以及用于在互联网上对数据包进行路由和重新组装元数据。
  • CSN-1.C.3 数据包可能按序到达目的地,也可能乱序到达,甚至根本不会到达。
  • CSN-1.C.4 IP、TCP 和 UDP 是在互联网上常用的协议。

学习目标 CSN-1.D: 描述互联网与万维网之间的区别。[技能 5.A]

  • CSN-1.D.1 万维网是一个由链接的页面、程序和文件组成的系统。
  • CSN-1.D.2 HTTP 是万维网使用的协议。
  • CSN-1.D.3 万维网使用互联网。

来源:College Board AP 课程与考试说明

English
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.

探索

数据如何在互联网中以数据包形式传输

互联网将消息分割为编号的数据包,每个数据包独立寻址和路由(通常通过不同路径),然后在目的地重新组装。这种设计使其具有容错性——如果某条路由失败,数据包会选择其他路径。

词汇 训练
English 中文 拼音
Internet/ˈɪntənet/ 互联网 hù lián wǎng
network/ˈnetwɜːk/ 网络 wǎng luò
packets/ˈpækɪts/ 数据包 shù jù bāo
destination/ˌdestɪˈneɪʃn/ 目的地 mù dì dì
Protocols/ˈprəʊtəkɒlz/ 协议 xié yì
routes/ruːts/ 路由 lù yóu
Redundancy/rɪˈdʌndənsi/ 冗余 rǒng yú
fault-tolerant/fɒlt ˈtɒlərənt/ 容错 róng cuò
open/ˈəʊpən/ 开放的 kāi fàng de
scalable/ˈskeɪləbl/ 可扩展的 kě kuò zhǎn de
standards/ˈstændədz/ 标准 biāo zhǔn
devices/dɪˈvaɪsɪz/ 设备 shè bèi
Bandwidth/ˈbændwɪdθ/ 带宽 dài kuān
computing device/kəmˈpjuːtɪŋ dɪˈvaɪs/ 计算设备 jì suàn shè bèi
computing system/kəmˈpjuːtɪŋ ˈsɪstəm/ 计算系统 jì suàn xì tǒng
computer network/kəmˈpjuːtə ˈnetwɜːk/ 计算机网络 jì suàn jī wǎng luò
path/pæθ/ 路径 lù jìng
router/ˈruːtə/ 路由器 lù yóu qì
data stream/ˈdeɪtə striːm/ 数据流 shù jù liú
metadata/ˌmetəˈdeɪtə/ 元数据 yuán shù jù
reliable/rɪˈlaɪəbl/ 可靠的 kě kào de
layered/ˈleɪəd/ 分层的 fēn céng de
latency/ˈleɪtənsi/ 延迟 yán chí
bits/bɪts/ 位 wèi
World Wide Web/wɜːld waɪd web/ 万维网 wàn wéi wǎng
IP address/ˌaɪ ˈpiː əˈdres/ IP地址 IP dì zhǐ
4.2

容错

教学大纲

持久理解(CSN-1): 计算机系统和网络促进数据的传输。

学习目标 CSN-1.E: 对于容错系统,例如互联网: a. 描述容错性的优势。[技能 1.D] b. 解释给定系统是如何实现容错的。[技能 5.A] c. 识别系统中导致故障的脆弱点。[技能 1.D]

  • CSN-1.E.1 互联网经过设计具有容错性,包含用于路由和传输数据的抽象机制。
  • CSN-1.E.2 冗余是指包含额外的组件,以便在其他组件发生故障时能够缓解系统的整体失效。
  • CSN-1.E.3 实现网络冗余的一种方法是在任意两个已连接设备之间提供多条路径。
  • CSN-1.E.4 如果互联网上的特定设备或连接发生故障,后续数据将尽可能通过不同的路由发送。
  • CSN-1.E.5 当系统能够在支持故障的同时继续正常运作时,该系统被称为容错系统。这一点非常重要,因为复杂系统的组成部分往往在意外时间发生故障,且经常以群体形式出现;而容错性允许用户继续使用网络。
  • CSN-1.E.6 系统内部的冗余通常需要额外的资源,但可以提供容错的优势。
  • CSN-1.E.7 两点之间路由选项的冗余增加了互联网的可靠性,并帮助其扩展以支持更多的设备和用户。

来源:College Board AP 课程与考试说明

English
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
词汇 训练
English 中文 拼音
reliability/rɪˌlaɪəˈbɪlɪti/ 可靠性 kě kào xìng
backup route/ˈbækʌp ruːt/ 备用路由 bèi yòng lù yóu
single point of failure/ˈsɪŋɡl pɔɪnt ɒv ˈfeɪlɪə/ 单点故障 dān diǎn gù zhàng
4.3

并行与分布式计算

教学大纲

持久理解 (CSN-2): 并行和分布式计算利用多台计算机更快地解决复杂问题或处理大规模数据集。

学习目标 CSN-2.A: 针对顺序计算、并行计算和分布式计算: a. 比较问题解决方案。[技能 1.D] b. 确定解决方案的效率。[技能 1.D]

  • CSN-2.A.1 顺序计算 是一种计算模型,其中操作按顺序逐个执行。
  • CSN-2.A.2 并行计算 是一种计算模型,其中程序被分解为多个较小的顺序计算操作,其中一些操作同时进行。
  • CSN-2.A.3 分布式计算 是一种计算模型,其中使用多个设备来运行一个程序。
  • CSN-2.A.4 通过比较它们完成相同任务所需的时间,可以比较解决方案的效率。
  • CSN-2.A.5 顺序解决方案所花费的时间等于其所有步骤时间的总和。
  • CSN-2.A.6 并行计算解决方案所花费的时间等于其顺序任务时间加上其并行任务中最长的时间。
  • CSN-2.A.7 并行解决方案的“加速比”是通过用顺序完成该任务所需的时间除以并行完成该任务所需的时间来衡量的。

学习目标 CSN-2.B: 描述并行和分布式计算的优势与挑战。[技能 1.D]

  • CSN-2.B.1 并行计算由并行部分和顺序部分组成。
  • CSN-2.B.2 使用并行计算的解决方案比使用顺序计算的解决方案具有更好的可扩展性。
  • CSN-2.B.3 分布式计算使得原本因处理时间或存储需求而在单台计算机上无法解决的问题得以解决。
  • CSN-2.B.4 分布式计算能够比单台计算机更快地解决规模大得多的问题。
  • CSN-2.B.5 当在解决方案中增加并行计算的使用时,解决方案的效率仍受限于顺序部分。这意味着在某些时候,增加并行部分将不再能显著提高效率。

来源:College Board AP 课程与考试说明

English
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 处理器, potentially 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.

词汇 训练
English 中文 拼音
Sequential computing/siːˈkwenʃl kəmˈpjuːtɪŋ/ 顺序计算 shùn xù jì suàn
Parallel computing/ˈpærəlel kəmˈpjuːtɪŋ/ 并行计算 bìng xíng jì suàn
processors/ˈprəʊsesəz/ 处理器 chǔ lǐ qì
Distributed computing/ˈdɪstrɪbjuːtɪd kəmˈpjuːtɪŋ/ 分布式计算 fēn bù shì jì suàn
speedup/ˈspiːdʌp/ 加速比 jiā sù bǐ
4.3

练习

English

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

答案

English
  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

考试技巧

English
  • 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.
词汇 训练
English 中文 拼音
interoperate/ˌɪntəˈrɒpəreɪt/ 互操作 hù cāo zuò
scalability/ˌskeɪləˈbɪlɪti/ 可扩展性 kě kuò zhǎn xìng
central control/ˈsentrəl kənˈtrəʊl/ 集中控制 jí zhōng kòng zhì
digital divide/ˈdɪdʒɪtl dɪˈvaɪd/ 数字鸿沟 shù zì hóng gōu
encryption/enˈkrɪpʃn/ 加密 jiā mì
authentication/ɔːˌθentɪˈkeɪʃn/ 身份验证 shēn fèn yàn zhèng

该知识点的互动课程

逐步完成,配合即时检查练习。

历年真题

更多 AP 计算机科学原理 知识点

IGCSE, A-Level & AP