Network foundation: 5. UDP's reliable transmission protocol QUIC

1. UDP

UDP (User Datagram Protocol) is a connectionless network transmission protocol. It does not guarantee the reliability and order of data transmission, but it has the characteristics of high efficiency, low delay and flexibility. UDP is often used in real-time communication applications such as audio, video, and online games. Since UDP sends packets to the destination without establishing a connection, it is simpler, lighter and faster than TCP. However, since it does not provide a data integrity check and retransmission mechanism, data loss or errors may occur in some application scenarios.

2. Reliable transmission

Reliable transmission means that in network communication, data can be sent, received, processed, and stored correctly without errors such as loss, disorder, and duplication. Reliable transmission requires various technical means to enhance the stability and accuracy of data transmission, such as data verification, confirmation response, timeout retransmission, flow control, and congestion control. Reliable transmission can ensure the integrity and availability of data, thereby ensuring the quality and reliability of network communication.

3. QUIC

1. What is QUIC?

QUIC, namely Quick UDP Internet Connections (Quick UDP Internet Connections), was born in 2012. It is an experimental network transmission protocol proposed by Google, which is located in the OSI model transmission layer. QUIC aims to solve the defects of the TCP protocol and eventually replace the TCP protocol to reduce data transmission, reduce connection establishment delay time, and speed up web page transmission.

2. Why is QUIC implemented at the application layer

  1. Fast iteration: QUIC is a relatively new protocol. Because it is implemented at the application layer, developers can more flexibly modify and update the protocol, thereby quickly iterating the protocol.
  2. Avoid operating system dependence: As an application layer protocol, QUIC does not depend on the support of the underlying operating system, which means that it can be run on any platform, including various mobile devices and embedded devices.
  3. Strong customizability: The implementation of the application layer enables the QUIC protocol to be adjusted and optimized according to specific needs. For example, in some network environments, the packet loss rate can be reduced by reducing the size of the data packet.
  4. Ease of Deployment: Since QUIC is an application layer protocol, it can be deployed with a simple software update. This is much easier than traditional transport layer protocols such as TCP which require more configuration and setup, especially when firewalls and NAT networks are involved.

3. The difference between QUIC and TCP

features WHO TCP
connection establishment method 0-RTT and 1-RTT connections 3-way handshake connection
reliability Built-in reliability mechanism to reduce packet loss Depends on the reliability mechanism of the upper layer protocol
flow control Stream-Based Transport Control byte-based transfer control
congestion control UDP-based congestion control TCP-based congestion control
head size Larger, may cause network overload Smaller, but the length of the head cannot be changed
encryption Built-in TLS 1.3 encryption Requires separate TLS encryption
Supported Application Layer Protocols HTTP/3, QUIC native protocol, etc. HTTP/1.x、HTTP/2等

Note: 0-RTT means sending data at the same time when connecting for the first time; 1-RTT means sending data after completing the connection.

4. QUIC message format

field length describe
head 13 bytes Contains version, flags and connection id
encryption variable depends on encryption level
data variable Contains request and response data

Note: The length and description are approximate only, depending on the QUIC implementation.

5. Features of QUIC

  1. Connection establishment with low latency
  2. Multiplexing
  3. no head-of-line blocking
  4. Flexible Congestion Control Mechanism
  5. connection migration
  6. Authentication and encryption of packet header and data in the packet
  7. FEC Forward Error Correction
  8. reliable transmission

6. QUIC establishes a low-latency connection

  1. The client sends a QUIC version negotiation packet to the server, which contains the supported QUIC version number.
  2. The server selects a version number and returns a QUIC connection handle (Connection Handle) and a random number (Server Nonce).
  3. The client uses the QUIC connection handle and the server nonce to build an encryption context, and generates a client nonce (Client Nonce).
  4. The client uses the encryption context and the client random number to encrypt the data, and sends the encrypted key information to the server.
  5. The server constructs an encryption context using the QUIC connection handle, the server nonce, and the client nonce, and decrypts data using the key information sent by the client.
  6. The server encrypts the data using the encryption context and the server random number, and sends the encrypted key information to the client.
  7. The client uses the QUIC connection handle, the client random number and the server random number to build an encryption context, and uses the key information sent by the server to decrypt the data.
  8. After the QUIC connection is established, the client and server can start communicating through the QUIC protocol. Because QUIC uses some technical means to reduce network delay, it can establish a low-latency connection.

It should be noted that QUIC uses encryption technology to ensure data security in the process of establishing a low-latency connection. Therefore, the client and server must authenticate each other and exchange key information before establishing a connection. Only in this way can the data be protected during transmission.

7. Disadvantages of QUIC

  1. Not fully compatible with TLS: Although QUIC uses encryption, it does not use the traditional TLS protocol, which means that it cannot be fully compatible with the existing TLS protocol.
  2. High consumption of device resources: QUIC needs to run an additional protocol stack on both the client and server, which may cause performance problems on some devices with limited resources.
  3. Difficulty in network deployment: Because QUIC is a relatively new protocol, it needs to be deployed in network devices. This means network administrators will need to upgrade their equipment to support QUIC.
  4. Still in development: Since QUIC is still relatively young, it still has some problems in practical application. For example, QUIC may not perform as expected in a mobile network environment.
  5. Difficult to monitor and debug: QUIC communicates using the UDP protocol, which means it is harder to monitor and debug than TCP. This can present some challenges for network administrators.

Recommend a free open course of Zero Sound Academy. I personally think the teacher taught it well, so I would like to share it with you:

Linux, Nginx, ZeroMQ, MySQL, Redis, fastdfs, MongoDB, ZK, streaming media, CDN, P2P, K8S, Docker, TCP/IP, coroutines, DPDK and other technical content, learn now

Guess you like

Origin blog.csdn.net/weixin_44839362/article/details/130517273