Tor 0.4.9.0-alpha-dev
Macros | Functions | Variables
congestion_control_vegas.c File Reference

Code that implements the TOR_VEGAS congestion control algorithm from Proposal #324. More...

#include "core/or/or.h"
#include "core/or/crypt_path.h"
#include "core/or/or_circuit_st.h"
#include "core/or/sendme.h"
#include "core/or/congestion_control_st.h"
#include "core/or/congestion_control_common.h"
#include "core/or/congestion_control_vegas.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/channel.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/control/control_events.h"
#include "lib/math/stats.h"

Go to the source code of this file.

Macros

#define TOR_CONGESTION_CONTROL_VEGAS_PRIVATE
 
#define OUTBUF_CELLS   (2*TLS_RECORD_MAX_CELLS)
 
#define SS_CWND_MAX_DFLT   (5000)
 
#define VEGAS_ALPHA_SBWS_DFLT   (2*OUTBUF_CELLS-TLS_RECORD_MAX_CELLS)
 
#define VEGAS_BETA_SBWS_DFLT   (2*OUTBUF_CELLS+TLS_RECORD_MAX_CELLS)
 
#define VEGAS_GAMMA_SBWS_DFLT   (2*OUTBUF_CELLS)
 
#define VEGAS_DELTA_SBWS_DFLT   (4*OUTBUF_CELLS)
 
#define VEGAS_SSCAP_SBWS_DFLT   (400)
 
#define VEGAS_ALPHA_EXIT_DFLT   (3*OUTBUF_CELLS)
 
#define VEGAS_BETA_EXIT_DFLT   (4*OUTBUF_CELLS)
 
#define VEGAS_GAMMA_EXIT_DFLT   (3*OUTBUF_CELLS)
 
#define VEGAS_DELTA_EXIT_DFLT   (5*OUTBUF_CELLS)
 
#define VEGAS_SSCAP_EXIT_DFLT   (600)
 
#define VEGAS_ALPHA_ONION_DFLT   (3*OUTBUF_CELLS)
 
#define VEGAS_BETA_ONION_DFLT   (6*OUTBUF_CELLS)
 
#define VEGAS_GAMMA_ONION_DFLT   (4*OUTBUF_CELLS)
 
#define VEGAS_DELTA_ONION_DFLT   (7*OUTBUF_CELLS)
 
#define VEGAS_SSCAP_ONION_DFLT   (475)
 
#define VEGAS_CWND_FULL_GAP_DFLT   (4)
 
#define VEGAS_CWND_FULL_MINPCT_DFLT   (25)
 
#define VEGAS_CWND_FULL_PER_CWND_DFLT   (1)
 

Functions

static uint64_t vegas_bdp (const congestion_control_t *cc)
 
void congestion_control_vegas_set_params (congestion_control_t *cc, cc_path_t path)
 
static void congestion_control_vegas_log (const circuit_t *circ, const congestion_control_t *cc)
 
static uint64_t rfc3742_ss_inc (const congestion_control_t *cc)
 
static void congestion_control_vegas_exit_slow_start (const circuit_t *circ, congestion_control_t *cc)
 
static bool cwnd_became_full (const congestion_control_t *cc)
 
static bool cwnd_became_nonfull (const congestion_control_t *cc)
 
static bool cwnd_full_reset (const congestion_control_t *cc)
 
int congestion_control_vegas_process_sendme (congestion_control_t *cc, const circuit_t *circ)
 

Variables

static int cc_vegas_cwnd_full_gap = VEGAS_CWND_FULL_GAP_DFLT
 
static int cc_vegas_cwnd_full_minpct = VEGAS_CWND_FULL_MINPCT_DFLT
 
static int cc_cwnd_full_per_cwnd = VEGAS_CWND_FULL_PER_CWND_DFLT
 
double cc_stats_vegas_exit_ss_cwnd_ma = 0
 
double cc_stats_vegas_exit_ss_bdp_ma = 0
 
double cc_stats_vegas_exit_ss_inc_ma = 0
 
double cc_stats_vegas_gamma_drop_ma = 0
 
double cc_stats_vegas_delta_drop_ma = 0
 
double cc_stats_vegas_ss_csig_blocked_ma = 0
 
double cc_stats_vegas_csig_blocked_ma = 0
 
double cc_stats_vegas_csig_alpha_ma = 0
 
double cc_stats_vegas_csig_beta_ma = 0
 
double cc_stats_vegas_csig_delta_ma = 0
 
double cc_stats_vegas_ss_queue_ma = 0
 
double cc_stats_vegas_queue_ma = 0
 
double cc_stats_vegas_bdp_ma = 0
 
uint64_t cc_stats_vegas_above_delta = 0
 
uint64_t cc_stats_vegas_above_ss_cwnd_max = 0
 
uint64_t cc_stats_vegas_below_ss_inc_floor = 0
 
uint64_t cc_stats_vegas_circ_exited_ss = 0
 

Detailed Description

Code that implements the TOR_VEGAS congestion control algorithm from Proposal #324.

Definition in file congestion_control_vegas.c.

Macro Definition Documentation

◆ OUTBUF_CELLS

#define OUTBUF_CELLS   (2*TLS_RECORD_MAX_CELLS)

Definition at line 28 of file congestion_control_vegas.c.

◆ SS_CWND_MAX_DFLT

#define SS_CWND_MAX_DFLT   (5000)

Definition at line 30 of file congestion_control_vegas.c.

◆ TOR_CONGESTION_CONTROL_VEGAS_PRIVATE

#define TOR_CONGESTION_CONTROL_VEGAS_PRIVATE

Definition at line 10 of file congestion_control_vegas.c.

◆ VEGAS_ALPHA_EXIT_DFLT

#define VEGAS_ALPHA_EXIT_DFLT   (3*OUTBUF_CELLS)

Definition at line 40 of file congestion_control_vegas.c.

◆ VEGAS_ALPHA_ONION_DFLT

#define VEGAS_ALPHA_ONION_DFLT   (3*OUTBUF_CELLS)

Definition at line 47 of file congestion_control_vegas.c.

◆ VEGAS_ALPHA_SBWS_DFLT

#define VEGAS_ALPHA_SBWS_DFLT   (2*OUTBUF_CELLS-TLS_RECORD_MAX_CELLS)

Definition at line 33 of file congestion_control_vegas.c.

◆ VEGAS_BETA_EXIT_DFLT

#define VEGAS_BETA_EXIT_DFLT   (4*OUTBUF_CELLS)

Definition at line 41 of file congestion_control_vegas.c.

◆ VEGAS_BETA_ONION_DFLT

#define VEGAS_BETA_ONION_DFLT   (6*OUTBUF_CELLS)

Definition at line 48 of file congestion_control_vegas.c.

◆ VEGAS_BETA_SBWS_DFLT

#define VEGAS_BETA_SBWS_DFLT   (2*OUTBUF_CELLS+TLS_RECORD_MAX_CELLS)

Definition at line 34 of file congestion_control_vegas.c.

◆ VEGAS_CWND_FULL_GAP_DFLT

#define VEGAS_CWND_FULL_GAP_DFLT   (4)

Number of sendme_incs between cwnd and inflight for cwnd to be still considered full

Definition at line 56 of file congestion_control_vegas.c.

◆ VEGAS_CWND_FULL_MINPCT_DFLT

#define VEGAS_CWND_FULL_MINPCT_DFLT   (25)

If the cwnd becomes less than this percent full at any point, we declare it not full immediately.

Definition at line 63 of file congestion_control_vegas.c.

◆ VEGAS_CWND_FULL_PER_CWND_DFLT

#define VEGAS_CWND_FULL_PER_CWND_DFLT   (1)

Param to decide when to reset the cwnd.

Definition at line 69 of file congestion_control_vegas.c.

◆ VEGAS_DELTA_EXIT_DFLT

#define VEGAS_DELTA_EXIT_DFLT   (5*OUTBUF_CELLS)

Definition at line 43 of file congestion_control_vegas.c.

◆ VEGAS_DELTA_ONION_DFLT

#define VEGAS_DELTA_ONION_DFLT   (7*OUTBUF_CELLS)

Definition at line 50 of file congestion_control_vegas.c.

◆ VEGAS_DELTA_SBWS_DFLT

#define VEGAS_DELTA_SBWS_DFLT   (4*OUTBUF_CELLS)

Definition at line 36 of file congestion_control_vegas.c.

◆ VEGAS_GAMMA_EXIT_DFLT

