|
Tor 0.4.9.8
|
Code that implements flow control for congestion controlled circuits. More...
#include "core/or/or.h"#include "core/or/relay.h"#include "core/mainloop/connection.h"#include "core/or/connection_edge.h"#include "core/mainloop/mainloop.h"#include "core/or/congestion_control_common.h"#include "core/or/congestion_control_flow.h"#include "core/or/congestion_control_st.h"#include "core/or/circuitlist.h"#include "core/or/trace_probes_cc.h"#include "feature/nodelist/networkstatus.h"#include "trunnel/flow_control_cells.h"#include "feature/control/control_events.h"#include "lib/math/stats.h"#include "core/or/connection_st.h"#include "core/or/cell_st.h"#include "app/config/config.h"#include "core/or/conflux_util.h"Go to the source code of this file.
Macros | |
| #define | TOR_CONGESTION_CONTROL_FLOW_PRIVATE |
| #define | MAX_EXPECTED_CELL_BURST 32 |
| #define | XOFF_GRACE_PERIOD_USEC (5000) |
| #define | XON_COUNT_SCALE_AT 200 |
| #define | XOFF_COUNT_SCALE_AT 200 |
| #define | ONE_MEGABYTE (UINT64_C(1) << 20) |
| #define | TOTAL_XMIT_SCALE_AT (10 * ONE_MEGABYTE) |
| #define | CC_XOFF_CLIENT_DFLT 500 |
| #define | CC_XOFF_CLIENT_MIN 1 |
| #define | CC_XOFF_CLIENT_MAX 10000 |
| #define | CC_XOFF_EXIT_DFLT 500 |
| #define | CC_XOFF_EXIT_MIN 1 |
| #define | CC_XOFF_EXIT_MAX 10000 |
| #define | CC_XON_CHANGE_PCT_DFLT 25 |
| #define | CC_XON_CHANGE_PCT_MIN 1 |
| #define | CC_XON_CHANGE_PCT_MAX 99 |
| #define | CC_XON_RATE_BYTES_DFLT (500) |
| #define | CC_XON_RATE_BYTES_MIN (1) |
| #define | CC_XON_RATE_BYTES_MAX (5000) |
| #define | CC_XON_EWMA_CNT_DFLT (2) |
| #define | CC_XON_EWMA_CNT_MIN (2) |
| #define | CC_XON_EWMA_CNT_MAX (100) |
Functions | |
| void | flow_control_new_consensus_params (const networkstatus_t *ns) |
| static void | circuit_send_stream_xoff (edge_connection_t *stream) |
| static uint32_t | compute_drain_rate (const edge_connection_t *stream) |
| static void | circuit_send_stream_xon (edge_connection_t *stream) |
| bool | circuit_process_stream_xoff (edge_connection_t *conn, const crypt_path_t *layer_hint) |
| bool | circuit_process_stream_xon (edge_connection_t *conn, const crypt_path_t *layer_hint, const relay_msg_t *msg) |
| int | flow_control_decide_xoff (edge_connection_t *stream) |
| static bool | stream_drain_rate_changed (const edge_connection_t *stream) |
| void | flow_control_decide_xon (edge_connection_t *stream, size_t n_written) |
| void | flow_control_note_sent_data (edge_connection_t *stream, size_t len) |
| bool | edge_uses_flow_control (const edge_connection_t *stream) |
| bool | conn_uses_flow_control (connection_t *conn) |
Variables | |
| static uint32_t | xoff_client |
| static uint32_t | xoff_exit |
| static uint32_t | xon_change_pct |
| static uint32_t | xon_ewma_cnt |
| static uint32_t | xon_rate_bytes |
| uint64_t | cc_stats_flow_num_xoff_sent |
| uint64_t | cc_stats_flow_num_xon_sent |
| double | cc_stats_flow_xoff_outbuf_ma = 0 |
| double | cc_stats_flow_xon_outbuf_ma = 0 |
Code that implements flow control for congestion controlled circuits.
Definition in file congestion_control_flow.c.
| #define MAX_EXPECTED_CELL_BURST 32 |
Definition at line 50 of file congestion_control_flow.c.
| #define ONE_MEGABYTE (UINT64_C(1) << 20) |
Definition at line 88 of file congestion_control_flow.c.
| #define TOR_CONGESTION_CONTROL_FLOW_PRIVATE |
Definition at line 10 of file congestion_control_flow.c.
| #define TOTAL_XMIT_SCALE_AT (10 * ONE_MEGABYTE) |
Definition at line 89 of file congestion_control_flow.c.
| #define XOFF_COUNT_SCALE_AT 200 |
Definition at line 87 of file congestion_control_flow.c.
| #define XOFF_GRACE_PERIOD_USEC (5000) |
Definition at line 77 of file congestion_control_flow.c.
| #define XON_COUNT_SCALE_AT 200 |
Definition at line 86 of file congestion_control_flow.c.
| bool circuit_process_stream_xoff | ( | edge_connection_t * | conn, |
| const crypt_path_t * | layer_hint ) |
Process a stream XOFF, parsing it, and then stopping reading on the edge connection.
Record that we have received an xoff, so we know not to resume reading on this edge conn until we get an XON.
Returns false if the XOFF did not validate; true if it does.
Definition at line 261 of file congestion_control_flow.c.
Referenced by handle_relay_msg().
| bool circuit_process_stream_xon | ( | edge_connection_t * | conn, |
| const crypt_path_t * | layer_hint, | ||
| const relay_msg_t * | msg ) |
Process a stream XON, and if it validates, clear the xoff flag and resume reading on this edge connection.
Also, use provided rate information to rate limit reading on this edge (or packagaing from it onto the circuit), to avoid XON/XOFF chatter.
Returns true if the XON validates, false otherwise.
Definition at line 353 of file congestion_control_flow.c.
Referenced by handle_relay_msg().
|
static |
Send an XOFF for this stream, and note that we sent one
Definition at line 146 of file congestion_control_flow.c.
Referenced by flow_control_decide_xoff().
|
static |
Send an XON for this stream, with appropriate advisory rate information.
Reverts the xoff sent status, and stores the rate information we sent, in case it changes.
Definition at line 214 of file congestion_control_flow.c.
Referenced by flow_control_decide_xon().
|
inlinestatic |
Compute the recent drain rate (write rate) for this edge connection and return it, in KB/sec (1000 bytes/sec).
Returns 0 if the monotime clock is busted.
Definition at line 183 of file congestion_control_flow.c.
Referenced by flow_control_decide_xon().
| bool conn_uses_flow_control | ( | connection_t * | conn | ) |
Returns true if a connection is an edge conn that uses flow control
Definition at line 753 of file congestion_control_flow.c.
Referenced by connection_handle_write_impl().
| bool edge_uses_flow_control | ( | const edge_connection_t * | stream | ) |
Returns true if an edge connection uses flow control
Definition at line 742 of file congestion_control_flow.c.
Referenced by circuit_process_stream_xoff(), circuit_process_stream_xon(), conn_uses_flow_control(), connection_half_edge_add(), flow_control_decide_xoff(), and sendme_connection_edge_consider_sending().
| int flow_control_decide_xoff | ( | edge_connection_t * | stream | ) |
Called from sendme_stream_data_received(), when data arrives from a circuit to our edge's outbuf, to decide if we need to send an XOFF.
Returns the amount of cells remaining until the buffer is full, at which point it sends an XOFF, and returns 0.
Returns less than 0 if we have queued more than a congestion window worth of data and need to close the circuit.
Definition at line 466 of file congestion_control_flow.c.
| void flow_control_decide_xon | ( | edge_connection_t * | stream, |
| size_t | n_written ) |
Called whenever we drain an edge connection outbuf by writing on its socket, to decide if it is time to send an xon.
The n_written parameter tells us how many bytes we have written this time, which is used to compute the advisory drain rate fields.
Definition at line 581 of file congestion_control_flow.c.
Referenced by connection_handle_write_impl(), and flow_control_decide_xoff().
| void flow_control_new_consensus_params | ( | const networkstatus_t * | ns | ) |
Update global congestion control related consensus parameter values, every consensus update.
More details for each of the parameters can be found in proposal 324, section 6.5 including tuning notes.
Definition at line 99 of file congestion_control_flow.c.
Referenced by tor_init().
| void flow_control_note_sent_data | ( | edge_connection_t * | stream, |
| size_t | len ) |
Note that we packaged some data on this stream. Used to enforce client-side dropmark limits
Definition at line 723 of file congestion_control_flow.c.
|
static |
Returns true if the stream's drain rate has changed significantly.
Returns false if the monotime clock is stalled, or if we have no previous drain rate information.
Definition at line 550 of file congestion_control_flow.c.
Referenced by flow_control_decide_xon().
| uint64_t cc_stats_flow_num_xoff_sent |
Metricsport stats
Definition at line 42 of file congestion_control_flow.c.
Referenced by circuit_send_stream_xoff(), and fill_cc_counters_values().
| uint64_t cc_stats_flow_num_xon_sent |
Definition at line 43 of file congestion_control_flow.c.
| double cc_stats_flow_xoff_outbuf_ma = 0 |
Definition at line 44 of file congestion_control_flow.c.
| double cc_stats_flow_xon_outbuf_ma = 0 |
Definition at line 45 of file congestion_control_flow.c.
|
static |
Cache consensus parameters
Definition at line 34 of file congestion_control_flow.c.
Referenced by circuit_process_stream_xoff(), circuit_process_stream_xon(), flow_control_decide_xoff(), and flow_control_new_consensus_params().
|
static |
Definition at line 35 of file congestion_control_flow.c.
|
static |
Definition at line 37 of file congestion_control_flow.c.
|
static |
Definition at line 38 of file congestion_control_flow.c.
|
static |
Definition at line 39 of file congestion_control_flow.c.