xref: /freebsd/crypto/openssl/doc/designs/quic-design/quic-statm.md (revision e7be843b4a162e68651d3911f0357ed464915629)
1*e7be843bSPierre ProncheryQUIC Statistics Manager
2*e7be843bSPierre Pronchery=======================
3*e7be843bSPierre Pronchery
4*e7be843bSPierre ProncheryThe statistics manager keeps track of RTT statistics for use by the QUIC
5*e7be843bSPierre Proncheryimplementation.
6*e7be843bSPierre Pronchery
7*e7be843bSPierre ProncheryIt provides the following interface:
8*e7be843bSPierre Pronchery
9*e7be843bSPierre ProncheryInstantiation
10*e7be843bSPierre Pronchery-------------
11*e7be843bSPierre Pronchery
12*e7be843bSPierre ProncheryThe QUIC statistics manager is instantiated as follows:
13*e7be843bSPierre Pronchery
14*e7be843bSPierre Pronchery```c
15*e7be843bSPierre Proncherytypedef struct ossl_statm_st {
16*e7be843bSPierre Pronchery    ...
17*e7be843bSPierre Pronchery} OSSL_STATM;
18*e7be843bSPierre Pronchery
19*e7be843bSPierre Proncheryint ossl_statm_init(OSSL_STATM *statm);
20*e7be843bSPierre Pronchery
21*e7be843bSPierre Proncheryvoid ossl_statm_destroy(OSSL_STATM *statm);
22*e7be843bSPierre Pronchery```
23*e7be843bSPierre Pronchery
24*e7be843bSPierre ProncheryThe structure is defined in headers, so it may be initialised without needing
25*e7be843bSPierre Proncheryits own memory allocation. However, other code should not examine the fields of
26*e7be843bSPierre Pronchery`OSSL_STATM` directly.
27*e7be843bSPierre Pronchery
28*e7be843bSPierre ProncheryGet RTT Info
29*e7be843bSPierre Pronchery------------
30*e7be843bSPierre Pronchery
31*e7be843bSPierre ProncheryThe current RTT info is retrieved using the function `ossl_statm_get_rtt_info`,
32*e7be843bSPierre Proncherywhich fills an `OSSL_RTT_INFO` structure:
33*e7be843bSPierre Pronchery
34*e7be843bSPierre Pronchery```c
35*e7be843bSPierre Proncherytypedef struct ossl_rtt_info_st {
36*e7be843bSPierre Pronchery    /* As defined in RFC 9002. */
37*e7be843bSPierre Pronchery    OSSL_TIME smoothed_rtt, latest_rtt, rtt_variance, min_rtt,
38*e7be843bSPierre Pronchery              max_ack_delay;
39*e7be843bSPierre Pronchery} OSSL_RTT_INFO;
40*e7be843bSPierre Pronchery
41*e7be843bSPierre Proncheryvoid ossl_statm_get_rtt_info(OSSL_STATM *statm, OSSL_RTT_INFO *rtt_info);
42*e7be843bSPierre Pronchery```
43*e7be843bSPierre Pronchery
44*e7be843bSPierre ProncheryUpdate RTT
45*e7be843bSPierre Pronchery----------
46*e7be843bSPierre Pronchery
47*e7be843bSPierre ProncheryNew RTT samples are provided using the  `ossl_statm_update_rtt` function:
48*e7be843bSPierre Pronchery
49*e7be843bSPierre Pronchery  - `ack_delay`. This is the ACK Delay value; see RFC 9000.
50*e7be843bSPierre Pronchery
51*e7be843bSPierre Pronchery  - `override_latest_rtt` provides a new latest RTT sample. If it is
52*e7be843bSPierre Pronchery    `OSSL_TIME_ZERO`, the existing Latest RTT value is used when updating the
53*e7be843bSPierre Pronchery    RTT.
54*e7be843bSPierre Pronchery
55*e7be843bSPierre ProncheryThe maximum ACK delay configured using `ossl_statm_set_max_ack_delay` is not
56*e7be843bSPierre Proncheryenforced automatically on the `ack_delay` argument as the circumstances where
57*e7be843bSPierre Proncherythis should be enforced are context sensitive. It is the caller's responsibility
58*e7be843bSPierre Proncheryto retrieve the value and enforce the maximum ACK delay if appropriate.
59*e7be843bSPierre Pronchery
60*e7be843bSPierre Pronchery```c
61*e7be843bSPierre Proncheryvoid ossl_statm_update_rtt(OSSL_STATM *statm,
62*e7be843bSPierre Pronchery                           OSSL_TIME ack_delay,
63*e7be843bSPierre Pronchery                           OSSL_TIME override_latest_rtt);
64*e7be843bSPierre Pronchery```
65*e7be843bSPierre Pronchery
66*e7be843bSPierre ProncherySet Max. Ack Delay
67*e7be843bSPierre Pronchery------------------
68*e7be843bSPierre Pronchery
69*e7be843bSPierre ProncherySets the maximum ACK delay field reported by `OSSL_RTT_INFO`.
70*e7be843bSPierre Pronchery
71*e7be843bSPierre Pronchery```c
72*e7be843bSPierre Proncheryvoid ossl_statm_set_max_ack_delay(OSSL_STATM *statm, OSSL_TIME max_ack_delay);
73*e7be843bSPierre Pronchery```
74