Quinn. quic-p2p. You may have seen these two words pop up in our weekly dev updates for the past couple of weeks, so we thought it was about time we explained to you, in some more detail, what is going on.
We’ll start off with a super quick glossary.
- QUIC (Quick UDP Internet Connections) is a specification. QUIC is the solution to a number of transport and application layer problems. Whilst it’s very similar to TCP and TLS, it’s implemented on top of UDP.
- Quinn is the crate we’re adopting QUIC from.
QUIC: A Brief History
So where did QUIC come from? While we may not agree with their surveillance capitalistic practices, QUIC originated at Google — but stay with us. It was an experimental network protocol designed by Jim Roskind who worked at Google at the time. They deployed it across Chrome, YouTube and Search as well as other services to allow them to observe the protocol in action. However, the version that Google developed is very different to how it looks today. From the wire format of the packets, to the handshake and the mapping of HTTP, QUIC grew organically thanks to open collaboration and a shared goal by many developers of making the Internet faster and more secure.
How the SAFE Network Uses QUIC
Originally, MaidSafe did not intend to build a network library. We developed Crust, an open-source library that enabled computers to connect to each other on a peer-to-peer network, because nothing existed with the features we needed. Never content to stand still, we looked at other libraries (such as uTP) but found that they all lacked our vision of a fully-secured networking library.
We then identified that we could achieve the same objectives by using open source code based on the QUIC specifications. The Quinn crate is an open-source implementation of QUIC that has been developed in Rust (the programming language of choice for the backend of the SAFE Network). We made the decision to replace Crust with QUIC. We’ve named our library quic-p2p because we wanted the name to be self-explanatory (we’re using the QUIC protocol to code our p2p library). Plus it’s pretty catchy, don’t you think?
So why have we moved from Crust to quic-p2p?
Crust was built upon TCP and provided the basis for all additional protocol engineering. QUIC is different. It’s a fully-formed, single protocol so there is no requirement for any additional protocol engineering. Secondly, its ready…almost. It’s been adopted by the IETF and whilst that standard may evolve over time, any future changes won’t affect the functionality that it already has today that we’ll be relying on. Plus our ambition is to get to full launch as speedily as possible which means we’re more than happy to utilise existing solutions; this is open development and open source at its best. QUIC is also fast, can setup connections cheaper than TCP and can accept hole punched (UDP) sockets. And last but not least, QUIC already has functionality that we were building into Crust. So why wouldn’t we grab the opportunity to build on work that solves our problems?
So is Quinn better for the SAFE Network than Crust?
In a word — yes. There are three main advantages;
- Encryption: QUIC sits upon UDP protocol and it’s encrypted by default. Crust would previously have dealt with this by encrypting before sending anything through TCP (because TCP isn’t encrypted itself). However in the new world, QUIC has encryption with built-in TLS certificates — so encryption is free.
- Multi-streaming: Another issue with TCP is head-of-the-queue blocking. In other words, whatever arrives first in the queue gets delivered first. An application treats a stream of bytes sent via a TCP connection essentially as FIFO. For example, if you send 1GB of data and then 1KB data, they’ll be received sequentially, biggest first. So this means subsequent smaller data can be left sitting in the pipes, held up until that first packet is received. QUIC does things differently. On the same pipe, you can open a stream and send different data down different channels simultaneously, so there’s no head-of-the-queue blocking. In Crust, we emulated this by using our chunking algorithm and priority queues. By adopting Quinn, we no longer need these things.
- IETF Approval: While QUIC is a living standard (in the sense that it is not finalised), it was adopted by the IETF in 2016. The standardisation of this provides added credibility for SAFE newcomers. While Crust was built on TCP (which of course is an IETF standard), the additions we built on top weren’t specifically addressed by the IETF.
There are many other benefits (such as prevention of IP spoofing, stateless retries etc.) that QUIC brings with it. Being a modern protocol, the specification has considered the shortfalls of the existing mechanisms studied over decades and addressed those issues in QUIC. And even better, we’re one of the first to actively use this protocol.
So there we have it. While Crust was the right solution for us to pursue until now, we’re hungry enough to understand that if better solutions exist that let us get the Network ready for you faster, without any compromises, we should take that opportunity and grab it with both hands. The move towards fully encrypted, secured private communications built on the efforts of a global community gives us solid foundations to build the SAFE Network.