Yes, you’re right. Here comes http3

Time:2021-12-9

brief introduction

Many small partners may still be immersed in the world of HTTP1.1, but the torrent of the times has led us to the world of http3. Yes, you are watching the scenery on the bridge, and someone is watching you in the house by the bridge.

In order not to be abandoned by the times, today I’d like to explain the new features of http3.

HTTP growth introduction

The full name of HTTP is called hypertext transport} protocol, which is the application layer transport protocol based on the world wide web. The original version was HTTP 0.9, which was produced in the late 1980s. Later, it was upgraded to 1.0 in 1996

But HTTP 1.0 can not meet the growing material and cultural needs and the longing for a better world. Therefore, HTTP 1.1 appeared in 1997, and then HTTP 1.1 has been updated until 2014.

Then in 2015, in order to meet the needs of fast sending web applications and modern browsers, a new http2 protocol was developed based on Google’s spdy project.

Four years later, in 2019, Google developed a new protocol standard quic protocol, which is the cornerstone of http3. Its purpose is to improve the speed and security of users’ interaction with websites and APIs.

Problems solved by different HTTP protocols

Different HTTP protocols solve different problems. What are the problems with HTTP 1.1?

  1. Because the data in a connection of HTTP 1.1 is transmitted sequentially, there will be a problem of head of line blocking. If there is a large packet in front, it will lead to the blocking of subsequent packets.
  2. HTTP 1.1 cannot compress request headers and cookies, so the transmission efficiency will be low.
  3. In order to ensure that the buffer will not overflow, HTTP 1.1 has a TCP slow start function. As a congestion control measure, the protocol repeatedly detects the network to calculate the available capacity, but this will lead to multiple data transmission and message delay.

For http2, it uses binary for message transmission, and splits messages into streams one by one. The stream contains multiple frames, which allows resources to be sent through multiplexing using the same connection, solves the problem of line header blocking, and also supports the priority of data packets and server push.

However, the server push of http2 will lead to the complexity of the application. The TCP level header blocking problem can still occur when the packets are lost and must be re sent in the correct order.

Note that http / 2 is an extension of HTTP / 1.1, not a substitute for it. The application semantics remain the same, with the same HTTP method, status code, URI, and header fields. So http / 2 can be used anywhere http / 1.1 is used.

Http / 2 uses a single TCP connection between the client and the server, which remains open during the interaction.

Although http / 2 supports concurrency, too much concurrency will cause the HTTP / 2 server to receive a large number of requests, resulting in request timeout.

Http3 and quic

The goal of HTTP / 3 is to provide fast, reliable and secure web connections on all forms of devices by solving the problems related to http / 2 transmission. To this end, it uses a different transport layer network protocol, called quic, which was originally developed by Google.

Sigh that although China has made some progress in the application of the system recently, looking at these underlying protocols, they are all made by foreigners.

The fundamental difference between http / 2 and HTTP / 3 is that the bottom layer of HTTP / 2 uses TCP protocol, while http / 3 uses quic, while the bottom layer of quic uses UDP protocol.

Let’s take a look at the protocol stack comparison between http / 2 and HTTP / 3:

Yes, you're right. Here comes http3

TCP protocol mainly ensures the reliability and orderly delivery of services, but TCP needs to shake hands with to establish a connection. This is to ensure that both clients and servers exist and that they are willing and able to exchange data. However, it also requires a complete network round trip to complete, and then to complete any other operations on the connection. If the client and server are far away, it will take more time to connect.

We know that UDP is connectionless, so it is much simpler than TCP. It doesn’t need TCP to establish multiple connections. It just needs to send data packets.

Therefore, the advantage of using quic is that it reduces the delay of the system and is suitable for some data packet loss situations, such as online games, advertising bidding, online video, real-time streaming and so on.

In addition, because UDP supports broadcasting, http3 is also suitable for broadcasting applications, such as precise time protocol and routing information protocol.

In addition, http3 can also be used in the Internet of things, big data and VR.

Since HTTP 3 uses quic protocol, what is quic?

Generally speaking, quic is a general transport protocol, which is very similar to TCP. Why create a new set of agreements? This is because the existing TCP protocol is very difficult to expand, because too many devices have used different versions of TCP protocol. It is very difficult to expand directly on the existing TCP protocol, because it is almost impossible to upgrade so many devices.

Therefore, quic chooses to build on the UDP protocol. Quic uses UDP mainly because it hopes to make http / 3 easier to deploy, because it has been known and implemented by all devices on the Internet

Quic actually rewrites the functions of TCP based on UDP, but it is more intelligent and efficient than TCP to realize the core functions of TCP.

Next, let’s look at the specific features of quic.

TLS1.3

TLS is mainly used to ensure the data security of the client and server in the data transmission process, and can encrypt the plaintext data. Tls1.3 is the latest version of TLS protocol. In the old version such as tls1.2, the handshake between the client and the server requires at least two network round trips, but in tls1.3, it is reduced to only one round trip.

Although the unencrypted transmission mode is supported in http / 2, all modern browsers do not support this mode by default, so http / 2 must be used with HTTPS. In the long run, HTTPS is definitely the future trend, so TLS 1.3 protocol is directly used in quic. Quic itself encapsulates tls1.3.

The advantage of this is that quic cannot run plaintext, so it is more secure. And quic has built-in encryption protocol, which combines transmission and encryption handshake, saving round-trip.

Because quic is encrypted in the whole process, for some ISPs and intermediate networks, network data can no longer be analyzed and counted, so its use may be limited. And because quic encrypts each packet separately, it may cause performance problems in the case of high concurrency.

Resolve hol blocking

The traditional underlying protocol of HTTP1.1 and http2 is TCP, although http2 can split the data of different files into streams in the application layer and transmit them in the same connection. But for TCP itself, it does not know that these streams belong to different files. It will treat them as the same file. Therefore, in case of packet loss, TCP will resend all packets. This leads to the problem of hol blocking.

Quic is more fine-grained. It can perform packet loss detection and recovery logic on a per stream basis. This will only resend the failed stream, not the entire file.

Migration of connections

In TCP, if I want to establish a connection between the client and the server, I need to know these four elements: client IP address + client port + server IP address + server port.

If one of the four elements sends a change, you need to re-establish the TCP connection. And the operation in the process needs to be restarted according to the application level protocol.

For example, if you are downloading a large file, but the network address changes suddenly, you may need to re request the file.

To solve this problem, quic introduces a concept called connection identifier (CID). Each connection is assigned an additional number in the above four elements to mark the unique connection between the client and the server.

Because this CID is defined by quic, it will not change with the change of network migration. Thus, a new handshake is not required, which is called connection migration.

summary

Well, that’s all for today’s http / 3 and quic. Although we didn’t cover more details of the bottom layer, I believe everyone should understand it. To sum up, quic actually recreates a more advanced and effective TCP protocol on top of UDP protocol.

This article has been included inhttp://www.flydean.com/03-http3/

The most popular interpretation, the most profound dry goods, the most concise tutorial, and many tips you don’t know are waiting for you to find!

Welcome to my official account: “those things in procedure”, understand technology, know you better!

Recommended Today

Source generator unit test

Hello, I’m Li Weihan, a laboratory researcher in this issue. Today, I’ll show you how to do unit testing based on source generator. Next, let’s go to the lab and find out! Source generator unit test Intro The source generator is Net 5.0, a mechanism for dynamically generating code during compilation, which can be referred […]