TCP/IP Mastery for AQA A-Level Computer Science | AQA A-Level 计算机 TCP/IP 考点精讲

📚 TCP/IP Mastery for AQA A-Level Computer Science | AQA A-Level 计算机 TCP/IP 考点精讲

The TCP/IP protocol suite is the backbone of modern networking and a core topic in the AQA A-Level Computer Science specification. Understanding how data travels from an application on one host to an application on another – through layers, encapsulation, addressing and ports – is essential for both the written exam and practical network thinking. This article covers every key concept, protocol and exam detail you need, presented in clear bilingual sections.

TCP/IP 协议族是现代网络的骨干,也是 AQA A-Level 计算机科学大纲的核心主题。理解数据如何从一台主机的应用程序传输到另一台主机的应用程序——通过分层、封装、寻址和端口——对笔试和网络思维都至关重要。本文以清晰的双语小节涵盖了你需要掌握的每个关键概念、协议和考试细节。

1. The TCP/IP Protocol Stack | TCP/IP 协议栈

The TCP/IP model organises network communication into four conceptual layers. From top to bottom they are: Application, Transport, Internet (sometimes called Network) and Link (or Network Access). Each layer provides services to the layer above it and uses services from the layer below, hiding the complexity of lower-level operations. The model was developed by the US Department of Defense and is simpler than the OSI model, yet perfectly captures how the Internet works.

TCP/IP 模型将网络通信组织为四个概念层。从上到下依次是:应用层、传输层、网际层(有时称网络层)和链路层(或网络接入层)。每一层为上层提供服务并使用下层的服务,隐藏了较低层操作的复杂性。该模型由美国国防部开发,比 OSI 模型更简单,却完美地描述了互联网的工作方式。

  • Application Layer: Contains high-level protocols like HTTP, FTP, SMTP that applications use to exchange data.
  • 应用层:包含应用程序用来交换数据的高层协议,如 HTTP、FTP、SMTP。
  • Transport Layer: Ensures end-to-end communication, error recovery and flow control. TCP and UDP operate here.
  • 传输层:确保端到端通信、错误恢复和流量控制。TCP 和 UDP 在此工作。
  • Internet Layer: Handles logical addressing and routing. IP (Internet Protocol) lives here, providing a best-effort delivery service.
  • 网际层:处理逻辑寻址和路由。IP 协议位于此层,提供尽力而为的交付服务。
  • Link Layer: Deals with hardware addressing (MAC) and the physical transmission of bits over a medium, e.g., Ethernet, Wi‑Fi.
  • 链路层:处理硬件寻址(MAC)和在介质上的物理位传输,例如以太网、Wi‑Fi。

2. Application Layer Protocols | 应用层协议

This top layer interfaces directly with software applications. It defines how messages are formatted and exchanged for specific services. When a browser fetches a webpage, it uses HTTP or HTTPS; when an email client sends mail, it uses SMTP. AQA candidates must recognise the purpose of several key protocols and their default port numbers.

这一顶层直接与软件应用程序接口。它定义了消息如何被格式化以及如何为特定服务交换。当浏览器获取网页时,它使用 HTTP 或 HTTPS;当邮件客户端发送邮件时,它使用 SMTP。AQA 考生必须识别若干关键协议的目的及其默认端口号。

Protocol Full Name Typical Use
HTTP / HTTPS Hypertext Transfer Protocol (Secure) Web page transfer
FTP File Transfer Protocol Uploading/downloading files
SMTP Simple Mail Transfer Protocol Sending emails
POP3 / IMAP Post Office Protocol 3 / Internet Message Access Protocol Receiving/retrieving emails
DNS Domain Name System Resolving domain names to IP addresses
DHCP Dynamic Host Configuration Protocol Automatically assigning IP addresses

Application layer protocols rely on the transport layer to deliver their messages reliably or quickly. The choice of transport protocol (TCP or UDP) depends on whether the application needs guaranteed delivery.

