summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/pol/ca-mb-ecn.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2020-12-05 15:05:13 +0100
committerSander Vrijders <sander@ouroboros.rocks>2020-12-05 16:00:21 +0100
commit962b37bb28724bdf28abbe5d48350adba6000ed4 (patch)
tree7dab94fc1f13cd6c00b5de45bd730829959d2023 /src/ipcpd/unicast/pol/ca-mb-ecn.c
parent1bb26d793e8b95313769e4fcf530321076401390 (diff)
downloadouroboros-962b37bb28724bdf28abbe5d48350adba6000ed4.tar.gz
ouroboros-962b37bb28724bdf28abbe5d48350adba6000ed4.zip
ipcpd: Add RIB statistics for flow allocator
The RIB will now show some stats for the flow allocator, including congestion avoidance statistics. This is needed before decoupling the data transfer component and the flow allocator as some current stats show in DT will move to FA. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/pol/ca-mb-ecn.c')
-rw-r--r--src/ipcpd/unicast/pol/ca-mb-ecn.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.c b/src/ipcpd/unicast/pol/ca-mb-ecn.c
index 03f7044d..0542e291 100644
--- a/src/ipcpd/unicast/pol/ca-mb-ecn.c
+++ b/src/ipcpd/unicast/pol/ca-mb-ecn.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
/* congestion avoidance constants */
#define CA_SHFT 5 /* Average over 32 pkts */
@@ -72,7 +73,8 @@ struct pol_ca_ops mb_ecn_ca_ops = {
.ctx_update_rcv = mb_ecn_ctx_update_rcv,
.ctx_update_ece = mb_ecn_ctx_update_ece,
.wnd_wait = mb_ecn_wnd_wait,
- .calc_ecn = mb_ecn_calc_ecn
+ .calc_ecn = mb_ecn_calc_ecn,
+ .print_stats = mb_ecn_print_stats
};
void * mb_ecn_ctx_create(void)
@@ -229,3 +231,40 @@ uint8_t mb_ecn_calc_ecn(int fd,
return (uint8_t) (q >> ECN_Q_SHFT);
}
+
+ssize_t mb_ecn_print_stats(void * _ctx,
+ char * buf,
+ size_t len)
+{
+ struct mb_ecn_ctx* ctx = _ctx;
+ char * regime;
+
+ if (len < 1024)
+ return 0;
+
+ if (!ctx->tx_cav)
+ regime = "Slow start";
+ else if (ctx->tx_ece)
+ regime = "Multiplicative dec";
+ else
+ regime = "Additive inc";
+
+ sprintf(buf,
+ "Congestion avoidance algorithm: %20s\n"
+ "Upstream congestion level: %20u\n"
+ "Upstream packet counter: %20zu\n"
+ "Downstream congestion level: %20u\n"
+ "Downstream packet counter: %20zu\n"
+ "Congestion window size (ns): %20zu\n"
+ "Packets in this window: %20zu\n"
+ "Bytes in this window: %20zu\n"
+ "Max bytes in this window: %20zu\n"
+ "Current congestion regime: %20s\n",
+ "Multi-bit ECN",
+ ctx->rx_ece, ctx->rx_ctr,
+ ctx->tx_ece, ctx->tx_ctr, (size_t) (1 << ctx->tx_mul),
+ ctx->tx_wpc, ctx->tx_wbc, ctx->tx_wbl,
+ regime);
+
+ return strlen(buf);
+}