lsquic_qpack_exp.h revision a74702c6
1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE. */
2758aff32SDmitri Tikhonov/* QPACK Experiment record */
3758aff32SDmitri Tikhonov
4758aff32SDmitri Tikhonov#ifndef LSQUIC_QPACK_EXP_H
5758aff32SDmitri Tikhonov#define LSQUIC_QPACK_EXP_H
6758aff32SDmitri Tikhonov
7758aff32SDmitri Tikhonovstruct qpack_exp_record
8758aff32SDmitri Tikhonov{
9758aff32SDmitri Tikhonov    enum {
10758aff32SDmitri Tikhonov        QER_SERVER       = 1 << 0,      /* Client or server */
11758aff32SDmitri Tikhonov        QER_ENCODER      = 1 << 1,      /* If not set, this is decoder */
12758aff32SDmitri Tikhonov    }               qer_flags;
13758aff32SDmitri Tikhonov
14758aff32SDmitri Tikhonov    /* Timestamp of the first request */
15758aff32SDmitri Tikhonov    lsquic_time_t   qer_first_req;
16758aff32SDmitri Tikhonov
17758aff32SDmitri Tikhonov    /* Timestamp of the last request */
18758aff32SDmitri Tikhonov    lsquic_time_t   qer_last_req;
19758aff32SDmitri Tikhonov
20758aff32SDmitri Tikhonov    /* Number of header blocks passed through the encoder or the decoder */
21758aff32SDmitri Tikhonov    unsigned        qer_hblock_count;
22758aff32SDmitri Tikhonov
23758aff32SDmitri Tikhonov    /* Cumulative size of all header blocks processed */
24758aff32SDmitri Tikhonov    unsigned        qer_hblock_size;
25758aff32SDmitri Tikhonov
26758aff32SDmitri Tikhonov    /* For encoder, the "peer max size" is the maximum size advertised by
27758aff32SDmitri Tikhonov     * the peer and the "used max size" is the maximum size that our
28758aff32SDmitri Tikhonov     * encoder ends up using (the value selected by experiment).
29758aff32SDmitri Tikhonov     *
30758aff32SDmitri Tikhonov     * For decoder, the "used max size" is the maximum size we advertize
31758aff32SDmitri Tikhonov     * (selecte by experiment), while the "peer max size" is the size the
32758aff32SDmitri Tikhonov     * encoder uses as given by the value of the last TSU instruction.
33758aff32SDmitri Tikhonov     */
34758aff32SDmitri Tikhonov    unsigned        qer_peer_max_size;
35758aff32SDmitri Tikhonov    unsigned        qer_used_max_size;
36758aff32SDmitri Tikhonov
37758aff32SDmitri Tikhonov    /* For encoder, the "peer max blocked" is the maximum number of blocked
38758aff32SDmitri Tikhonov     * streams advertised by the peer, while the "used max blocked" is the
39758aff32SDmitri Tikhonov     * self-imposed limit (selected by experiment).
40758aff32SDmitri Tikhonov     *
41758aff32SDmitri Tikhonov     * For decoder, the "used max blocked" is the maximum number of blocked
42758aff32SDmitri Tikhonov     * streams that we advertised (selected by experiment) and the "peer max
43758aff32SDmitri Tikhonov     * blocked" is the total number of times a header was blocked.  Note
44758aff32SDmitri Tikhonov     * that the latter does not count the duration of blockage and it may be
45758aff32SDmitri Tikhonov     * insignificant.  For example, a single packet may have header block
46758aff32SDmitri Tikhonov     * packaged before the required encoder stream update, in which case the
47758aff32SDmitri Tikhonov     * header block will be blocked and then unblocked immediately.
48758aff32SDmitri Tikhonov     */
49758aff32SDmitri Tikhonov    unsigned        qer_peer_max_blocked;
50758aff32SDmitri Tikhonov    unsigned        qer_used_max_blocked;
51758aff32SDmitri Tikhonov
52758aff32SDmitri Tikhonov    /* The compression ratio is taken when experiment concludes via
53758aff32SDmitri Tikhonov     * lsqpack_enc_ratio() or lsqpack_dec_ratio().
54758aff32SDmitri Tikhonov     */
55758aff32SDmitri Tikhonov    float           qer_comp_ratio;
56758aff32SDmitri Tikhonov
57758aff32SDmitri Tikhonov    /* Either 'Server:' or 'User-Agent:' */
58758aff32SDmitri Tikhonov    char           *qer_user_agent;
59758aff32SDmitri Tikhonov};
60758aff32SDmitri Tikhonov
61758aff32SDmitri Tikhonovstruct qpack_exp_record *
62758aff32SDmitri Tikhonovlsquic_qpack_exp_new (void);
63758aff32SDmitri Tikhonov
64758aff32SDmitri Tikhonovvoid
65758aff32SDmitri Tikhonovlsquic_qpack_exp_destroy (struct qpack_exp_record *);
66758aff32SDmitri Tikhonov
67758aff32SDmitri Tikhonov/* Returns same as snprintf(3) */
68758aff32SDmitri Tikhonovint
69758aff32SDmitri Tikhonovlsquic_qpack_exp_to_xml (const struct qpack_exp_record *, char *, size_t);
70758aff32SDmitri Tikhonov
71758aff32SDmitri Tikhonov#endif
72