Skip to content

测试功能样例

本页提供一些常用功能的测试案例:

运行测试用例

你可以使用 ./script/case_test.sh 作为测试工具或字典,其中包含了几乎所有 XQUIC 功能的测试用例。希望这能帮助你更好地理解 XQUIC。

bash
sh ../scripts/case_test.sh

支持的功能

根据 RFC9000/RFC9001/RFC9002/RFC9114/RFC9204,XQUIC 实现了 QUIC 协议的大部分基本功能,包括但不限于以下基本特性:

传输特性

XQUIC 当前支持以下扩展功能:

bash
# ./build
${SERVER_BIN} = ./tests/test_server
${CLIENT_BIN} = ./tests/test_client

0-RTT

XQUIC 支持传输 0-RTT 数据包,在首次握手后保存了 session ticket 的情况下。

bash
# ./build
# start (or restart) server
${SERVER_BIN} -l i -e

# remove cached session ticket
rm -f test_session
# start client twice to enable 0-RTT
${CLIENT_BIN} -s 1024000 -l d -N -t 1 -E | grep ">>>>>>>> pass"     # normal res: ">>>>>>>> pass:1", with test_session generated
${CLIENT_BIN} -s 1024000 -l d -N -t 1 -E | grep "early_data_flag:1" # success res: "early_data_flag:1"

并行传输

bash
# ./build
# start (or restart) server
${SERVER_BIN} -l d -e -x 1

# start client with -P {parallel number}
${CLIENT_BIN} -s 1 -l e -t 1 -E -P 1025 -G > ccfc.log
grep ">>>>>>>> pass:1" ccfc.log | wc -l # success res: 1024

多路径传输

  • 在多个路径上使用多路径版本 04 发送 1M 数据
bash
# ./build
# start (or restart) server
${SERVER_BIN} -l d -e -M

# start client with:
# -M to enable multi-path;
# -i {interface} to set multi-path interface;
# -v {version} to set multipath version;
sudo ${CLIENT_BIN} -s 1024000 -l d -t 1 -M -i lo -i lo -E -v 4
grep "multipath version negotiation succeed on multipath 04" clog   # success res: "multipath version negotiation succeed on multipath 04"
  • 在多个路径上使用多路径版本 05 发送 1M 数据
bash
# ./build
# start (or restart) server
${SERVER_BIN} -l d -e -M

# start client with:
# -M to enable multi-path;
# -i {interface} to set multi-path interface;
# -v {version} to set multipath version;
sudo ${CLIENT_BIN} -s 1024000 -l d -t 1 -M -i lo -i lo -E -v 5
grep "multipath version negotiation succeed on multipath 05" clog   # success res: "multipath version negotiation succeed on multipath 04"

拥塞控制

bash
# ./build
# start (or restart) server
${SERVER_BIN} -l d -e -x 1

# start client with:
# -c to set congestion control algorithm;
${CLIENT_BIN} -s 10240000 -l e -E -c bbr | grep ">>>>>>>> pass" #success res: ">>>>>>>> pass:1"

${CLIENT_BIN} -s 10240000 -l e -E -c bbr+ | grep ">>>>>>>> pass" #success res: ">>>>>>>> pass:1"

${CLIENT_BIN} -s 10240000 -l e -E -c cubic | grep ">>>>>>>> pass" #success res: ">>>>>>>> pass:1"

负载均衡

bash
# ./build
# start (or restart) server
# and set -E to enable lb-cid encryption on
${SERVER_BIN} -l d -e -S "server_id_0" -E

${CLIENT_BIN} -s 1024000 -l d -t 1
grep "|lb cid encrypted|" slog  # success res : != ""

Qlog

基于 qlog (draft-ietf-quic-qlog-main-schema, draft-ietf-quic-qlog-quic-eventsdraft-ietf-quic-qlog-h3-events),xquic 实现了 QUIC 事件日志记录。

通过 DXQC_ENABLE_EVENT_LOG 激活 qlog

shell
cd build
rm -rf * 
# add "-DXQC_ENABLE_EVENT_LOG=1"
cmake -DGCOV=on -DCMAKE_BUILD_TYPE=Debug -DXQC_ENABLE_TESTING=1 -DXQC_SUPPORT_SENDMMSG_BUILD=1 -DXQC_ENABLE_EVENT_LOG=1 -DXQC_ENABLE_BBR2=1 -DXQC_ENABLE_RENO=1 -DSSL_TYPE=${SSL_TYPE_STR} -DSSL_PATH=${SSL_PATH_STR} ..

make -j

示例 Qlog 定义了三个事件重要性级别,按重要性和预期使用频率递减顺序排列:核心、基础、额外。可以通过 "--qlog_importance" 参数设置级别:

shell
./tests/test_server -l e -e --qlog_importance extra

./tests/test_client -s 10240 -l e -t 1 -E --qlog_importance extra

要禁用 qlog,使用 "--qlog_disable":

shell
./tests/test_server -l e -e --qlog_disable

./tests/test_client -s 10240 -l e -t 1 -E --qlog_disable

JSON 格式序列化

shell
python ../scripts/qlog_parser.py --clog clog --slog slog --qlog_path demo_qlog.json

FEC

FEC 是一个尚处于测试阶段的功能,尚未草拟,旨在解决由于数据包丢失引起的传输延迟问题。

开启编译选项

bash
# fec compile option 
cmake ... -DXQC_ENABLE_FEC=1
# fec scheme compile option
cmake ... -DXQC_ENABLE_XOR=1 -DXQC_ENABLE_RSC=1 -DXQC_ENABLE_PKM=1

测试用例

bash
# ./build
# start (or restart) server
# set -f to enable FEC
${SERVER_BIN} -e -f

# set -g to enable FEC
# set --fec_encoder and --fec_decoder to set FEC encoder and decoder (default: 11 (XOR), Option: 8 (Reed-Solomon), 11 (XOR), 12 (Packet Mask))
${CLIENT_BIN} -g --fec_encoder 11 --fec_decoder 11
grep "|client set final encoder fec scheme: " clog  # success res : "client set final encoder fec scheme: XOR
grep "|server set final encoder fec scheme: " slog  # success res : "server set final encoder fec scheme: XOR
grep "|client set final decoder fec scheme: " clog  # success res : "client set final decoder fec scheme: XOR
grep "|server set final decoder fec scheme: " slog  # success res : "server set final decoder fec scheme: XOR