aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/objects
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-23 15:27:34 +0000
committerEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-23 15:39:43 +0000
commitd2072866a012548f1f9e9bc93d9b8d7a84b654f5 (patch)
tree02f4900849de793ca68259f5cdf126e91ef5484f /ctrl/libhicnctrl/src/objects
parentadbdfdf7489e1909f29e2dd02edb7d15c258ed19 (diff)
fix(stats): fix forwarder statistics retrieval
Ref: HICN-794 Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I13162174f45855989727f92e96c11a1d48d710dd
Diffstat (limited to 'ctrl/libhicnctrl/src/objects')
-rw-r--r--ctrl/libhicnctrl/src/objects/stats.c101
-rw-r--r--ctrl/libhicnctrl/src/objects/stats.h29
2 files changed, 104 insertions, 26 deletions
diff --git a/ctrl/libhicnctrl/src/objects/stats.c b/ctrl/libhicnctrl/src/objects/stats.c
index 2c3135d3c..f9d0e1de7 100644
--- a/ctrl/libhicnctrl/src/objects/stats.c
+++ b/ctrl/libhicnctrl/src/objects/stats.c
@@ -18,42 +18,91 @@
* \brief Implementation of stats.
*/
-#include <string.h>
-
#include <hicn/ctrl/api.h>
-#include <hicn/ctrl/object.h>
-#include <hicn/ctrl/objects/stats.h>
#include <hicn/util/log.h>
#include "../object_vft.h"
-#include "../object_private.h"
-int hc_stats_snprintf(char *s, size_t size, const hc_stats_t *stats) {
-#if 0
- INFO("Connection #%d:", conn_stats->id);
- INFO("\tinterests received: %d pkts (%d bytes)",
- conn_stats->stats.interests.rx_pkts,
- conn_stats->stats.interests.rx_bytes);
- INFO("\tinterests transmitted: %d pkts (%d bytes)",
- conn_stats->stats.interests.tx_pkts,
- conn_stats->stats.interests.tx_bytes);
- INFO("\tdata received: %d pkts (%d bytes)",
- conn_stats->stats.data.rx_pkts,
- conn_stats->stats.data.rx_bytes);
- INFO("\tdata transmitted: %d pkts (%d bytes)",
- conn_stats->stats.data.tx_pkts,
- conn_stats->stats.data.tx_bytes);
-#endif
+/* GENERAL STATS */
+
+int _hc_stats_validate(const hc_object_t *object, bool allow_partial) {
+ // Nothing to validate
return 0;
}
-int hc_stats_get(hc_sock_t *s, hc_data_t **pdata) {
- hc_object_t object;
- memset(&object, 0, sizeof(hc_object_t));
- object.listener = *listener;
- return hc_execute(s, ACTION_GET, OBJECT_TYPE_STATS, &object, pdata);
+int _hc_stats_cmp(const hc_object_t *object1, const hc_object_t *object2) {
+ ERROR("[_hc_stats_cmp] Not implemented");
+ return -1;
+}
+
+int _hc_stats_snprintf(char *s, size_t size, const hc_object_t *object) {
+ return hc_stats_snprintf(s, size, &object->stats);
+}
+
+int hc_stats_snprintf(char *s, size_t size, const hc_stats_t *stats) {
+ return snprintf(
+ s, size,
+ "*** STATS ***\nreceived = %u (interest = %u, data = %u)\ndropped = %u "
+ "(interest = %u, data = %u, other = %u)\nforwarded = { interests = "
+ "%u, data = %u }\ndropped_reason = { connection_not_found = %u, "
+ "send_failure = %u, no_route_in_fib = %u }\ninterest processing = { "
+ "aggregated = %u, retransmitted = %u, satisfied_from_cs = %u, "
+ "expired_interests = %u, expired_data = %u }\ndata processing = { "
+ "no_reverse_path = %u }\npacket cache = {PIT size = %u, CS size = %u, "
+ "eviction = %u}",
+ stats->forwarder.countReceived, stats->forwarder.countInterestsReceived,
+ stats->forwarder.countObjectsReceived, stats->forwarder.countDropped,
+ stats->forwarder.countInterestsDropped,
+ stats->forwarder.countObjectsDropped, stats->forwarder.countOtherDropped,
+ stats->forwarder.countInterestForwarded,
+ stats->forwarder.countObjectsForwarded,
+ stats->forwarder.countDroppedConnectionNotFound,
+ stats->forwarder.countSendFailures, stats->forwarder.countDroppedNoRoute,
+ stats->forwarder.countInterestsAggregated,
+ stats->forwarder.countInterestsRetransmitted,
+ stats->forwarder.countInterestsSatisfiedFromStore,
+ stats->forwarder.countInterestsExpired, stats->forwarder.countDataExpired,
+ stats->forwarder.countDroppedNoReversePath,
+ stats->pkt_cache.n_pit_entries, stats->pkt_cache.n_cs_entries,
+ stats->pkt_cache.n_lru_evictions);
}
int hc_stats_list(hc_sock_t *s, hc_data_t **pdata) {
return hc_execute(s, ACTION_LIST, OBJECT_TYPE_STATS, NULL, pdata);
}
+
+DECLARE_OBJECT_OPS(OBJECT_TYPE_STATS, stats);
+
+/* PER-FACE STATS */
+
+int _hc_face_stats_validate(const hc_object_t *object, bool allow_partial) {
+ // Nothing to validate
+ return 0;
+}
+
+int _hc_face_stats_cmp(const hc_object_t *object1, const hc_object_t *object2) {
+ ERROR("[_hc_stats_cmp] Not implemented");
+ return -1;
+}
+
+int _hc_face_stats_snprintf(char *s, size_t size, const hc_object_t *object) {
+ return hc_face_stats_snprintf(s, size, &object->face_stats);
+}
+
+int hc_face_stats_snprintf(char *s, size_t size, const hc_face_stats_t *stats) {
+ return snprintf(
+ s, size,
+ "conn #%u:\tinterests =\t{ rx packets = %u, rx bytes = %u, "
+ "tx packets = %u, tx bytes = %u }\n\t\tdata =\t\t{ rx packets "
+ "= %u, rx bytes = %u, "
+ "tx packets = %u, tx bytes = %u }",
+ stats->conn_id, stats->interests.rx_pkts, stats->interests.rx_bytes,
+ stats->interests.tx_pkts, stats->interests.tx_bytes, stats->data.rx_pkts,
+ stats->data.rx_bytes, stats->data.tx_pkts, stats->data.tx_bytes);
+}
+
+int hc_face_stats_list(hc_sock_t *s, hc_data_t **pdata) {
+ return hc_execute(s, ACTION_LIST, OBJECT_TYPE_FACE_STATS, NULL, pdata);
+}
+
+DECLARE_OBJECT_OPS(OBJECT_TYPE_FACE_STATS, face_stats); \ No newline at end of file
diff --git a/ctrl/libhicnctrl/src/objects/stats.h b/ctrl/libhicnctrl/src/objects/stats.h
new file mode 100644
index 000000000..3a4f04b2e
--- /dev/null
+++ b/ctrl/libhicnctrl/src/objects/stats.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2022 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * \file stats.h
+ * \brief Stats.
+ */
+
+#ifndef HICNCTRL_IMPL_OBJECTS_STATS_H
+#define HICNCTRL_IMPL_OBJECTS_STATS_H
+
+#include "../object_vft.h"
+
+DECLARE_OBJECT_OPS_H(OBJECT_TYPE_STATS, stats);
+DECLARE_OBJECT_OPS_H(OBJECT_TYPE_FACE_STATS, face_stats);
+
+#endif /* HICNCTRL_IMPL_OBJECTS_STATS_H */ \ No newline at end of file