9 #ifndef TOR_CONGESTION_CONTROL_COMMON_H
10 #define TOR_CONGESTION_CONTROL_COMMON_H
18 #define TLS_RECORD_MAX_CELLS ((16 * 1024) / CELL_MAX_NETWORK_SIZE)
29 CC_PATH_ONION_SOS = 2,
35 #define SBWS_ROUTE_LEN 2
38 #define congestion_control_free(cc) \
39 FREE_AND_NULL(congestion_control_t, congestion_control_free_, cc)
74 const size_t msg_len);
92 extern uint32_t or_conn_highwater;
93 extern uint32_t or_conn_lowwater;
94 extern int32_t cell_queue_high;
95 extern int32_t cell_queue_low;
96 extern uint8_t cc_sendme_inc;
99 static inline uint32_t
102 return or_conn_highwater;
106 static inline uint32_t
109 return or_conn_lowwater;
114 static inline int32_t
117 return cell_queue_high;
122 static inline int32_t
125 return cell_queue_low;
129 static inline uint8_t
132 return cc_sendme_inc;
144 static inline uint64_t
150 return (2*curr + (N-1)*prev)/(N+1);
163 static inline uint64_t
166 uint64_t max =
MAX(a, b);
167 uint64_t min = MIN(a, b);
169 if (BUG(pct_max > 100)) {
173 return pct_max*max/100 + (100-pct_max)*min/100;
177 #ifdef TOR_CONGESTION_CONTROL_PRIVATE
182 #ifdef TOR_UNIT_TESTS
void congestion_control_set_cc_enabled(void)
congestion_control_t * congestion_control_new(const circuit_params_t *params, cc_path_t path)
static uint32_t or_conn_highwatermark(void)
bool congestion_control_validate_sendme_increment(uint8_t sendme_inc)
char * congestion_control_get_control_port_fields(const origin_circuit_t *)
bool congestion_control_update_circuit_estimates(congestion_control_t *, const circuit_t *, const crypt_path_t *)
static uint64_t n_count_ewma(uint64_t curr, uint64_t prev, uint64_t N)
int sendme_get_inc_count(const circuit_t *, const crypt_path_t *)
void congestion_control_free_(congestion_control_t *cc)
int congestion_control_dispatch_cc_alg(congestion_control_t *cc, const circuit_t *circ, const crypt_path_t *layer_hint)
uint64_t congestion_control_get_num_clock_stalls(void)
uint64_t congestion_control_get_num_rtt_reset(void)
void congestion_control_note_cell_sent(congestion_control_t *cc, const circuit_t *circ, const crypt_path_t *cpath)
int congestion_control_get_package_window(const circuit_t *, const crypt_path_t *)
int congestion_control_build_ext_response(const circuit_params_t *our_params, const circuit_params_t *circ_params, uint8_t **msg_out, size_t *msg_len_out)
int congestion_control_parse_ext_request(const uint8_t *msg, const size_t msg_len)
static uint64_t percent_max_mix(uint64_t a, uint64_t b, uint8_t pct_max)
static uint8_t congestion_control_sendme_inc(void)
static uint32_t or_conn_lowwatermark(void)
int congestion_control_build_ext_request(uint8_t **msg_out, size_t *msg_len_out)
int congestion_control_parse_ext_response(const uint8_t *msg, const size_t msg_len, circuit_params_t *params_out)
bool congestion_control_enabled(void)
bool circuit_sent_cell_for_sendme(const circuit_t *, const crypt_path_t *)
uint64_t cc_stats_circs_created
bool is_monotime_clock_reliable(void)
static int32_t cell_queue_highwatermark(void)
void congestion_control_new_consensus_params(const networkstatus_t *ns)
static int32_t cell_queue_lowwatermark(void)
Path structures for origin circuits.
Header file for onion_crypto.c.