QUIC Protocol
QUIC Protocol
Puneet Kumar
SCU-ID: 00001424550
This document is intended to explain the new transport protocol which is going to revolutionize
the network industry. It is important to have prior knowledge of the transport protocols (TCP
and UDP). QUIC is exploring it’s way into TCP world on a fast pace. This documents explains
the protocol in a great detail. It targets audience of the class who are taking taken COEN -
233 (Computer Networks), as fundamentals to understand this document was explained in the
class, as in lecture slides, OSI layer, transport layer protocols and it’s interaction with layer
3(Network layer) and layer 7 (Application layer) are covered.
ii
Contents
Audience ii
1 Introduction 1
1.1 Connection Overhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Migrating Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Multiple Connections to Same Server . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 TCP Half-Open Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Head-of-Line Blocking (HOL) . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Contribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 QUIC Protocol 6
2.1 QUIC Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Connection Establishment . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2 Improved Congestion Control . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.3 Multiplexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.4 Forward Error Correction . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.5 Connection Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.6 Built-in Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.7 Solves Head-of-Line Blocking . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.8 NAT Rebinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.9 QPACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 QUIC Packet Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 QUIC Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.2 Connection Identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.3 Stream Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.4 Packet Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.5 Flow Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.5.1 Data Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 15
iii
2.2.5.2 Flow Credits Increments . . . . . . . . . . . . . . . . . . . . . 15
2.2.6 Re-transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4 Acronyms 19
Bibliography 21
iv
List of Figures
v
List of Tables
vi
1. Introduction
SYN-ACK
ACK
Since TCP is the most important connection oriented protocol, it has been a center point
of the research. Several improved version of TCP have been published in the last couple of
decades(refer Table 1.1). These TCP versions have mainly focused on the throughput [3, 4].
Albeit, throughput is the main factor for determining the quality of traffic, TCP might not be
for suitable for a lot of different types of traffic. Some of the examples of such traffic are: IoT
(Internet of Things) [5], IIoT (Industrial Internet of Things) [6]. Traffic in these technologies
are generally characterized by short-lived bursts of exchanging small data chunks. For such
short lived connections, establishing connections every single time before an exchange of short
live burst data is a lot of overhead. Connection start up latency in TCP is high, as it requires
two round trips (RTT) for declaring a peer-to-peer connection alive and ready.
1
Table 1.1: TCP Versions Comparison
2
Generally, applications which are required to have connection oriented transport protocol such
as HTTPS [7], have some form of security enabled on top of transport layer. One of the most
popular protocol used for such purpose is TLS (Transport Layer Security) [8]. This protocol
provides security over the TCP by encrypting everything in application layer. Encryption is
based on the keys exchange happened between end entities. This process adds one or two RTTs
into the additional two RTTs in connection establishment between end points after connec-
tion establishment. Securing transport layer is necessary as it provides symmetric encryption
which enables authenticated, confidential and integrity-preserved communication between two
devices. TLS protocol has it’s own handshake like TCP and it is unique per connection. So
total 3-4 RTTs are required to establish and secure a connection oriented connection between
end-to-end hosts.
As we have seen, it takes 3-4 RTT just to establish a TCP connection. Networks which are
lossy in nature, such as wireless networks, will pay a heavy price of connection overhead.
Everytime an IoT device gets disconnected from the network, to connect to the desired device
again, TCP connection needs to be re-established. If a network has a lot of lossy connections,
the amount of connection establishment overhead can be enormous.
Client Server
SYN
SYN-ACK TCP
Connection
ACK establishment
Client He
llo
Server Hello
ClientKe TLS
Change Ci yExchanged Handshake
pherSpec
Finished
ed
pec Finish
CipherS
Changed
Limitations of TCP is not stopped only to connection overhead. Another major price TCP
connection pays is flow migration. Flow is generally identified by a combination of several
factors to identify single connection. Parameters involved in identifying a flow are source IP
address, destination IP address, source port number, destination port number and the protocol
(called 5-tuple). Some of these parameters (port numbers) are unique for a connection while
others are common across device (ip address). Changing the application or device can lead to
a different identifier than the previous one. This will eventually lead to tear down the establish
TCP connection. Such condition will force devices to establish a new TCP connection and
perhaps negotiate TLS handshake again. This could lead to a catastrophic event, imagine
3
a user is paying a credit card bill and the money has been reduced from his account, but
while contacting the vendor, connection is teared down. All session information prior to this
connection is gone and now in new connection, packets have no information about prior bill
pay. Second limitation arises due to flow migration is NAT rebinding. Generally, users are
behind firewall in their LAN network, with non-routable IP (such as 192.168.x.x or 172.16.x.x),
these IP and port makes a NAT table in the outgoing router to identify each device. Upon
connection migration, this table can be inconsistent and can lead to breach in LAN hosts
securities.
Some applications, specially the web applications, such as HTTP [9] require to have multiple
TCP connections established with the server in order to fetch data. These connection occupies
bandwidth and bring connection overhead with them. Currently there is only one flavor of
TCP out there called SPDY [10] which supports multiplexing (SCTP is not a flavor of TCP).
Problem with SPDY is that it is not supported by many networks and it’s limited usage to
HTTP2 hindered it’s popularity.
Another limitation of TCP is half open connections. Receiving data in TCP is passive. It
means that dropped connections are only detected by the sender and receiver has no way
of detecting them. In order to understand this problem, lets take an example. Suppose a
connection is being established between client and server. If a server is failed to receive an ACK
from client, this port is continued to be occupied and resources will only be released once the
TCP state transitions to Closed State after timer expires.
Client Server
SYN -
Initiate 1
connection
Incomplete
K Connection
, AC
SYN attern
it h p
w
Doesn’t
Complete Half Open
connection ACK
connection
Head-of-Line blocking problem is a limitation phenomena, which occurs when resources are
being held up by some entity in order to complete an action. As shown in figure 1.4, three
4
packets are coming from server and if packet 3 is dropped for some reason then packet 1 and
2 will not be pushed to application, until packet 3 is re-transmitted and packet re-ordering is
completed. As one might guess, this phenomena only occurs if a connection oriented transport
protocol is used. This out of delivery of packets can happen due to several reasons, such as
lossy nature of the network, different paths taken by the packets and being dropped. HOL
can significantly increase the packet reordering delay and which lead to consume resources and
latency in packets being processed by network stack and application.
3
2
Client 2 Server
1 3
1
1.6 Contribution
With the increasing number of devices connected to internet, a new transport mechanism
is needed to replace TCP to be able to address all the problems mentioned above. In this
research report we will investigate and dissect QUIC [11] protocol. QUIC (Quick UDP Internet
Connections) addresses these issues and bring a new perspective to the transport layer. Not
only it provides fast transport but in terms of security it integrates TLS-1.3 which is the next
generation transport layer security protocol. Chapter 2 will be focused on QUIC protocol
specifically, chapter 3 will mainly talk about conclusion and explanation about the future
aspects of the protocol.
5
2. QUIC Protocol
QUIC stands for Quick UDP Internet connections [11] and developed by Google. Initially this
protocol was designed and developed for HTTP but later it was declared as general purpose
transport layer protocol. This protocol provides security and reliability along with reduced
connection and transport latency. Google has widely deployed QUIC in their servers and is
currently in use.
Network IP IP IP
Layer
As shown in figure 2.1, QUIC sits in application layer unlike other traditional transport layer
protocol such as TCP or UDP. QUIC runs on UDP to be compatible with all the middleboxes.
When middleboxes encounter QUIC traffic, they see only UDP traffic. The main idea behind
QUIC is to overcome TCP limitations discussed in Chapter 1. As one might guess that the
main transport protocol for QUIC, which is UDP, it is unreliable and doesn’t provide any
features needed for reliable connection.
QUIC solves the problems mentioned in Chapter 1. QUIC is very similar to TCP+TLS+HTTP2,
but since it is implemented on top of UDP, all the connection reliability features are in ap-
plication layer. As a self contained protocol, there are limitless opportunity for innovation
in QUIC, which are not going to be possible with existing protocols as they bound to follow
legacy.
6
2.1 QUIC Features
Client Server
mc , pkj ms
Send m1 = c_i_hello(pkj)
Send m2 = s_reject(m1)
}
Server key
ks:get_key_s(m6) key_settlement
Client key
kc:get_key_c(m6,sqns)
Send m7 = pak(k, sqnc, mc)
7
move further in connection establishment, this information is necessary. Next time, the client
sends a CHLO packet, which can use the cache credentials from the previous connection to
immediately send encrypted requests to the server.
Client Server
mc , pkj ms
}
Server key
ks:get_key_s(m6)
Client key key_settlement
kc:get_key_c(m6,sqns)
Figure 2.2 shows the packet exchanges in QUIC connection establishment in 1-RTT scenario.
In 0-RTT scenario, server and client have communicated in the past and no need to establish
connection again. As shown in figure 2.3, first packet itself carry the data, there is no need for
connection establishment or key exchanges.
2.1.3 Multiplexing
As mentioned in subsection 1.3, a client opens up multiple TCP connections to server to fetch
data from server. QUIC solves this problem by having multiple streams over one UDP pipeline.
8
Client Client
Multiple Connections
Client Client
In QUIC, there is only one UDP connection for transport, while in the usage of TCP, there
are multiple connections being established.
9
In addition to that QUIC also encrypts additional metadata so that middleboxes such as
firewalls, proxies do not manipulate the connection.
10
2.1.9 QPACK
HTTP2 introduced header compression (HPACK)[14], which allows HTTP2 end hosts to re-
duce the amount of data transmitted. In particular HPACK has dynamic tables, filled by
headers sent from previous HTTP requests/response. This allows end hosts to refer previously
encountered headers in new requests, instead of having them transmitted again. HPACK ta-
bles need to be synchronized between HTTP sender and receiver. With TCP, synchronization
is transparent, as TCP takes care of delivering HTTP requests and responses in the same order
as they came in. On the other hand, QUIC can deliver multiple HTTP requests/responses,
with the help of streams. This means that although it takes care of the data delivery in order,
as long as it is a single stream, it doesn’t guarantees any ordering among streams.
Figure 2.6 shows the general packet format for QUIC. Generally, there are a lot of variants
of those packet formats, such as Long header, short header, version negotiation packet, initial
packet, 1-RTT packet, 0-RTT packet etc. Discussing those packet format is out of scope for
this project, but interested readers can go [15] to read about those packet structures.
• Destination Connection ID
• Packet Number
• Protected Payload
11
Table 2.1: Type of Long Header
Type Name
0x0 Initial
0x1 0-RTT
0x2 Handshake
0x3 Retry
QUIC .......................
Frame 1 Frame 2 Frame N
Header
Figure 2.6: The solid and dashed lines show the clear-text and encrypted parts of a QUIC packet, respectively.
The non-encrypted part is used for routing and decrypting the encrypted part of the packet.
12
Stream frames consists of the following:
• Stream ID: A variable length integer indicating the stream ID of the stream.
• Offset: A variable-length integer specifying the byte offset in the stream for the data in
this stream frame.
• Length: An integer of variable length. It specifies the length of the stream data field.
• Stream Data: Bytes to be delivered.
A packet number space is a context in which a packet can be processed and acknowledged.
For instance, initial packets can only be sent by initial packet protection keys. Similarly
handshake packets are only sent at handshake encryption level. This brings cryptography
separation between the data sent in the different packet sequence number spaces. Each space
starts packets number as 0 and subsequent packets must increase the packet number by 1.
0-RTT and 1-RTT data exists in the same packet number space. There are certain additional
rules to be followed in regards to packet number.
• A QUIC end point must not reuse packet number within same packet number space in
one connection.
• If a packet number reaches 262−1 , then the connection must be closed by sender without
sending any notification.
• A newly unprotected packet must be discarded by receiver, unless receiver is certain that
another packet bearing same packet number has not been processed.
13
Figure 2.7: Inside of a QUIC Packet
14
2.2.5 Flow Control
As any connection oriented protocol demands, there has to be a way to limit the amount of data
a receiver could buffer. In order to impose that limit, flow control is necessary. TCP implements
it’s own way of flow control [16]. QUIC imposes flow control by controlling the maximum
amount of data a sender can send on a stream at any given time. Also to limit concurrency
within a connection, QUIC endpoint also controls the maximum cumulative number of streams
that an endpoint can initiate. Since QUIC have TLS packets as a stream as shown in figure
2.7. Those streams are referred as CRYPTO frames. They are not flow controlled like stream
data because QUIC relies to have an interface to the TLS about the buffer limit.
• Stream Flow Control: It prevents a single stream from consuming the entire buffer for
a connection by limiting the amount of data that can be sent on any stream.
• Connection Flow Control: It prevents sender from exceeding a receiver’s buffer ca-
pacity for the connection. It is done by limiting the total bytes of stream data sent in
STREAM frames on all streams.
A receiver advertises credit for a stream by sending a MAX_STREAM_DATA frame with stream ID.
MAX_STREAM_DATA frame indicates the maximum absolute byte offset of a stream. In addition
to that, receiver also advertises credit for connection in MAX_DATA frame. This frame indicates
the maximum of the sum of the absolute byte offsets of all streams. To close connection,
receiver uses FLOW_CONTROL_ERROR frame, if sender sends any corrupted packet, with regards
to advertised connection or stream data limits.
Sender on the other hand, must ignore any MAX_STREAM_DATA or MAX_DATA frames that do
not increase any flow control limits. In case sender runs out of any credit, it will be unable
to send any new data and will be considered blocked. In such event, a sender will send
STREAM_DATA_BLOCKED or DATA_BLOCKED frame to indicate that it has data to write but is
blocked by flow control limits.
15
MAX_STREAM_DATA frame at least two RTT before it expects the sender to get blocked. In ad-
dition, a receiver must not wait for a STREAM_DATA_BLOCKED or DATA_BLOCKED frames before
sending MAX_STREAM_DATA or MAX_DATA frame, since doing so will mean that a sender will be
blocked for at least an entire rount trip, and potentially longer if the peer chooses not to send
STREAM_DATA_BLOCKED or DATA_BLOCKED frame.
2.2.6 Re-transmission
In TCP world, packets are ACKed based on the sequence number and the next expected
sequence number in the ACK packet. There are a lot of literature on TCP re-transmission,
so we will not get into it. QUIC re-transmission is a bit different that TCP. As mentioned
earlier, QUIC has multiple streams and any stream can be an ACK frame, acknowledging any
past or present data frame. Due to this, QUIC maintains two counts, ACK Range Count and
First ACK Range. ACK Range Count basically tells us till what packet number data frames
has been received, and First ACK Range tells us till what packet number data frames have
been received and acknowledged.
In case of any frame dropped, QUIC receiver tells sender via Gap in ACK frame. This tells
sender how many packets were dropped and the NACK count tells what packet numbers are
missing. Figure 2.8 shows re-transmission ACK frame.
16
3. Conclusion and Future Aspects
In this project, we examined different problems of TCP protocols faced today and explained
their scenarios. In second chapter we dived down into QUIC protocol in detail. What we have
found out is that QUIC protocol solves problems currently facing by TCP. Since QUIC sits in
application layer, it brings substantial benefits, and it makes development and testing cycles
fairly simple. QUIC is widely used in every type of traffic. Majorly it is used in user internet
traffic and IoT traffic. We can conclude the QUIC protocol in these two parts.
17
Table 3.1: Comparison of TCP, UDP and QUIC
18
4. Acronyms
19
Bibliography
20
[14] Roberto Peon and Herve Ruellan. Hpack: Header compression for http/2. Internet Re-
quests for Comments, RFC Editor, RFC, 7541, 2015.
[15] M. Thomson J. Iyengar. RFC Draft: QUIC: A UDP-Based Multiplexed and Secure
Transport, 2019.
[16] Timothy James Speight. Method and arrangement for tcp flow control, November 27 2012.
US Patent 8,320,250.
[17] David D Clark, John Wroclawski, Karen R Sollins, and Robert Braden. Tussle in cy-
berspace: defining tomorrow’s internet. In ACM SIGCOMM Computer Communication
Review, volume 32, pages 347–356. ACM, 2002.
[18] Shin Maruyama, Michael Tuexen, Randall Stewart, Qiaobing Xie, and Masahiro Kozuka.
Stream control transmission protocol (sctp) dynamic address reconfiguration. 2007.
[19] Yuchung Cheng, Jerry Chu, Sivasankar Radhakrishnan, and Arvind Jain. Tcp fast open.
RFC 7413 (Experimental), Internet Engineering Task Force, 2014.
21