2019-01-03 16:48:45 +00:00
|
|
|
# Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE.
|
2017-09-22 21:00:03 +00:00
|
|
|
LSQUIC Examples
|
|
|
|
===============
|
|
|
|
|
|
|
|
test/http_client.c demonstrates how to use HTTP features of QUIC.
|
|
|
|
|
|
|
|
Usage Examples
|
|
|
|
--------------
|
|
|
|
|
|
|
|
Fetch Google's home page:
|
|
|
|
|
2018-05-16 19:48:43 +00:00
|
|
|
./http_client -s www.google.com -p /
|
2017-09-26 15:26:05 +00:00
|
|
|
|
2018-05-16 19:48:43 +00:00
|
|
|
The default port number is 443, but it can be specified after colon
|
|
|
|
using the -s flag. The value of the `host' header as well as the SNI
|
|
|
|
value defaults to the host part of the -s option. -H option can be
|
|
|
|
used to override it. For example:
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2018-05-16 19:48:43 +00:00
|
|
|
./http_client -H www.youtube.com -s www.google.com:443 -p / -M HEAD
|
2018-05-16 16:14:02 +00:00
|
|
|
|
2018-05-16 19:48:43 +00:00
|
|
|
The host part can be an IP address. Both IPv4 and IPv6 are supported.
|
|
|
|
See ./http_client -h for a (long) list of different flags.
|
2018-04-23 20:12:38 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
POST a file to calculate its CRC32 checksum:
|
|
|
|
|
2018-05-16 16:14:02 +00:00
|
|
|
./http_client -H www.litespeedtech.com -s 443 \
|
2017-09-22 21:00:03 +00:00
|
|
|
-p /cgi-bin/crc32.cgi -P file-256M -M POST
|
|
|
|
|
|
|
|
HTTP/1.1 200 OK
|
|
|
|
content-type: text/plain
|
|
|
|
date: Fri, 09 Jun 2017 08:40:45 GMT
|
|
|
|
server: LiteSpeed
|
|
|
|
alt-svc: quic=":443"; v="35,37"
|
|
|
|
|
|
|
|
CRC32: 2A0E7DBB
|
|
|
|
|
|
|
|
This is a good way to check that the payload gets to the other side
|
|
|
|
correctly. The CGI script is:
|
|
|
|
|
|
|
|
#!/usr/bin/perl
|
|
|
|
use String::CRC32;
|
|
|
|
printf "Content-type: text/plain\r\n\r\nCRC32: %X\n", crc32(*STDIN)
|
|
|
|
|
|
|
|
On the command line, I do
|
|
|
|
|
|
|
|
alias crc32="perl -MString::CRC32 -e'printf qq(%X\n), crc32(<>)'"
|
|
|
|
|
|
|
|
To submit several requests concurrently, one can use -n and -r options:
|
|
|
|
|
2018-05-16 16:14:02 +00:00
|
|
|
./http_client -H www.litespeedtech.com -s 443 \
|
2017-09-22 21:00:03 +00:00
|
|
|
-p /cgi-bin/crc32.cgi -P file-256M -M POST -n 3 -r 10
|
|
|
|
|
|
|
|
This will open three parallel connections which will make ten POST
|
|
|
|
requests together.
|
|
|
|
|
|
|
|
To perform load testing, it is good to mix sending and receiving data:
|
|
|
|
|
|
|
|
for i in {1..100}; do
|
|
|
|
./http_client $COMMON_OPTS -p /cgi-bin/crc32.cgi -P file-256M \
|
|
|
|
-M POST >out-post.$i &
|
|
|
|
./http_client $COMMON_OPTS -p /docs/file-256M >out-get.$i &
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
If you don't want to create a hundred 256-megabyte out-get.* files, use -K
|
|
|
|
flag to discard output.
|
|
|
|
|
|
|
|
Control QUIC Settings via -o Flag
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
Most of the settings in struct lsquic_engine_settings can be controlled
|
|
|
|
via -o flag. With exception of es_versions, which is a bit mask, other
|
|
|
|
es_* options can be mapped to corresponding -o value via s/^es_//:
|
|
|
|
|
|
|
|
es_cfcw => -o cwcf=12345
|
|
|
|
es_max_streams_in => -o max_streams_in=123
|
|
|
|
|
|
|
|
And so on.
|
|
|
|
|
|
|
|
The code to set options via -o flag lives in set_engine_option(). It is good
|
|
|
|
to update this function at the same time as member fields are added to struct
|
|
|
|
lsquic_engine_settings.
|
|
|
|
|
|
|
|
Control LSQUIC Behavior via Environment Variables
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
|
|
LSQUIC_PACER_INTERTICK
|
|
|
|
|
|
|
|
Number of microsecods to use as constant intertick time in lieu of the
|
|
|
|
pacer's dynamic intertick time approximation.
|
|
|
|
|
|
|
|
Only available in debug builds.
|
|
|
|
|
2018-02-26 21:01:16 +00:00
|
|
|
LSQUIC_CUBIC_SAMPLING_RATE
|
|
|
|
|
|
|
|
Number of microseconds between times CWND is logged at info level.
|
|
|
|
|
|
|
|
Only available in debug builds.
|
|
|
|
|
2018-05-21 19:02:33 +00:00
|
|
|
LSQUIC_RANDOM_SEND_FAILURE
|
|
|
|
|
|
|
|
Frequency with which sending of packets fails: one out of this many
|
|
|
|
times on average.
|
|
|
|
|
|
|
|
Only available when compiled with -DLSQUIC_RANDOM_SEND_FAILURE=1
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
Control Network-Related Stuff
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
-D Set `do not fragment' flag on outgoing UDP packets.
|
|
|
|
|
|
|
|
-z BYTES Maximum size of outgoing UDP packets. The default is 1370
|
|
|
|
bytes for IPv4 socket and 1350 bytes for IPv6 socket.
|
|
|
|
|
|
|
|
-S opt=val Socket options. Supported options:
|
|
|
|
sndbuf=12345 # Sets SO_SNDBUF
|
|
|
|
rcvbuf=12345 # Sets SO_RCVBUF
|
|
|
|
|
|
|
|
More Compilation Options
|
|
|
|
------------------------
|
|
|
|
|
2019-01-16 20:13:59 +00:00
|
|
|
-DLSQUIC_CONN_STATS=1
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2019-01-16 20:13:59 +00:00
|
|
|
Track some statistics about connections -- packets in, sent, delayed,
|
2017-09-22 21:00:03 +00:00
|
|
|
stream payload per packet size ratio, and some others -- and print them
|
|
|
|
at NOTICE level when connection is destroyed.
|
|
|
|
|
2019-01-16 20:13:59 +00:00
|
|
|
Cumulative connections statistics are printed by the engine when it is
|
|
|
|
destroyed if lsquic_engine_api.ea_stats_fh is set. The HTTP client
|
|
|
|
programs sets it when -t or -T command-line option is used.
|
2017-09-22 21:00:03 +00:00
|
|
|
|
|
|
|
-DLSQUIC_PACKINTS_SANITY_CHECK=1
|
|
|
|
|
|
|
|
Turn on sanity checking for packet interval code. The packet interval
|
|
|
|
code, shared by both send and receive history modules, contained a bug
|
|
|
|
which prompted me to add a checking function.
|
|
|
|
|
|
|
|
-DLSQUIC_SEND_STATS=0
|
|
|
|
|
|
|
|
Turn off statistics collection performed by the send controller: number
|
|
|
|
of packets sent, resent, and delayed.
|
|
|
|
|
|
|
|
-DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_WARN
|
|
|
|
|
|
|
|
If you want to go even faster: compile out some log levels entirely.
|
2018-02-26 21:01:16 +00:00
|
|
|
|
|
|
|
-DLSQUIC_EXTRA_CHECKS=1
|
|
|
|
|
|
|
|
Add relatively expensive run-time sanity checks
|
|
|
|
|
2018-05-21 19:02:33 +00:00
|
|
|
-DLSQUIC_RANDOM_SEND_FAILURE=1
|
|
|
|
|
|
|
|
Simulate failure to send packets to test send resumption logic. When
|
|
|
|
this flag is specified, sending of packets will randomly fail, about
|
|
|
|
one out of every 10 attempts. Set environment variable
|
|
|
|
LSQUIC_RANDOM_SEND_FAILURE to change this frequency.
|