Skip to content

A .NET C# Implementation of QUIC protocol - Google's experimental transport layer.

License

Notifications You must be signed in to change notification settings

MindSwipe/Quic.NET

 
 

Repository files navigation

0x5C2AAD80

Build Status

QuicNet

Preamble

This is a fork, not the original. The purpose of this fork was to port the Libraries from .NET Framework 4.5.2 (and multiple other versions) to .NET Standard 2.0 to allow interoperability with .NET Framework and .NET Core. The Unit Test project and the Console test projects are still .NET Framework, although they are .NET Framework 4.7.2 now. I also updated the .csproj files from their old VS 2015 format to the new VS 2017 and upwards format. I may or may not continue developing this, I just got it into a state where I can work with it and can start experimenting to see if it fits my needs or not.

Table of contents

What is QuicNet?

QuicNet is a .NET implementation of the QUIC protocol mentioned below. The implementation stays in line with the 17th version of the quic-transport draft, and does NOT YET offer implementation of the following related drafts:

Get started

Minimal working examples

Preview

Alt

Server

using System;
using QuicNet;
using QuicNet.Context;

namespace QuickNet.Tests.ConsoleServer
{
    class Program
    {
        static void Main(string[] args)
        {
            QuicListener listener = new QuicListener(11000);
            listener.Start();
            while (true)
            {
                // Blocks while waiting for a connection
                QuicConnection client = listener.AcceptQuicClient();

                // Assign an action when a data is received from that client.
                client.OnDataReceived += (c) => {
                    byte[] data = c.Data;
                    Console.WriteLine("Data received: " + Encoding.UTF8.GetString(data));
                    // Echo back data to the client
                    c.Send(Encoding.UTF8.GetBytes("Echo!"));
                };
            }
        }
    }
}

Client

using QuickNet;

namespace QuicNet.Tests.ConsoleClient
{
    class Program
    {
        static void Main(string[] args)
        {
            QuicClient client = new QuicClient();
            QuicConnection connection = client.Connect("127.0.0.1", 11000);   // Connect to peer (Server)
            
            // Create a Bidirectional data stream
            QuicStream stream = connection.CreateStream(QuickNet.Utilities.StreamType.ClientBidirectional);
            
            // Send Data
            stream.Send(Encoding.UTF8.GetBytes("Hello from Client!"));        
            
            // Receive from server (Blocks)
            byte[] data = stream.Receive();                                   
            Console.ReadKey();
        }
    }
}

What is QUIC?

QUIC is an experimental transport layer protocol designed by Google, aiming to speed up the data transfer of connection-oriented web applications. This application-level protocol aims to switch from TCP to UDP by using several techniques to resemble the TCP transfer while reducing the connection handshakes, as well as to provide sensible multiplexing techniques in a way that different data entities can be interleaved during transfer.

Connections

Connections are the first tier logical channels representing a communication between two endpoints. When a connection is established, a ConnectionId is negotiated between the two endpoints. The ConnectionId is used for identifying connection even if changes occur on the lower protocol layers, such as a Phone changing Wi-Fi or switching from Wi-Fi to Mobile data. This mechanism prevents restarting the negotiation flow and resending data.

Streams

Streams are second tier logical channels representing streams of data. A single connection can have a negotiated number of streams (8 maximum for example) which serve as multiplexing entities. Every stream has it's own, generated StreamId, used for identifiying the different data objects being transferred. Streams are closed when all of the data is read, or the negotiated maximum data transfer is reached.

Packet

Packets are the data transfer units. The packet header contains information about the connection that this packet is being sent to, and cryptographic information. After stipping off the additional transfer information, what is left are the Frames of data (A packet can have multiple frames).

Frame

Frames are the smallest unit that contain either data that needs to be trasferred to the Endpoint or protocol packets necessary for actions such as handshake negotiation, error handling and other.

Contributing

Following the Fork and Pull GitHub workflow:

  1. Fork the repo on GitHub;
  2. Clone the project locally;
  3. Commit changes;
  4. Push your work back up to your fork;
  5. Submit a Pull request so that the changes go through a review.

For more info, read the CONTRIBUTING

More

The quic-transport draft can be found, as previously mentioned at quic-transport.

To test QUIC and find additional information, you can visit Playing with QUIC.

The official C++ source code can be found at proto-quic.

About

A .NET C# Implementation of QUIC protocol - Google's experimental transport layer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%