Skip to content

Commit

Permalink
add foreign packets per second stat
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 28, 2023
1 parent 6a6db50 commit 71f92a3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,16 +758,15 @@ void WBTxRx::recalculate_pollution_perc() {
if(elapsed<=std::chrono::seconds(1)){
return ;
}
if(m_pollution_total_rx_packets<=0 || m_pollution_openhd_rx_packets<=0 ){
return ;
}
m_last_pollution_calculation=std::chrono::steady_clock::now();
const auto non_openhd_packets=m_pollution_total_rx_packets-m_pollution_openhd_rx_packets;
if(m_pollution_total_rx_packets>0){
double perc_non_openhd_packets=(double)non_openhd_packets/(double)m_pollution_total_rx_packets*100.0;
//m_console->debug("Link pollution: {}% [{}:{}]",perc_non_openhd_packets,non_openhd_packets,m_pollution_total_rx_packets);
m_rx_stats.curr_link_pollution_perc=std::ceil(perc_non_openhd_packets);
//curr_link_pollution_perc=std::ceil();
}else{
m_rx_stats.curr_link_pollution_perc=0;
}
const int elapsed_ms=static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
m_rx_stats.curr_n_foreign_packets_pps=(int)non_openhd_packets * 1000 / elapsed_ms;
Expand Down

0 comments on commit 71f92a3

Please sign in to comment.