aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/core/prefix_stats.h
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2020-04-27 09:42:17 +0000
committerGerrit Code Review <gerrit@fd.io>2020-04-27 09:42:17 +0000
commite94a00b51ce795a8629c33edefd3fcd4b4af05ef (patch)
treeda6b4eb58ec6cb6042b21b05fa194fad9b5d6b8e /hicn-light/src/hicn/core/prefix_stats.h
parent0ea5735b98f38beacf92dfdca74b7a6d5b3f7182 (diff)
parent15ad172a847fa667c57a4594ef4158405db9a984 (diff)
Merge "[HICN-554] hicn-light refactoring" into hicn-light-ng
Diffstat (limited to 'hicn-light/src/hicn/core/prefix_stats.h')
-rw-r--r--hicn-light/src/hicn/core/prefix_stats.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/hicn-light/src/hicn/core/prefix_stats.h b/hicn-light/src/hicn/core/prefix_stats.h
new file mode 100644
index 000000000..257f6b44d
--- /dev/null
+++ b/hicn-light/src/hicn/core/prefix_stats.h
@@ -0,0 +1,91 @@
+
+#ifndef HICNLIGHT_PREFIX_STATS_H
+#define HICNLIGHT_PREFIX_STATS_H
+
+#ifdef WITH_PREFIX_STATS
+
+typedef struct prefix_stats_mgr_s {
+ void * forwarder;
+ int timer_fd;
+} prefix_stats_mgr_t;
+
+
+/* PER-INTERFACE PREFIX STATS */
+
+typedef struct {
+ float throughput;
+ float latency;
+ float loss_rate;
+} interface_stats_t;
+
+/* PREFIX STATS */
+
+typedef struct {
+ interface_stats_t wired;
+ interface_stats_t wifi;
+ interface_stats_t cellular;
+ interface_stats_t all;
+} prefix_stats_t;
+
+typedef struct {
+ uint32_t num_packets;
+ uint32_t num_bytes;
+ uint32_t num_losses;
+ uint32_t latency_idle;
+} interface_counters_t;
+
+typedef struct {
+ interface_counters_t wired;
+ interface_counters_t wifi;
+ interface_counters_t cellular;
+ interface_counters_t all;
+ uint64_t last_update;
+} prefix_counters_t;
+
+#define INTERFACE_STATS_EMPTY (interface_stats_t) { \
+ .throughput = 0, \
+ .latency = 0, \
+ .loss_rate = 0, \
+}
+
+#define PREFIX_STATS_EMPTY (prefix_stats_t) { \
+ .wired = INTERFACE_STATS_EMPTY, \
+ .wifi = INTERFACE_STATS_EMPTY, \
+ .cellular = INTERFACE_STATS_EMPTY, \
+ .all = INTERFACE_STATS_EMPTY, \
+}
+
+#define INTERFACE_COUNTERS_EMPTY (interface_counters_t) { \
+ .num_packets = 0, \
+ .num_bytes = 0, \
+ .num_losses = 0, \
+ .latency_idle = 0, \
+}
+
+#define PREFIX_COUNTERS_EMPTY (prefix_counters_t) { \
+ .wired = INTERFACE_COUNTERS_EMPTY, \
+ .wifi = INTERFACE_COUNTERS_EMPTY, \
+ .cellular = INTERFACE_COUNTERS_EMPTY, \
+ .all = INTERFACE_COUNTERS_EMPTY, \
+ .last_update = 0, \
+}
+
+int prefix_stats_mgr_initialize(prefix_stats_mgr_t * mgr, void * forwarder);
+
+void prefix_stats_mgr_finalize(prefix_stats_mgr_t * mgr);
+
+void prefix_stats_on_retransmission(const prefix_stats_mgr_t * mgr,
+ prefix_counters_t * countrs, const nexthops_t * nexthops);
+
+void prefix_stats_on_data(const prefix_stats_mgr_t * mgr, prefix_stats_t * stats,
+ prefix_counters_t * counters, const nexthops_t * nexthops,
+ const msgbuf_t * msgbuf, Ticks rtt);
+
+void prefix_stats_on_timeout(const prefix_stats_mgr_t * mgr, prefix_counters_t * counters,
+ const nexthops_t * nexthops);
+
+void prefix_stats_update(prefix_stats_t * stats, prefix_counters_t * counters, uint64_t now);
+
+#endif /* WITH_PREFIX_STATS */
+
+#endif /* HICNLIGHT_PREFIX_STATS_H */