Browse Source

change avg_delay handling for extended conversations of UDP

fix some casts
Jens Keim 4 years ago
parent
commit
c468253ce7

+ 1 - 1
code_boost/src/cxx/statistics.cpp

@@ -467,7 +467,7 @@ void statistics::createCommIntervalStats(){
                 time_between_ints_sum += intervals[i].start - intervals[i - 1].end;
             }
 
-            entry.avg_int_pkts_count = summed_pkts_count / ((double) intervals.size());
+            entry.avg_int_pkts_count = static_cast<double>(summed_pkts_count) / static_cast<double>(intervals.size());
             entry.avg_time_between_ints = (time_between_ints_sum.count() / (double) (intervals.size() - 1)) / (double) 1e6;
             entry.avg_interval_time = (summed_int_duration.count() / (double) intervals.size()) / (double) 1e6;
 

+ 6 - 6
code_boost/src/cxx/statistics_db.cpp

@@ -574,9 +574,9 @@ void statistics_db::writeStatisticsConvExt(std::unordered_map<convWithProt, entr
                         minDelay = e.interarrival_time[i].count();
                 }
                 if (e.interarrival_time.size() > 0)
-                    e.avg_interarrival_time = (std::chrono::microseconds) sumDelay / e.interarrival_time.size(); // average
+                    e.avg_interarrival_time = static_cast<std::chrono::microseconds>(sumDelay) / e.interarrival_time.size(); // average
                 else
-                    e.avg_interarrival_time = (std::chrono::microseconds) 0;
+                    e.avg_interarrival_time = static_cast<std::chrono::microseconds>(0);
             }
 
             if (e.total_comm_duration == 0)
@@ -590,13 +590,13 @@ void statistics_db::writeStatisticsConvExt(std::unordered_map<convWithProt, entr
                 query.bindNoCopy(3, f.ipAddressB);
                 query.bind(4, f.portB);
                 query.bindNoCopy(5, f.protocol);
-                query.bind(6, (int) e.pkts_count);
-                query.bind(7, (float) e.avg_pkt_rate);
+                query.bind(6, static_cast<int>(e.pkts_count));
+                query.bind(7, static_cast<float>(e.avg_pkt_rate));
 
-                if (f.protocol == "UDP" || (f.protocol == "TCP" && e.pkts_count < 2))
+                if ((f.protocol == "UDP" || f.protocol == "TCP") && e.pkts_count < 2)
                     query.bind(8);
                 else
-                    query.bind(8, (int) e.avg_interarrival_time.count());
+                    query.bind(8, static_cast<int>(e.avg_interarrival_time.count()));
 
                 if (minDelay == -1)
                     query.bind(9);

+ 1 - 1
code_boost/src/cxx/statistics_db.h

@@ -26,7 +26,7 @@ public:
     /*
      * Database version: Increment number on every change in the C++ code!
      */
-    static const int DB_VERSION = 26;
+    static const int DB_VERSION = 27;
 
     /*
      * Methods to read from database