[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/main] Export the n_ewma function for flow control use.



commit 33d8974f4d6b3697f021ece1b9b12a9b8c69e4b5
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
Date:   Sat Aug 21 00:02:30 2021 +0000

    Export the n_ewma function for flow control use.
---
 src/core/or/congestion_control_common.c | 18 ------------------
 src/core/or/congestion_control_common.h | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c
index edb65d2b70..fa603e8df8 100644
--- a/src/core/or/congestion_control_common.c
+++ b/src/core/or/congestion_control_common.c
@@ -224,24 +224,6 @@ congestion_control_free_(congestion_control_t *cc)
   tor_free(cc);
 }
 
-/**
- * Compute an N-count EWMA, aka N-EWMA. N-EWMA is defined as:
- *  EWMA = alpha*value + (1-alpha)*EWMA_prev
- * with alpha = 2/(N+1).
- *
- * This works out to:
- *  EWMA = value*2/(N+1) + EMA_prev*(N-1)/(N+1)
- *       = (value*2 + EWMA_prev*(N-1))/(N+1)
- */
-static inline uint64_t
-n_count_ewma(uint64_t curr, uint64_t prev, uint64_t N)
-{
-  if (prev == 0)
-    return curr;
-  else
-    return (2*curr + (N-1)*prev)/(N+1);
-}
-
 /**
  * Enqueue a u64 timestamp to the end of a queue of timestamps.
  */
diff --git a/src/core/or/congestion_control_common.h b/src/core/or/congestion_control_common.h
index 12da0cb4e0..e8b9681ac6 100644
--- a/src/core/or/congestion_control_common.h
+++ b/src/core/or/congestion_control_common.h
@@ -41,6 +41,24 @@ int sendme_get_inc_count(const circuit_t *, const crypt_path_t *);
 bool circuit_sent_cell_for_sendme(const circuit_t *, const crypt_path_t *);
 bool is_monotime_clock_reliable(void);
 
+/**
+ * Compute an N-count EWMA, aka N-EWMA. N-EWMA is defined as:
+ *  EWMA = alpha*value + (1-alpha)*EWMA_prev
+ * with alpha = 2/(N+1).
+ *
+ * This works out to:
+ *  EWMA = value*2/(N+1) + EMA_prev*(N-1)/(N+1)
+ *       = (value*2 + EWMA_prev*(N-1))/(N+1)
+ */
+static inline uint64_t
+n_count_ewma(uint64_t curr, uint64_t prev, uint64_t N)
+{
+  if (prev == 0)
+    return curr;
+  else
+    return (2*curr + (N-1)*prev)/(N+1);
+}
+
 /* Private section starts. */
 #ifdef TOR_CONGESTION_CONTROL_PRIVATE
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits