📚 TCP/IP Key Points for CIE A-Level Computer Science | TCP/IP 考点精讲
The TCP/IP protocol suite is the backbone of the modern internet and a core topic in the CIE A-Level Computer Science syllabus. Mastering it requires a clear understanding of the four-layer model, addressing schemes, transport layer mechanisms, and common application protocols. This article breaks down every essential concept, ensuring you are fully equipped for the exam.
TCP/IP 协议族是现代互联网的支柱,也是 CIE A-Level 计算机科学教学大纲中的核心主题。要掌握它,需要清晰理解四层模型、寻址方案、传输层机制以及常见应用协议。本文分解每个关键概念,确保你为考试做好充分准备。
1. The TCP/IP Four-Layer Model | TCP/IP 四层模型
The TCP/IP model used by CIE consists of four layers: Application, Transport, Internet, and Network Access. This simplifies the OSI model while retaining all functionality needed for real-world networking. Each layer adds its own header (encapsulation) during sending and removes it (decapsulation) upon receipt.
CIE 使用的 TCP/IP 模型由四层组成:应用层、传输层、互联网层和网络接入层。它在保留实际网络所需全部功能的同时简化了 OSI 模型。每一层在发送时添加自己的头部(封装),在接收时移除头部(解封装)。
Encapsulation ess). On receiving, the process reverses, with each layer verifying and removing its header.
封装顺序为:应用数据 → TCP/UDP 段(传输层)→ IP 数据包(互联网层)→ 帧(网络接入层)。接收时过程相反,每一层验证并移除其头部。
Key protocols at each layer: Application (HTTP, FTP, SMTP, DNS), Transport (TCP, UDP), Internet (IP, ICMP), Network Access (Ethernet, Wi-Fi). You must be able to relate protocols to the correct layer for exam questions.
每一层的关键协议:应用层(HTTP, FTP, SMTP, DNS),传输层(TCP, UDP),互联网层(IP, ICMP),网络接入层(Ethernet, Wi-Fi)。你必须能将协议对应到正确的层来回答考题。
2. IP Addressing (IPv4) and Subnet Masks | IP 地址 (IPv4) 和子网掩码
An IPv4 address is a 32-bit value written in dotted decimal notation, e.g., 192.168.1.10. It consists of a network portion and a host portion, determined by the subnet mask. The mask identifies which bits belong to the network by using 1s; for example, 255.255.255.0 means the first 24 bits are the network part.
IPv4 地址是一个 32 位的数值,用点分十进制写法表示,如 192.168.1.10。它由网络部分和主机部分组成,由子网掩码决定。掩码用 1 标识哪些位属于网络;例如 255.255.255.0 表示前 24 位是网络部分。
The network address is obtained by performing a bitwise AND between the IP address and the mask. Two devices with the same network address are on the same local network and can communicate without a router.
网络地址通过对 IP 地址和掩码执行按位与运算得到。具有相同网络地址的两台设备处于同一本地网络,无需路由器即可通信。
| IP: 192.168.1.10 / 11000000 10101000 00000001 00001010 |
| Mask: 255.255.255.0 / 11111111 11111111 11111111 00000000 |
| AND: 192.168.1.0 (Network address) |
Subnetting divides a larger network into smaller subnetworks, improving security and reducing broadcast traffic. By borrowing host bits to extend the network portion, we create subnets. The number of usable subnets is 2ⁿ where n is the number of borrowed bits.
子网划分将较大的网络分成较小的子网,提高安全性并减少广播流量。通过借主机位扩展网络部分来创建子网。可用子网数为 2ⁿ,其中 n 是借用的位数。
CIDR notation combines the network address with the prefix length: 192.168.1.0/24. The /24 indicates 24 bits for the network, leaving 8 bits for hosts. The exam often asks you to calculate the number of usable hosts (2ʰ − 2, where h is host bits, subtracting network and broadcast addresses).
CIDR 记法将网络地址与前缀长度合并:192.168.1.0/24。/24 表示 24 位用于网络,剩余 8 位给主机。考试经常要求计算可用主机数(2ʰ − 2,其中 h 为主机位数,减去网络地址和广播地址)。
3. IPv6: The Next-Generation Protocol | IPv6:下一代协议
IPv6 was designed to overcome IPv4 address exhaustion. It uses 128-bit addresses, providing an astronomically large address space. An IPv6 address is written in eight groups of four hexadecimal digits, separated by colons, e.g., 2001:0db8:85a3::8a2e:0370:7334.
IPv6 旨在解决 IPv4 地址枯竭问题。它使用 128 位地址,提供天文数字的地址空间。IPv6 地址用八组四位十六进制数书写,用冒号分隔,例如 2001:0db8:85a3::8a2e:0370:7334。
Leading zeros in each group can be omitted, and one consecutive run of zero groups can be replaced with double colons (::) only once per address. The exam may test your ability to compress or expand IPv6 addresses.
每组前导零可省略,一段连续的零组可用双冒号 (::) 替代,但每个地址只能使用一次。考试可能考查你压缩或展开 IPv6 地址的能力。
Unlike IPv4, IPv6 does not use broadcast. Instead, it uses multicast and anycast. Network discovery uses Neighbor Discovery Protocol (NDP). For the CIE syllabus, you need to know the benefits: larger address space, simplified header, built-in security (IPsec), and stateless address autoconfiguration (SLAAC).
与 IPv4 不同,IPv6 不使用广播。它使用多播和任播。网络发现使用邻居发现协议 (NDP)。按照 CIE 考纲,你需要了解其优点:更大的地址空间、简化的头部、内置安全性 (IPsec) 和无状态地址自动配置 (SLAAC)。
4. Transport Layer: TCP vs UDP | 传输层:TCP 与 UDP 对比
On the Transport layer, TCP provides a reliable, connection-oriented stream. It guarantees delivery through sequence numbers, acknowledgments, retransmissions, and flow control (sliding window). The three-way handshake (SYN, SYN-ACK, ACK) establishes connections, and FIN flags terminate them.
在传输层,TCP 提供可靠的、面向连接的流。它通过序列号、确认、重传和流量控制(滑动窗口)保证交付。三次握手(SYN, SYN-ACK, ACK)建立连接,FIN 标志终止连接。
UDP is connectionless and unreliable. It sends datagrams without establishing a connection, no sequencing, and no retransmission. This makes it lightweight and fast, ideal for real-time applications like VoIP, live streaming, and online gaming, where a few lost packets are acceptable.
UDP 是无连接的、不可靠的。它发送数据报时不建立连接,无序列号,无重传。这使其轻量快速,适合 VoIP、直播、在线游戏等实时应用,这些场景可接受少量丢失的数据包。
Exam questions often ask you to compare TCP and UDP in terms of speed, overhead, reliability, and use cases. Memorize the key differences and be ready to justify which protocol is appropriate for a given scenario.
考题常要求比较 TCP 和 UDP 在速度、开销、可靠性和使用场景方面的差异。记住关键区别,并准备好论证给定场景下哪种协议更合适。
5. Ports and Sockets | 端口与套接字
A port is a 16-bit number (0–65535) used by the transport layer to direct data to the correct application. Common well-known ports: HTTP (80), HTTPS (443), FTP (21 for control, 20 for data), SMTP (25), POP3 (110), IMAP (143), DNS (53). The exam expects you to know these associations.
端口是一个 16 位数字(0–65535),传输层用它把数据导向正确的应用。常见知名端口:HTTP (80)、HTTPS (443)、FTP(21 控制,20 数据)、SMTP (25)、POP3 (110)、IMAP (143)、DNS (53)。考试要求你了解这些对应关系。
A socket is the combination of an IP address and a port number, e.g., 192.168.1.10:80. It provides a unique endpoint for communication. A pair of sockets (client IP+port, server IP+port) identifies a specific TCP connection.
套接字是 IP 地址和端口号的组合,例如 192.168.1.10:80。它提供一个唯一的通信端点。一对套接字(客户端 IP+端口,服务器 IP+端口)标识一个特定的 TCP 连接。
TCP uses client ports (ephemeral ports) typically chosen randomly above 1023. The server binds to a well-known port. In a session, the same server port can handle many connections simultaneously because each client's IP and port differ.
TCP 使用的客户端端口(临时端口)通常在 1023 以上随机选择。服务器绑定到知名端口。在一个会话中,同一服务器端口可以同时处理多连接,因为每个客户端的 IP 和端口不同。
6. Network Address Translation (NAT) | 网络地址转换 (NAT)
NAT enables multiple devices on a private network to share a single public IP address. The NAT router replaces the private source IP and port with its own public IP and a unique ephemeral port, maintaining a translation table to forward return traffic correctly.
NAT 使私有网络上的多台设备共享一个公网 IP 地址。NAT 路由器将私有源 IP 和端口替换为自己的公网 IP 和一个唯一的临时端口,并维护一个转换表,以便正确转发返回流量。
This conserves IPv4 addresses and adds a layer of security by hiding internal addresses. However, it can break end-to-end connectivity, causing problems for protocols that embed IP addresses in payloads (like FTP in active mode).
这节约了 IPv4 地址,并通过隐藏内部地址增加了一层安全性。但它会破坏端到端连通性,给在载荷中嵌入 IP 地址的协议(如主动模式的 FTP)带来问题。
CIE often asks about the role of NAT in a home router scenario and its benefits/drawbacks. Port forwarding is a related concept where specific inbound traffic is forwarded to a private host based on the destination port.
CIE 常问及 NAT 在家用路由器场景中的作用及其优缺点。端口转发是一个相关概念,根据目标端口将特定的入站流量转发到私有主机。
7. Application Layer Protocols in Detail | 应用层协议详解
HTTP/HTTPS: Hypertext Transfer Protocol (Secure). HTTP uses TCP port 80, HTTPS uses TCP 443. It is stateless, but cookies enable stateful sessions. Request methods include GET, POST, HEAD. HTTPS uses TLS/SSL for encryption.
HTTP/HTTPS:超文本传输协议(安全)。HTTP 使用 TCP 80 端口,HTTPS 使用 TCP 443 端口。它本身是无状态的,但 Cookie 可启用有状态会话。请求方法包括 GET、POST、HEAD。HTTPS 使用 TLS/SSL 加密。
FTP: File Transfer Protocol. Uses a control connection (TCP 21) for commands and a data connection (TCP 20 or random negotiated port) for file transfers. Active mode allows the server to initiate the data connection back to the client; passive mode (PASV) has the client initiate both to avoid firewall issues.
FTP:文件传输协议。使用控制连接(TCP 21)传命令,数据连接(TCP 20 或随机协商端口)传文件。主动模式允许服务器向客户端发起数据连接;被动模式 (PASV) 由客户端发起两个连接以避免防火墙问题。
SMTP: Simple Mail Transfer Protocol (TCP 25 or 587) is used to send emails from client to server and between servers. It uses a push model. POP3 (110) and IMAP (143) are used to retrieve emails; IMAP keeps messages on the server and supports folders, while POP3 downloads and deletes by default.
SMTP:简单邮件传输协议(TCP 25 或 587)用于从客户端到服务器以及服务器之间发送邮件,采用推送模型。POP3 (110) 和 IMAP (143) 用于接收邮件;IMAP 将邮件保存在服务器并支持文件夹,POP3 默认下载后删除邮件。
DNS: ursively or iteratively to get the final answer. DNS hierarchy: root servers → TLD servers → authoritative servers.
DNS:域名系统将人类可读的名称解析为 IP 地址。它在 53 端口使用 UDP(有时也使用 TCP)。解析器通过递归或迭代查询名字服务器获得最终答案。DNS 层级:根服务器 → 顶级域名服务器 → 权威服务器。
8. The Three-Way Handshake and TCP Reliability | 三次握手与 TCP 可靠性
The three-way handshake establishes a TCP connection: Client sends SYN with initial sequence number x. Server replies with SYN-ACK, acknowledging x+1 and supplying its own sequence number y. Client sends ACK acknowledging y+1. Connection is now ESTABLISHED.
三次握手建立 TCP 连接:客户端发送 SYN,带有初始序列号 x。服务器回复 SYN-ACK,确认 x+1 并提供自己的序列号 y。客户端发送 ACK 确认 y+1。连接现在为 ESTABLISHED 状态。
Reliability is ensured with positive acknowledgment and retransmission. If a segment is not acknowledged within a timeout, it is resent. The sliding window mechanism provides flow control, allowing multiple unacknowledged segments to be in flight according to the receiver's buffer capacity (window size).
可靠性通过肯定确认和重传来保证。如果某个报文段在超时时间内未得到确认,就重新发送。滑动窗口机制提供流量控制,允许根据接收方的缓冲容量(窗口大小)同时发送多个未确认的报文段。
Sequence numbers allow data to be reassembled in the correct order and detect duplicates. The cyclic nature of sequence numbers (32-bit, modulo 2³²) must be understood conceptually; exam questions may ask about how lost ACKs or retransmissions are handled.
序列号使数据可按正确顺序重组并检测重复。必须从概念上理解序列号的循环特性(32 位,模 2³²);考题可能会问丢失 ACK 或重传如何处理。
9. DHCP: Automatic IP Configuration | DHCP:自动 IP 配置
The Dynamic Host Configuration Protocol allows devices to obtain IP addresses and configuration automatically. The process uses four steps: DHCPDISCOVER (client broadcast), DHCPOFFER (server response with offered IP), DHCPREQUEST (client requests that IP), DHCPACK (server acknowledges).
动态主机配置协议使设备能自动获取 IP 地址和配置。过程分四步:DHCPDISCOVER(客户端广播)、DHCPOFFER(服务器响应并提供 IP)、DHCPREQUEST(客户端请求该 IP)、DHCPACK(服务器确认)。
DHCP leases include a renewal time (T1) and rebinding time (T2). Before expiry, the client tries to renew the lease. DHCP also supplies subnet mask, default gateway, and DNS server addresses. This is essential for allowing mobile devices to connect seamlessly.
DHCP 租约包含续订时间 (T1) 和重新绑定时间 (T2)。到期前客户端尝试续订租约。DHCP 还提供子网掩码、默认网关和 DNS 服务器地址。这对于移动设备无缝连接至关重要。
Compare with APIPA (Automatic Private IP Addressing) used when DHCP servers are unavailable: devices self-assign 169.254.x.x addresses. This is not in the CIE spec but is useful context.
与 DHCP 服务器不可用时使用的 APIPA(自动专用 IP 寻址)对比:设备自分配 169.254.x.x 地址。这虽然不在 CIE 考纲里,但有助于理解。
10. Routing and Gateways | 路由与网关
Routers operate at the Internet layer and forward packets based on the destination IP address. They use routing tables that contain network destinations, netmasks, gateways, and metrics. A default route (0.0.0.0/0) catches all packets not matching any specific entry.
路由器工作在互联网层,根据目标 IP 地址转发数据包。它们使用路由表,其中包含网络目标、子网掩码、网关和度量值。默认路由(0.0.0.0/0)捕获所有不匹配任何特定条目的数据包。
The default gateway is the router's IP on a local network. When a host's destination IP is not in the same network, it sends the frame to the MAC address of the default gateway (after ARP resolution).
默认网关是本地网络里路由器端的 IP。当主机的目标 IP 不在同一网络时,它将帧发送到默认网关的 MAC 地址(经过 ARP 解析后)。
Static routing uses manually configured routes. Dynamic routing protocols like RIP, OSPF, and BGP allow routers to exchange information and adapt to changes. For CIE, you should know the basic concept of routing hops and how a packet typically traverses multiple routers.
静态路由使用手工配置的路由。动态路由协议如 RIP、OSPF 和 BGP 使路由器能交换信息并适应变化。就 CIE 而言,你需要了解路由跳数的基本概念,以及数据包通常如何穿越多个路由器。
11. Common Exam Pitfalls and How to Avoid Them | 常见考试陷阱及对策
Confusing layers: Make sure you can correctly assign protocols to layers. For example, TCP is Transport, not Internet; ARP is considered part of the Network Access or Internet layer depending on context. CIE usually places ARP in the Network Access layer. Refresh the exact specification.
混淆层级:确保能正确将协议分配到各层。例如 TCP 属于传输层,不是互联网层;ARP 根据不同上下文被视为网络接入层或互联网层。CIE 通常将 ARP 放在网络接入层。请重温考纲的确切划分。
Subnetting math errors: Practice binary–decimal conversions and logical AND operations. Always double-check the number of host bits subtracted by 2 (network and broadcast). Know how to find the range of valid host IPs.
子网划分计算错误:练习二进制与十进制的转换和逻辑与运算。务必复核主机位数减去 2(网络地址和广播地址)。知道如何找出有效主机 IP 范围。
IPv6 compression rules: Do not misuse double colon; it can replace only the longest contiguous block of zero fields once. If you miss this, the expanded form will be incorrect.
IPv6 压缩规则:不要误用双冒号;它只能替代最长连续零字段一次。如果你弄错,展开形式会不正确。
Port number memorization: CIE often includes multiple-choice or short-answer questions requiring exact port numbers. Create mnemonics or flashcards for the core protocols.
端口号记忆:CIE 经常会有选择题或简答题要求写出精确端口号。为核心协议创建助记法或闪卡。
12. Exam-Style Revision Questions | 考试式复习题
1. Explain why TCP is considered reliable while UDP is not. Use the terms acknowledgment and sequence number in your answer.
2. Given IP address 172.16.5.10/18, find the network address and the number of usable hosts.
3. Describe the four-step DHCP process and explain why broadcasts are necessary during discovery.
4. A user types a URL in a browser. Outline the roles of DNS, HTTP, TCP, IP, and Ethernet in loading that page.
1. 解释为何 TCP 被视为可靠而 UDP 不可靠。在答案中使用“确认”和“序列号”术语。
2. 给定 IP 地址 172.16.5.10/18,求网络地址和可用主机数。
3. 描述 DHCP 的四步过程,并解释为何在发现阶段必须使用广播。
4. 用户在网上浏览器中输入一个 URL,概述 DNS、HTTP、TCP、IP 和 Ethernet 在加载该页面时的作用。
Practicing structured answers with accurate technical vocabulary is critical. For each question, provide definitions, apply concepts, and give examples. Use diagrams of the TCP/IP stack and encapsulation to support your reasoning.
运用准确的技术词汇练习结构化答题至关重要。对每个问题,要给出定义、应用概念并举例。使用 TCP/IP 协议栈和封装的相关图示来支撑你的推理。
Published by TutorHao | CIE A-Level Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图