Understanding the OSI and TCP/IP Network Models | OSI与TCP/IP网络模型详解

📚 Understanding the OSI and TCP/IP Network Models | OSI与TCP/IP网络模型详解

In the world of computer networking, the OSI and TCP/IP models serve as the fundamental blueprints that describe how data travels from one device to another. Understanding these models is essential for any computer science student preparing for exams, as they form the basis of network architecture, protocol design, and troubleshooting.

在计算机网络的世界中,OSI和TCP/IP模型是描述数据如何在设备之间传输的基础蓝图。对于任何备考的计算机科学学生来说,理解这些模型至关重要,因为它们构成了网络架构、协议设计和故障排除的基础。


1. Why Layered Models Matter | 分层模型的重要性

Layered network models break down the complex process of data communication into manageable, modular stages. Each layer is responsible for a specific set of functions and communicates only with the layers directly above and below it. This modularity allows engineers to update protocols in one layer without redesigning the entire network stack.

分层网络模型将复杂的数据通信过程分解为可管理的模块化阶段。每一层负责一组特定的功能,并且只与直接相邻的上下层通信。这种模块化设计使得工程师可以在不重新设计整个网络栈的情况下更新某一层的协议。

For example, when a new wireless technology replaces the physical transmission medium, the upper layers (such as application and transport) remain unchanged. This separation of concerns is the core design philosophy behind both the OSI and TCP/IP models.

例如,当新的无线技术取代物理传输介质时,上层(如应用层和传输层)保持不变。这种关注点分离是OSI和TCP/IP模型背后的核心设计理念。


2. The OSI Model Overview | OSI模型概述

The Open Systems Interconnection (OSI) model was developed by the International Organization for Standardization (ISO) in 1984. It defines seven distinct layers, numbered from bottom to top: Physical (Layer 1), Data Link (Layer 2), Network (Layer 3), Transport (Layer 4), Session (Layer 5), Presentation (Layer 6), and Application (Layer 7).

开放系统互连(OSI)模型由国际标准化组织(ISO)于1984年制定。它定义了七个独立的层,从下到上依次编号:物理层(第1层)、数据链路层(第2层)、网络层(第3层)、传输层(第4层)、会话层(第5层)、表示层(第6层)和应用层(第7层)。

Layer 7: Application → Layer 6: Presentation → Layer 5: Session → Layer 4: Transport → Layer 3: Network → Layer 2: Data Link → Layer 1: Physical

第7层:应用层 → 第6层:表示层 → 第5层:会话层 → 第4层:传输层 → 第3层:网络层 → 第2层:数据链路层 → 第1层:物理层

The OSI model is a conceptual framework; it does not define specific protocols. Instead, it provides a reference architecture that vendors and engineers use to design interoperable network systems. Many exam questions test whether students can identify which layer handles a given function.

OSI模型是一个概念框架;它并未定义具体的协议。相反,它提供了一个参考架构,供供应商和工程师设计可互操作的网络系统。许多考试题目测试学生是否能识别出某一功能由哪一层负责。


3. OSI Layers 1-2: Physical and Data Link | OSI第1-2层:物理层与数据链路层

Layer 1, the Physical layer, deals with the raw transmission of bits over a physical medium. It defines electrical signals, cable types, connectors, voltage levels, and data rates. Common devices at this layer include hubs, repeaters, and network interface cards (NICs). The Physical layer does not interpret data; it simply moves bits from one point to another.

第1层物理层负责比特在物理介质上的原始传输。它定义了电信号、电缆类型、连接器、电压电平和数据速率。该层的常见设备包括集线器、中继器和网络接口卡(NIC)。物理层不解释数据;它只是将比特从一个点传输到另一个点。

Layer 2, the Data Link layer, packages bits into frames and adds physical addresses (MAC addresses) to enable delivery within a local network. It handles error detection through techniques such as cyclic redundancy check (CRC) and controls access to the shared medium using protocols like Ethernet and Wi-Fi (IEEE 802.11). Switches operate at this layer.

