lsquic_cubic.h revision 50aadb33
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 lsquic_time_t cu_K; 13 lsquic_time_t cu_app_limited; 14 unsigned cu_origin_point; 15 unsigned cu_last_max_cwnd; 16 unsigned cu_cwnd; 17 unsigned cu_ssthresh; 18 lsquic_cid_t cu_cid; /* Used for logging */ 19 enum cubic_flags { 20 CU_TCP_FRIENDLY = (1 << 0), 21 CU_SHIFT_EPOCH = (1 << 1), 22 } cu_flags; 23 lsquic_time_t cu_last_logged; 24}; 25 26#define DEFAULT_CUBIC_FLAGS (CU_TCP_FRIENDLY|CU_SHIFT_EPOCH) 27 28void 29lsquic_cubic_init_ext (struct lsquic_cubic *, lsquic_cid_t, enum cubic_flags); 30 31#define lsquic_cubic_init(cubic, cid) \ 32 lsquic_cubic_init_ext(cubic, cid, DEFAULT_CUBIC_FLAGS) 33 34void 35lsquic_cubic_ack (struct lsquic_cubic *cubic, lsquic_time_t now, 36 lsquic_time_t rtt, int app_limited); 37 38void 39lsquic_cubic_loss (struct lsquic_cubic *cubic); 40 41void 42lsquic_cubic_timeout (struct lsquic_cubic *cubic); 43 44#define lsquic_cubic_get_cwnd(c) (+(c)->cu_cwnd) 45 46#define lsquic_cubic_in_slow_start(cubic) \ 47 ((cubic)->cu_cwnd < (cubic)->cu_ssthresh) 48 49#endif 50