#define VEGAS_GAMMA_EXIT_DFLT   (3*OUTBUF_CELLS)

Definition at line 42 of file congestion_control_vegas.c.

◆ VEGAS_GAMMA_ONION_DFLT

#define VEGAS_GAMMA_ONION_DFLT   (4*OUTBUF_CELLS)

Definition at line 49 of file congestion_control_vegas.c.

◆ VEGAS_GAMMA_SBWS_DFLT

#define VEGAS_GAMMA_SBWS_DFLT   (2*OUTBUF_CELLS)

Definition at line 35 of file congestion_control_vegas.c.

◆ VEGAS_SSCAP_EXIT_DFLT

#define VEGAS_SSCAP_EXIT_DFLT   (600)

Definition at line 44 of file congestion_control_vegas.c.

◆ VEGAS_SSCAP_ONION_DFLT

#define VEGAS_SSCAP_ONION_DFLT   (475)

Definition at line 51 of file congestion_control_vegas.c.

◆ VEGAS_SSCAP_SBWS_DFLT

#define VEGAS_SSCAP_SBWS_DFLT   (400)

Definition at line 37 of file congestion_control_vegas.c.

Function Documentation

◆ congestion_control_vegas_exit_slow_start()

static void congestion_control_vegas_exit_slow_start ( const circuit_t circ,
congestion_control_t cc 
)
static

Exit Vegas slow start.

This function sets our slow-start state to 0, and emits logs and control port information signifying end of slow start. It also schedules the next CWND update for steady-state.

Definition at line 302 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_process_sendme().

◆ congestion_control_vegas_log()

static void congestion_control_vegas_log ( const circuit_t circ,
const congestion_control_t cc 
)
static

Common log function for tracking all vegas state.

Definition at line 219 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_exit_slow_start().

◆ congestion_control_vegas_process_sendme()

int congestion_control_vegas_process_sendme ( congestion_control_t cc,
const circuit_t circ 
)

Process a SENDME and update the congestion window according to the rules specified in TOR_VEGAS of Proposal #324.

Essentially, this algorithm attempts to measure queue lengths on the circuit by subtracting the bandwidth-delay-product estimate from the current congestion window.

If the congestion window is larger than the bandwidth-delay-product, then data is assumed to be queuing. We reduce the congestion window in that case.

If the congestion window is smaller than the bandwidth-delay-product, then there is spare bandwidth capacity on the circuit. We increase the congestion window in that case.

The congestion window is updated only once every congestion window worth of packets, even if the signal persists. It is also updated whenever the upstream orcon blocks, or unblocks. This minimizes local client queues.

Definition at line 407 of file congestion_control_vegas.c.

◆ congestion_control_vegas_set_params()

void congestion_control_vegas_set_params ( congestion_control_t cc,
cc_path_t  path 
)

Cache Vegas consensus parameters.

Definition at line 108 of file congestion_control_vegas.c.

◆ cwnd_became_full()

static bool cwnd_became_full ( const congestion_control_t cc)
inlinestatic

Returns true if the congestion window is considered full.

We allow a number of sendme_incs gap in case buffering issues with edge conns cause the window to occasionally be not quite full. This can happen if several SENDMEs arrive before we return to the eventloop to fill the inbuf on edge connections.

Definition at line 339 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_process_sendme().

◆ cwnd_became_nonfull()

static bool cwnd_became_nonfull ( const congestion_control_t cc)
inlinestatic

Returns true if the congestion window is no longer full.

This functions as a low watermark, below which we stop allowing cwnd increments.

Definition at line 355 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_process_sendme().

◆ cwnd_full_reset()

static bool cwnd_full_reset ( const congestion_control_t cc)
inlinestatic

Decide if it is time to reset the cwnd_full status.

If cc_cwnd_full_per_cwnd=1, we reset cwnd_full once per congestion window, ie: next_cwnd_event == SENDME_PER_CWND(cc)

Otherwise, we reset cwnd_full whenever there is an update of the congestion window, ie: next_cc_event == CWND_UPDATE_RATE(cc)

Definition at line 377 of file congestion_control_vegas.c.

◆ rfc3742_ss_inc()

static uint64_t rfc3742_ss_inc ( const congestion_control_t cc)
inlinestatic

Implements RFC3742: Limited Slow Start. https://datatracker.ietf.org/doc/html/rfc3742#section-2

