Giter VIP home page Giter VIP logo

lsquic-tutorial's Introduction

Build Status

lsquic-tutorial

lsquic tutorial teaches one how to build an application using lsquic.

Description

The tutorial program, tut.c, contains client and server logic for a simple echo program. The client connects to the server and sends lines of text; the server reverses the lines of text and sends them back.

The tutorial program was written as an educational aid. Various aspects of the ways LSQUIC is used in it are considered in Netdev 0x14 slides. In addition to the slides, please refer to the LSQUIC API Reference.

tut.c contains several versions of reading and writing from stream to illustrate different ways of using the library. There are also two ways to send packets.

Building

To build the tutorial:

git submodule update --init --recursive
cmake .
make

This clones and builds BoringSSL, so it may take a few minutes.

Usage

All options

sh$ ./tut -h
Usage: tut [-c cert -k key] [options] IP port

   -c cert.file    Certificate.
   -k key.file     Key file.
   -f log.file     Log message to this log file.  If not specified, the
                     are printed to stderr.
   -L level        Set library-wide log level.  Defaults to 'warn'.
   -l module=level Set log level of specific module.  Several of these
                     can be specified via multiple -l flags or by combining
                     these with comma, e.g. -l event=debug,conn=info.
   -v              Verbose: log program messages as well.
   -b VERSION      Use callbacks version VERSION.
   -p VERSION      Use packets_out version VERSION.
   -w VERSION      Use server write callback version VERSION.
   -o opt=val      Set lsquic engine setting to some value, overriding the
                     defaults.  For example,
                           -o version=ff00001c -o cc_algo=2
   -G DIR          Log TLS secrets to a file in directory DIR.
   -h              Print this help screen and exit.

Running the server

Both client and server logic are contained in the tut program. It knows it is meant to run in the server mode when -c and -k options are specified:

sh$ ./tut -c mycert-cert.pem -k mycert-key.pem ::0 12345 -p 1 -L debug -f server.log

The server can select one of two versions of "on stream write" callbacks. Use -w command-line option for that.

Running the client

sh$ ./tut ::1 12345 -L debug -f client.log
Hello!
!olleH
^D
sh$

The server can select one of three versions of "on stream read" callbacks. Use -b command-line option for that.

Both client and server can use the -p option to select one of two "send packets out" callbacks.

HTTP/3 Client

As a bonus, a simple HTTP/3 client is provided. Example:

sh$ ./h3cli -M HEAD www.litespeedtech.com 443 /
HTTP/1.1 200 OK
x-powered-by: PHP/7.3.5
x-logged-in: False
x-content-powered-by: K2 v2.7.1 (by JoomlaWorks)
content-type: text/html; charset=utf-8
expires: Wed, 17 Aug 2005 00:00:00 GMT
last-modified: Wed, 12 Aug 2020 18:54:05 GMT
cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
pragma: no-cache
etag: "23485-1597258445;gz"
vary: Accept-Encoding
x-frame-options: SAMEORIGIN
x-lsadc-cache: hit
date: Thu, 13 Aug 2020 02:48:06 GMT
server: LiteSpeed

Besides www.litespeedtech.com, other websites to try are www.facebook.com and www.google.com.

More Information

Latest QUIC and HTTP/3 GitHub artefacts can be found here. The QUIC IETF Working Group materials are here.

The LSQUIC GitHub Repo contains several more advanced examples, among them HTTP/3 client and server programs.

lsquic-tutorial's People

Contributors

dtikhonov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lsquic-tutorial's Issues

During the handshake, the following error is reported

Hello, Is it possible that openssl is a version dependent issue?

error infomation:

01:36:46.765482 [DEBUG] [QUIC:EBB10049E9C34712] event: version negotiation: proposed version 00000001
01:36:46.765498 [DEBUG] [QUIC:EBB10049E9C34712] qlog: [1021559069,"CONNECTIVITY","VERNEG","LINE",{"proposed_version":"00000001"}]
01:36:46.765521 [DEBUG] [QUIC:EBB10049E9C34712] conn: record path 0: (0.0.0.0:0 - 112.17.51.59:12345)
01:36:46.765550 [DEBUG] [QUIC:EBB10049E9C34712] conn: spin bit enabled on path 0
01:36:46.765564 [DEBUG] [QUIC:EBB10049E9C34712] conn: record new path ID 0
01:36:46.765589 [DEBUG] engine: decref conn EBB10049E9C34712, 'HT' -> 'H'
01:36:46.765623 [DEBUG] [QUIC:EBB10049E9C34712] pacer: lsquic_pacer_can_schedule: 1
01:36:46.765640 [DEBUG] [QUIC:EBB10049E9C34712] sendctl: pacer blocked: 0, in_flight_all: 0
01:36:46.765664 [DEBUG] [QUIC:EBB10049E9C34712-18446744073709551615] stream: dispatch_write_events, sm_qflags: 2. stream_flags: 131072, sm_bflags: 58, max_send_off: 18446744073709551615, tosend_off: 0, sm_n_buffered: 0
01:36:46.767493 [DEBUG] [QUIC:EBB10049E9C34712] handshake: handshake: error:00000001:invalid library (0):OPENSSL_internal:unknown library
01:36:46.767536 [DEBUG] [QUIC:EBB10049E9C34712] handshake: handshake failed
01:36:46.767550 [DEBUG] [QUIC:EBB10049E9C34712] conn: handshake failed
01:36:46.767563 [DEBUG] [QUIC:EBB10049E9C34712] handshake: enc level INIT after on_write: stop
01:36:46.767578 [DEBUG] [QUIC:EBB10049E9C34712] handshake: Exit shake_stream
01:36:46.767594 [DEBUG] [QUIC:EBB10049E9C34712] sendctl: app-limited

Maintain the connection between the client and the server and change the value of the string sent

I have two concerns about this lsquic's tutorial (https://github.com/dtikhonov/lsquic-tutorial/blob/master/tut.c).
Concern 1 :
You said that server reads a string from client, reverse it and sends it back to client.
I tried to see where the string is given in the code but I didn't see.
Can you show me how and where can I get the value of spec[n].iov in order to see the value of the
string sent between client and server, please?

Concern 2 :
How can I do to maintain the connexion between client and server and send the string many times?

Apologize me for many questions, I'm new on lsquic and also on socket programming.

Your help will be appreciated.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.