TCP/IP Protocol Stack Explained for IB & OCR Computer Science | IB OCR 计算机:TCP/IP 考点精讲

📚 TCP/IP Protocol Stack Explained for IB & OCR Computer Science | IB OCR 计算机:TCP/IP 考点精讲

The TCP/IP protocol suite is the foundation of modern internet communication, and it appears consistently in both IB Computer Science (Topic 3: Networks) and OCR A Level Computer Science (Component 1: Computer Systems). Understanding its layered architecture, key protocols, addressing schemes, and handshaking processes is essential for scoring top marks. This article breaks down every critical concept with paired English and Chinese explanations, helping you master the syllabus efficiently.

TCP/IP 协议族是现代互联网通信的基石,在 IB 计算机科学(主题 3:网络)和 OCR A Level 计算机科学(组件 1:计算机系统)中反复出现。理解其分层架构、关键协议、寻址方案和握手过程是取得高分的关键。本文通过中英对照讲解各个核心概念,助你高效掌握考点。

1. The TCP/IP Model vs OSI Model | TCP/IP 模型与 OSI 模型的对比

The TCP/IP model is often compared with the OSI model in exam questions. While the OSI model has seven theoretical layers, TCP/IP uses a simpler four-layer structure that reflects real-world internet protocols more accurately.

考试中经常会比较 TCP/IP 模型与 OSI 模型。OSI 模型有七层理论结构,而 TCP/IP 采用更简洁的四层结构,更贴近互联网实际使用的协议。

OSI Model (7 layers) TCP/IP Model (4 layers) Example Protocols
Application, Presentation, Session Application HTTP, FTP, SMTP, DNS
Transport Transport TCP, UDP
Network Internet IP, ICMP, ARP
Data Link, Physical Network Access (Link) Ethernet, Wi-Fi

In both IB and OCR syllabuses, students are expected to name the layers and map common protocols to them. Remember that the TCP/IP model’s Application layer combines the top three OSI layers, while the Network Access layer covers both Data Link and Physical.

IB 和 OCR 考纲均要求学生能说出各层名称并将常用协议对应到相应层次。记住 TCP/IP 模型的应用层合并了 OSI 的上三层,而网络接入层覆盖了数据链路层和物理层。


2. Layer Functions Overview | 各层功能概述

The Application layer provides network services directly to user applications. It handles high-level protocols like HTTP for web browsing and SMTP for email. Data is generated here in the form of messages.

应用层直接为用户程序提供网络服务,负责处理高层协议,如用于网页浏览的 HTTP 和用于电子邮件的 SMTP。数据在此以消息形式生成。

The Transport layer ensures reliable or unreliable delivery of data between processes. TCP offers connection-oriented, error-checked transmission, while UDP provides a faster, connectionless service. Port numbers are used to identify which application the data belongs to.

传输层确保进程间数据的可靠或不可靠传输。TCP 提供面向连接、带差错校验的传输,而 UDP 提供更快但无连接的服务。端口号用来标识数据属于哪个应用程序。

The Internet layer is responsible for logical addressing and routing. The Internet Protocol (IP) adds source and destination IP addresses to packets. Routers operate at this layer, forwarding packets across different networks using routing tables.

网络层(互联网层)负责逻辑寻址和路由。网际协议 (IP) 为数据包添加源 IP 地址和目的 IP 地址。路由器工作在这一层,利用路由表在不同网络之间转发数据包。

The Network Access layer defines how data is physically transmitted over the medium. It deals with hardware addressing (MAC addresses), framing, and access to the physical cable or wireless signal. Switches and network interface cards operate here.

网络接入层定义数据如何在物理介质上传输。它处理硬件寻址(MAC 地址)、成帧以及对物理线缆或无线信号的访问。交换机和网卡工作在这一层。

Data encapsulation is a key concept: at each layer, a header (and sometimes a trailer) is added, forming a Protocol Data Unit (PDU). The PDU is called a segment at Transport, a packet at Internet, and a frame at Network Access.

