1. TFO

In order to improve the latency of web applications, Google released TFO(TCP Fast Open, RFC 7413), which uses the three-way handshake to exchange data by modifying TCP protocol.

TFO allows data in the initial SYN packet to be sent and received during a TCP handshake. If both the client and the server support TFO, the delay in establishing multiple TCP connections to the same server can be reduced. This is done by storing TFO cookies on the client after the initial TCP handshake. If the client reconnects later, this TFO cookie is sent to the server, reducing latency by allowing successive TCP handshakes to skip a round-trip delay.

2. TFO principle

First connection:

  1. The client sends SYN packets with the Fast open option and an empty cookie value
  2. After receiving the SYN, the client generates a Cookie and puts it in the FAST Open option of the ACK+SYN packet and sends it back to the client
  3. After the client receives the cookie, it stores it.

The first connection is disconnected and the second connection is started:

  1. When the client sends an ACK to the server, it takes the cookie and the data with it

  2. The server verifies the validity of the received cookie. If not, throw away the current bag and do the normal three-way handshake. If it is valid, the server sends ACK+SYN to the client with a packet

  3. The client sends an ACK to the server

3. Benefits of TFO

Take establishing a connection and sending a request twice

On the second request, TFO can put the request and response messages in the process of the previous two handshakes, so the second request can get the response data in one RTT