src: Implement packet statistics collection
refs: #2955, #2956
Change-Id: I57476a63562dbd378e566ad0280c89ccc5883e3e
diff --git a/src/statistics.hpp b/src/statistics.hpp
new file mode 100644
index 0000000..435938f
--- /dev/null
+++ b/src/statistics.hpp
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2017, The University of Memphis,
+ * Regents of the University of California,
+ * Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#ifndef NLSR_STATISTICS_HPP
+#define NLSR_STATISTICS_HPP
+
+#include <map>
+
+namespace nlsr {
+
+class Statistics
+{
+
+public:
+ enum class PacketType {
+ SENT_HELLO_INTEREST,
+ SENT_HELLO_DATA,
+ RCV_HELLO_INTEREST,
+ RCV_HELLO_DATA,
+ SENT_LSA_INTEREST,
+ SENT_ADJ_LSA_INTEREST,
+ SENT_COORD_LSA_INTEREST,
+ SENT_NAME_LSA_INTEREST,
+ SENT_LSA_DATA,
+ SENT_ADJ_LSA_DATA,
+ SENT_COORD_LSA_DATA,
+ SENT_NAME_LSA_DATA,
+ RCV_LSA_INTEREST,
+ RCV_ADJ_LSA_INTEREST,
+ RCV_COORD_LSA_INTEREST,
+ RCV_NAME_LSA_INTEREST,
+ RCV_LSA_DATA,
+ RCV_ADJ_LSA_DATA,
+ RCV_COORD_LSA_DATA,
+ RCV_NAME_LSA_DATA
+ };
+
+ size_t
+ get(PacketType) const;
+
+ void
+ resetAll();
+
+ void
+ increment(PacketType);
+
+ const std::map<PacketType,int>&
+ getCounter() const
+ {
+ return m_packetCounter;
+ }
+
+private:
+ std::map<PacketType,int> m_packetCounter;
+};
+
+std::ostream&
+operator<<(std::ostream&, const Statistics& stats);
+
+} // namespace nlsr
+
+#endif // NLSR_STATISTICS_HPP