数据封装是关键概念:每一层都会添加报头(有时还有报尾),形成协议数据单元 (PDU)。在传输层 PDU 称为段,在网络层称为包,在网络接入层称为帧。


3. Application Layer Protocols | 应用层协议

Common application layer protocols include HTTP/HTTPS for web pages, FTP for file transfer, SMTP and POP3/IMAP for email, and DNS for domain name resolution. For IB and OCR exams, you need to know the purpose and port numbers of each.

常见的应用层协议包括用于网页的 HTTP/HTTPS、用于文件传输的 FTP、用于电子邮件的 SMTP 与 POP3/IMAP,以及用于域名解析的 DNS。在 IB 和 OCR 考试中,你需要知道每个协议的作用及端口号。

  • HTTP (80) – Hypertext Transfer Protocol; used to retrieve web pages from servers.
  • HTTPS (443) – HTTP Secure; uses TLS/SSL encryption for secure communication.
  • FTP (21 for control, 20 for data) – File Transfer Protocol; used to upload and download files.
  • SMTP (25) – Simple Mail Transfer Protocol; sends emails from client to server and between servers.
  • POP3 (110) – Post Office Protocol v3; downloads emails to a local client and typically deletes them from the server.
  • IMAP (143) – Internet Message Access Protocol; manages emails directly on the server, allowing multiple devices to synchronize.
  • DNS (53) – Domain Name System; translates human-readable domain names (e.g., aleveler.com) into IP addresses.

中文对应:HTTP (80) 超文本传输协议,用于从服务器获取网页;HTTPS (443) 安全超文本传输协议,使用 TLS/SSL 加密;FTP (21 控制, 20 数据) 文件传输协议;SMTP (25) 简单邮件传输协议,发送邮件;POP3 (110) 邮局协议第三版,下载邮件到本地;IMAP (143) 互联网消息访问协议,在服务器上管理邮件;DNS (53) 域名系统,将域名转换为 IP 地址。

IB questions often ask to justify protocol choices in a given scenario, while OCR may include protocol stacks in trace route or packet analysis tasks. Memorizing the well-known port numbers is essential.

IB 题目常要求针对给定场景选择并论证协议,OCR 则可能在路由追踪或分组分析题中涉及协议栈。牢记知名端口号是必须的。


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

Transmission Control Protocol (TCP) is a connection-oriented protocol that guarantees delivery through acknowledgements, sequencing, and flow control. It is used when data integrity is critical, such as in web browsing, file transfers, and emails.

传输控制协议 (TCP) 是面向连接的协议,通过确认、序号和流量控制来保证交付。当数据完整性至关重要时使用,例如网页浏览、文件传输和电子邮件。

User Datagram Protocol (UDP) is a connectionless protocol that sends datagrams without establishing a connection. It does not guarantee delivery or order, making it lightweight and fast. Common uses include live video streaming, online gaming, and DNS queries.

用户数据报协议 (UDP) 是无连接协议,无需建立连接即可发送数据报。它不保证交付或顺序,因此轻量快速。常用于直播视频、在线游戏和 DNS 查询。

Feature TCP UDP
Connection Connection-oriented Connectionless
Reliability Reliable – uses ACKs and retransmission Unreliable – best-effort delivery
Ordering Packets are sequenced and re-ordered No sequencing – packets may arrive out of order
Overhead Higher due to header size and handshakes Lower – 8-byte header only
Typical uses HTTP, FTP, SMTP VoIP, streaming, online gaming, DNS

中文对照:连接方面,TCP 面向连接,UDP 无连接;可靠性上 TCP 可靠(使用确认与重传),UDP 不可靠(尽力交付);排序上 TCP 有排序和重组,UDP 无排序;开销 TCP 较高(报头大、需握手),UDP 低(仅 8 字节报头);典型应用 TCP 用于 HTTP, FTP, SMTP,UDP 用于网络电话、流媒体、在线游戏和 DNS。

