lsquic_cubic.h revision bfc7bfd8
1/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_cubic.h -- CUBIC congestion control protocol.
4 */
5
6#ifndef LSQUIC_CUBIC_H
7#define LSQUIC_CUBIC_H 1
8
9struct lsquic_cubic {
10    lsquic_time_t   cu_min_delay;
11    lsquic_time_t   cu_epoch_start;
12    double          cu_K;
13    unsigned long   cu_origin_point;
14    unsigned long   cu_last_max_cwnd;
15    unsigned long   cu_cwnd;
16    unsigned long   cu_tcp_cwnd;
17    unsigned long   cu_ssthresh;
18    lsquic_cid_t    cu_cid;            /* Used for logging */
19    enum cubic_flags {
20        CU_TCP_FRIENDLY = (1 << 0),
21    }               cu_flags;
22    unsigned        cu_sampling_rate;
23    lsquic_time_t   cu_last_logged;
24};
25
26#define DEFAULT_CUBIC_FLAGS (CU_TCP_FRIENDLY)
27
28#define TCP_MSS 1460
29
30void
31lsquic_cubic_init_ext (struct lsquic_cubic *, lsquic_cid_t, enum cubic_flags);
32
33#define lsquic_cubic_init(cubic, cid) \
34            lsquic_cubic_init_ext(cubic, cid, DEFAULT_CUBIC_FLAGS)
35
36void
37lsquic_cubic_ack (struct lsquic_cubic *cubic, lsquic_time_t now,
38                  lsquic_time_t rtt, int app_limited, unsigned n_bytes);
39
40void
41lsquic_cubic_loss (struct lsquic_cubic *cubic);
42
43void
44lsquic_cubic_timeout (struct lsquic_cubic *cubic);
45
46void
47lsquic_cubic_was_quiet (struct lsquic_cubic *, lsquic_time_t now);
48
49#define lsquic_cubic_get_cwnd(c) (+(c)->cu_cwnd)
50
51#define lsquic_cubic_in_slow_start(cubic) \
52                        ((cubic)->cu_cwnd < (cubic)->cu_ssthresh)
53
54#endif
55