SPDY, HTTP/2, QUIC Protocol

Source: Internet
Author: User
Tags quic linux mint

1 SPDY protocol 1.1 Overview

SPDY is the abbreviation of speedy, which is the pronunciation of speedy.

The SPDY protocol has published four drafts: Version 1, version 2, version 3, and Version 3.1. Version 4 is currently in the trial phase, but has not yet been released. There are some code for version 4 in Chromium.

Advantages of SPDY over HTTP:

Disadvantages:

Due to these disadvantages, SPDY is less effective on small websites (with a small number of resource files) and may be slower than multi-concurrency connections. (This gave birth to QUIC)

1.2 protocol level

Based on security considerations, SPDY rules are established on top of TLS, that is, URL scheme is https. The inventor said that TLS handshake takes time and traffic to a certain extent, but network security is an inevitable trend, so he does not care about this cost. The protocol layers are as follows:

   SPDY  ←  HTTP      ↓   TLS   ←  NPN      ↓   TCP

Compare the common HTTPS protocol layers:

    HTTP       ↓  SSL/TLS        ↓    TCP

Although the SPDY Protocol replaces the HTTP protocol on the basis of TLS, the content of SPDY contains the content of the HTTP protocol. The design mode is used to understand that the application modifier mode extends HTTP.

In addition, in order not to use the standard HTTP Protocol on top of TLS, the Next Protocol Negotiation (Protocol Negotiation) is extended for TLS ).

1.3

To put it simply, some fields are added in the handshake phase of TLS to indicate that the server and client want to use a Protocol other than HTTP (SPDY) based on TLS. The same is proposed by Google, which paves the way for SPDY.

The implementation of the Client program is: set which protocols can be accepted for OpenSSL (or the database that encapsulates it) before handshaking, obtain the Protocol selected after handshaking, and then communicate according to the selected protocol.

1.4 Data Format

This section does not fully introduce SPDY, but focuses on it. It is assumed that the reader is familiar with the HTTP protocol and does not explain the concept similar to HTTP in SPDY.

SPDY calls the content of one-way transmission (from the server to the client or from the client to the server) as a frame, and the content of frame assembly by protocol is called framing ). The content of a frame can be divided into header and payload, which are similar to HTTP header and entity, but there are the following differences:

Based on the load content, frames are divided into control frames and data frames.

Control Frame data format:

+----------------------------------+|C| Version(15bits) | Type(16bits) |+----------------------------------+| Flags (8)  |  Length (24 bits)   |+----------------------------------+|               Data               |+----------------------------------+

Data format of the data frame:

+----------------------------------+|C|       Stream-ID (31bits)       |+----------------------------------+| Flags (8)  |  Length (24 bits)   |+----------------------------------+|               Data               |+----------------------------------+

Meaning of each data bit:

  • C is the first bit. The value 0 or 1 indicates the data frame and the control frame respectively.
  • Version is the SPDY Protocol Version. Currently, it is 3.
  • Type is used to differentiate the types of control frames.
  • Flags mark some operation indications. Different types have different Flags. FLAG_FIN indicates that a Stream ends.
  • Length indicates the Data Length.
  • Data, that is, payload. The Data of a Data frame is a file (HTML documents, images, scripts, etc.). The Data of the control frame varies according to the Type.
  • Stream-ID records the serial number.