应用层协议依赖传输层来可靠或快速地传递消息。选择哪种传输协议(TCP 或 UDP)取决于应用程序是否需要保证交付。


3. Transport Layer: TCP and UDP | 传输层:TCP 与 UDP

The transport layer provides logical communication between applications running on different hosts. The two dominant protocols are the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). TCP is connection-oriented and reliable; UDP is connectionless and lightweight. The exam expects you to compare them and justify when each is appropriate.

传输层提供运行在不同主机上的应用程序之间的逻辑通信。两个主要协议是传输控制协议(TCP)和用户数据报协议(UDP)。TCP 是面向连接且可靠的;UDP 是无连接且轻量的。考试要求你比较它们并说明各自适用的场合。

  • TCP: Establishes a connection before data transfer, numbers every byte, acknowledges received segments, and retransmits lost data. It provides flow control and congestion control. Used for web browsing, email, file transfers – anywhere data integrity matters.
  • TCP:在数据传输前建立连接,为每个字节编号,确认收到的报文段,重传丢失的数据。它提供流量控制和拥塞控制。用于网页浏览、电子邮件、文件传输等数据完整性至关重要的场合。
  • UDP: Sends datagrams without a handshake, no acknowledgements, no retransmissions. It is faster and has lower overhead. Used for live streaming, VoIP, online gaming where speed matters more than occasional packet loss.
  • UDP:不需要握手就发送数据报,没有确认,没有重传。它更快,开销更低。用于直播、VoIP、在线游戏等速度比偶尔丢包更重要的场合。

4. TCP Three-Way Handshake | TCP 三次握手

Before TCP can transfer application data, it must establish a connection using a three-way handshake. This process synchronises sequence numbers and ensures both endpoints are ready to communicate. The handshake is a favourite exam diagram because it illustrates the client–server model clearly.

TCP 在传输应用数据之前,必须通过三次握手建立连接。该过程同步序列号并确保两端都准备好通信。握手是考试中常见的图示题,因为它清晰地展示了客户端-服务器模型。

The three steps are:

三个步骤如下:

  1. SYN: The client sends a segment with the SYN flag set and an initial sequence number x.
  2. SYN:客户端发送一个设置了 SYN 标志的报文段,并带上初始序列号 x。
  3. SYN-ACK: The server replies with a segment that has both SYN and ACK flags set. Its own sequence number is y, and the acknowledgement number is x+1.
  4. SYN-ACK:服务器回复一个同时设置了 SYN 和 ACK 标志的报文段。它自己的序列号是 y,确认号是 x+1。
  5. ACK: The client sends an ACK segment with acknowledgement number y+1. The connection is now established and data can flow.
  6. ACK:客户端发送一个 ACK 报文段,确认号为 y+1。连接现已建立,数据可以开始传输。

A terminated connection uses a four-way handshake (FIN, FIN-ACK, etc.), but the three-way handshake is the critical concept for A-Level.

连接终止使用四次挥手(FIN、FIN-ACK 等),但三次握手是 A-Level 的关键概念。


5. TCP Reliability: Flow Control and Error Checking | TCP 可靠性:流量控制与错误检测

TCP guarantees that data sent from one end arrives correctly and in order at the other. Two mechanisms underpin this reliability: flow control and error checking. Flow control prevents a fast sender from overwhelming a slow receiver, while error checking detects and corrects corrupted or lost segments.

TCP 保证从一端发送的数据能正确且有序地到达另一端。两个机制支撑着这种可靠性:流量控制和错误检测。流量控制防止快速发送方淹没慢速接收方,而错误检测则发现并纠正损坏或丢失的报文段。

Flow control uses a sliding window. The receiver advertises a window size – the number of bytes it can accept beyond the last acknowledged byte. The sender must not send more than this window. As the receiver processes data and frees buffer space, the window slides forward.

流量控制使用滑动窗口。接收方通告一个窗口大小——即它能接受的超过最后一个已确认字节的字节数。发送方发送的数据不能超过这个窗口。随着接收方处理数据并释放缓冲区空间,窗口向前滑动。

Error detection relies on checksums and acknowledgements. Each TCP segment carries a checksum computed over the header and data. If the receiver detects a mismatch, it discards the segment and does not acknowledge it. The sender, after a timeout, retransmits the unacknowledged segment. Sequence numbers let the receiver reassemble segments in the correct order and detect duplicates.

错误检测依赖校验和与确认。每个 TCP 报文段都携带一个根据首部和数据计算出的校验和。如果接收方检测到不匹配,它会丢弃该报文段且不确认。发送方在超时后重传未确认的报文段。序列号使接收方能按正确顺序重组报文段并检测重复。


6. UDP Characteristics and When to Use It | UDP 特性及其适用场景

UDP strips away almost everything that makes TCP reliable. There is no connection setup, no sequencing, no acknowledgements, no flow control. A UDP datagram is a simple fire-and-forget message. Because of this, it has extremely low latency and protocol overhead – just an 8-byte header compared to TCP’s 20 bytes minimum.

UDP 几乎去掉了 TCP 为保证可靠性所做的所有事情。没有连接建立,没有序列号,没有确认,没有流量控制。UDP 数据报是一种简单的“发后不理”的消息。因此,它具有极低的延迟和协议开销——只有 8 字节的首部,而 TCP 最少需要 20 字节。

Typical UDP applications are those where occasional data loss is acceptable but delay is not. Voice over IP (VoIP), live video streaming, online multiplayer games and DNS queries all favour UDP. DNS, for instance, sends a single small request and expects a single reply; the overhead of a TCP handshake for every query would be wasteful. However, DNS also uses TCP for zone transfers or large responses beyond 512 bytes.

典型的 UDP 应用是那些可以接受偶尔数据丢失但无法容忍延迟的场景。VoIP、实时视频流、在线多人游戏和 DNS 查询都倾向于使用 UDP。例如,DNS 发送一个小的请求并期望一个答复;如果每个查询都使用 TCP 握手将会浪费资源。不过,DNS 在区域传输或超过 512 字节的大响应中也会使用 TCP。

UDP still provides a checksum to detect corrupted data, but it does not retransmit – the application layer must handle any necessary recovery.

UDP 仍提供校验和来检测损坏的数据,但它不会重传——应用层必须处理任何必要的恢复。


7. Internet Layer and IP Addressing | 网际层与 IP 寻址

The internet layer is responsible for moving packets from the source host to the destination host across potentially many intermediate routers. The core protocol is the Internet Protocol (IP), which defines a logical addressing scheme and an unreliable, connectionless datagram delivery service. Every device on the Internet is identified by at least one IP address.

网际层负责将数据包从源主机通过可能许多中间路由器传送到目的主机。核心协议是网际协议(IP),它定义了逻辑寻址方案和不可靠、无连接的数据报交付服务。互联网上的每个设备都至少由一个 IP 地址标识。

Routers operate at this layer, examining the destination IP address of each packet and forwarding it along the best path according to their routing tables. IP does not guarantee delivery, order or duplicate protection; those functions are left to the transport layer. Two versions coexist: IPv4 (32-bit addresses) and IPv6 (128-bit addresses).

路由器在这一层工作,检查每个数据包的目的 IP 地址,并根据其路由表沿最佳路径转发。IP 不保证交付、顺序或防止重复;这些功能留给传输层。目前共存两个版本:IPv4(32 位地址)和 IPv6(128 位地址)。


8. IPv4 Addressing and Subnet Masks | IPv4 地址与子网掩码

An IPv4 address is a 32-bit number, typically written in dotted-decimal notation: four octets separated by dots, e.g., 192.168.1.10. In theory, IPv4 can address 2³² (about 4.3 billion) devices. The address contains a network portion and a host portion. The boundary between them is defined by the subnet mask.