第2层数据链路层将比特封装成帧,并添加物理地址(MAC地址)以实现局域网内的交付。它通过循环冗余校验(CRC)等技术处理错误检测,并使用以太网和Wi-Fi(IEEE 802.11)等协议控制对共享介质的访问。交换机在这一层工作。

  • Physical layer units: bits | 物理层数据单元:比特(bit)
  • Data Link layer units: frames | 数据链路层数据单元:帧(frame)
  • Data Link layer addresses: MAC addresses (e.g., 00:1A:2B:3C:4D:5E) | 数据链路层地址:MAC地址(如 00:1A:2B:3C:4D:5E)

4. OSI Layer 3: Network | OSI第3层:网络层

The Network layer is responsible for logical addressing, routing, and packet forwarding. It takes data from the transport layer, encapsulates it into packets, and determines the best path to the destination using routing algorithms. The most important protocol at this layer is the Internet Protocol (IP).

网络层负责逻辑寻址、路由选择和分组转发。它从传输层接收数据,将其封装为数据包,并使用路由算法确定到达目的地的最佳路径。这一层最重要的协议是互联网协议(IP)。

IP addresses are logical addresses that identify a device on a network. IPv4 uses 32-bit addresses (e.g., 192.168.1.1), while IPv6 uses 128-bit addresses written in hexadecimal. The Network layer also handles fragmentation, where large packets are split into smaller pieces to fit the maximum transmission unit (MTU) of the underlying link.

IP地址是标识网络上设备的逻辑地址。IPv4使用32位地址(如 192.168.1.1),而IPv6使用以十六进制书写的128位地址。网络层还处理分片,即大数据包被分割成较小的片段以适应底层链路的最大传输单元(MTU)。

IPv4 address: 192.168.1.1 (32-bit) | IPv6 address: 2001:0db8:85a3::8a2e:0370:7334 (128-bit)

IPv4地址:192.168.1.1(32位) | IPv6地址:2001:0db8:85a3::8a2e:0370:7334(128位)

Routers are the primary devices operating at Layer 3. They examine the destination IP address of each packet and consult their routing tables to decide where to forward it next. Key routing protocols include OSPF (Open Shortest Path First) and BGP (Border Gateway Protocol).

路由器是第3层的主要设备。它们检查每个数据包的目的IP地址,并查阅路由表以决定下一步将它转发到哪里。关键路由协议包括OSPF(开放最短路径优先)和BGP(边界网关协议)。


5. OSI Layer 4: Transport | OSI第4层:传输层

The Transport layer provides end-to-end communication services between applications running on different devices. It is responsible for segmentation, reassembly, flow control, and error recovery. The two most significant protocols at this layer are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).

传输层提供运行在不同设备上的应用程序之间的端到端通信服务。它负责分段、重组、流量控制和错误恢复。该层两个最重要的协议是TCP(传输控制协议)和UDP(用户数据报协议)。

TCP is a connection-oriented protocol that ensures reliable data delivery. It establishes a connection through a three-way handshake (SYN, SYN-ACK, ACK), numbers each segment for correct ordering, and uses acknowledgments and retransmissions to guarantee delivery. UDP, in contrast, is connectionless and offers no guarantees, making it faster and suitable for real-time applications like video streaming and online gaming.

TCP是面向连接的协议,确保可靠的数据交付。它通过三次握手(SYN、SYN-ACK、ACK)建立连接,为每个段编号以保证正确排序,并使用确认和重传机制来保证交付。相比之下,UDP是无连接的,不提供任何保证,因此速度更快,适合视频流媒体和在线游戏等实时应用。

Feature | 特性 TCP | TCP UDP | UDP
Connection | 连接 Connection-oriented | 面向连接 Connectionless | 无连接
Reliability | 可靠性 High (ACK + retransmission) | 高(确认+重传) Low / None | 低/无
Speed | 速度 Slower | 较慢 Faster | 较快
Use cases | 典型应用 Web (HTTP), Email (SMTP), FTP | 网页、电子邮件、文件传输 DNS, VoIP, Video streaming | DNS、网络电话、视频流媒体

Port numbers at the Transport layer identify specific applications. For example, HTTP uses port 80, HTTPS uses port 443, DNS uses port 53, and FTP uses port 21. A socket is defined as the combination of an IP address and a port number.

传输层的端口号用于标识特定应用程序。例如,HTTP使用端口80,HTTPS使用端口443,DNS使用端口53,FTP使用端口21。套接字(socket)定义为IP地址和端口号的组合。


6. OSI Layers 5-7: Session, Presentation, Application | OSI第5-7层:会话层、表示层与应用层

Layer 5, the Session layer, establishes, manages, and terminates sessions between applications. A session is a persistent logical connection that enables dialogue control, synchronization, and checkpointing. For example, when you log into a remote server, the session layer keeps that connection alive and tracks its state.

第5层会话层负责建立、管理和终止应用程序之间的会话。会话是一种持久的逻辑连接,支持对话控制、同步和检查点设置。例如,当您登录远程服务器时,会话层保持该连接有效并跟踪其状态。

Layer 6, the Presentation layer, is concerned with data formatting, encryption, and compression. It ensures that data sent by one system can be interpreted by another, translating between different data formats such as ASCII, EBCDIC, JPEG, and MPEG. Encryption protocols like SSL/TLS historically operate at this layer.

第6层表示层关注数据格式化、加密和压缩。它确保一个系统发送的数据能够被另一个系统解释,在不同数据格式(如ASCII、EBCDIC、JPEG和MPEG)之间进行转换。SSL/TLS等加密协议传统上在这一层运作。

Layer 7, the Application layer, is the closest to the end user. It provides network services directly to applications, such as file transfer, email, web browsing, and remote access. Protocols at this layer include HTTP, HTTPS, FTP, SMTP, POP3, IMAP, and DNS. Note that DNS itself is a complex protocol used for domain name resolution, and some textbooks place it at the Application layer even though it conceptually spans multiple layers.

第7层应用层是最接近最终用户的层。它直接向应用程序提供网络服务,如文件传输、电子邮件、网页浏览和远程访问。该层的协议包括HTTP、HTTPS、FTP、SMTP、POP3、IMAP和DNS。需要注意的是,DNS本身是用于域名解析的复杂协议,一些教科书将其放在应用层,尽管它在概念上跨越多个层。


7. The TCP/IP Model | TCP/IP模型

The TCP/IP model was developed in the 1970s by the U.S. Department of Defense (DoD) and is the practical model used on the modern Internet. It originally consisted of four layers: Network Interface, Internet, Transport, and Application. In modern textbooks, the Network Interface layer is often split into Physical and Data Link layers, yielding a five-layer model that aligns more closely with the OSI model.

TCP/IP模型由美国国防部(DoD)在20世纪70年代开发,是现代互联网上实际使用的模型。它最初包含四个层:网络接口层、网际层、传输层和应用层。在现代教科书中,网络接口层常被拆分为物理层和数据链路层,形成与OSI模型更为对齐的五层模型。

Application → Transport → Internet → Data Link → Physical

应用层 → 传输层 → 网际层 → 数据链路层 → 物理层

The TCP/IP model is protocol-driven; each layer maps to specific real-world protocols. The Internet layer uses IP for addressing and routing, ICMP for error reporting (used by ping), and ARP for resolving IP addresses to MAC addresses. The Transport layer uses TCP and UDP as described above. The Application layer encompasses all higher-level protocols.

TCP/IP模型是协议驱动的;每一层映射到具体的现实协议。网际层使用IP进行寻址和路由,使用ICMP进行错误报告(ping命令所依赖),使用ARP将IP地址解析为MAC地址。传输层使用上述TCP和UDP。应用层涵盖所有高层协议。


8. Comparing OSI and TCP/IP | OSI与TCP/IP对比

Students often need to compare the two models in exams. The key differences can be summarized as follows:

学生经常需要在考试中比较这两个模型。关键差异可以总结如下:

