架构
🌐 Architecture
quic 模块构建在三个核心抽象之上:
🌐 The quic module is built around three core abstractions:
QuicEndpoint:表示 QUIC 的本地 UDP 套接字绑定。它用于发送和接收 QUIC 数据包,并且可以在多个会话之间共享。单个端点可以同时用作客户端和服务器。QuicSession:表示本地端点与远程对等体之间的 QUIC 连接。会话可以通过使用quic.connect()向远程对等体发起连接来创建,或者通过quic.listen()接受来自远程对等体的传入连接来创建。QuicStream:表示会话中的 QUIC 流。流可以由本地或远程端创建,并且可以是双向的或单向的。
与传统的基于 TCP 的协议不同,QUIC “连接”并不固有地绑定到特定的本地端口/远程端口对。会话通过 QUIC 端点启动,但在其生命周期内可能迁移到不同的本地或远程地址,可以超出创建它的端点存在,甚至可能同时与多个端点关联。这种灵活性允许高级用例,例如连接迁移、多宿主和负载均衡。然而,在大多数情况下,端点与会话之间的一对一简单关系已经足够。
🌐 Unlike traditional TCP-based protocols, QUIC "connections" are not inherently tied to a specific local port / remote port pair. A session is initiated via a QUIC endpoint but may be migrated to a different local or remote address over its lifetime, outlive the endpoint that created it, and may even be associated with multiple endpoints simultaneously. This flexibility allows for advanced use cases such as connection migration, multi-homing, and load balancing. Most often, however, a simple one-to-one relationship between endpoint and session is sufficient.