Skip to content

Commit

Permalink
optimize loss recalculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Aug 9, 2023
1 parent 085129f commit f584076
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/HelperSources/NonceSeqNrHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class NonceSeqNrHelper{
// recalculate the loss in percentage in fixed intervals
// resets the received and missing packet count
void recalculate_loss_if_needed(){
if(std::chrono::steady_clock::now()-m_last_loss_perc_recalculation>std::chrono::seconds(2)){
const auto elapsed=std::chrono::steady_clock::now()-m_last_loss_perc_recalculation;
if(elapsed>=std::chrono::seconds(2) || m_n_received_packets>500){
m_last_loss_perc_recalculation=std::chrono::steady_clock::now();
const auto n_total_packets=m_n_received_packets+m_n_missing_packets;
//m_console->debug("x_n_missing_packets:{} x_n_received_packets:{} n_total_packets:{}",x_n_missing_packets,x_n_received_packets,n_total_packets);
Expand Down
5 changes: 4 additions & 1 deletion src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ void WBTxRx::on_new_packet(const uint8_t wlan_idx, const pcap_pkthdr &hdr,
const auto rssi=parsedPacket->allAntennaValues[0].rssi;
auto opt_minmaxavg= this_wifi_card_calc.card_rssi.add_and_recalculate_if_needed(rssi);
if(opt_minmaxavg.has_value()){
this_wifi_card_stats.card_dbm=opt_minmaxavg.value().avg;
// See below for how this value is calculated on rtl8812au
if(m_wifi_cards[wlan_idx].type!=WIFI_CARD_TYPE_RTL8812AU){
this_wifi_card_stats.card_dbm=opt_minmaxavg.value().avg;
}
if(m_options.debug_rssi>=1){
m_console->debug("Card{}:{}",wlan_idx, RSSIAccumulator::min_max_avg_to_string(opt_minmaxavg.value(), false));
}
Expand Down

0 comments on commit f584076

Please sign in to comment.