Skip to content

Commit

Permalink
Merge pull request #38 from OpenHD/consti-dev
Browse files Browse the repository at this point in the history
add foreign packets per second stat
  • Loading branch information
Consti10 authored Sep 28, 2023
2 parents a34b6d8 + 71f92a3 commit cb97192
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 cb97192

Please sign in to comment.