Skip to content

Commit

Permalink
injection rate test
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Jul 25, 2023
1 parent 34bb27a commit 028a174
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
21 changes: 9 additions & 12 deletions executables/injection_rate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ static TestResult increase_pps_until_fail(std::shared_ptr<WBTxRx> txrx,const int
txrx->tx_reset_stats();
stream_generator->start();
m_console->info("Testing MCS {} with {} pps", mcs, pps);
/*const auto begin=std::chrono::steady_clock::now();
while (std::chrono::steady_clock::now()-begin<std::chrono::seconds(5)){
auto txstats=txrx->get_tx_stats();
if(txstats.count_tx_injections_error_hint>0 || stream_generator->n_times_cannot_keep_up_wanted_pps>20){
// stop early
break ;
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}*/
std::this_thread::sleep_for(std::chrono::seconds(3));
const auto txstats = txrx->get_tx_stats();
if (txstats.count_tx_injections_error_hint > 0 || stream_generator->n_times_cannot_keep_up_wanted_pps>10 ) {
Expand Down Expand Up @@ -200,19 +191,25 @@ void long_test(std::shared_ptr<WBTxRx> txrx,bool use_40mhz){
txrx->tx_update_channel_width(freq_w);
const auto res_first= calculate_rough(txrx,50);
const auto res_second= calculate_rough(txrx,50);
const auto res_third= calculate_rough(txrx,50);
m_console->info("First run:");
print_test_results_rough(res_first);
m_console->info("Second run:");
print_test_results_rough(res_second);
m_console->info("Third run:");
print_test_results_rough(res_third);
m_console->info("---------------------------");
m_console->info("First run:");
print_test_results_and_theoretical(res_first, use_40mhz);
m_console->info("Second run:");
print_test_results_and_theoretical(res_second, use_40mhz);
m_console->info("Third run:");
print_test_results_and_theoretical(res_third, use_40mhz);
for(int i=0;i<res_first.size();i++){
m_console->info("MCS {} possible {}--{}",res_first.at(i).mcs_index,
m_console->info("MCS {} possible {}--{}--{}",res_first.at(i).mcs_index,
StringHelper::bitrate_readable(res_first.at(i).pass_bps_measured),
StringHelper::bitrate_readable(res_second.at(i).pass_bps_measured));
StringHelper::bitrate_readable(res_second.at(i).pass_bps_measured),
StringHelper::bitrate_readable(res_third.at(i).pass_bps_measured));
}
}

Expand Down Expand Up @@ -271,7 +268,7 @@ int main(int argc, char *const *argv) {
//m_console->info("Short guard");
//print_test_results_rough(res_sgi);

long_test(txrx, false);
long_test(txrx, true);

/*txrx->tx_update_channel_width(20);
const auto res_20mhz= calculate_rough(txrx,20);
Expand Down
16 changes: 8 additions & 8 deletions src/HelperSources/Rates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ static std::vector<Rate> openhd_rtl8812au_5G_practical_rates() {
Rate{11000,0}, // MCS 1
Rate{15000,0}, // MCS 2
Rate{19000,0}, // MCS 3
Rate{26120,0}, // MCS 4
Rate{33230,0}, // MCS 5
Rate{33330,0}, // MCS 6
Rate{36060,0}, // MCS 7
Rate{5530 ,0}, // MCS 8
Rate{11480,0}, // MCS 9
Rate{13810,0}, // MCS 10
Rate{14240,0}, // MCS 11
Rate{26000,0}, // MCS 4
Rate{26000,0}, // MCS 5
Rate{32000,0}, // MCS 6
Rate{38000,0}, // MCS 7
Rate{11000 ,0}, // MCS 8
Rate{19000,0}, // MCS 9
Rate{27000,0}, // MCS 10
Rate{32000,0}, // MCS 11
};
}

Expand Down
7 changes: 4 additions & 3 deletions src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void WBTxRx::on_new_packet(const uint8_t wlan_idx, const pcap_pkthdr &hdr,
// Same for iee80211 seq nr
uint16_t iee_seq_nr=parsedPacket->ieee80211Header->getSequenceNumber();
m_seq_nr_helper_iee80211.on_new_sequence_number(iee_seq_nr);
m_console->debug("IEE SEQ NR PACKET LOSS {}",m_seq_nr_helper_iee80211.get_current_loss_percent());
//m_console->debug("IEE SEQ NR PACKET LOSS {}",m_seq_nr_helper_iee80211.get_current_loss_percent());
}
// Adjustment of which card is used for injecting packets in case there are multiple RX card(s)
if(m_wifi_cards.size()>1 && m_options.enable_auto_switch_tx_card){
Expand Down Expand Up @@ -502,8 +502,9 @@ bool WBTxRx::get_card_has_disconnected(int card_idx) {
return m_card_is_disconnected[card_idx];
}
std::string WBTxRx::tx_stats_to_string(const WBTxRx::TxStats& data) {
return fmt::format("TxStats[injected packets:{} bytes:{} tx errors:{} pps:{} bps:{}-{}]",
data.n_injected_packets,data.n_injected_bytes_including_overhead,data.count_tx_injections_error_hint,
return fmt::format("TxStats[injected packets:{} bytes:{} tx errors:{}-{} pps:{} bps:{}-{}]",
data.n_injected_packets,data.n_injected_bytes_including_overhead,
data.count_tx_injections_error_hint,data.count_tx_errors,
data.curr_packets_per_second,
StringHelper::bitrate_readable(data.curr_bits_per_second_excluding_overhead),
StringHelper::bitrate_readable(data.curr_bits_per_second_including_overhead));
Expand Down
7 changes: 4 additions & 3 deletions src/WBTxRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ class WBTxRx {
int64_t n_injected_bytes_excluding_overhead =0;
// including wifi / radiotap / encryption overhead
int64_t n_injected_bytes_including_overhead =0;
// recalculated in X second intervals
int curr_packets_per_second=-1;
int curr_bits_per_second_excluding_overhead=-1;
int curr_bits_per_second_including_overhead=-1;
// tx error hint, first sign the tx can't keep up with the provided bitrate
int32_t count_tx_injections_error_hint=0;
// actual tx errors
int32_t count_tx_errors=0;
int curr_packets_per_second=-1;
int curr_bits_per_second_excluding_overhead=-1;
int curr_bits_per_second_including_overhead=-1;
};
struct RxStats{
// Total count of received packets / bytes - can be from another wb tx, but also from someone else using wifi
Expand Down

0 comments on commit 028a174

Please sign in to comment.