SPDY calls an HTTP Request/Response back and forth as a Stream. Because TCP connections are reused, multiple streams exist in a SPDY connection. To distinguish different streams, use Stream-ID to mark the serial number (Note: Because reload is allowed, a Stream cannot be determined by URL ). Stream-ID also exists in payload of four Control Frames (SYN_STREAM, SYN_REPLY, RST_STREAM, and HEADERS.

Control Frame types and functions:

For details about the format of frames, refer to (you need to understand the specific meaning of the protocol document. You can skip this step and click to view the large image ):


1.5 Process

Common procedures include:


Server Push server process: After replying to SYN_STREAM on the client side, initiate SYN_STREAM on the server side, and use the field Associated_To_Stream_ID in payload to indicate which stream the Push is associated.

2 HTTP/22.1 Overview

The HTTP/2 Quasi-version 11th draft was updated on March 17, 2014 at http://http2.github.io/http2-spec /.

HTTP/2 is developed by the Standardization Organization Based on SPDY. The difference is:

The HTTP/2 document contains some examples and detailed descriptions, which are not available in SPDY.

Chromium's latest code and Google website support HTTP2-10 (HTTP/2 Draft 10th ).

2.2 ALPN

The draft version of ALPN 5th was published on March 3, 2014 at http://tools.ietf.org/html/draw.ietf-tls-applayerprotoneg-05. It is based on the type and optimizes the process, but the principle remains unchanged. It is to add a negotiation protocol in the TLS handshake process. The standard process is as follows:

   Client                                              Server   ClientHello                     -------->       ServerHello     (ALPN extension &                               (ALPN extension &      list of protocols)                              selected protocol)                                                   Certificate*                                                   ServerKeyExchange*                                                   CertificateRequest*                                   <--------       serverhellodone certificate* clientkeyexchange* certificateverify* [changecipherspec] finished                           -------->                                                   [ChangeCipherSpec]                                   <--------       Finished   Application Data                <------->       Application Data

Currently, the PC release version of Chromium is already using ALPN, with no need for an ALPN.

2.3 TCP applications

HTTP/2 can use http or https scheme as the URL.

When using http scheme, the client first sends the request from HTTP/1.1 to the server, but adds the header Upgrade and HTTP2-Settings. Format:

GET /default.htm HTTP/1.1Host: server.example.comConnection: Upgrade, HTTP2-SettingsUpgrade: h2cHTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

If the server supports HTTP/2, status code 101 is used to reply to the request. The format is as follows:

HTTP/1.1 101 Switching ProtocolsConnection: UpgradeUpgrade: h2[ HTTP/2 connection ...

Then both parties start to use HTTP/2 as the transmission protocol. Otherwise, HTTP/1.1 is used to reply to response, that is, HTTP/1.1 200 OK.

3 QUIC

QUIC is short for Quick UDP Internet Connections. Developed by Google, the summary design document is stored in google docs. Detailed design documents of the transmission format are placed in workshop.

The summary design document starts from TCP/UDP features, network security, and so on. It discusses a lot of design ideas and describes four disadvantages of SPDY at the beginning:

It can be considered that QUIC is a solution designed to solve the TCP bottleneck of SPDY and explore UDP. According to SPDY, the transmission content of QUIC is considered to be divided into two layers. The upper layer is similar to SPDY, and the lower layer is simulating TCP connection-oriented features and Reliability on UDP and adding encryption Processes similar to TLS.

The QUIC documentation is still in unfinished state, and the Implementation Code of Chromium is also being improved. This is still an experimental semi-finished product with no performance comparison data. It's just a little research.

Reprinted please indicate the source: http://blog.csdn.net/hursing

4 Research and Investigation 4.1 SPDY server construction 4.1.1 Apache

For more information about how to build an SSL/HTTPS/SPDY server, see Linux Mint + Apache2.2.

The environment is configured as Linux + Apache2.2 + mod_spdy. Mod_spdy is a plug-in developed by Chromium for Apache. It only supports Apache2.2 and directly installs the plug-in package. The SPDY protocol supports version 3.

4.1.2 Nginx

For more information about how to build an SSL/HTTPS/SPDY server, see Linux Mint + Nginx 1.5.11.

The environment is configured as Linux + Nginx1.5.11. You need to compile the source code to enable SPDY, which is not supported by normal release packages. SPDY supports version 3.1, but does not support Server Push.

4.1.3 share

Based on news pages. Microsoft-IIS, which ranks first and second, and third respectively, does not support SPDY.

4.2 Wireshark packet capture

Chromium implements source code patch for Wireshark1.7.1, called spdyshark. You need to download the Wireshark source code and the spdyshark source code to compile it together to make Wireshark support the SPDY protocol. For more information about how to compile and install Wireshark in Linux Mint, see install and compile Wireshark that supports the SPDY protocol.

Because SPDY is based on TLS, Wireshark needs to decrypt SSL before parsing the SPDY protocol. For more information about packet capture methods, see Wireshark + Apache2.4 decrypt SSLv3 and use Wireshark packet capture (including spdyshark plug-ins) that support the SPDY protocol.

4.3 Server application status 4.3.1 Survey Method

Check whether the Web server supports SPDY. You can use the Third-Party website method: Visit http://spdycheck.org/and enter the network token on the webpage to check whether SPDY is supported. For example:


However, not all Chinese websites Use HTTPS scheme. Therefore, you need to manually find the Logon account page for testing.

You can also use Wireshark to capture packets and find Extension in the Server Hello information of TLS. ALPN will display Unknown 16, which can be recognized as Extension: next_protocol_negotiation.

We can see that Google currently uses 3.1:


Facebook uses 2 and 3:


4.3.2 The survey results showed that only four common websites at home and abroad were found: Google, Facebook, wordpress.com and www.cloudflare.com. There is no website support in China. (Note: This survey result is very rough and cannot be considered as an authoritative conclusion) 4.4 Browser Application Status 4.4.1 Test Method

Visit https://isspdyenabled.com/using the target browser to display the support for spdyon the page.

4.4.2 data

Based on third-party data, SPDY-supported browsers include:

SPDY support accounts for 65.26% of browsers. For more information, see http://caniuse.com/spdy.

I found CNZZ statistics on browser shares in China, but I cannot intuitively see the proportion of SPDY supported. My personal estimation is that the desktop version is less than 50%, and the mobile version is less than 30%. Http://brow.data.cnzz.com/main.php? S = brow & uv = 1 & type = 2 & date = 2014% E5 % B9 % B402 % E6 % 9C % 88.

5. browser implementation solution

For browser implementation, SPDY works at the network layer of the framework to be loaded. If SPDY has been implemented, describe layer-by-layer refinement within the network layer and responsibilities of each layer-by-layer:


Both HTTP and SPDY require each refined layer to assume all responsibilities in a single loading process. In code implementation, if HTTP and SPDY are different, you need to design the base classes for each responsibility. HTTP and SPDY inherit the base classes to implement different processes.

SPDY has the following special implementation responsibilities:

In addition to Chromium itself, its SPDY documentation also lists several implementations. Other implementations of C/C ++ share one thing in common: because they work at the underlying layer, they rely on a lot of External library code. In addition, they have updated in the last three months. Most of them do not support all SPDY features and are fixing bugs. Therefore, the Code perfection level cannot meet the browser-level standards.
6. Does the website support SPDY?

No need to support SPDY, HTTP/2, and QUIC.

Cause:

Reprinted please indicate the source: http://blog.csdn.net/hursing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.