IPv4 地址是一个 32 位的数字,通常用点分十进制表示:四个用点分隔的八位组,例如 192.168.1.10。理论上,IPv4 可以寻址 2³²(约 43 亿)个设备。地址包含网络部分和主机部分。两者之间的边界由子网掩码定义。

A subnet mask is also a 32-bit number where a set bit (1) indicates the network part and a clear bit (0) indicates the host part. For example, the mask 255.255.255.0 means the first 24 bits are the network ID and the last 8 bits identify a host. This can be written in CIDR notation as /24, e.g., 192.168.1.0/24. A device uses the subnet mask to determine whether a destination IP is on the same local network or must be sent via a router.

子网掩码也是一个 32 位的数字,其中置位(1)表示网络部分,清零(0)表示主机部分。例如,掩码 255.255.255.0 意味着前 24 位是网络 ID,后 8 位标识主机。这可以用 CIDR 记法写为 /24,例如 192.168.1.0/24。设备使用子网掩码来判断目标 IP 是否在同一个本地网络上,还是必须通过路由器发送。

Exam questions often ask you to calculate the network ID, broadcast address, or the number of usable hosts given an IP and mask. For a /n network, the number of host bits is 32 − n, so the number of usable host addresses is 2^(32−n) − 2 (subtracting the network address and broadcast address).

考试题常常要求你根据给定的 IP 和掩码计算网络 ID、广播地址或可用主机数量。对于 /n 网络,主机位数为 32 − n,因此可用主机地址数为 2^(32−n) − 2(减去网络地址和广播地址)。


9. IPv6 Addressing | IPv6 寻址

IPv6 was developed to solve IPv4 address exhaustion. Its 128-bit addresses provide an astronomically large address space (2¹²⁸). Addresses are written as eight groups of four hexadecimal digits separated by colons, e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Leading zeros in each group and consecutive groups of zeros can be omitted (once per address), making representation more compact.

IPv6 的开发是为了解决 IPv4 地址枯竭。其 128 位地址提供了天文数字般的地址空间(2¹²⁸)。地址表示为八组由冒号分隔的四位十六进制数字,例如 2001:0db8:85a3:0000:0000:8a2e:0370:7334。每组前导零和连续的零组可以被省略(每个地址仅限一次省略),使表示更紧凑。

Besides larger addresses, IPv6 simplifies the header format to speed up router processing, introduces built-in support for IPsec (security), and eliminates the need for Network Address Translation (NAT) in many scenarios. Transition technologies such as dual-stack, tunnelling and translation allow IPv4 and IPv6 networks to coexist. A-Level candidates should know the basic address format and the reasons for moving to IPv6.

除了更大的地址,IPv6 简化了首部格式以加快路由器处理,引入了对 IPsec(安全)的内置支持,并在许多场景中消除了对网络地址转换(NAT)的需求。双栈、隧道和转换等过渡技术使 IPv4 和 IPv6 网络能够共存。A-Level 考生应了解基本的地址格式和转向 IPv6 的原因。


10. Port Numbers and Sockets | 端口号与套接字

An IP address identifies a host, but a port number identifies a specific process or service running on that host. Ports allow a single device to run multiple network applications simultaneously – web server on port 80, email server on port 25, SSH on port 22, each destination distinct. The combination of an IP address and a port number is called a socket.

IP 地址标识主机,而端口号标识该主机上运行的特定进程或服务。端口使单个设备能够同时运行多个网络应用程序——端口 80 上的 Web 服务器、端口 25 上的邮件服务器、端口 22 上的 SSH,每个目的地都不同。IP 地址和端口号的组合称为套接字。

A socket pair uniquely identifies a connection. For a TCP connection between client and server, there are four pieces: source IP, source port, destination IP, destination port. The source port for a client is usually an ephemeral (temporary) high-numbered port assigned by the operating system. Well‑known ports (0–1023) are reserved for standard services; registered ports (1024–49151) for user applications; and dynamic/private ports (49152–65535) for ephemeral use.

