/* For unit tests */
void congestion_control_set_cc_enabled(void);
+/* Number of times the RTT value was reset. For MetricsPort. */
+static uint64_t num_rtt_reset;
+
/* Consensus parameters cached. The non static ones are extern. */
static uint32_t cwnd_max = CWND_MAX_DFLT;
int32_t cell_queue_high = CELL_QUEUE_HIGH_DFLT;
*/
static uint8_t rtt_reset_pct;
+/** Return the number of RTT reset that have been done. */
+uint64_t
+congestion_control_get_num_rtt_reset(void)
+{
+ return num_rtt_reset;
+}
+
/**
* Update global congestion control related consensus parameter values,
* every consensus update.
cc->min_rtt_usec/1000, new_rtt/1000);
cc->min_rtt_usec = new_rtt;
+ num_rtt_reset++; /* Accounting */
} else if (cc->ewma_rtt_usec < cc->min_rtt_usec) {
// Using the EWMA for min instead of current RTT helps average out
// effects from other conns
bool congestion_control_validate_sendme_increment(uint8_t sendme_inc);
char *congestion_control_get_control_port_fields(const origin_circuit_t *);
+uint64_t congestion_control_get_num_rtt_reset(void);
+
/* Ugh, C.. these are private. Use the getter instead, when
* external to the congestion control code. */
extern uint32_t or_conn_highwater;
#include "core/or/or.h"
#include "core/mainloop/connection.h"
+#include "core/or/congestion_control_common.h"
#include "core/or/relay.h"
#include "lib/malloc/malloc.h"
#include <event2/dns.h>
/** Declarations of each fill function for metrics defined in base_metrics. */
+static void fill_cc_values(void);
static void fill_connections_values(void);
static void fill_dns_error_values(void);
static void fill_dns_query_values(void);
.help = "Total number of streams",
.fill_fn = fill_streams_values,
},
+ {
+ .key = RELAY_METRICS_NUM_CC,
+ .type = METRICS_TYPE_COUNTER,
+ .name = METRICS_NAME(relay_congestion_control_total),
+ .help = "Congestion control related counters",
+ .fill_fn = fill_cc_values,
+ },
};
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
}
}
+/** Fill function for the RELAY_METRICS_NUM_CC metric. */
+static void
+fill_cc_values(void)
+{
+ const relay_metrics_entry_t *rentry = &base_metrics[RELAY_METRICS_NUM_CC];
+ metrics_store_entry_t *sentry =
+ metrics_store_add(the_store, rentry->type, rentry->name, rentry->help);
+
+ metrics_store_entry_add_label(sentry,
+ metrics_format_label("state", "starvation"));
+ metrics_store_entry_add_label(sentry,
+ metrics_format_label("action", "rtt_reset"));
+ metrics_store_entry_update(sentry, congestion_control_get_num_rtt_reset());
+}
+
/** Helper: Fill in single stream metrics output. */
static void
fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd)