lsquic_qpack_exp.h revision 06b2a236
1/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE. */
2/* QPACK Experiment record */
3
4#ifndef LSQUIC_QPACK_EXP_H
5#define LSQUIC_QPACK_EXP_H
6
7struct qpack_exp_record
8{
9    enum {
10        QER_SERVER       = 1 << 0,      /* Client or server */
11        QER_ENCODER      = 1 << 1,      /* If not set, this is decoder */
12    }               qer_flags;
13
14    /* Timestamp of the first request */
15    lsquic_time_t   qer_first_req;
16
17    /* Timestamp of the last request */
18    lsquic_time_t   qer_last_req;
19
20    /* Number of header blocks passed through the encoder or the decoder */
21    unsigned        qer_hblock_count;
22
23    /* Cumulative size of all header blocks processed */
24    unsigned        qer_hblock_size;
25
26    /* For encoder, the "peer max size" is the maximum size advertised by
27     * the peer and the "used max size" is the maximum size that our
28     * encoder ends up using (the value selected by experiment).
29     *
30     * For decoder, the "used max size" is the maximum size we advertize
31     * (selecte by experiment), while the "peer max size" is the size the
32     * encoder uses as given by the value of the last TSU instruction.
33     */
34    unsigned        qer_peer_max_size;
35    unsigned        qer_used_max_size;
36
37    /* For encoder, the "peer max blocked" is the maximum number of blocked
38     * streams advertised by the peer, while the "used max blocked" is the
39     * self-imposed limit (selected by experiment).
40     *
41     * For decoder, the "used max blocked" is the maximum number of blocked
42     * streams that we advertised (selected by experiment) and the "peer max
43     * blocked" is the total number of times a header was blocked.  Note
44     * that the latter does not count the duration of blockage and it may be
45     * insignificant.  For example, a single packet may have header block
46     * packaged before the required encoder stream update, in which case the
47     * header block will be blocked and then unblocked immediately.
48     */
49    unsigned        qer_peer_max_blocked;
50    unsigned        qer_used_max_blocked;
51
52    /* The compression ratio is taken when experiment concludes via
53     * lsqpack_enc_ratio() or lsqpack_dec_ratio().
54     */
55    float           qer_comp_ratio;
56
57    /* Either 'Server:' or 'User-Agent:' */
58    char           *qer_user_agent;
59};
60
61struct qpack_exp_record *
62lsquic_qpack_exp_new (void);
63
64void
65lsquic_qpack_exp_destroy (struct qpack_exp_record *);
66
67/* Returns same as snprintf(3) */
68int
69lsquic_qpack_exp_to_xml (const struct qpack_exp_record *, char *, size_t);
70
71#endif
72