📚 IB AQA Computer Science: TCP/IP Exam Essentials | IB AQA 计算机:TCP/IP 考点精讲
TCP/IP is the fundamental protocol suite that powers the internet and modern networking. For IB AQA Computer Science, grasping the layered architecture, key protocols, IP addressing, and the reliable transport mechanisms of TCP is essential. This guide breaks down the most examinable concepts in a clear, bilingual format.
TCP/IP 是支撑互联网和现代网络的基础协议组。对于 IB AQA 计算机科学,掌握分层架构、关键协议、IP 地址以及 TCP 的可靠传输机制至关重要。本指南以清晰的双语形式分解了最有可能考察的概念。
1. Introduction to TCP/IP Protocol Suite | TCP/IP 协议组简介
The TCP/IP model is a conceptual framework that standardises communication functions across diverse networks. It is named after its two core protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP). Unlike the seven-layer OSI model, TCP/IP uses a streamlined four-layer architecture, which reflects real-world internet design more closely.
TCP/IP 模型是一种概念框架,用于标准化不同网络之间的通信功能。它以其两个核心协议命名:传输控制协议 (TCP) 和互联网协议 (IP)。与七层的 OSI 模型不同,TCP/IP 采用了更简洁的四层架构,这也更贴近实际的互联网设计。
Each layer performs a specific role and communicates only with adjacent layers. This modularity allows developers to replace or upgrade one layer without affecting others, as long as the interfaces remain consistent.
每一层执行特定功能,并且仅与相邻层通信。这种模块化使得开发人员可以在不影响其他层的情况下替换或升级某一层,只要接口保持一致即可。
2. TCP/IP Layers Overview | TCP/IP 层次结构概览
The four layers of the TCP/IP model from top to bottom are: Application, Transport, Internet, and Network Access (also called the Link layer). Each layer encapsulates data into protocol data units (PDUs) before passing it to the layer below.
TCP/IP 模型从上到下的四层分别为:应用层、传输层、网际层和网络访问层(也称链路层)。每一层在将数据传递给下层之前,都会将数据封装为协议数据单元 (PDU)。
| Layer | Key Function | Example Protocols |
|---|---|---|
| Application | Provides network services to user applications | HTTP, DNS, SMTP, FTP |
| Transport | End-to-end communication, error checking, flow control | TCP, UDP |
| Internet | Logical addressing, routing, fragmentation | IP, ICMP, ARP |
| Network Access | Physical transmission and media access control | Ethernet, Wi-Fi |
A message from an application is packed with an Application-layer header, then a TCP or UDP header, then an IP header, and finally a frame header and trailer for transmission over the physical medium.
来自应用程序的消息依次被添加应用层报头、TCP 或 UDP 报头、IP 报头,最后封装为帧报头与报尾,以便通过物理介质传输。
3. Application Layer Protocols | 应用层协议
The Application layer includes protocols that directly serve user or software requests. Each protocol uses a well-known port number, allowing the transport layer to deliver data to the correct service.
应用层包含直接为用户或软件请求提供服务的协议。每个协议都使用一个知名端口号,使传输层能够将数据交付给正确的服务。
| Protocol | Port | Purpose |
|---|---|---|
| HTTP | 80 | Transfer web pages |
| HTTPS | 443 | Secure HTTP with TLS/SSL |
| DNS | 53 | Resolve domain names to IP addresses |
| DHCP | 67/68 | Automatic IP configuration |
| SMTP | 25 | Send emails |
| FTP | 20/21 | File transfer |
HTTP is stateless, meaning each request-response pair is independent. Cookies and session IDs are often used to simulate stateful behaviour in web applications.
HTTP 是无状态的,意味着每个请求-响应对都是独立的。Web 应用程序通常使用 Cookie 和会话 ID 来模拟有状态行为。
4. Transport Layer: TCP and UDP | 传输层:TCP 与 UDP
The transport layer is responsible for segmenting data and providing reliability where needed. TCP offers a connection-oriented, reliable service with error correction and flow control, while UDP is a connectionless, lightweight protocol that prioritises speed over reliability.
传输层负责分段数据,并在需要时提供可靠性。TCP 提供面向连接、可靠的服务,具备纠错和流量控制功能;而 UDP 是一种无连接、轻量级协议,将速度置于可靠性之上。
- TCP: guarantees delivery, orders packets, retransmits lost segments, uses acknowledgements.
- UDP: no guarantee of delivery, no ordering, no retransmission – ideal for live streaming and VoIP.
- TCP:保证交付,对数据包排序,重传丢失的段,使用确认机制。
- UDP:不保证交付,不排序,无重传——非常适合直播和 VoIP。
TCP establishes a virtual circuit through a three-way handshake, maintains it during the session, and performs a graceful four-way close when the communication ends.
TCP 通过三次握手建立虚拟电路,在会话期间维持该电路,并在通信结束时执行优雅的四次挥手关闭。
5. TCP Three-Way Handshake | TCP 三次握手
The three-way handshake is the procedure used by TCP to set up a connection between a client and a server. It synchronises sequence numbers and ensures both sides are ready to transmit data.
三次握手是 TCP 用于在客户端和服务器之间建立连接的过程。它同步序列号,并确保双方都已准备好传输数据。
Step 1 (SYN): The client sends a segment with the SYN flag set and an initial sequence number x.
步骤 1 (SYN): 客户端发送一个设置了 SYN 标志的段,并携带初始序列号 x。
Step 2 (SYN-ACK): The server replies with its own SYN (sequence number y) and acknowledges the client’s SYN by setting ACK to x+1.
步骤 2 (SYN-ACK): 服务器以自己的 SYN(序列号 y)回复,并通过将 ACK 设置为 x+1 来确认客户端的 SYN。
Step 3 (ACK): The client sends an ACK segment with sequence number x+1 and acknowledgement y+1. The connection is now established.
步骤 3 (ACK): 客户端发送一个 ACK 段,序列号为 x+1,确认号为 y+1。连接此时建立。
This exchange prevents half-open connections and helps avoid old duplicate packets from mistakenly initiating a session.
此交换过程可防止半开连接,并有助于避免旧的重复数据包错误地发起会话。
6. Flow Control and Congestion Control | 流量控制与拥塞控制
TCP employs a sliding window mechanism for flow control. The receiver advertises a window size indicating how many bytes it can handle. The sender must not exceed this window without receiving further acknowledgements.
TCP 使用滑动窗口机制进行流量控制。接收方通告一个窗口大小,表明它能够处理多少字节。发送方在未收到进一步的确认之前,不得超过此窗口发送数据。
Congestion control prevents network overload. TCP uses algorithms such as slow start, congestion avoidance, fast retransmit, and fast recovery. In slow start, the congestion window (cwnd) grows exponentially until a threshold is reached, after which it increases linearly.
拥塞控制可防止网络过载。TCP 使用慢启动、拥塞避免、快速重传和快速恢复等算法。在慢启动中,拥塞窗口 (cwnd) 呈指数增长,直到达到阈值,之后转为线性增长。
If packet loss is detected (e.g., via triple duplicate ACKs or timeout), cwnd is reduced sharply to alleviate congestion. This dynamic adjustment is vital for internet stability.
如果检测到数据包丢失(例如通过三次重复 ACK 或超时),cwnd 会大幅减小以缓解拥塞。这种动态调整对互联网的稳定性至关重要。
7. Internet Layer: IP Addressing | 网际层:IP 地址
The Internet layer handles logical addressing and routing. IP addresses uniquely identify devices on an internetwork. IPv4 addresses are 32-bit numbers, usually expressed in dotted decimal notation, e.g., 192.168.1.1.
网际层处理逻辑寻址和路由。IP 地址在网络互联中唯一标识设备。IPv4 地址是 32 位数字,通常以点分十进制表示,例如 192.168.1.1。
Each IPv4 address consists of a network portion and a host portion, determined by the subnet mask. The mask 255.255.255.0 means the first 24 bits identify the network, leaving 8 bits for hosts (2⁸ – 2 = 254 usable addresses).
每个 IPv4 地址由网络部分和主机部分组成,该划分由于掩码决定。掩码 255.255.255.0 表示前 24 位标识网络,剩余 8 位用于主机(2⁸ – 2 = 254 个可用地址)。
An IP packet includes source and destination IP addresses, a time-to-live (TTL) field to prevent infinite loops, and a protocol field that indicates which transport protocol (TCP=6, UDP=17) to pass the payload to.
IP 数据包包含源 IP 地址、目的 IP 地址、用于防止无限循环的生存时间 (TTL) 字段,以及指示应将有效载荷传递给哪个传输协议(TCP=6,UDP=17)的协议字段。
8. Subnetting and CIDR | 子网划分与 CIDR
Subnetting divides a large network into smaller, more manageable subnetworks. It improves security and reduces broadcast traffic. CIDR (Classless Inter-Domain Routing) notation combines the base address and subnet mask into a single expression like 192.168.1.0/24.
子网划分将大型网络分割为更小、更易管理的子网。它提高了安全性并减少了广播流量。CIDR(无类别域间路由)表示法将基地址和子网掩码合并为一个表达式,如 192.168.1.0/24。
/24 means the first 24 bits are the network prefix; /16 uses a mask of 255.255.0.0. The number of subnets and hosts per subnet can be calculated as 2ⁿ and 2ⁿ – 2 respectively, where n is the number of borrowed bits or remaining host bits.
/24 表示前 24 位是网络前缀;/16 的掩码为 255.255.0.0。子网数量和每个子网的主机数量可分别按 2ⁿ 和 2ⁿ – 2 计算,其中 n 为借位数或剩余主机位数。
A common exam scenario is to find the network address by performing a bitwise AND between the IP address and mask, then determine the broadcast address and usable host range.
常见的考试场景是:通过 IP 地址与掩码的按位 AND 运算找到网络地址,然后确定广播地址和可用主机范围。
9. IPv4 vs IPv6 | IPv4 与 IPv6 对比
IPv4’s 32-bit address space provides about 4.3 billion addresses, which have been exhausted. IPv6 uses 128-bit addresses, yielding an enormous pool (approximately 3.4 × 10³⁸) and eliminating the need for NAT in many scenarios.
IPv4 的 32 位地址空间提供约 43 亿个地址,现已耗尽。IPv6 采用 128 位地址,生成一个巨大的地址池(约 3.4×10³⁸),并在许多场景中不再需要 NAT。
IPv6 addresses are written as eight groups of four hexadecimal digits, e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Leading zeros may be omitted, and a single double colon (::) can replace consecutive zero groups once per address.
IPv6 地址写为八组四位十六进制数字,例如 2001:0db8:85a3:0000:0000:8a2e:0370:7334。前导零可省略,且每地址可使用一次双冒号 (::) 替代连续的零组。
IPv6 features a simplified header, better support for multicasting, built-in IPsec, and stateless address autoconfiguration (SLAAC), allowing devices to generate their own addresses without a DHCP server.
IPv6 具有简化的报头、更好的组播支持、内置 IPsec 以及无状态地址自动配置 (SLAAC),使设备无需 DHCP 服务器即可生成自己的地址。
10. Routing and Default Gateway | 路由与默认网关
Routing is the process of forwarding packets from one network to another. A router examines the destination IP address and consults its routing table to decide the next hop. A default gateway is the router used when no specific route matches.
路由是将数据包从一个网络转发到另一个网络的过程。路由器检查目标 IP 地址,并查阅其路由表以决定下一跳。默认网关是当没有特定路由匹配时所使用的路由器。
The Address Resolution Protocol (ARP) bridges the Internet layer and Network Access layer by mapping an IP address to a MAC address. A host broadcasts an ARP request asking ‘Who has 192.168.1.1?’ and the target replies with its MAC address.
地址解析协议 (ARP) 通过将 IP 地址映射到 MAC 地址,在网际层与网络访问层之间建立桥梁。主机广播一条 ARP 请求:“谁拥有 192.168.1.1?”,目标以其 MAC 地址应答。
Routers decrement the TTL field at each hop; if TTL reaches 0, the packet is discarded and an ICMP ‘Time Exceeded’ message is sent back. This mechanism is used by traceroute tools to map the path across the internet.
路由器在每一跳上递减 TTL 字段值;如果 TTL 降为 0,数据包将被丢弃,并回送一条 ICMP“超时”消息。此机制被 traceroute 工具用于绘制互联网路径。
11. Port Numbers and Sockets | 端口号与套接字
A port is a 16-bit integer (0–65535) used by the transport layer to distinguish between multiple services running on the same device. Well-known ports (0–1023) are assigned to standard services like HTTP (80) and DNS (53).
端口是一个 16 位整数(0–65535),由传输层用于区分同一设备上运行的多个服务。知名端口(0–1023)分配给标准服务,如 HTTP (80) 和 DNS (53)。
A socket is the combination of an IP address and a port number, often written as IP:port (e.g., 192.168.1.5:80). A server socket listens on a specific port; a client socket connects to that port to establish a session.
套接字是 IP 地址和端口号的组合,通常写为 IP:port(例如 192.168.1.5:80)。服务器套接字在特定端口上侦听;客户端套接字连接到该端口以建立会话。
Ephemeral (dynamic) ports (49152–65535) are temporarily assigned to client applications. This allows multiple simultaneous connections from the same client IP without port conflicts.
临时(动态)端口(49152–65535)被临时分配给客户端应用程序。这使得来自同一客户端 IP 的多个并发连接不会产生端口冲突。
12. Client-Server Model in TCP/IP | TCP/IP 客户端-服务器模型
Most internet applications follow the client-server model, where the server passively waits for requests and the client initiates communication. For example, when you browse a website, your browser (client) sends an HTTP GET request to the server’s IP address on port 80.
大多数互联网应用遵循客户端-服务器模型,其中服务器被动等待请求,客户端发起通信。例如,当你浏览网站时,浏览器(客户端)向服务器的 IP 地址 80 端口发送 HTTP GET 请求。
Behind the scenes, DNS resolves the URL to an IP address, TCP performs the three-way handshake, and TLS may encrypt the session if HTTPS is used. The server processes the request and returns an HTTP response containing HTML, CSS, and other resources.
幕后,DNS 将 URL 解析为 IP 地址,TCP 执行三次握手,如果使用 HTTPS,TLS 可能对会话进行加密。服务器处理请求并返回包含 HTML、CSS 和其他资源的 HTTP 响应。
This layered cooperation exemplifies why understanding TCP/IP is critical: a problem at any layer can disrupt the entire communication flow, and systematic troubleshooting relies on isolating the faulty layer.
这种分层协作体现了理解 TCP/IP 为何至关重要:任何一层的问题都可能中断整个通信流程,而系统化的故障排查则依赖于隔离出故障层。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply