计算机网络协议分层
目前关于网络通信的标准有两套协议,分别是 OSI 参考模型和 TCP/IP 模型。OSI 参考模型只用于理论研究,而 TCP/IP 模型更注重于实际应用,他们的关系如下:
+-------------------------+ +----------------------+
| | | |
| OSI Model | | TCP/IP Model |
| | | |
+-------------------------+ +----------------------+
| Application Layer | | |
+-------------------------+ | |
| Presentation Layer | | Application Layer |
+-------------------------+ | |
| Session Layer | | |
-------------------------------------------------------------------------------
| Transport Layer | | Transport Layer |
+-------------------------+ +----------------------+
| Network Layer | | Internet Layer |
-------------------------------------------------------------------------------
| Data Link Layer | | |
+-------------------------+ | Network Access Layer |
| Physical Layer | | |
+-------------------------+ +----------------------+
TCP/IP 模型各层常见协议
+--------+ +--------+ +-----------+ +--------+ |
Application Layer | ping | | telnet | | OSPF | | DNS | User Space |
+---+----+ +----+---+ +----+------+ +---+----+ |
| | | | |
--------------------------------------------------------------------------------------socket------------
| | | | |
| +----+---+ | +---+----+ |
Transport Layer | | TCP | | | UDP | |
| +--------+----+ | +-------+--------+ |
| | | | |
---------------------------------------------------------------------------------- |
| | | | |
+---+----+ +--+--+--+-+ |
Internet Layer | ICMP +-------------+ IP | Kernel Space |
+--------+ +-----+----+ |
| |
---------------------------------------------------------------------------------- |
| |
+--------+ +-----+----+ +-------+ |
Network Access Layer | ARP +------------+ DataLink +------+ RARP | |
+--------+ +-----+----+ +-------+ |
| v
-------------------------------------------------------+-------------------------- Physical media
TCP/IP 数据包的封装与解封
在 TCP/IP 网络中,通信双方的交互过程就是对协议的封装与解封装的过程,发送方数