A classic exam topic is choosing between TCP and UDP for a given application. Always justify your answer with the specific characteristics described above.

经典考点是为特定应用选择 TCP 或 UDP 并说明理由。务必根据上述特性进行论证。


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

Before any data transmission, TCP establishes a virtual connection using a three-way handshake. This synchronizes sequence numbers and ensures both hosts are ready to communicate.

在传输任何数据之前,TCP 通过三次握手建立虚拟连接。这可以同步序列号,确保双方主机都已准备好通信。

Step 1: The client sends a SYN (synchronize) segment to the server, containing an initial sequence number (ISN), e.g., x. No data is carried yet, but the SYN flag is set.

步骤 1:客户端向服务器发送 SYN(同步)报文段,包含初始序列号 (ISN),例如 x。此时不携带数据,但 SYN 标志位置 1。

Step 2: The server responds with a SYN-ACK segment. It acknowledges the client’s ISN by setting the ACK number to x+1, and provides its own sequence number, e.g., y.

步骤 2:服务器回复 SYN-ACK 报文段。它将确认号设为 x+1 以确认客户端的 ISN,并提供自己的序列号,例如 y。

Step 3: The client sends an ACK segment with ACK number y+1, confirming the server’s sequence number. After this step, the connection is established and data can flow.

步骤 3:客户端发送 ACK 报文段,确认号为 y+1,以确认服务器的序列号。此步完成后,连接建立,可以开始传输数据。

This exchange is often represented as: Client → SYN (seq=x); Server → SYN+ACK (seq=y, ack=x+1); Client → ACK (seq=x+1, ack=y+1). IB and OCR may include sequence diagram questions or ask you to explain the purpose of each step.

此过程常表示为:客户端 → SYN (seq=x);服务器 → SYN+ACK (seq=y, ack=x+1);客户端 → ACK (seq=x+1, ack=y+1)。IB 和 OCR 考试可能出时序图题,或要求解释每一步的目的。

Connection termination uses a four-way handshake with FIN flags, but is less frequently examined. The three-way handshake is fundamental for understanding how reliable connections are initiated.

连接终止使用带 FIN 标志的四次挥手,但考察较少。三次握手是理解可靠连接如何启动的基础。


6. IP Addressing and Subnetting | IP 寻址与子网划分

An IP address is a logical identifier for a device on a network. IPv4 addresses are 32-bit numbers usually written in dotted decimal (e.g., 192.168.1.10). Each address is split into a network portion and a host portion determined by the subnet mask.

IP 地址是网络上设备的逻辑标识符。IPv4 地址是 32 位数字,通常写成点分十进制形式(如 192.168.1.10)。每个地址分为网络部分和主机部分,由子网掩码决定。

The subnet mask defines which bits belong to the network. A mask of 255.255.255.0 means the first 24 bits are the network ID, and the last 8 bits are host ID. This is written as /24 in CIDR notation.

子网掩码定义哪些位属于网络。掩码 255.255.255.0 表示前 24 位是网络 ID,后 8 位是主机 ID。在 CIDR 表示法中写作 /24。

To subnet a network, you borrow host bits to create additional subnets. For example, using /26 on a 192.168.1.0 network creates 4 subnets (2² = 4) with 62 usable hosts each (2⁶ – 2 = 62). The formula for number of subnets is 2ⁿ (where n is borrowed bits), and usable hosts per subnet is 2ʰ – 2 (where h is remaining host bits).

划分子网时,借用主机位来创建额外的子网。例如,在 192.168.1.0 网络上使用 /26 可创建 4 个子网(2² = 4),每个子网有 62 个可用主机(2⁶ – 2 = 62)。子网数公式为 2ⁿ(n 为借用的位数),每个子网可用主机数为 2ʰ – 2(h 为剩余主机位数)。

IB often includes subnetting calculations as part of network design questions. OCR may require identifying whether two IP addresses are on the same subnet by performing a logical AND with the mask.

IB 常将子网划分计算作为网络设计题的一部分。OCR 可能要求通过将 IP 地址与掩码做逻辑与运算来判断两个地址是否在同一子网。

Key addresses: the network address (all host bits 0) identifies the subnet itself, and the broadcast address (all host bits 1) sends data to all hosts in the subnet. Neither can be assigned to a device.

关键地址:网络地址(主机位全 0)标识子网本身,广播地址(主机位全 1)向子网内所有主机发送数据。两者均不能分配给设备。


7. IPv4 vs IPv6 | IPv4 与 IPv6 对比

IPv4 uses 32-bit addresses, yielding about 4.3 billion unique addresses. Due to address exhaustion, IPv6 was developed with 128-bit addresses, providing an astronomically large address space.

IPv4 使用 32 位地址,约提供 43 亿个唯一地址。由于地址耗尽问题,开发了 IPv6,采用 128 位地址,提供极其庞大的地址空间。

Feature IPv4 IPv6
Address length 32 bits 128 bits
Format Dotted decimal (192.168.1.1) Hexadecimal colon-separated (2001:0db8:85a3::8a2e:0370:7334)
Header complexity Variable length, options field Simplified fixed 40-byte header
Fragmentation Performed by routers and sender Only by sender; routers do not fragment
NAT requirement Often uses NAT due to address scarcity No NAT needed – end-to-end connectivity
Autoconfiguration DHCP typically required Stateless autoconfiguration (SLAAC) built-in

IPv6 addresses are often abbreviated by omitting leading zeros and using double colon (::) to represent consecutive zero blocks (only once per address). Students should be able to simplify and expand IPv6 addresses.

IPv6 地址常省略前导零,并用双冒号 (::) 表示连续的零块(每个地址中只能使用一次)。学生应能简化和展开 IPv6 地址。

Transition mechanisms like dual stack, tunnelling, and NAT64 are part of the OCR specification. IB may include IPv6 when discussing the evolution of the internet and network layer improvements.

过渡机制如双栈、隧道和 NAT64 是 OCR 考纲的一部分。IB 可能在讨论互联网演进和网络层改进时涉及 IPv6。


8. MAC Addresses and ARP | MAC 地址与 ARP 协议

A MAC (Media Access Control) address is a 48-bit hardware identifier burned into network interface cards. It is used at the Network Access layer for communication within the same local network. MAC addresses are typically represented as 6 groups of two hexadecimal digits (e.g., 00:1A:2B:3C:4D:5E).

MAC(介质访问控制)地址是烧录在网卡中的 48 位硬件标识符,用于网络接入层在同一局域网内通信。MAC 地址通常表示为 6 组两位十六进制数字(如 00:1A:2B:3C:4D:5E)。

The Address Resolution Protocol (ARP) maps IP addresses to MAC addresses. When a device knows the destination IP but not its MAC, it broadcasts an ARP request. The host with that IP replies with its MAC address. The mapping is cached in an ARP table for future use.

地址解析协议 (ARP) 将 IP 地址映射到 MAC 地址。当设备知道目的 IP 但不知道其 MAC 地址时,它广播 ARP 请求。该 IP 对应的主机返回其 MAC 地址。映射关系会缓存在 ARP 表中备用。

In IB and OCR, you may be asked to explain how ARP facilitates communication within a LAN and why switches use MAC addresses rather than IP addresses to forward frames.

在 IB 和 OCR 中,可能要求解释 ARP 如何促进局域网内的通信,以及交换机为何使用 MAC 地址而非 IP 地址来转发帧。


9. Routing and Default Gateway | 路由与默认网关

Routers connect different networks and forward packets based on destination IP address. They maintain a routing table with entries for directly connected networks, static routes, and dynamic routes learned via protocols like OSPF or RIP.