Aspect | 方面 OSI Model | OSI模型 TCP/IP Model | TCP/IP模型
Number of layers | 层数 7 | 7层 4 or 5 (depending on convention) | 4或5层(视约定而定)
Development approach | 开发方式 Theory first, then protocols | 先理论后协议 Protocols first, then model | 先有协议后有模型
Layer separation | 层分离 Strict separation of session and presentation | 严格区分会话层和表示层 Session and presentation merged into application | 会话和表示合并到应用层
Usage | 实际使用 Reference model (conceptual) | 参考模型(概念性) Implemented model (Internet) | 实际实现的模型(互联网)
Protocol specificity | 协议指定 Does not specify protocols | 不指定协议 Tightly coupled to TCP/IP protocols | 与TCP/IP协议紧密耦合

Despite their differences, both models share a layered architecture and use encapsulation to transmit data. The OSI model is more detailed and serves as an excellent teaching tool, while the TCP/IP model reflects what actually happens on the Internet.

尽管存在差异,两个模型都采用分层架构,并使用封装来传输数据。OSI模型更详细,是极佳的教学工具,而TCP/IP模型反映了互联网上实际发生的情况。


9. Encapsulation and Data Flow | 封装与数据流

Encapsulation is the process by which each layer adds its own header (and sometimes trailer) to the data as it travels down the stack. This is analogous to placing a letter into an envelope, then placing that envelope into a larger padded bag, and so on. The unit of data at each layer has a specific name:

封装是每一层在数据沿协议栈向下传输时添加自己的头部(有时还有尾部)的过程。这类似于把信放入信封,再把信封放入更大的邮袋中。每一层的数据单元都有特定的名称:

  • Application layer: message / data | 应用层:消息/数据
  • Transport layer: segment (TCP) or datagram (UDP) | 传输层:段(TCP)或数据报(UDP)
  • Network layer: packet | 网络层:分组/数据包
  • Data Link layer: frame | 数据链路层:
  • Physical layer: bits | 物理层:比特

Consider sending an HTTP request. The application layer creates the request message. The transport layer adds a TCP header with source and destination ports. The network layer adds an IP header with source and destination IP addresses. The data link layer adds a frame header with MAC addresses and a trailer with error-checking information. Finally, the physical layer transmits these bits onto the wire.

考虑发送一个HTTP请求。应用层创建请求消息。传输层添加带有源端口和目的端口的TCP头部。网络层添加带有源IP地址和目的IP地址的IP头部。数据链路层添加带有MAC地址的帧头和包含错误校验信息的帧尾。最后,物理层将这些比特传输到线缆上。

At the receiving end, the reverse process called de-encapsulation occurs. Each layer strips off its corresponding header and passes the remaining payload up to the next layer. This ensures that only the intended application receives the original data.

在接收端,发生称为解封装的逆向过程。每一层剥离其对应的头部,并将剩余的有效载荷传递给上一层。这确保了只有预期的应用程序才能收到原始数据。


10. Common Exam Questions and Memory Aids | 常见考题与记忆技巧

Exam questions on this topic often fall into four categories: identifying which layer performs a specific function, matching protocols to layers, comparing OSI and TCP/IP, and tracing the data flow through encapsulation. To master these, students should memorize the seven OSI layers in order and associate each function with its layer.

关于这一主题的考题通常分为四类:识别执行特定功能的是哪一层、将协议与层匹配、比较OSI和TCP/IP,以及追踪数据通过封装的流动。要掌握这些,学生应记住OSI七层的顺序,并将每个功能与其对应层关联起来。

Common memory aids for the OSI model include: “Please Do Not Throw Sausage Pizza Away” (top to bottom: P-D-N-T-S-P-A) and its reverse for bottom to top: “All People Seem To Need Data Processing” (A-P-S-T-N-D-P). For the TCP/IP model, remember that it merges OSI layers 5-7 into Application and merges layers 1-2 into Network Interface.

OSI模型常用的记忆口诀包括:英文首字母句 “Please Do Not Throw Sausage Pizza Away”(从上到下:P-D-N-T-S-P-A),以及其反向句 “All People Seem To Need Data Processing”(从下到上:A-P-S-T-N-D-P)。对于TCP/IP模型,记住它将OSI第5-7层合并为应用层,并将第1-2层合并为网络接口层。

