summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/pol
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/unicast/pol')
-rw-r--r--src/ipcpd/unicast/pol/ca-mb-ecn.c41
-rw-r--r--src/ipcpd/unicast/pol/ca-mb-ecn.h4
-rw-r--r--src/ipcpd/unicast/pol/ca-nop.c3
3 files changed, 46 insertions, 2 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);
+}
diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.h b/src/ipcpd/unicast/pol/ca-mb-ecn.h
index 456b9b13..945b0df5 100644
--- a/src/ipcpd/unicast/pol/ca-mb-ecn.h
+++ b/src/ipcpd/unicast/pol/ca-mb-ecn.h
@@ -45,6 +45,10 @@ void mb_ecn_wnd_wait(ca_wnd_t wnd);
uint8_t mb_ecn_calc_ecn(int fd,
size_t len);
+ssize_t mb_ecn_print_stats(void * ctx,
+ char * buf,
+ size_t len);
+
extern struct pol_ca_ops mb_ecn_ca_ops;
#endif /* OUROBOROS_IPCPD_UNICAST_CA_MB_ECN_H */
diff --git a/src/ipcpd/unicast/pol/ca-nop.c b/src/ipcpd/unicast/pol/ca-nop.c
index d0d89a2e..15b253ca 100644
--- a/src/ipcpd/unicast/pol/ca-nop.c
+++ b/src/ipcpd/unicast/pol/ca-nop.c
@@ -31,7 +31,8 @@ struct pol_ca_ops nop_ca_ops = {
.ctx_update_rcv = nop_ctx_update_rcv,
.ctx_update_ece = nop_ctx_update_ece,
.wnd_wait = nop_wnd_wait,
- .calc_ecn = nop_calc_ecn
+ .calc_ecn = nop_calc_ecn,
+ .print_stats = NULL
};
void * nop_ctx_create(void)