路由器连接不同网络,并根据目的 IP 地址转发数据包。它们维护一个路由表,包含直连网络条目、静态路由以及通过 OSPF 或 RIP 等协议学习的动态路由。

The default gateway is the router that a host uses to reach destinations outside its local subnet. If a host’s routing table has no specific entry for a destination, it sends the packet to the default gateway.

默认网关是主机用来访问本地子网外目的地的路由器。如果主机的路由表没有特定目的条目,它将数据包发送到默认网关。

A typical network setup: Host A (192.168.1.10/24) with default gateway 192.168.1.1 wants to send a packet to 10.0.0.5. It determines the destination is on a different network, so it encapsulates the IP packet in a frame addressed to the default gateway’s MAC address (obtained via ARP). The router then forwards the packet out of the appropriate interface.

典型网络设置:主机 A (192.168.1.10/24) 默认网关 192.168.1.1,向 10.0.0.5 发送数据包。它判断目的地在不同网络,于是将 IP 包封装在帧中,目的 MAC 地址为默认网关的 MAC(通过 ARP 获取)。路由器随后从相应接口转发数据包。

Both IB and OCR expect candidates to trace a packet’s journey across networks, identifying each layer’s role and the changing addresses (MAC changes hop-by-hop, IP remains unless NAT alters it).

IB 和 OCR 都期望考生能追踪数据包跨网络传输的过程,识别各层的作用以及变化的地址(MAC 逐跳改变,IP 保持不变除非 NAT 修改)。


10. Common Exam Questions | 常见考题解析

Exam questions frequently combine several TCP/IP concepts. For example: “A user types a URL into a browser. Explain how the TCP/IP protocol stack facilitates the loading of the web page.” You must describe DNS resolution (Application), TCP handshake (Transport), IP routing (Internet), and Ethernet framing (Network Access).

考题常结合多个 TCP/IP 概念。例如:“用户在浏览器中输入 URL。解释 TCP/IP 协议栈如何帮助加载该网页。” 你必须描述 DNS 解析(应用层)、TCP 握手(传输层)、IP 路由(网络层)和以太网帧封装(网络接入层)。

Another typical question: “Compare TCP and UDP, giving one example of when each would be preferred.” Or: “Given the IP address 172.16.5.34/27, determine the network address and broadcast address.” Such calculations require binary understanding.

另一典型题:“比较 TCP 和 UDP,各举一个优选使用场景。” 或:“给定 IP 地址 172.16.5.34/27,求网络地址和广播地址。” 这类计算需要二进制理解。

For /27, the subnet mask is 255.255.255.224. The block size is 2⁽³²⁻²⁷⁾ = 2⁵ = 32. The 172.16.5.34 address falls in the range 172.16.5.32 to 172.16.5.63, so the network address is 172.16.5.32 and broadcast is 172.16.5.63. Always show working.

对于 /27,子网掩码为 255.255.255.224。块大小为 2⁽³²⁻²⁷⁾ = 2⁵ = 32。地址 172.16.5.34 落在 172.16.5.32 到 172.16.5.63 范围内,因此网络地址为 172.16.5.32,广播地址为 172.16.5.63。务必展示计算过程。

In IB, long-answer questions may ask you to evaluate the suitability of TCP/IP protocols for specific network scenarios, demanding both technical accuracy and reasoned argument. OCR’s structured questions often include completing protocol stack diagrams or analysing protocol headers.

在 IB 中,长答题可能要求评估 TCP/IP 协议对特定网络场景的适用性,需要技术准确性和合理论述。OCR 的结构化题目常包括填写协议栈图或分析协议报头。

Finally, always associate port numbers with their protocols, understand the difference between private and public IP addresses (RFC 1918), and be ready to sketch a three-way handshake diagram. These fundamentals consistently secure marks.

最后,要熟记端口号与协议对应关系,理解私有和公共 IP 地址的区别 (RFC 1918),并准备好画出三次握手示意图。这些基础知识能稳定拿分。


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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

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

Exit mobile version