Definition at line 276 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_process_sendme().

◆ vegas_bdp()

static uint64_t vegas_bdp ( const congestion_control_t cc)
inlinestatic

The original TCP Vegas congestion window BDP estimator.

Definition at line 99 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_log(), and congestion_control_vegas_process_sendme().

Variable Documentation

◆ cc_cwnd_full_per_cwnd

int cc_cwnd_full_per_cwnd = VEGAS_CWND_FULL_PER_CWND_DFLT
static

Definition at line 70 of file congestion_control_vegas.c.

◆ cc_stats_vegas_above_delta

uint64_t cc_stats_vegas_above_delta = 0

Stats on how many times we reached "delta" param.

Definition at line 89 of file congestion_control_vegas.c.

◆ cc_stats_vegas_above_ss_cwnd_max

uint64_t cc_stats_vegas_above_ss_cwnd_max = 0

Stats on how many times we reached "ss_cwnd_max" param.

Definition at line 91 of file congestion_control_vegas.c.

◆ cc_stats_vegas_bdp_ma

double cc_stats_vegas_bdp_ma = 0

Definition at line 86 of file congestion_control_vegas.c.

◆ cc_stats_vegas_below_ss_inc_floor

uint64_t cc_stats_vegas_below_ss_inc_floor = 0

Definition at line 92 of file congestion_control_vegas.c.

◆ cc_stats_vegas_circ_exited_ss

uint64_t cc_stats_vegas_circ_exited_ss = 0

Definition at line 93 of file congestion_control_vegas.c.

◆ cc_stats_vegas_csig_alpha_ma

double cc_stats_vegas_csig_alpha_ma = 0

Definition at line 80 of file congestion_control_vegas.c.

◆ cc_stats_vegas_csig_beta_ma

double cc_stats_vegas_csig_beta_ma = 0

Definition at line 81 of file congestion_control_vegas.c.

◆ cc_stats_vegas_csig_blocked_ma

double cc_stats_vegas_csig_blocked_ma = 0

Definition at line 79 of file congestion_control_vegas.c.

◆ cc_stats_vegas_csig_delta_ma

double cc_stats_vegas_csig_delta_ma = 0

Definition at line 82 of file congestion_control_vegas.c.

◆ cc_stats_vegas_delta_drop_ma

double cc_stats_vegas_delta_drop_ma = 0

Definition at line 77 of file congestion_control_vegas.c.

◆ cc_stats_vegas_exit_ss_bdp_ma

double cc_stats_vegas_exit_ss_bdp_ma = 0

Definition at line 74 of file congestion_control_vegas.c.

◆ cc_stats_vegas_exit_ss_cwnd_ma

double cc_stats_vegas_exit_ss_cwnd_ma = 0

Moving average of the cc->cwnd from each circuit exiting slowstart.

Definition at line 73 of file congestion_control_vegas.c.

Referenced by congestion_control_vegas_exit_slow_start(), and fill_cc_gauges_values().

◆ cc_stats_vegas_exit_ss_inc_ma

double cc_stats_vegas_exit_ss_inc_ma = 0

Definition at line 75 of file congestion_control_vegas.c.

◆ cc_stats_vegas_gamma_drop_ma

double cc_stats_vegas_gamma_drop_ma = 0

Definition at line 76 of file congestion_control_vegas.c.

◆ cc_stats_vegas_queue_ma

double cc_stats_vegas_queue_ma = 0

Definition at line 85 of file congestion_control_vegas.c.

◆ cc_stats_vegas_ss_csig_blocked_ma

double cc_stats_vegas_ss_csig_blocked_ma = 0

Definition at line 78 of file congestion_control_vegas.c.

◆ cc_stats_vegas_ss_queue_ma

double cc_stats_vegas_ss_queue_ma = 0

Definition at line 84 of file congestion_control_vegas.c.

◆ cc_vegas_cwnd_full_gap

int cc_vegas_cwnd_full_gap = VEGAS_CWND_FULL_GAP_DFLT
static

Definition at line 57 of file congestion_control_vegas.c.

◆ cc_vegas_cwnd_full_minpct

int cc_vegas_cwnd_full_minpct = VEGAS_CWND_FULL_MINPCT_DFLT
static

Definition at line 64 of file congestion_control_vegas.c.