中文
HTTPS 与 TLS 1.3 握手原理:密钥交换、证书和 RTT 实验
HTTPS 绝不只是“在 HTTP 外面套一层加密”那么简单。它是现代网络安全架构的基石。在 TLS 1.3 中,握手协议被重构为一个高度优化的状态机,旨在最大化密码学抗性的同时最小化网络往返延迟。它严格协商密码学参数,通过椭圆曲线计算临时共享密钥,验证服务器的 X.509 身份,并校验整个握手 transcript 的完整性。本文将深入工程底层,从伽罗瓦域(Galois field)的数学基础、OpenSSL 的 C 语言源码实现,到内核级的 eBPF 性能追踪,对 TLS 1.3 进行极致剖析。
一、TLS 1.3 架构:1-RTT 与状态机重构
TLS 1.3 通过激进地废弃过时的密码学原语(如 RSA 密钥传输、SHA-1)并强制启用前向安全(Forward Secrecy),将握手延迟从 2-RTT 大幅降低至 1-RTT。在 OpenSSL 的 C 语言实现中,这一切由 statem_clnt.c 和 statem_srvr.c 中的状态机驱动。客户端发送包含预计算 key_share 扩展的 ClientHello。服务器立刻状态转移至 TLS_ST_SW_SRVR_HELLO,计算共享密钥,并在单个 flight 中回传 ServerHello、EncryptedExtensions、Certificate、CertificateVerify 和 Finished 消息。
二、高阶状态机与 HKDF 可视化
下面的时序图展开了 1-RTT 的详细流程,重点标出了基于 HMAC 的密钥派生函数(HKDF)提取(Extract)和展开(Expand)握手与应用流量密钥的具体阶段。
sequenceDiagram
autonumber
participant Client as 客户端
participant Server as 服务端
Client->>Server: ClientHello + Key Share (X25519) + ALPN
Note right of Server: statem_srvr.c: tls_process_client_hello()
HKDF-Extract(0, ECDHE Shared Secret)
HKDF-Expand(Handshake Secret)
Server->>Client: ServerHello + Key Share
Server->>Client: {EncryptedExtensions + Certificate + CertVerify + Finished}
Note left of Client: statem_clnt.c: tls_process_server_hello()
派生密钥,验证签名,校验 Finished MAC
Client->>Server: {Finished} + [Application Data (HTTP Request)]
Note right of Server: HKDF-Expand(Master Secret) -> 应用层流量密钥
Server->>Client: [Application Data (HTTP Response)]
三、数学严密性:ECDLP 与 AES-GCM 多项式运算
现代 TLS 1.3 生产部署严重依赖 Curve25519 进行密钥交换,以及 AES-GCM 进行认证加密(AEAD)。
椭圆曲线离散对数问题 (ECDLP)
密钥交换使用了 Curve25519 蒙哥马利曲线,该曲线定义在素数域 (mathbb{F}_p) 上的方程为:
[ v^2 = u^3 + 486662u^2 + u pmod{2^{255} - 19} ]
其安全性依赖于 ECDLP 的难解性:已知基点 ( G ) 和公钥 ( P = dG ),在计算上无法反推私有标量 ( d )。共享密钥的计算公式为 ( S = d_{client} P_{server} = d_{client} d_{server} G = d_{server} P_{client} )。OpenSSL 在底层使用了高度优化的、恒定时间(constant-time)的蒙哥马利阶梯算法(Montgomery ladders)来实现,从而杜绝了时间侧信道攻击。
伽罗瓦/计数器模式 (GCM) 的数学原理
密钥协商完毕后,AES-GCM 负责加密应用层记录。GCM 的认证标签(Authentication tag)是基于伽罗瓦域 ( text{GF}(2^{128}) ) 上的通用哈希函数 GHASH 计算出来的。该域由以下不可约多项式定义:
[ P(x) = x^{128} + x^7 + x^2 + x + 1 ]
域中的元素是 128 位的块。GHASH 函数求解的是一个以密文块为系数、以哈希子密钥 ( H ) 为变量的多项式。在生产环境中,这种多项式乘法会被 CPU 硬件指令极大地加速,例如 Intel 的 AES-NI 指令集(特别是用于无进位乘法的 vpclmulqdq 指令)。
四、生产工程:OpenSSL 与硬件加速
在高吞吐量的网关架构中(如每秒终结 10 万个 TLS 连接),CPU 开销是核心瓶颈。现代边缘负载均衡器完全绕过通用的 C 语言实现,直接调用汇编指令。例如,在 OpenSSL 的 evp_cipher API 中,AES-GCM 被直接路由至 AES-NI 向量计算单元。工程师在为 Envoy 或 Nginx 进行调优时,必须确保宿主机操作系统的 CPU 标志位(flags)将 aes, pclmulqdq, 以及 avx512f 暴露给用户态进程。
此外,OpenSSL 中用于 ECDSA/RSA 证书签名的 EVP_DigestSign 函数经常通过 engine 模块被卸载到异步密码学硬件加速引擎(如 Intel QAT)上。这使得 Nginx 的事件循环在硬件计算 ECDLP 标量乘法的过程中,仍能继续处理其他的 epoll 事件。
五、高阶诊断工具:eBPF 流量拦截与追踪
使用 tcpdump 来排查生产环境下的 TLS 问题(如握手延迟毛刺或加密套件协商失败)毫无意义,因为载荷已被加密。相反,顶尖 SRE 会部署 eBPF(扩展的伯克利数据包过滤器)在用户态动态追踪 OpenSSL。
下面是一段 BCC (BPF Compiler Collection) 代码片段,它通过挂载 uprobe 到 OpenSSL 的 SSL_do_handshake 函数,在内核态精准测量握手延迟分布:
#include <uapi/linux/ptrace.h>
BPF_HASH(start, u32);
BPF_HISTOGRAM(dist);
int probe_ssl_handshake_start(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
return 0;
}
int probe_ssl_handshake_return(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 *tsp = start.lookup(&pid);
if (tsp != 0) {
u64 delta = bpf_ktime_get_ns() - *tsp;
dist.increment(bpf_log2l(delta / 1000000)); // 以毫秒为单位的 Log2 直方图
start.delete(&pid);
}
return 0;
}
通过将此 eBPF 程序注入 libssl.so 的代码段,SRE 可以直观地监控 TLS 握手的 P99 延迟百分位图,而且完全无需修改应用代码或承受 tcpdump 抓包带来的上下文切换开销。
六、安全复盘:侧信道攻击防御
生产环境必须加固以抵御各种侧信道漏洞,例如 Bleichenbacher 攻击、Lucky Thirteen 或缓存时间攻击(如 Flush+Reload)。TLS 1.3 移除了 RSA 加密(PKCS#1 v1.5 填充)和 MAC-then-Encrypt 的 CBC 模式,从根本上消除了许多此类攻击。为了防御剩余的标量乘法时间泄漏,底层库采用了蒙哥马利阶梯算法,并在代码层面严格保证分支指令和内存访问模式与密钥的标量比特完全无关(恒定时间执行)。
FAQ
证书会用来加密应用层数据吗?
不会。X.509 证书的数学作用是通过数字签名(例如基于 P-256 的 ECDSA)对握手 transcript 杂凑值进行签名,以验证服务器身份并证明对公钥的所有权。应用层数据的加密专属由 ephemeral ECDHE 交换并通过 HKDF 派生出的对称 AEAD 密钥负责,从而保障了前向安全性。
为什么不要从零开始自己写一个 TLS?
生产级别的 TLS 要求极其苛刻的恒定时间(constant-time)算术运算以防止微架构级别的侧信道数据泄漏。在高级语言中“造密码学轮子”经常会引入缓存时间漏洞、分支预测泄漏以及内存安全缺陷。请务必依赖身经百战的、支持硬件加速的开源库,如 OpenSSL、BoringSSL 或 Rustls。
参考资料
英文
HTTPS and TLS 1.3 Handshake: Keys, Certificates, and RTT in Practice
在独立页面打开HTTPS is fundamentally more than "HTTP over an encrypted channel." It is the cornerstone of modern network security architecture. In TLS 1.3, the handshake is a heavily optimized state machine designed to minimize round-trips while maximizing cryptographic resilience. It rigorously negotiates cryptographic parameters, computes ephemeral shared secrets via elliptic curves, authenticates the server's X.509 identity, and verifies the transcript integrity. Below, we dissect TLS 1.3 at an extreme engineering depth—ranging from Galois field mathematics to OpenSSL's C implementation and eBPF kernel-level profiling.
1. The Architecture of TLS 1.3: 1-RTT and State Machine Overhaul
TLS 1.3 drastically reduced the handshake latency from 2-RTT to 1-RTT by aggressively deprecating obsolete primitives (RSA key transport, SHA-1) and enforcing Forward Secrecy (FS). In the OpenSSL C implementation, this is driven by the state machine inside statem_clnt.c and statem_srvr.c. A client sends a ClientHello containing pre-computed key_share extensions. The server immediately transitions to TLS_ST_SW_SRVR_HELLO, computing the shared secret, and responds with a ServerHello, EncryptedExtensions, Certificate, CertificateVerify, and Finished messages in a single flight.
2. Advanced State Machine & HKDF Visualization
The following diagram expands the 1-RTT flow to highlight the exact stages where the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) is applied to generate the Handshake and Application Traffic Secrets.
sequenceDiagram
autonumber
participant Client
participant Server
Client->>Server: ClientHello + Key Share (X25519) + ALPN
Note right of Server: statem_srvr.c: tls_process_client_hello()
HKDF-Extract(0, ECDHE Shared Secret)
HKDF-Expand(Handshake Secret)
Server->>Client: ServerHello + Key Share
Server->>Client: {EncryptedExtensions + Certificate + CertVerify + Finished}
Note left of Client: statem_clnt.c: tls_process_server_hello()
Derive keys, Verify Signature, Verify Finished MAC
Client->>Server: {Finished} + [Application Data (HTTP Request)]
Note right of Server: HKDF-Expand(Master Secret) -> Application Traffic Keys
Server->>Client: [Application Data (HTTP Response)]
3. Mathematical Rigor: ECDLP and AES-GCM Polynomials
Modern TLS 1.3 deployments rely heavily on Curve25519 for the key exchange and AES-GCM for Authenticated Encryption with Associated Data (AEAD).
Elliptic Curve Discrete Logarithm Problem (ECDLP)
The key exchange leverages the Curve25519 Montgomery curve defined by the equation over a prime field (mathbb{F}_p):
[ v^2 = u^3 + 486662u^2 + u pmod{2^{255} - 19} ]
The security relies on the intractability of the ECDLP: given a base point ( G ) and a public key ( P = dG ), it is computationally infeasible to find the private scalar ( d ). The shared secret is computed as ( S = d_{client} P_{server} = d_{client} d_{server} G = d_{server} P_{client} ). OpenSSL implements this using highly optimized, constant-time Montgomery ladders to prevent timing side-channel attacks.
Galois/Counter Mode (GCM) Mathematics
Once keys are established, AES-GCM encrypts the application records. The authentication tag in GCM is computed using a universal hash function GHASH over the Galois field ( text{GF}(2^{128}) ). The field is defined by the irreducible polynomial:
[ P(x) = x^{128} + x^7 + x^2 + x + 1 ]
Elements of the field are 128-bit blocks. The GHASH function evaluates a polynomial where the coefficients are the ciphertext blocks and the variable is the hash subkey ( H ). In production, this multiplication is massively accelerated using CPU hardware instructions like Intel's AES-NI (specifically the vpclmulqdq instruction for carry-less multiplication).
4. Production Engineering: OpenSSL and Hardware Acceleration
In high-throughput architectures (e.g., terminating 100k+ TLS connections/sec), CPU overhead is the primary bottleneck. Modern edge load balancers bypass generic C implementations and invoke raw assembly. For example, in OpenSSL's evp_cipher API, AES-GCM is routed directly to the AES-NI vector units. Engineers tuning Envoy or Nginx for TLS termination must ensure that the OS CPU flags expose aes, pclmulqdq, and avx512f to the user-space process.
Furthermore, OpenSSL's EVP_DigestSign for ECDSA/RSA certificate signatures is often offloaded to asynchronous cryptographic engines (e.g., Intel QAT) via engine modules, allowing the Nginx event loop to continue serving other epoll events while the hardware computes the ECDLP scalar multiplication.
5. Advanced Tooling: eBPF Traffic Interception
Debugging production TLS issues (like handshake latency spikes or cipher negotiation failures) using TCP dumps is useless since the payload is encrypted. Instead, elite engineers deploy eBPF (Extended Berkeley Packet Filter) to trace OpenSSL dynamically in user-space.
#include <uapi/linux/ptrace.h>
BPF_HASH(start, u32);
BPF_HISTOGRAM(dist);
int probe_ssl_handshake_start(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
return 0;
}
int probe_ssl_handshake_return(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 *tsp = start.lookup(&pid);
if (tsp != 0) {
u64 delta = bpf_ktime_get_ns() - *tsp;
dist.increment(bpf_log2l(delta / 1000000)); // Log2 histogram in ms
start.delete(&pid);
}
return 0;
}
By injecting this eBPF program into the libssl.so text segment, SREs can visualize TLS handshake percentiles (p99 latency) without modifying the application code or suffering tcpdump context-switch overhead.
6. Post-mortem: Side-Channel Attack Mitigations
Production environments must harden against side-channel vulnerabilities such as Bleichenbacher attacks, Lucky Thirteen, or cache-timing attacks (e.g., Flush+Reload). TLS 1.3 eliminates many of these by removing RSA encryption (PKCS#1 v1.5 padding) and MAC-then-Encrypt CBC modes. To defend against remaining scalar multiplication timing leaks, libraries use Montgomery Ladders and ensure that branch instructions and memory access patterns are strictly independent of the secret scalar bits.
FAQ
Does the certificate encrypt application records?
No. The X.509 certificate mathematically authenticates the server via a digital signature (e.g., ECDSA over P-256) over the transcript hash, proving ownership of the public key. Encryption of the application layer is exclusively handled by the symmetric AEAD keys derived from the ephemeral ECDHE exchange via HKDF, guaranteeing Forward Secrecy.
Why not implement TLS from scratch?
Production TLS requires constant-time arithmetic to prevent microarchitectural side-channel data leaks. Rolling your own crypto in high-level languages often introduces cache-timing vulnerabilities, branch-prediction leaks, and memory-safety flaws. Always rely on battle-tested, hardware-accelerated libraries like OpenSSL, BoringSSL, or Rustls.
References
HTTPS 绝不只是“在 HTTP 外面套一层加密”那么简单。它是现代网络安全架构的基石。在 TLS 1.3 中,握手协议被重构为一个高度优化的状态机,旨在最大化密码学抗性的同时最小化网络往返延迟。它严格协商密码学参数,通过椭圆曲线计算临时共享密钥,验证服务器的 X.509 身份,并校验整个握手 transcript 的完整性。本文将深入工程底层,从伽罗瓦域(Galois field)的数学基础、OpenSSL 的 C 语言源码实现,到内核级的 eBPF 性能追踪,对 TLS 1.3 进行极致剖析。
一、TLS 1.3 架构:1-RTT 与状态机重构
TLS 1.3 通过激进地废弃过时的密码学原语(如 RSA 密钥传输、SHA-1)并强制启用前向安全(Forward Secrecy),将握手延迟从 2-RTT 大幅降低至 1-RTT。在 OpenSSL 的 C 语言实现中,这一切由 statem_clnt.c 和 statem_srvr.c 中的状态机驱动。客户端发送包含预计算 key_share 扩展的 ClientHello。服务器立刻状态转移至 TLS_ST_SW_SRVR_HELLO,计算共享密钥,并在单个 flight 中回传 ServerHello、EncryptedExtensions、Certificate、CertificateVerify 和 Finished 消息。

二、高阶状态机与 HKDF 可视化
下面的时序图展开了 1-RTT 的详细流程,重点标出了基于 HMAC 的密钥派生函数(HKDF)提取(Extract)和展开(Expand)握手与应用流量密钥的具体阶段。
sequenceDiagram
autonumber
participant Client as 客户端
participant Server as 服务端
Client->>Server: ClientHello + Key Share (X25519) + ALPN
Note right of Server: statem_srvr.c: tls_process_client_hello()
HKDF-Extract(0, ECDHE Shared Secret)
HKDF-Expand(Handshake Secret)
Server->>Client: ServerHello + Key Share
Server->>Client: {EncryptedExtensions + Certificate + CertVerify + Finished}
Note left of Client: statem_clnt.c: tls_process_server_hello()
派生密钥,验证签名,校验 Finished MAC
Client->>Server: {Finished} + [Application Data (HTTP Request)]
Note right of Server: HKDF-Expand(Master Secret) -> 应用层流量密钥
Server->>Client: [Application Data (HTTP Response)]
三、数学严密性:ECDLP 与 AES-GCM 多项式运算
现代 TLS 1.3 生产部署严重依赖 Curve25519 进行密钥交换,以及 AES-GCM 进行认证加密(AEAD)。
椭圆曲线离散对数问题 (ECDLP)
密钥交换使用了 Curve25519 蒙哥马利曲线,该曲线定义在素数域 (mathbb{F}_p) 上的方程为:
[ v^2 = u^3 + 486662u^2 + u pmod{2^{255} – 19} ]
其安全性依赖于 ECDLP 的难解性:已知基点 ( G ) 和公钥 ( P = dG ),在计算上无法反推私有标量 ( d )。共享密钥的计算公式为 ( S = d_{client} P_{server} = d_{client} d_{server} G = d_{server} P_{client} )。OpenSSL 在底层使用了高度优化的、恒定时间(constant-time)的蒙哥马利阶梯算法(Montgomery ladders)来实现,从而杜绝了时间侧信道攻击。
伽罗瓦/计数器模式 (GCM) 的数学原理
密钥协商完毕后,AES-GCM 负责加密应用层记录。GCM 的认证标签(Authentication tag)是基于伽罗瓦域 ( text{GF}(2^{128}) ) 上的通用哈希函数 GHASH 计算出来的。该域由以下不可约多项式定义:
[ P(x) = x^{128} + x^7 + x^2 + x + 1 ]
域中的元素是 128 位的块。GHASH 函数求解的是一个以密文块为系数、以哈希子密钥 ( H ) 为变量的多项式。在生产环境中,这种多项式乘法会被 CPU 硬件指令极大地加速,例如 Intel 的 AES-NI 指令集(特别是用于无进位乘法的 vpclmulqdq 指令)。
四、生产工程:OpenSSL 与硬件加速
在高吞吐量的网关架构中(如每秒终结 10 万个 TLS 连接),CPU 开销是核心瓶颈。现代边缘负载均衡器完全绕过通用的 C 语言实现,直接调用汇编指令。例如,在 OpenSSL 的 evp_cipher API 中,AES-GCM 被直接路由至 AES-NI 向量计算单元。工程师在为 Envoy 或 Nginx 进行调优时,必须确保宿主机操作系统的 CPU 标志位(flags)将 aes, pclmulqdq, 以及 avx512f 暴露给用户态进程。
此外,OpenSSL 中用于 ECDSA/RSA 证书签名的 EVP_DigestSign 函数经常通过 engine 模块被卸载到异步密码学硬件加速引擎(如 Intel QAT)上。这使得 Nginx 的事件循环在硬件计算 ECDLP 标量乘法的过程中,仍能继续处理其他的 epoll 事件。
五、高阶诊断工具:eBPF 流量拦截与追踪
使用 tcpdump 来排查生产环境下的 TLS 问题(如握手延迟毛刺或加密套件协商失败)毫无意义,因为载荷已被加密。相反,顶尖 SRE 会部署 eBPF(扩展的伯克利数据包过滤器)在用户态动态追踪 OpenSSL。
下面是一段 BCC (BPF Compiler Collection) 代码片段,它通过挂载 uprobe 到 OpenSSL 的 SSL_do_handshake 函数,在内核态精准测量握手延迟分布:
#include <uapi/linux/ptrace.h>
BPF_HASH(start, u32);
BPF_HISTOGRAM(dist);
int probe_ssl_handshake_start(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
return 0;
}
int probe_ssl_handshake_return(struct pt_regs *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u64 *tsp = start.lookup(&pid);
if (tsp != 0) {
u64 delta = bpf_ktime_get_ns() - *tsp;
dist.increment(bpf_log2l(delta / 1000000)); // 以毫秒为单位的 Log2 直方图
start.delete(&pid);
}
return 0;
}
通过将此 eBPF 程序注入 libssl.so 的代码段,SRE 可以直观地监控 TLS 握手的 P99 延迟百分位图,而且完全无需修改应用代码或承受 tcpdump 抓包带来的上下文切换开销。
六、安全复盘:侧信道攻击防御
生产环境必须加固以抵御各种侧信道漏洞,例如 Bleichenbacher 攻击、Lucky Thirteen 或缓存时间攻击(如 Flush+Reload)。TLS 1.3 移除了 RSA 加密(PKCS#1 v1.5 填充)和 MAC-then-Encrypt 的 CBC 模式,从根本上消除了许多此类攻击。为了防御剩余的标量乘法时间泄漏,底层库采用了蒙哥马利阶梯算法,并在代码层面严格保证分支指令和内存访问模式与密钥的标量比特完全无关(恒定时间执行)。
FAQ
证书会用来加密应用层数据吗?
不会。X.509 证书的数学作用是通过数字签名(例如基于 P-256 的 ECDSA)对握手 transcript 杂凑值进行签名,以验证服务器身份并证明对公钥的所有权。应用层数据的加密专属由 ephemeral ECDHE 交换并通过 HKDF 派生出的对称 AEAD 密钥负责,从而保障了前向安全性。
为什么不要从零开始自己写一个 TLS?
生产级别的 TLS 要求极其苛刻的恒定时间(constant-time)算术运算以防止微架构级别的侧信道数据泄漏。在高级语言中“造密码学轮子”经常会引入缓存时间漏洞、分支预测泄漏以及内存安全缺陷。请务必依赖身经百战的、支持硬件加速的开源库,如 OpenSSL、BoringSSL 或 Rustls。
参考资料
搜索问题
常见问题
这篇文章适合谁读?
这篇文章适合想用 专业 难度理解“HTTPS 与 TLS 1.3 握手原理:密钥交换、证书和 RTT 实验”的读者,预计阅读时间约 13 分钟,重点覆盖 TLS 1.3, HTTPS, Key Agreement, Python。
读完后下一步应该看什么?
推荐下一步阅读“HTTP/2、HTTP/3 与 CDN 缓存:从网络瀑布图理解网页加载速度”,这样可以把当前知识点接到更完整的学习路线里。
这篇文章有没有可运行代码或配套资源?
有。页面里的运行说明、资源卡片和下载入口会指向复现实验所需的命令、数据、代码或说明文件。
这篇文章和整个网站的学习路线有什么关系?
它会通过文章上下文、学习路线、资源库和项目时间线连接到同一主题下的其他内容。
文章上下文
网络基础原理
从 DNS、TCP、TLS 与 HTTP/3 到代理隧道、负载均衡和共享缓存,以可重现的代码和图分析网页请求路径。
配套资源
网络基础原理 / GUIDE
Network Fundamentals Lab 说明
安装、无权限安全边界、十个 Python 实验和三个 C 示例的运行说明。
网络基础原理 / DATASET
TLS 1.3 flight 结果 CSV
固定 RTT 模型中的消息方向、时间点和教学共享值。
网络基础原理 / ARCHIVE
网络基础原理完整实验包
打包 Python/C 源码、固定场景、十份结果 CSV 与协议/代理图。
网络基础原理 / TOOL
网络请求链路交互演示
在浏览器里调整 TTL、前缀、丢包、握手 RTT 与缓存路径。
项目时间线
已发布文章
- DNS 解析过程详解:从域名查询到 TTL 缓存的 Python 实验 从 RFC DNS 报文与递归查询出发,用 Python 和 C 实验计算 TTL 缓存命中对解析延迟的影响。
- CIDR、子网掩码与最长前缀匹配:用代码算清 IP 路由和 MTU 手算 CIDR 网段、最长前缀匹配与 MTU/MSS 分段,并用 Python/C 输出固定路由结果。
- TCP 三次握手、重传与拥塞窗口:可运行的序列号实验 从 TCP sequence/ACK 和慢启动出发,用确定性丢包曲线与 localhost C socket 实验理解可靠传输。
- HTTPS 与 TLS 1.3 握手原理:密钥交换、证书和 RTT 实验 解释 TLS 1.3 消息 flight、证书与临时密钥交换,用安全的教学模型计算一次 RTT 握手。
- HTTP/2、HTTP/3 与 CDN 缓存:从网络瀑布图理解网页加载速度 用确定性 waterfall 模型拆解 HTTP/2、HTTP/3、QUIC stream 和 CDN HIT/MISS 对网页等待时间的影响。
- 正向代理与反向代理原理:连接路径、信任边界和时延计算 从连接方向和 TLS 终止点解释正向代理、反向代理与隧道代理,并用 Python 模型分段计算代理 hop 与缓存收益。
- HTTP CONNECT 与 HTTPS 代理隧道:TLS 边界和握手时延 以 RFC CONNECT 状态机解释 HTTPS 代理隧道、TLS 可见性和首次加密请求时延。
- SOCKS5 代理原理:协议字节、DNS 解析边界与泄漏风险 按 RFC 1928 拆解 SOCKS5 CONNECT 字节,通过安全编码实验比较本地 DNS 与代理侧域名解析。
- 反向代理负载均衡原理:队列、健康检查和可复现调度实验 用固定请求队列比较 round robin 与负载感知调度,并解释反向代理健康检查和重试边界。
- 代理缓存与重新验证:Cache-Control、ETag 和可观测性实验 依据 RFC 9111 计算共享缓存 MISS、HIT 与 304 revalidation 的时延,并解释缓存 key 和隐私边界。
已公开资源
- Network Fundamentals Lab 说明 安装、无权限安全边界、十个 Python 实验和三个 C 示例的运行说明。
- 网络基础原理完整实验包 打包 Python/C 源码、固定场景、十份结果 CSV 与协议/代理图。
- DNS TTL 结果 CSV 四次固定查询的 HIT/MISS、过期时间和解析延迟。
- CIDR 与 MTU 结果 CSV 最长前缀路由和 3600 B payload 分段计算结果。
- TCP cwnd 事件 CSV 逐轮记录 ACK、窗口和固定重传事件。
- TLS 1.3 flight 结果 CSV 固定 RTT 模型中的消息方向、时间点和教学共享值。
- HTTP/CDN waterfall 结果 CSV HTTP/2 与 HTTP/3 在冷暖缓存模型中的分阶段耗时。
- 代理路径时延结果 CSV 直接访问、正向代理隧道与反向代理缓存路径的分阶段等待。
- CONNECT/TLS 时间线 CSV 记录 CONNECT authority、隧道建立与加密 HTTPS 请求的状态边界。
- SOCKS5 DNS 边界 CSV 保存 ATYP、目标字节、请求长度和本机 DNS 解析计数。
- 代理负载均衡队列 CSV 比较 round robin 与 least queue 的 backend 选择和排队等待。
- 代理缓存重新验证 CSV 记录 MISS、HIT、304 重新验证、对象年龄和响应时延。
- 网络请求链路交互演示 在浏览器里调整 TTL、前缀、丢包、握手 RTT 与缓存路径。
- 网络基础原理专题分享图 用于分享 DNS、TLS、HTTP/3、代理隧道和缓存专题的 1200x630 SVG 图。
下一步计划
- 补充 IPv6 与 QUIC 报文观察笔记
- 继续用真实用户指标复查缓存与协议收益
