/** * Class writing the statistics to the database. */ #ifndef CPP_PCAPREADER_STATISTICSDB_H #define CPP_PCAPREADER_STATISTICSDB_H #include #include #include #include "statistics.h" #include #include #include namespace py = pybind11; class statistics_db { public: /* * Constructor: Creates new database / Opens existing database */ statistics_db(std::string database_path, std::string resourcePath); /* * Database version: Increment number on every change in the C++ code! */ static const int DB_VERSION = 21; /* * Methods to read from database */ void getNoneExtraTestsInveralStats(std::vector& intervals); /* * Methods for writing values into database */ void writeStatisticsIP(const std::unordered_map &ipStatistics); void writeStatisticsDegree(const std::unordered_map &ipStatistics); void writeStatisticsTTL(const std::unordered_map &ttlDistribution); void writeStatisticsMSS(const std::unordered_map &mssDistribution); void writeStatisticsToS(const std::unordered_map &tosDistribution); void writeStatisticsWin(const std::unordered_map &winDistribution); void writeStatisticsProtocols(const std::unordered_map &protocolDistribution); void writeStatisticsPorts(const std::unordered_map &portsStatistics); void writeStatisticsIpMac(const std::unordered_map &IpMacStatistics); void writeStatisticsFile(int packetCount, float captureDuration, std::string timestampFirstPkt, std::string timestampLastPkt, float avgPacketRate, float avgPacketSize, float avgPacketsSentPerHost, float avgBandwidthIn, float avgBandwidthOut, bool doExtraTests); void writeStatisticsConv(std::unordered_map &convStatistics); void writeStatisticsConvExt(std::unordered_map &conv_statistics_extended); void writeStatisticsInterval(const std::unordered_map &intervalStatistics, std::vector> timeInterval, bool del, int defaultInterval, bool extraTests); void writeDbVersion(); void readPortServicesFromNmap(); void writeStatisticsUnrecognizedPDUs(const std::unordered_map &unrecognized_PDUs); private: // Pointer to the SQLite database std::unique_ptr db; // Vector which contains all ports and their corresponding services std::unordered_map portServices; std::string resourcePath; }; #endif //CPP_PCAPREADER_STATISTICSDB_H