statistics_db.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. *
  3. */
  4. #ifndef CPP_PCAPREADER_STATISTICSDB_H
  5. #define CPP_PCAPREADER_STATISTICSDB_H
  6. #include <string>
  7. #include "statistics.h"
  8. #include <SQLiteCpp/SQLiteCpp.h>
  9. class statistics_db {
  10. public:
  11. /*
  12. * Constructor: Creates new database / Opens existing database
  13. */
  14. statistics_db(std::string database_path);
  15. /*
  16. * Methods for writing values into database
  17. */
  18. void writeStatisticsIP(std::unordered_map<std::string, entry_ipStat> ipStatistics);
  19. void writeStatisticsTTL(std::unordered_map<ipAddress_ttl, int> ttlDistribution);
  20. void writeStatisticsProtocols(std::unordered_map<ipAddress_protocol, int> protocolDistribution);
  21. void writeStatisticsPorts(std::unordered_map<ipAddress_inOut_port, int> portsStatistics);
  22. void writeStatisticsIpMac(std::unordered_map<std::string, std::string> IpMacStatistics);
  23. void writeStatisticsMss(std::unordered_map<std::string, int> mssStatistics);
  24. void writeStatisticsFile(int packetCount, float captureDuration, std::string timestampFirstPkt,
  25. std::string timestampLastPkt, float avgPacketRate, float avgPacketSize,
  26. float avgPacketsSentPerHost, float avgBandwidthIn, float avgBandwidthOut);
  27. private:
  28. // Pointer to the SQLite database
  29. std::unique_ptr<SQLite::Database> db;
  30. };
  31. #endif //CPP_PCAPREADER_STATISTICSDB_H