OSI top-down: Application → Presentation → Session → Transport → Network → Data Link → Physical

OSI自顶向下:应用层 → 表示层 → 会话层 → 传输层 → 网络层 → 数据链路层 → 物理层

Another tip: remember the key devices per layer. Hubs and repeaters → Physical. Bridges and switches → Data Link. Routers → Network. Gateway and firewall (in some contexts) → Network or Application. Protocols can also be grouped: HTTP, SMTP, FTP, DNS → Application; TCP, UDP → Transport; IP, ICMP, ARP → Network.

另一个技巧:记住每层的关键设备。集线器和中继器 → 物理层。网桥和交换机 → 数据链路层。路由器 → 网络层。网关和防火墙(在某些上下文) → 网络层或应用层。协议也可以分组:HTTP、SMTP、FTP、DNS → 应用层;TCP、UDP → 传输层;IP、ICMP、ARP → 网络层。


11. Practical Example: Loading a Web Page | 实际示例:加载网页

Let us trace the complete journey of a web request to see how both models work together. When you type “https://www.aleveler.com” into your browser, the application layer first performs a DNS lookup to resolve the domain name into an IP address. This DNS query itself is sent using UDP to port 53 of a DNS server.

让我们追踪一个网页请求的完整旅程,看看这两个模型如何协同工作。当您在浏览器中输入”https://www.aleveler.com”时,应用层首先执行DNS查询,将域名解析为IP地址。这个DNS查询本身通过UDP发送到DNS服务器的53端口。

Once the IP address is obtained, the browser initiates a TCP connection to the server using a three-way handshake on port 443 (HTTPS). After the connection is established, the application layer sends an HTTP GET request. The transport layer segments the request, assigns sequence numbers, and forwards the segments to the network layer.

获得IP地址后,浏览器在443端口(HTTPS)上通过三次握手发起TCP连接到服务器。连接建立后,应用层发送HTTP GET请求。传输层对请求进行分段、分配序列号,并将段转发给网络层。

The network layer wraps each segment in an IP packet with the source IP (your computer) and destination IP (the web server). The data link layer then frames the packet with MAC addresses of your computer and the default gateway (router). Each router along the path performs the same process, using its routing table to forward the packet hop-by-hop until it reaches the destination server.

网络层将每个段封装为带有源IP(您的计算机)和目的IP(Web服务器)的IP数据包。数据链路层随后使用您的计算机和默认网关(路由器)的MAC地址将数据包装帧。路径上的每个路由器都执行相同的过程,使用其路由表将数据包逐跳转发,直到到达目标服务器。

The server responds with the requested web page, which travels back through the network using the same layered process in reverse. This bidirectional flow demonstrates how the layered design enables reliable, scalable communication across heterogeneous networks.

服务器以请求的网页作为响应,该响应通过相同的分层过程逆向穿越网络返回。这种双向流动展示了分层设计如何实现跨异构网络的可靠、可扩展通信。


12. Conclusion | 总结

The OSI and TCP/IP models are indispensable tools for understanding computer networks. The OSI model offers a detailed seven-layer framework ideal for teaching and standardization, while the TCP/IP model provides the practical five-layer (or four-layer) structure that powers the Internet. Mastery of layer functions, protocol responsibilities, encapsulation, and inter-model comparisons is crucial for academic success.

OSI和TCP/IP模型是理解计算机网络不可或缺的工具。OSI模型提供了详细的七层框架,非常适合教学和标准化,而TCP/IP模型提供了驱动互联网的实际五层(或四层)结构。掌握层功能、协议职责、封装和模型间比较对学术成功至关重要。

We recommend that students draw both models side by side, label each layer with its key protocols and devices, and practice tracing data flows. This active learning approach will solidify your understanding and prepare you for a wide range of exam questions.

我们建议学生并排绘制两个模型,在每个层上标注其关键协议和设备,并练习追踪数据流。这种主动学习方法将巩固您的理解,并帮助您应对各种考试问题。

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