statistics.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "statistics.hpp"
23 #include "nlsr.hpp"
24 #include "utility/name-helper.hpp"
25 
26 namespace nlsr {
27 
28 size_t
30 {
31  std::map<PacketType,int>::const_iterator it = m_packetCounter.find(type);
32  if(it != m_packetCounter.end())
33  {
34  return it->second;
35  }
36  else
37  {
38  return 0;
39  }
40 }
41 
42 void
44 {
45  m_packetCounter[type]++;
46 }
47 
48 void
50 {
51  for (auto&& it : m_packetCounter )
52  {
53  it.second = 0;
54  }
55 }
56 
57 std::ostream&
58 operator<<(std::ostream& os, const Statistics& stats)
59 {
61 
62  os << "++++++++++++++++++++++++++++++++++++++++\n"
63  << "+ +\n"
64  << "+ Statistics +\n"
65  << "+ +\n"
66  << "++++++++++++++++++++++++++++++++++++++++\n"
67  << "HELLO PROTOCOL\n"
68  << " Sent Hello Interests: " << stats.get(PacketType::SENT_HELLO_INTEREST) << "\n"
69  << " Sent Hello Data: " << stats.get(PacketType::SENT_HELLO_DATA) << "\n"
70  << "\n"
71  << " Received Hello Interests: " << stats.get(PacketType::RCV_HELLO_INTEREST) << "\n"
72  << " Received Hello Data: " << stats.get(PacketType::RCV_HELLO_DATA) << "\n"
73  << "\n"
74  << "LSDB\n"
75  << " Total Sent LSA Interests: " << stats.get(PacketType::SENT_LSA_INTEREST) << "\n"
76  << " Total Received LSA Interests: " << stats.get(PacketType::RCV_LSA_INTEREST) << "\n"
77  << "\n"
78  << " Total Sent LSA Data: " << stats.get(PacketType::SENT_LSA_DATA) << "\n"
79  << " Total Received LSA Data: " << stats.get(PacketType::RCV_LSA_DATA) << "\n"
80  << "\n"
81  << " Sent Adjacency LSA Interests: " << stats.get(PacketType::SENT_ADJ_LSA_INTEREST) << "\n"
82  << " Sent Coordinate LSA Interests: " << stats.get(PacketType::SENT_COORD_LSA_INTEREST) << "\n"
83  << " Sent Name LSA Interests: " << stats.get(PacketType::SENT_NAME_LSA_INTEREST) << "\n"
84  << "\n"
85  << " Received Adjacency LSA Interests: " << stats.get(PacketType::RCV_ADJ_LSA_INTEREST) << "\n"
86  << " Received Coordinate LSA Interests: " << stats.get(PacketType::RCV_COORD_LSA_INTEREST) << "\n"
87  << " Received Name LSA Interests: " << stats.get(PacketType::RCV_NAME_LSA_INTEREST) << "\n"
88  << "\n"
89  << " Sent Adjacency LSA Data: " << stats.get(PacketType::SENT_ADJ_LSA_DATA) << "\n"
90  << " Sent Coordinate LSA Data: " << stats.get(PacketType::SENT_COORD_LSA_DATA) << "\n"
91  << " Sent Name LSA Data: " << stats.get(PacketType::SENT_NAME_LSA_DATA) << "\n"
92  << "\n"
93  << " Received Adjacency LSA Data: " << stats.get(PacketType::RCV_ADJ_LSA_DATA) << "\n"
94  << " Received Coordinate LSA Data: " << stats.get(PacketType::RCV_COORD_LSA_DATA) << "\n"
95  << " Received Name LSA Data: " << stats.get(PacketType::RCV_NAME_LSA_DATA) << "\n"
96  << "++++++++++++++++++++++++++++++++++++++++\n";
97 
98  return os;
99 }
100 
101 } // namespace nlsr
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:99
size_t get(PacketType) const
Definition: statistics.cpp:29
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void increment(PacketType)
Definition: statistics.cpp:43