套接字对唯一标识一个连接。对于客户端和服务器之间的 TCP 连接,共有四个要素:源 IP、源端口、目的 IP、目的端口。客户端的源端口通常是由操作系统分配的临时高端口号。知名端口(0–1023)保留给标准服务;注册端口(1024–49151)用于用户应用程序;动态/私有端口(49152–65535)用于临时使用。


11. Data Encapsulation in the TCP/IP Stack | TCP/IP 协议栈中的数据封装

As data moves down the sending stack, each layer wraps the payload from the layer above with its own header (and sometimes a trailer). This process is called encapsulation. On the receiving side, the headers are stripped in reverse order – decapsulation. Understanding encapsulation helps explain how protocols at different layers cooperate without needing to know each other’s internals.

当数据沿着发送协议栈下行时,每一层用自己添加的首部(有时还有尾部)包裹来自上层的数据。这个处理称为封装。在接收端,首部按相反顺序被剥离——解封装。理解封装有助于解释不同层的协议如何协作而不需要了解彼此的内部细节。

  • Application layer produces the original message (e.g., HTTP request).
  • 应用层生成原始消息(如 HTTP 请求)。
  • Transport layer adds a TCP or UDP header, creating a segment (TCP) or datagram (UDP). This header contains source and destination ports.
  • 传输层添加 TCP 或 UDP 首部,生成一个报文段(TCP)或数据报(UDP)。这个首部包含源端口和目的端口。
  • Internet layer prepends an IP header, creating an IP packet (or datagram). The IP header holds source and destination IP addresses.
  • 网际层在前面加上 IP 首部,生成 IP 数据包(或数据报)。IP 首部包含源 IP 地址和目的 IP 地址。
  • Link layer adds a frame header (e.g., Ethernet header with MAC addresses) and a trailer (e.g., CRC for error detection). The result is a frame that can be transmitted as bits over the physical medium.
  • 链路层添加帧首部(例如带有 MAC 地址的以太网首部)和尾部(例如用于错误检测的 CRC)。结果是一个可以在物理介质上以比特流传输的帧。

At the receiver, the link layer removes the frame header and trailer, the internet layer processes the IP header and routes the payload up to TCP or UDP, and the transport layer delivers the original data to the correct application port.

在接收端,链路层去除帧首部和尾部,网际层处理 IP 首部并将载荷向上传递给 TCP 或 UDP,传输层将原始数据递送到正确的应用程序端口。


12. Well-Known Protocols and Their Ports | 常见协议与知名端口

Exam questions frequently test your knowledge of which protocol uses which default port and whether it runs over TCP, UDP or both. You must be able to map service names to port numbers and explain why a particular transport protocol is chosen.

考试题经常测试你是否知道哪个协议使用哪个默认端口,以及它是基于 TCP、UDP 还是两者。你必须能够将服务名称映射到端口号,并解释为什么选择特定的传输协议。

Protocol Default Port(s) Transport Purpose
HTTP 80 TCP Unencrypted web pages
HTTPS 443 TCP Secure web pages (TLS/SSL)
FTP (control) 21 TCP File transfer commands
SMTP 25 TCP Sending email
POP3 110 TCP Downloading email
IMAP 143 TCP Managing email on server
DNS 53 TCP & UDP Domain name resolution
DHCP 67 (server), 68 (client) UDP Automatic IP configuration
SSH 22 TCP Secure remote command-line access

Memorising these associations is vital. When a question describes a scenario, identify the required service and immediately recall its transport protocol and port. This forms the basis for many 2–4 mark questions.

记住这些对应关系至关重要。当题目描述一个场景时,确定所需的服务并立即回想其传输协议和端口。这是许多 2–4 分题的基础。


Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading