lsquic_cubic.h revision 50aadb33
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_cubic.h -- CUBIC congestion control protocol. 450aadb33SDmitri Tikhonov */ 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#ifndef LSQUIC_CUBIC_H 750aadb33SDmitri Tikhonov#define LSQUIC_CUBIC_H 1 850aadb33SDmitri Tikhonov 950aadb33SDmitri Tikhonovstruct lsquic_cubic { 1050aadb33SDmitri Tikhonov lsquic_time_t cu_min_delay; 1150aadb33SDmitri Tikhonov lsquic_time_t cu_epoch_start; 1250aadb33SDmitri Tikhonov lsquic_time_t cu_K; 1350aadb33SDmitri Tikhonov lsquic_time_t cu_app_limited; 1450aadb33SDmitri Tikhonov unsigned cu_origin_point; 1550aadb33SDmitri Tikhonov unsigned cu_last_max_cwnd; 1650aadb33SDmitri Tikhonov unsigned cu_cwnd; 1750aadb33SDmitri Tikhonov unsigned cu_ssthresh; 1850aadb33SDmitri Tikhonov lsquic_cid_t cu_cid; /* Used for logging */ 1950aadb33SDmitri Tikhonov enum cubic_flags { 2050aadb33SDmitri Tikhonov CU_TCP_FRIENDLY = (1 << 0), 2150aadb33SDmitri Tikhonov CU_SHIFT_EPOCH = (1 << 1), 2250aadb33SDmitri Tikhonov } cu_flags; 2350aadb33SDmitri Tikhonov lsquic_time_t cu_last_logged; 2450aadb33SDmitri Tikhonov}; 2550aadb33SDmitri Tikhonov 2650aadb33SDmitri Tikhonov#define DEFAULT_CUBIC_FLAGS (CU_TCP_FRIENDLY|CU_SHIFT_EPOCH) 2750aadb33SDmitri Tikhonov 2850aadb33SDmitri Tikhonovvoid 2950aadb33SDmitri Tikhonovlsquic_cubic_init_ext (struct lsquic_cubic *, lsquic_cid_t, enum cubic_flags); 3050aadb33SDmitri Tikhonov 3150aadb33SDmitri Tikhonov#define lsquic_cubic_init(cubic, cid) \ 3250aadb33SDmitri Tikhonov lsquic_cubic_init_ext(cubic, cid, DEFAULT_CUBIC_FLAGS) 3350aadb33SDmitri Tikhonov 3450aadb33SDmitri Tikhonovvoid 3550aadb33SDmitri Tikhonovlsquic_cubic_ack (struct lsquic_cubic *cubic, lsquic_time_t now, 3650aadb33SDmitri Tikhonov lsquic_time_t rtt, int app_limited); 3750aadb33SDmitri Tikhonov 3850aadb33SDmitri Tikhonovvoid 3950aadb33SDmitri Tikhonovlsquic_cubic_loss (struct lsquic_cubic *cubic); 4050aadb33SDmitri Tikhonov 4150aadb33SDmitri Tikhonovvoid 4250aadb33SDmitri Tikhonovlsquic_cubic_timeout (struct lsquic_cubic *cubic); 4350aadb33SDmitri Tikhonov 4450aadb33SDmitri Tikhonov#define lsquic_cubic_get_cwnd(c) (+(c)->cu_cwnd) 4550aadb33SDmitri Tikhonov 4650aadb33SDmitri Tikhonov#define lsquic_cubic_in_slow_start(cubic) \ 4750aadb33SDmitri Tikhonov ((cubic)->cu_cwnd < (cubic)->cu_ssthresh) 4850aadb33SDmitri Tikhonov 4950aadb33SDmitri Tikhonov#endif 50