English
A network protocol is a set of rules for how computers communicate. The rules specify what messages are exchanged, in what order, in what format, and what each party should do when a message is lost, corrupted, or arrives out of order. That specification — precise enough for independent implementations to interoperate, robust enough to survive the full range of conditions the network can create — is the primary artifact of network design. The protocol is not the wire; it is not the packet; it is the agreement that makes the wire and the packet useful.
What makes computer networks a foundational subject is not the specific protocols the Internet uses today, which will evolve, but the problems those protocols address: how to build reliable communication on top of an unreliable substrate; how to route packets across a global network of millions of heterogeneous machines with no central coordination; how to design protocols that will scale from thousands to billions of participants and remain useful across decades of evolution without synchronized replacement. These problems are harder than they look, and the solutions encode decades of design wisdom that is not obvious from either the protocols’ specifications or their everyday use.
The layered model of the Internet — link layer, network layer, transport layer, application layer — is the organizational framework for thinking about this complexity. Each layer addresses a specific set of concerns, provides services to the layer above, and uses services from the layer below. The layering is not just pedagogical; it is a design principle that allows each layer to be implemented, debugged, and evolved independently. Understanding what each layer does and why it is separated from adjacent layers is more important than memorizing which specific protocol belongs at which layer.
Prerequisites: Operating systems (§4.2) — network protocols are implemented in the kernel, and the system-call interface for network programming is an OS concern. Algorithms (§2.6) — routing algorithms are graph algorithms with additional complexity. Discrete mathematics (§2.2) — error-correcting codes, checksums, and analysis of routing convergence all draw on this material.
How the Internet Was Designed and What It Revealed About Networks
Computer communication predates the Internet by decades — telegraph networks in the nineteenth century, telephone networks in the twentieth — but the conceptual breakthrough that produced the Internet was the invention of packet switching.
Traditional telephone networks used circuit switching: before a call could begin, a dedicated circuit was established through the network from caller to receiver, reserving capacity at every intermediate point. The circuit held capacity whether or not the parties were speaking. This worked for voice telephony, where conversations are continuous, but it was economically wasteful for data communication, where traffic is bursty — idle most of the time and intense in short bursts. Paul Baran at RAND Corporation (working on military communications in 1964) and Donald Davies at the National Physical Laboratory in Britain (1965) independently proposed packet switching: messages are divided into short packets, each labeled with source and destination addresses, and each packet is routed independently through the network, sharing links with packets from other messages. A failed link does not break a communication; packets are simply routed around it. A dedicated circuit is never reserved; capacity is shared among all active flows. The two inventors arrived at the same idea from different motivations — Baran from survivability of military communications under attack, Davies from efficient use of shared network capacity — which suggests the idea was timely rather than accidental.
ARPANET, funded by the U.S. Department of Defense’s Advanced Research Projects Agency, implemented packet switching beginning in 1969, initially connecting four universities: UCLA, Stanford Research Institute, UC Santa Barbara, and the University of Utah. The first message transmitted over ARPANET was “LO” — an attempt to log into a remote computer that crashed the system before the third character could be sent. By 1971, ARPANET had fifteen nodes. By 1981, it had over two hundred. The network worked, demonstrating practically that packet switching at scale was feasible.
The critical architectural decision that shaped the modern Internet was made in the early 1970s, when Vint Cerf and Bob Kahn designed the Transmission Control Protocol. The original ARPANET used a protocol, NCP, that made reliability guarantees at the network level — intermediate routers were responsible for ensuring delivery. Cerf and Kahn proposed a different architecture: the network layer (which became IP) would provide only best-effort packet delivery, making no guarantees of ordering or delivery, while a transport layer (TCP) at the endpoints would provide reliable, ordered delivery for applications that needed it. The logic was the end-to-end argument, articulated precisely in 1981 by Saltzer, Reed, and Clark: functions can be implemented correctly only at the endpoints of a communication, and intermediate nodes should provide only the minimum services necessary for communication. A network that provides reliability at the intermediate nodes still requires the endpoints to implement reliability anyway — they cannot trust that every intermediate node has implemented it correctly — so the intermediate implementation provides no benefit at the cost of added complexity. A simple network whose intermediate nodes only route packets is more reliable (because it has fewer components that can fail), more evolvable (because its nodes do not need to be updated when new applications require new behaviors), and more general (because any transport-layer behavior can be built on top of it) than a complex network that provides more services internally.
TCP and IP were officially separated in 1978, and ARPANET switched from NCP to TCP/IP in a cutover on January 1, 1983 — one of the few hard cutover events in the Internet’s history. The same year, the Domain Name System was designed by Paul Mockapetris. Early Internet addressing required maintaining flat host-name-to-IP-address mapping files, centrally maintained and distributed to all hosts — a system that was collapsing under the weight of the network’s growth. DNS replaced the flat file with a distributed hierarchical database, delegating authority for subdomains to their respective administrators, allowing the namespace to grow without central coordination. The design — distributed, delegated, with eventual consistency across replicas — set the template for distributed data systems that would be built for decades afterward.
The World Wide Web, created by Tim Berners-Lee at CERN in 1991, was not a network invention but an application that ran on the network and triggered explosive growth. In 1990 there were roughly three hundred thousand Internet hosts. In 1995, after web browsers made the Internet visually navigable, there were six million. In 2000, two hundred and fifty million. The growth rate overwhelmed IPv4’s original design, which allocated only 32-bit addresses — a theoretical maximum of four billion addresses. The community had recognized the address exhaustion problem in the early 1990s and begun developing two responses: Network Address Translation (NAT), which allowed multiple devices to share a single public IP address, and IPv6, which extended addresses to 128 bits. NAT was deployed quickly and extended IPv4’s lifespan by decades; IPv6 was standardized in 1998 and has been in gradual deployment since, though the transition is still far from complete in 2025.
The security of the Internet’s foundational protocols proved to be largely absent. IP, TCP, DNS, BGP — the core protocols were designed in an era of small, trusted networks and contain no authentication, no encryption, and limited protection against manipulation. The DNS cache poisoning attack, demonstrated by Dan Kaminsky in 2008, showed that an attacker could poison the DNS caches of major resolvers to redirect traffic across the Internet. BGP hijacking — advertising fake routes to capture traffic — has been demonstrated repeatedly, most dramatically when Pakistan Telecom accidentally hijacked YouTube’s address space globally in 2008, and more deliberately by state-level actors. The security retrofits — DNSSEC for DNS integrity, RPKI for BGP route origin authentication, TLS for application-layer encryption — have been developed and deployed incrementally, but the underlying protocols remain fundamentally insecure at the network layer. The 2010s saw a shift toward end-to-end encryption at the application layer: Let’s Encrypt, launched in 2016, made TLS certificates free and automated, enabling HTTPS for essentially any website, and by 2020 the majority of Internet traffic was encrypted.
The most significant recent protocol development is QUIC, developed by Google starting around 2012 and standardized by the IETF in 2021 as RFC 9000. QUIC runs on top of UDP and integrates the functions that TCP provides (reliable, ordered delivery; connection establishment; congestion control) with TLS encryption built in from the start. The key advantages over TCP are reduced connection setup latency (QUIC establishes an encrypted connection in one round trip, where TCP plus TLS required several), elimination of head-of-line blocking (QUIC handles multiple streams within a connection without blocking one stream when another has packet loss), and deployability in user space (enabling faster evolution than TCP’s kernel-space implementation allows). HTTP/3, the current version of the web’s primary application protocol, runs on QUIC. The transition from TCP to QUIC for web traffic is the largest architectural change in the Internet’s transport layer since TCP itself.
Routing, Reliability, and the Stack
The Network Layer: Addressing and Routing
The Internet Protocol (IP) provides a single abstraction across the heterogeneous collection of physical networks that compose the Internet: a packet with a source address, a destination address, and a payload, delivered on a best-effort basis from any host to any other host connected to the Internet. The simplicity of this abstraction — no guarantees, just forwarding — is what makes the Internet’s diversity possible. A packet traverses Ethernet links, fiber optic cables, wireless connections, and satellite links, each with different physical characteristics, and IP provides a uniform service across all of them.
IP addressing and routing are the core problems of the network layer. An IP address identifies both a device and its location in the network: the address hierarchy (network prefix, host portion) allows routers to make forwarding decisions based on the address’s prefix alone, without knowing about every individual host. Classless Inter-Domain Routing (CIDR), adopted in 1993, extended this by allowing arbitrary prefix lengths rather than fixed class boundaries, enabling more efficient address allocation. Border Gateway Protocol (BGP), the routing protocol that exchanges reachability information between the autonomous systems that compose the Internet, is responsible for ensuring that any prefix can be reached from any other. BGP is not optimized for speed or optimality — it converges slowly after topology changes and allows policy to override shortest-path routing — but it is designed for the Internet’s actual requirements: scalability to hundreds of thousands of prefixes, operator control over routing policy, and gradual convergence without requiring global coordination.
The interior routing protocols that operate within an autonomous system — OSPF and IS-IS for link-state routing, RIP and EIGRP for distance-vector routing — maintain routing tables for the internal network. Link-state protocols flood topology information to all routers in the domain and compute shortest paths using Dijkstra’s algorithm; the result is consistent routing tables that converge quickly after topology changes but require O(n²) memory and computation for large networks. Distance-vector protocols exchange only reachability and distance information with neighbors and converge more slowly but require less memory. The choice between link-state and distance-vector reflects engineering tradeoffs that depend on network size, stability, and topology.
The Transport Layer: Reliability and Congestion Control
TCP provides reliable, ordered byte-stream delivery between two endpoints. Its mechanisms — sliding window flow control, sequence numbers for ordering and duplicate detection, acknowledgment-based reliability with retransmission on timeout, three-way handshake for connection establishment — transform the unreliable IP service into a reliable stream. Understanding each mechanism requires understanding what failure it addresses: sequence numbers detect duplicates and enable ordering; acknowledgments with retransmission ensure delivery; flow control prevents the sender from overwhelming the receiver; the three-way handshake synchronizes state between endpoints before data flows.
Congestion control is the mechanism by which TCP prevents senders from overwhelming the network with more traffic than it can carry. Van Jacobson’s 1988 paper “Congestion Avoidance and Control” described the algorithms that transformed the Internet’s then-recent congestion collapse — in 1986, network throughput had dropped to fractions of its nominal capacity due to uncontrolled retransmission storms — into the controlled system that has operated since. TCP’s congestion control (slow start, congestion avoidance, fast retransmit, fast recovery) uses packet loss as a signal of congestion and reduces the sending rate in response. The elegance of the design is that it requires no explicit congestion signal from the network — loss is inferred from the absence of acknowledgment — and it is implemented at the endpoints without requiring network cooperation.
UDP provides unreliable datagram delivery: each datagram is independent, may be lost or arrive out of order, and there is no connection state or flow control. UDP is appropriate for applications that need low latency and can tolerate some loss (real-time audio and video, gaming, DNS queries) or that implement their own reliability above the transport layer (QUIC, SCTP, custom protocols in distributed systems). Understanding when UDP is the right choice — and when TCP’s reliability overhead is worth paying — requires understanding what each transport provides and what the application actually needs.
The Application Layer and Protocol Design
HTTP, DNS, TLS, SMTP, SSH — the application protocols that most network code directly uses — are built on top of the transport layer and implement the specific semantics required for each application. Understanding these protocols at the specification level, not just through the libraries that implement them, is what enables debugging, performance optimization, and security analysis.
TLS (Transport Layer Security) provides confidentiality, integrity, and authentication for application-layer protocols. TLS 1.3, the current version, achieves forward secrecy (compromise of long-term keys does not compromise past sessions), requires one round trip for connection establishment (compared to two for TLS 1.2), and removed the weak cryptographic algorithms that had been exploited in attacks like POODLE and BEAST. The design of TLS 1.3 is a case study in protocol security analysis: the academic community’s formal analysis of TLS 1.2 found subtle vulnerabilities that the 1.3 redesign addressed systematically.
DNS resolution involves a hierarchical delegation: a recursive resolver contacts the root nameservers, which delegate to the TLD nameservers (for .com, .org, etc.), which delegate to the authoritative nameservers for the specific domain. The delegation hierarchy allows the namespace to scale without central coordination, but it also creates a complex trust model: a compromise at any point in the delegation chain can redirect traffic. DNSSEC provides cryptographic signatures over DNS records, allowing recursive resolvers to verify that responses came from authoritative servers and have not been tampered with. DNS-over-HTTPS and DNS-over-TLS encrypt the resolution query itself, preventing eavesdropping on which names a client resolves — a significant privacy improvement, since DNS queries reveal browsing behavior.
Good protocol design requires specifying not just the successful case but every failure mode: what a client does when a server does not respond within the timeout, what a server does when it receives a request it cannot parse, how a half-open connection is cleaned up when one endpoint crashes. The RFCs that specify major Internet protocols devote substantial space to these edge cases, and implementations that fail to handle them correctly are a major source of security vulnerabilities and interoperability problems.
What Studying This Changes
Computer networks changes what practitioners can see in distributed systems and in security.
The first change is the ability to reason about communication failures. A network call may fail because the request was lost, the response was lost, or the remote end crashed after receiving the request but before responding. These cases are not distinguishable from the caller’s perspective. A distributed system that assumes network calls either succeed or fail cleanly will behave incorrectly when calls partially succeed — when a request is processed but the response is lost. Networks training instills the habit of reasoning about all failure modes, not just the happy path, and of designing protocols that behave correctly under partial failure.
The second change is fluency with the layered abstraction as a diagnostic tool. A connectivity problem can occur at any layer: a cable is disconnected (link layer), the routing table has no route to the destination (network layer), a firewall is blocking TCP connections to the port (transport layer), the server is not listening (application layer). The layered framework structures the diagnostic process — check each layer in order — and identifies which tools apply at each layer. Without the framework, debugging is trial and error; with it, debugging is systematic.
The third change is security awareness at the network level. Man-in-the-middle attacks exploit the absence of authentication in the network layer. DNS cache poisoning exploits the absence of integrity guarantees in DNS. BGP hijacking exploits the absence of route origin authentication. Understanding these attacks and their mitigations requires understanding the protocols they target. A practitioner who knows the protocols can read security advisories and reason about whether their systems are affected; one who does not must rely entirely on others for that assessment.
The fourth change is the ability to make informed protocol design decisions. Most practitioners design protocols in the broad sense regularly — defining the format and semantics of messages between services in a distributed system, specifying the behavior of APIs, designing the communication patterns of microservices. The discipline of protocol design — precise specification, failure-mode analysis, evolutionary design, careful tradeoff analysis — applies directly, and practitioners who have studied formal protocols bring more rigor to these informal protocol designs.
Resources
Books and Texts
Kurose and Ross’s Computer Networking: A Top-Down Approach (8th ed., Pearson, 2021) is the standard contemporary entry. Its top-down organization — beginning at the application layer and working down to the link layer — introduces concepts in a context that makes them immediately meaningful. A student who has used HTTP and DNS daily encounters their formal specifications; the motivation is clear. The writing is accessible, the examples are well-chosen, and the associated programming assignments (socket programming, HTTP server implementation) are effective. For self-study, it is the right starting point.
Peterson and Davie’s Computer Networks: A Systems Approach (free online at book.systemsapproach.org) covers similar ground with more emphasis on how protocols are actually implemented and how networks are operated. Where Kurose-Ross is pedagogically organized for students, Peterson-Davie is organized around systems-engineering concerns — how to build robust network systems — and is more informative about the engineering decisions behind protocol design. It is the right second text after Kurose-Ross, or the right primary text for readers with more systems background. The free online version is current.
For TCP/IP at depth, Stevens’s TCP/IP Illustrated, Volume 1 (2nd ed., revised by Fall, Addison-Wesley, 2011) remains the canonical reference. Stevens traces TCP and IP behavior through actual packet captures, showing what the protocols do under various conditions — normal operation, retransmission, congestion — with Wireshark traces. The depth it provides is unavailable elsewhere. For serious networking work — debugging TCP problems, implementing protocol components — it is indispensable.
For protocol security, Computer Security: Art and Science by Matt Bishop, and the IETF RFCs for TLS 1.3 (RFC 8446), DNSSEC (RFC 4034), and QUIC (RFC 9000) are the canonical references. The RFCs are the authoritative specifications; reading them directly teaches the standard of precision that protocol specifications require.
| Book | Role | Type |
|---|---|---|
| Kurose & Ross, Computer Networking: A Top-Down Approach (8th ed.) | Standard contemporary entry | Entry |
| Peterson & Davie, Computer Networks: A Systems Approach (free online) | Systems-engineering perspective | Entry |
| Bonaventure, Computer Networking: Principles, Protocols and Practice (free online) | Open textbook alternative | Auxiliary |
| Grigorik, High Performance Browser Networking (free online) | Web networking and performance bridge | Auxiliary |
| Stevens, TCP/IP Illustrated, Volume 1 (2nd ed.) | Deep TCP/IP reference | Reference |
| Saltzer, Reed & Clark, “End-to-End Arguments in System Design” (1981, free) | Foundational architectural paper | Depth |
| Major RFCs: 791 (IP), 793 (TCP), 1034/1035 (DNS), 8446 (TLS 1.3), 9000 (QUIC) | Authoritative protocol specifications | Reference |
Courses and Lectures
Stanford CS 144 (Introduction to Computer Networking, free materials and project) includes the most valuable network programming exercise in any university curriculum: implementing a TCP/IP stack from scratch in C++. The project requires implementing the three-way handshake, reliable in-order delivery, flow control, and connection teardown, using only UDP to send packets. Building TCP is the fastest route to deeply understanding it. The course lectures and lab materials are freely available.
Princeton’s COS 461 (Computer Networks, materials online) covers similar material with different emphasis, including more treatment of network measurement and Internet architecture. The lecture notes are high-quality and worth reading alongside Kurose-Ross.
Beej’s Guide to Network Programming (free online) is the most accessible introduction to Unix socket programming — the system call interface through which application code interacts with the network stack. It is narrower than the course materials but more practical for programmers who need to write network code immediately.
| Course | Platform | Type |
|---|---|---|
| Stanford CS 144 Introduction to Computer Networking (free) | Stanford / course site | Entry |
| Princeton COS 461 Computer Networks (free) | Princeton / course site | Entry |
| Beej’s Guide to Network Programming (free) | beej.us | Practice |
| Beej’s Guide to Network Concepts (free) | beej.us | Auxiliary |
| Julia Evans networking, DNS, and HTTP zines (paid) | wizardzines.com | Auxiliary |
Practice, Tools, and Current Sources
Wireshark (free) captures and analyzes network packets, showing the complete contents of every packet at every layer. Running Wireshark while making an HTTP request shows the DNS resolution, TCP handshake, TLS handshake, HTTP request, and HTTP response as individual packets with full decode. No other tool makes the protocol stack as concrete. The Wireshark University materials and the Practical Packet Analysis book provide structured learning.
curl with verbose flags (curl -v, curl --trace) shows the DNS resolution and connection establishment for an HTTP or HTTPS request. Adding --http1.1 or --http2 or --http3 switches between protocol versions. Running these in sequence shows the connection establishment differences between HTTP/1.1 (TCP + TLS separately), HTTP/2 (same, with multiplexed streams), and HTTP/3 (QUIC with integrated TLS).
netcat (nc) provides raw access to TCP and UDP connections, making it easy to observe protocol behavior directly. nc -l 8080 opens a listening TCP port; nc hostname 8080 connects to it; typing in one terminal sends data to the other. More interesting: nc hostname 80 followed by typing a raw HTTP request shows the HTTP response directly, without any library mediation.
QUIC implementations: The major QUIC implementations (quiche from Cloudflare, ngtcp2, MsQuic from Microsoft) are open source and well-documented. Reading the implementation of a QUIC connection establishment is the best way to understand how QUIC’s zero-RTT resumption and connection migration work.
The Cloudflare blog and APNIC blog are the best ongoing technical sources for Internet protocols and operations at scale. Cloudflare’s posts on TLS 1.3, QUIC, DNS over HTTPS, and BGP security are technically rigorous and reflect production experience at massive scale.
| Resource | Platform | Type |
|---|---|---|
| Wireshark (free) | wireshark.org | Practice |
| curl with verbose flags (free) | curl.se | Practice |
| Stanford CS 144 TCP implementation project | Course site | Practice |
| Cloudflare blog (free) | blog.cloudflare.com | Reference |
| APNIC blog (free) | blog.apnic.net | Reference |
| QUIC implementation projects: quiche, ngtcp2, MsQuic (free) | GitHub | Reference |
Traps
| Trap | Why it misleads | Better response |
|---|---|---|
| Layer-diagram fixation | Memorizing the OSI layers and which protocols occupy each layer is a common exam preparation strategy that produces minimal understanding. The layers are a tool for organizing concepts; what matters is what each layer does, what problems it addresses, and what assumptions it makes about the layer below. Learners who know the layer names but cannot explain why the transport layer is separated from the network layer have memorized a diagram without understanding the design principles behind it. | For each layer, ask: what problem does this layer solve that the layer below cannot? What does it guarantee to the layer above? What does it leave for the layer above to handle? The end-to-end principle (Saltzer, Reed, and Clark 1981) provides the organizing answer and should be read early, not late. |
| Protocol-detail overload | TCP has a large state machine; DNS has many record types; TLS has multiple cipher suites and extension points. Trying to memorize all of this detail produces overwhelm without understanding. The details matter in professional practice, but they are reference material to consult, not curricula to memorize. | Focus on the essential mechanisms of each protocol: what TCP’s sliding window and congestion control accomplish, what DNS’s hierarchical delegation provides, what TLS’s handshake establishes. The specific details — header field sizes, error codes, option formats — are in the RFC and in Stevens; look them up when needed rather than memorizing them in advance. |
| Practical familiarity as proxy for understanding | Most learners arrive at a networks course having used the Internet for years. This practical familiarity is useful but does not constitute understanding of how the Internet works. A learner who has made thousands of HTTPS requests but cannot explain the TLS handshake, cannot identify what a packet capture shows for a DNS failure, and cannot reason about what happens when a TCP connection is half-open has surface familiarity without the conceptual foundation. | Treat each topic as if encountering it fresh, regardless of practical experience. When studying HTTP, trace the protocol with Wireshark rather than just using it through a library. When studying DNS, query resolvers directly with dig rather than letting the operating system handle resolution transparently. The practical experience is useful context; the technical understanding requires deliberate engagement with the protocol details. |
| Treating the protocol specification as what runs | Protocol specifications (RFCs) define the correct behavior; production implementations deviate in documented and undocumented ways. TCP implementations optimize for common cases in ways that the specification allows but does not require. BGP implementations have vendor-specific behaviors that differ from the specification. TLS libraries have historically had bugs that created vulnerabilities in otherwise-correct protocols. The network that actually exists is not the network that the specifications describe. | Supplement specification study with implementation study. Read the Linux kernel’s TCP implementation alongside Stevens’s book. Use Wireshark on real traffic and compare to the specification. When specification and implementation diverge, understand why — it is usually either a bug, a performance optimization, or a deliberate extension. The gap between specification and implementation is where many security vulnerabilities live. |
| Missing the security dimension | Network security is not a separate chapter; it is a dimension of every protocol. IP’s lack of authentication enables spoofing. TCP’s predictable sequence numbers enable RST injection. DNS’s lack of integrity enables cache poisoning. SMTP’s unauthenticated sender enables phishing. TLS’s complexity enables implementation bugs. Treating security as an add-on to a complete understanding of protocols is backwards — security considerations should be part of understanding each protocol. | When studying each protocol, identify its security assumptions and attack surface. What does it authenticate? What does it protect from tampering? What does it reveal to an eavesdropper? What attacks have been demonstrated against it historically? The answers to these questions are part of understanding the protocol, not additional material to add later. |
| Skipping the implementation | Stanford’s CS 144 TCP implementation project is the most direct route to deep TCP understanding available. Building the state machine, handling retransmission, implementing flow control, and debugging the resulting implementation reveals what the specification actually requires and what the common failure modes are. Reading the specification and the textbook is valuable but qualitatively less educational than implementing the protocol. | Do the CS 144 TCP project or an equivalent. If CS 144’s specific project is not accessible, implement a simpler protocol — an HTTP/1.1 client that performs a GET request manually over a TCP socket, or a simple UDP-based reliable protocol. The cognitive difference between understanding a protocol’s description and implementing it correctly is large, and the implementation closes a gap that reading cannot. |
中文
网络协议是一组规定计算机如何通信的规则。这些规则规定要交换什么消息,按什么顺序交换,以什么格式交换,以及当消息丢失、损坏或乱序到达时,各方应当做什么。这种规约——精确到足以让独立实现彼此互操作,稳健到足以承受网络可能制造出的全部条件——是网络设计的主要产物。协议不是电线;不是数据包;而是让电线和数据包变得有用的约定。
计算机网络之所以是基础主题,并不在于今天 Internet 使用的具体协议——这些协议会演化——而在于这些协议所处理的问题:如何在不可靠的底层之上构建可靠通信;如何在一个由数百万异构机器组成、没有中心协调的全球网络中路由 packets;如何设计能从数千参与者扩展到数十亿参与者,并在几十年演化中保持有用、无需同步替换的协议。这些问题比看起来更难,而其解决方案编码了几十年的设计智慧;这些智慧既不会从协议规范中自动显现,也不会从日常使用中自然显现。
Internet 的分层模型——link layer、network layer、transport layer、application layer——是思考这种复杂性的组织框架。每一层处理一组特定关切,向上一层提供服务,并使用下一层提供的服务。分层不只是教学工具;它是一条设计原则,使每一层可以被独立实现、调试和演化。理解每一层做什么,以及为什么要与相邻层分离,比记住某个具体协议属于哪一层更重要。
前置知识:操作系统(§4.2)——网络协议在内核中实现,而网络编程的 system-call interface 是操作系统问题。算法(§2.6)——路由算法是带有额外复杂性的图算法。离散数学(§2.2)——纠错码、checksums 和路由收敛分析都会用到这些材料。
Internet 是如何被设计出来的,以及它揭示了什么网络问题
计算机通信早于 Internet 数十年——十九世纪有电报网络,二十世纪有电话网络——但产生 Internet 的概念突破,是 packet switching 的发明。
传统电话网络使用 circuit switching:一次通话开始之前,网络会先在呼叫者和接收者之间建立一条专用 circuit,并在每个中间节点预留容量。无论通话双方是否正在说话,这条 circuit 都会占用容量。这适合语音电话,因为对话是连续的;但对数据通信来说经济上浪费,因为数据流量具有 bursty 特征——大多数时候空闲,只在短时间内高度集中。RAND Corporation 的 Paul Baran(1964 年研究军事通信)和英国 National Physical Laboratory 的 Donald Davies(1965 年)独立提出了 packet switching:消息被分割成短 packets,每个 packet 都标有源地址和目的地址,并在网络中独立路由,与其他消息的 packets 共享链路。某条链路失效不会中断通信;packets 只需绕过它继续路由。不会预留专用 circuit;容量在所有活跃 flows 之间共享。两位发明者从不同动机抵达同一个想法——Baran 关注遭受攻击时军事通信的生存性,Davies 关注共享网络容量的高效使用——这说明这个想法的出现是时代成熟,而不是偶然。
ARPANET 由美国国防部 Advanced Research Projects Agency 资助,从 1969 年开始实现 packet switching,最初连接四所大学:UCLA、Stanford Research Institute、UC Santa Barbara 和 University of Utah。ARPANET 上传输的第一条消息是 “LO”——原本试图登录远程计算机,但系统在第三个字符发送前崩溃。到 1971 年,ARPANET 有十五个节点。到 1981 年,它已经超过两百个节点。网络确实能工作,实践性地证明了大规模 packet switching 是可行的。
塑造现代 Internet 的关键架构决策发生在 1970 年代早期,当时 Vint Cerf 和 Bob Kahn 设计了 Transmission Control Protocol。原始 ARPANET 使用 NCP 协议,它在网络层提供可靠性保证——中间 routers 负责确保投递。Cerf 和 Kahn 提出了一种不同架构:network layer(后来成为 IP)只提供 best-effort packet delivery,不保证顺序,也不保证投递;而 endpoints 上的 transport layer(TCP)则为需要它的应用提供可靠、有序投递。其逻辑是 end-to-end argument,这一点由 Saltzer、Reed 和 Clark 于 1981 年精确表述:某些功能只有在通信 endpoints 上才能被正确实现,而中间节点应只提供通信所需的最小服务。一个在中间节点提供可靠性的网络,仍然要求 endpoints 自己实现可靠性——它们不能信任每个中间节点都正确实现了可靠性——因此中间层实现不会带来收益,反而增加复杂性。一个中间节点只负责路由 packets 的简单网络,比一个内部提供更多服务的复杂网络更可靠(因为可失败组件更少)、更容易演化(因为新应用需要新行为时,节点不必更新),也更通用(因为任何 transport-layer 行为都可以建立在它之上)。
TCP 和 IP 于 1978 年正式分离,ARPANET 在 1983 年 1 月 1 日的一次切换中从 NCP 转向 TCP/IP——这是 Internet 历史上少数硬切换事件之一。同年,Paul Mockapetris 设计了 Domain Name System。早期 Internet 地址系统需要维护扁平的 host-name-to-IP-address 映射文件,由中心维护并分发给所有 hosts——随着网络增长,这个系统正在崩溃。DNS 用分布式层级数据库取代了扁平文件,把子域名的权威委托给对应管理员,使命名空间可以在没有中心协调的情况下增长。这种设计——分布式、委托式、在副本之间最终一致——为此后几十年构建的分布式数据系统提供了模板。
World Wide Web 由 Tim Berners-Lee 于 1991 年在 CERN 创建,它不是网络发明,而是运行在网络之上的应用,并触发了爆发式增长。1990 年大约有三十万个 Internet hosts。到 1995 年,Web 浏览器使 Internet 变得可视化、可导航后,hosts 数量达到六百万。到 2000 年,达到两亿五千万。增长速度压倒了 IPv4 的原始设计,因为 IPv4 只分配 32-bit addresses——理论上最多四十亿个地址。共同体在 1990 年代早期已经意识到地址耗尽问题,并开始发展两种回应:Network Address Translation(NAT),允许多个设备共享一个 public IP address;以及 IPv6,把地址扩展到 128 bits。NAT 很快部署,并把 IPv4 的寿命延长了几十年;IPv6 于 1998 年标准化,此后逐步部署,不过到 2025 年,迁移仍远未完成。
Internet 基础协议的安全性后来被证明基本缺席。IP、TCP、DNS、BGP——这些核心协议是在小型、可信网络时代设计的,没有认证,没有加密,也几乎没有防篡改保护。Dan Kaminsky 于 2008 年展示的 DNS cache poisoning attack 表明,攻击者可以污染主要 resolvers 的 DNS caches,从而重定向 Internet 上的流量。BGP hijacking——通过通告虚假 routes 捕获流量——已经被反复展示,最戏剧性的事件是 Pakistan Telecom 在 2008 年意外劫持 YouTube 的全球地址空间,也有更刻意的国家级行为。安全 retrofit——用于 DNS 完整性的 DNSSEC、用于 BGP route origin authentication 的 RPKI、用于 application-layer encryption 的 TLS——已经被逐步开发和部署,但底层协议在 network layer 仍然根本不安全。2010 年代出现了向 application layer 端到端加密的转变:Let’s Encrypt 于 2016 年推出,使 TLS certificates 免费且自动化,基本上让任何网站都能启用 HTTPS;到 2020 年,多数 Internet 流量已经被加密。
近期最重要的协议发展是 QUIC。它由 Google 大约从 2012 年开始开发,并于 2021 年由 IETF 标准化为 RFC 9000。QUIC 运行在 UDP 之上,把 TCP 提供的功能(可靠、有序投递;连接建立;拥塞控制)与从一开始就内置的 TLS encryption 整合在一起。它相对于 TCP 的关键优势包括:降低连接建立延迟(QUIC 用一个 round trip 建立加密连接,而 TCP 加 TLS 需要多个)、消除 head-of-line blocking(QUIC 在一个连接内处理多个 streams,当一个 stream 丢包时不会阻塞另一个),以及可以在 user space 中部署(从而比 TCP 的 kernel-space 实现更快演化)。HTTP/3,也就是当前 Web 主要 application protocol 的版本,运行在 QUIC 之上。从 TCP 到 QUIC 的 Web 流量迁移,是 TCP 以来 Internet transport layer 最大的架构变化。
路由、可靠性与协议栈
Network Layer:寻址与路由
Internet Protocol(IP)在构成 Internet 的异构物理网络集合之上,提供了一个单一抽象:一个带有源地址、目的地址和 payload 的 packet,以 best-effort 方式从 Internet 上任一 host 投递到另一个 host。这个抽象的简单性——没有保证,只是转发——正是 Internet 多样性成为可能的原因。一个 packet 会穿过 Ethernet links、fiber optic cables、wireless connections 和 satellite links,每种链路都有不同物理特征,而 IP 在它们之上提供统一服务。
IP addressing 和 routing 是 network layer 的核心问题。一个 IP address 同时标识一个设备及其在网络中的位置:地址层级(network prefix、host portion)允许 routers 仅根据地址前缀做 forwarding decisions,而不需要知道每个单独 host。Classless Inter-Domain Routing(CIDR)于 1993 年采用,通过允许任意 prefix lengths 而不是固定 class boundaries,提升了地址分配效率。Border Gateway Protocol(BGP)是负责在构成 Internet 的 autonomous systems 之间交换 reachability information 的 routing protocol,它确保任何 prefix 都可以从任意其他位置到达。BGP 并不针对速度或最优性优化——拓扑变化后收敛缓慢,并允许 policy 覆盖 shortest-path routing——但它面向 Internet 的真实要求而设计:能够扩展到数十万个 prefixes,允许 operator 控制 routing policy,并且可以在不需要全局协调的情况下逐步收敛。
在一个 autonomous system 内部运行的 interior routing protocols——用于 link-state routing 的 OSPF 和 IS-IS,用于 distance-vector routing 的 RIP 和 EIGRP——维护内部网络的 routing tables。Link-state protocols 会把拓扑信息 flood 到域内所有 routers,并用 Dijkstra 算法计算 shortest paths;结果是 routing tables 一致,拓扑变化后收敛较快,但对于大型网络需要 O(n²) 内存和计算。Distance-vector protocols 只与邻居交换 reachability 和 distance information,收敛较慢,但需要更少内存。link-state 与 distance-vector 之间的选择,反映了取决于网络规模、稳定性和拓扑的工程权衡。
Transport Layer:可靠性与拥塞控制
TCP 在两个 endpoints 之间提供可靠、有序的 byte-stream delivery。它的机制——sliding window flow control、用于排序和重复检测的 sequence numbers、基于 acknowledgment 的可靠性和 timeout retransmission、用于连接建立的 three-way handshake——把不可靠的 IP 服务转化为可靠 stream。理解每个机制,需要理解它处理什么失败:sequence numbers 检测重复并支持排序;acknowledgments 与 retransmission 确保投递;flow control 防止发送方压垮接收方;three-way handshake 在数据流动前同步 endpoints 之间的状态。
拥塞控制是 TCP 防止发送方向网络注入超过网络承载能力流量的机制。Van Jacobson 1988 年的论文 “Congestion Avoidance and Control” 描述了一组算法,把 Internet 当时刚发生的拥塞崩溃——1986 年,由于不受控制的重传风暴,网络吞吐量跌到名义容量的一小部分——转化为此后持续运行的受控系统。TCP 的 congestion control(slow start、congestion avoidance、fast retransmit、fast recovery)把 packet loss 作为拥塞信号,并在响应中降低发送速率。这个设计的优雅之处在于,它不需要网络显式发出拥塞信号——loss 从 acknowledgment 缺席中推断出来——并且它在 endpoints 实现,不需要网络配合。
UDP 提供不可靠 datagram delivery:每个 datagram 都是独立的,可能丢失或乱序到达,也没有连接状态或 flow control。UDP 适合那些需要低延迟且可以容忍部分丢失的应用(实时音频和视频、游戏、DNS queries),或者那些在 transport layer 之上实现自己可靠性的应用(QUIC、SCTP、分布式系统中的自定义协议)。理解什么时候 UDP 是正确选择,什么时候 TCP 的可靠性开销值得支付,需要理解每种 transport 提供什么,以及应用真正需要什么。
Application Layer 与协议设计
HTTP、DNS、TLS、SMTP、SSH——多数网络代码直接使用的 application protocols——都建立在 transport layer 之上,并为各自应用实现所需的具体语义。以规范层面理解这些协议,而不只是通过实现它们的库来使用它们,才能进行调试、性能优化和安全分析。
TLS(Transport Layer Security)为 application-layer protocols 提供机密性、完整性和认证。TLS 1.3 是当前版本,它实现了 forward secrecy(长期密钥泄露不会破坏过去 sessions),只需要一个 round trip 建立连接(TLS 1.2 需要两个),并移除了曾被 POODLE 和 BEAST 等攻击利用的弱密码算法。TLS 1.3 的设计是协议安全分析的一个案例:学术共同体对 TLS 1.2 的形式化分析发现了细微漏洞,而 1.3 的重新设计系统性地处理了这些问题。
DNS resolution 涉及层级委托:recursive resolver 联系 root nameservers,root nameservers 委托到 TLD nameservers(例如 .com、.org 等),TLD nameservers 再委托到特定 domain 的 authoritative nameservers。委托层级允许命名空间在没有中心协调的情况下扩展,但它也创造出复杂 trust model:委托链上任何一点被攻破,都可能重定向流量。DNSSEC 为 DNS records 提供加密签名,使 recursive resolvers 可以验证响应确实来自 authoritative servers,并且没有被篡改。DNS-over-HTTPS 和 DNS-over-TLS 会加密 resolution query 本身,防止旁观者窃听客户端解析了哪些 names——这是一项重要隐私改进,因为 DNS queries 会暴露浏览行为。
好的协议设计不只规定成功情况,还必须规定每种失败模式:当 server 在 timeout 内不响应时,client 做什么;当 server 收到一个无法解析的 request 时,server 做什么;当一个 endpoint 崩溃后,half-open connection 如何被清理。规定主要 Internet protocols 的 RFCs 会把大量篇幅用于这些边缘情况,而不能正确处理它们的实现,是安全漏洞和互操作性问题的主要来源。
学习这一部分会改变什么
计算机网络会改变实践者在分布式系统和安全中能够看见什么。
第一个变化,是能够推理通信失败。一次 network call 可能失败,是因为 request 丢失了,response 丢失了,或者远端在收到 request 后、回复前崩溃了。从调用者角度看,这些情况无法区分。一个假设 network calls 要么成功、要么干净失败的分布式系统,会在 partial success 时行为错误——也就是 request 已被处理,但 response 丢失。网络训练会建立一种习惯:推理所有失败模式,而不只是 happy path,并设计在 partial failure 下仍能正确行为的协议。
第二个变化,是熟练把分层抽象作为诊断工具。连接问题可能发生在任何层:电缆断开(link layer),routing table 没有通向目的地的 route(network layer),firewall 阻塞到该 port 的 TCP 连接(transport layer),server 没有监听(application layer)。分层框架组织了诊断过程——按顺序检查每一层——并指出每一层应使用哪些工具。没有这个框架,调试就是试错;有了它,调试就是系统性排查。
第三个变化,是网络层面的安全意识。Man-in-the-middle attacks 利用的是 network layer 中缺少认证。DNS cache poisoning 利用的是 DNS 中缺少完整性保证。BGP hijacking 利用的是缺少 route origin authentication。理解这些攻击及其缓解措施,需要理解它们所针对的协议。知道协议的实践者可以阅读安全公告,并推理自己的系统是否受影响;不知道协议的人只能完全依赖他人评估。
第四个变化,是能够做出有依据的协议设计决策。多数实践者其实经常在广义上设计协议——定义分布式系统中服务之间的消息格式和语义,规定 API 行为,设计 microservices 的通信模式。协议设计纪律——精确规约、失败模式分析、演化式设计、谨慎权衡分析——可以直接应用,而学习过正式协议的实践者,会把更多严谨性带入这些非正式协议设计中。
资源
书籍与文本
Kurose 和 Ross 的 Computer Networking: A Top-Down Approach(第 8 版,Pearson,2021)是标准当代入口。它的自顶向下组织方式——从 application layer 开始,再逐层下行到 link layer——会在立刻有意义的语境中引入概念。一个每天使用 HTTP 和 DNS 的学生,会接触到它们的正式规范;动机很清楚。写作易读,例子选择得当,配套编程作业(socket programming、HTTP server implementation)也有效。对于自学者,这是正确起点。
Peterson 和 Davie 的 Computer Networks: A Systems Approach(可在 book.systemsapproach.org 免费在线获取)覆盖类似内容,但更强调协议如何真正被实现,以及网络如何被运营。Kurose-Ross 更适合学生教学组织,Peterson-Davie 则围绕系统工程关切组织——如何构建稳健网络系统——并且对协议设计背后的工程决策提供更多信息。它适合作为 Kurose-Ross 之后的第二本书;对于系统背景更强的读者,也可以作为主教材。免费在线版本是当前版本。
对于深入 TCP/IP,Stevens 的 TCP/IP Illustrated, Volume 1(第 2 版,由 Fall 修订,Addison-Wesley,2011)仍然是经典参考。Stevens 通过真实 packet captures 追踪 TCP 和 IP 行为,展示协议在各种条件下做什么——正常运行、重传、拥塞——并配有 Wireshark traces。它提供的深度没有其他材料可替代。对于严肃网络工作——调试 TCP 问题,实现协议组件——它不可或缺。
对于协议安全,Matt Bishop 的 Computer Security: Art and Science,以及 TLS 1.3(RFC 8446)、DNSSEC(RFC 4034)和 QUIC(RFC 9000)的 IETF RFCs,是经典参考。RFCs 是权威规范;直接阅读它们,会让人学到协议规范所要求的精确性标准。
| 书籍 | 作用 | 类型 |
|---|---|---|
| Kurose & Ross, Computer Networking: A Top-Down Approach(第 8 版) | 标准当代入口 | 入门 |
| Peterson & Davie, Computer Networks: A Systems Approach(免费在线) | 系统工程视角 | 入门 |
| Bonaventure, Computer Networking: Principles, Protocols and Practice(免费在线) | 开放教材替代 | 辅助 |
| Grigorik, High Performance Browser Networking(免费在线) | Web 网络与性能桥梁 | 辅助 |
| Stevens, TCP/IP Illustrated, Volume 1(第 2 版) | 深入 TCP/IP 参考 | 参考 |
| Saltzer, Reed & Clark, “End-to-End Arguments in System Design”(1981,免费) | 奠基性架构论文 | 深入 |
| 主要 RFCs:791(IP)、793(TCP)、1034/1035(DNS)、8446(TLS 1.3)、9000(QUIC) | 权威协议规范 | 参考 |
课程与讲座
Stanford CS 144(Introduction to Computer Networking,免费材料和项目)包含大学课程中最有价值的网络编程练习:从零用 C++ 实现一个 TCP/IP stack。这个项目要求只用 UDP 发送 packets,同时实现 three-way handshake、可靠有序投递、flow control 和 connection teardown。构建 TCP 是深入理解 TCP 的最快路径。课程讲座和实验材料都可免费获取。
Princeton 的 COS 461(Computer Networks,材料在线)覆盖类似内容,但侧重点不同,包括更多网络测量和 Internet 架构处理。讲义质量很高,值得与 Kurose-Ross 一起阅读。
Beej’s Guide to Network Programming(免费在线)是 Unix socket programming 最易读的入门材料——socket programming 正是 application code 与 network stack 交互所经由的 system call interface。它比课程材料范围更窄,但对于需要立刻编写网络代码的程序员更实用。
| 课程 | 平台 | 类型 |
|---|---|---|
| Stanford CS 144 Introduction to Computer Networking(免费) | Stanford / course site | 入门 |
| Princeton COS 461 Computer Networks(免费) | Princeton / course site | 入门 |
| Beej’s Guide to Network Programming(免费) | beej.us | 实践 |
| Beej’s Guide to Network Concepts(免费) | beej.us | 辅助 |
| Julia Evans networking, DNS, and HTTP zines(付费) | wizardzines.com | 辅助 |
实践、工具与当前资料
Wireshark(免费)会捕获并分析 network packets,显示每一层中每个 packet 的完整内容。发起一次 HTTP request 时同时运行 Wireshark,会把 DNS resolution、TCP handshake、TLS handshake、HTTP request 和 HTTP response 显示为带完整解码的独立 packets。没有其他工具能把 protocol stack 变得如此具体。Wireshark University 材料和 Practical Packet Analysis 这本书提供了结构化学习路径。
带 verbose flags 的 curl(curl -v、curl --trace)会显示一次 HTTP 或 HTTPS request 的 DNS resolution 和连接建立过程。加入 --http1.1、--http2 或 --http3 可以在不同协议版本之间切换。按顺序运行这些命令,可以看到 HTTP/1.1(TCP 与 TLS 分开)、HTTP/2(同样如此,但有 multiplexed streams)和 HTTP/3(带集成 TLS 的 QUIC)之间的连接建立差异。
netcat(nc)提供对 TCP 和 UDP 连接的原始访问,使人可以直接观察协议行为。nc -l 8080 打开一个监听 TCP port;nc hostname 8080 连接到它;在一个 terminal 中输入会把数据发送到另一个。更有意思的是:nc hostname 80 后手动输入 raw HTTP request,可以直接看到 HTTP response,没有任何库作为中介。
QUIC implementations:主要 QUIC 实现(Cloudflare 的 quiche、ngtcp2、Microsoft 的 MsQuic)都是开源且文档良好。阅读 QUIC connection establishment 的实现,是理解 QUIC 的 zero-RTT resumption 和 connection migration 如何工作的最佳方式。
Cloudflare blog 和 APNIC blog 是持续跟进 Internet protocols 和大规模运营的最佳技术来源。Cloudflare 关于 TLS 1.3、QUIC、DNS over HTTPS 和 BGP security 的文章技术严谨,并反映了大规模生产经验。
| 资源 | 平台 | 类型 |
|---|---|---|
| Wireshark(免费) | wireshark.org | 实践 |
| curl with verbose flags(免费) | curl.se | 实践 |
| Stanford CS 144 TCP implementation project | Course site | 实践 |
| Cloudflare blog(免费) | blog.cloudflare.com | 参考 |
| APNIC blog(免费) | blog.apnic.net | 参考 |
| QUIC implementation projects: quiche, ngtcp2, MsQuic(免费) | GitHub | 参考 |
陷阱
| 陷阱 | 为什么会误导 | 更好的回应 |
|---|---|---|
| 迷恋层级图 | 记忆 OSI layers 以及哪些协议位于哪一层,是常见考试准备策略,但几乎不能产生理解。Layers 是组织概念的工具;重要的是每一层做什么、处理什么问题、对下一层做什么假设。知道 layer 名称,却无法解释为什么 transport layer 要与 network layer 分离的学习者,只是记住了一张图,而没有理解其背后的设计原则。 | 对每一层都问:这一层解决了下一层无法解决的什么问题?它向上一层保证什么?它把什么问题留给上一层处理?End-to-end principle(Saltzer、Reed 和 Clark,1981)给出了组织性答案,应当早读,而不是晚读。 |
| 协议细节过载 | TCP 有大型状态机;DNS 有许多 record types;TLS 有多个 cipher suites 和 extension points。试图记住所有细节,会带来压倒性负担,却不产生理解。这些细节在专业实践中确实重要,但它们是应当查阅的参考材料,不是应当背诵的课程主体。 | 聚焦每个协议的核心机制:TCP 的 sliding window 和 congestion control 完成什么,DNS 的 hierarchical delegation 提供什么,TLS 的 handshake 建立了什么。具体细节——header field sizes、error codes、option formats——在 RFC 和 Stevens 中,需要时查阅,而不是预先记忆。 |
| 把实践熟悉误认为理解 | 多数学习者进入网络课程前,已经使用 Internet 很多年。这种实践熟悉是有用的,但并不构成对 Internet 如何工作的理解。一个发起过数千次 HTTPS requests,却无法解释 TLS handshake,无法识别 DNS failure 的 packet capture 显示了什么,无法推理 TCP connection half-open 时发生什么的学习者,只是有表层熟悉,而没有概念基础。 | 无论已有多少实践经验,都把每个主题当作全新对象来学习。学习 HTTP 时,用 Wireshark trace 协议,而不只是通过库使用它。学习 DNS 时,用 dig 直接查询 resolvers,而不是让操作系统透明处理解析。实践经验是有用语境;技术理解需要有意识地接触协议细节。 |
| 把协议规范当成实际运行的东西 | 协议规范(RFCs)定义正确行为;生产实现则会以有文档或无文档的方式偏离规范。TCP 实现会以规范允许但不要求的方式优化常见情况。BGP 实现会有不同于规范的 vendor-specific behaviors。TLS libraries 历史上曾有 bug,使原本正确的协议出现漏洞。真实存在的网络,不等于规范描述的网络。 | 用实现研究补充规范研究。把 Linux kernel 的 TCP 实现与 Stevens 的书一起读。在真实流量上使用 Wireshark,并与规范比较。当规范和实现分歧时,理解原因——通常是 bug、性能优化或刻意扩展。规范与实现之间的缝隙,是许多安全漏洞存在的地方。 |
| 看不见安全维度 | 网络安全不是独立章节;它是每个协议的一个维度。IP 缺少认证,使 spoofing 成为可能。TCP sequence numbers 可预测,会使 RST injection 成为可能。DNS 缺少完整性,使 cache poisoning 成为可能。SMTP 的 sender 不认证,使 phishing 成为可能。TLS 的复杂性会引入实现 bug。把安全当成协议完整理解之后的附加内容,是反过来的。 | 学习每个协议时,识别它的安全假设和攻击面。它认证了什么?它防止什么被篡改?它会向窃听者暴露什么?历史上有哪些攻击被证明可行?这些问题的答案是理解协议的一部分,而不是之后追加的材料。 |
| 跳过实现 | Stanford 的 CS 144 TCP implementation project 是目前通向深度理解 TCP 最直接的路径。构建状态机、处理重传、实现 flow control,并调试最终实现,会揭示规格真正要求什么,以及常见失败模式是什么。阅读规格和教材有价值,但其教育效果在性质上不如实现协议。 | 完成 CS 144 TCP 项目,或一个等价项目。如果无法访问 CS 144 的具体项目,就实现一个更简单协议——一个通过 TCP socket 手动执行 GET request 的 HTTP/1.1 client,或一个简单的 UDP-based reliable protocol。理解协议描述与正确实现协议之间的认知差距很大,而实现会补上阅读无法补上的部分。 |