mirror of https://github.com/PentHertz/srsLTE.git
parameterize RLC AM stress tester and add to ctest suite
This commit is contained in:
parent
a85288566b
commit
507ce037bf
|
@ -31,7 +31,8 @@ target_link_libraries(rlc_am_test srslte_upper srslte_phy srslte_common)
|
|||
add_test(rlc_am_test rlc_am_test)
|
||||
|
||||
add_executable(rlc_am_stress_test rlc_am_stress_test.cc)
|
||||
target_link_libraries(rlc_am_stress_test srslte_upper srslte_phy srslte_common)
|
||||
target_link_libraries(rlc_am_stress_test srslte_upper srslte_phy srslte_common ${Boost_LIBRARIES})
|
||||
add_test(rlc_am_stress_test rlc_am_stress_test --duration 10)
|
||||
|
||||
add_executable(rlc_um_data_test rlc_um_data_test.cc)
|
||||
target_link_libraries(rlc_um_data_test srslte_upper srslte_phy srslte_common)
|
||||
|
|
|
@ -31,23 +31,66 @@
|
|||
#include "srslte/common/logger_stdout.h"
|
||||
#include "srslte/common/threads.h"
|
||||
#include "srslte/upper/rlc.h"
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/program_options/parsers.hpp>
|
||||
#include <assert.h>
|
||||
#define NBUFS 5
|
||||
|
||||
using namespace std;
|
||||
using namespace srsue;
|
||||
using namespace srslte;
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
typedef struct {
|
||||
uint32_t test_duration_sec;
|
||||
float error_rate;
|
||||
uint32_t sdu_gen_delay_usec;
|
||||
} stress_test_args_t;
|
||||
|
||||
void parse_args(stress_test_args_t *args, int argc, char *argv[]) {
|
||||
|
||||
// Command line only options
|
||||
bpo::options_description general("General options");
|
||||
|
||||
general.add_options()
|
||||
("help,h", "Produce help message")
|
||||
("version,v", "Print version information and exit");
|
||||
|
||||
// Command line or config file options
|
||||
bpo::options_description common("Configuration options");
|
||||
common.add_options()
|
||||
("duration", bpo::value<uint32_t>(&args->test_duration_sec)->default_value(10), "Duration (sec)")
|
||||
("sdu_gen_delay", bpo::value<uint32_t>(&args->sdu_gen_delay_usec)->default_value(10), "SDU generation delay (usec)")
|
||||
("error_rate", bpo::value<float>(&args->error_rate)->default_value(0.1), "Rate at which RLC PDUs are dropped");
|
||||
|
||||
// these options are allowed on the command line
|
||||
bpo::options_description cmdline_options;
|
||||
cmdline_options.add(common).add(general);
|
||||
|
||||
// parse the command line and store result in vm
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::command_line_parser(argc, argv).options(cmdline_options).run(), vm);
|
||||
bpo::notify(vm);
|
||||
|
||||
// help option was given - print usage and exit
|
||||
if (vm.count("help")) {
|
||||
cout << "Usage: " << argv[0] << " [OPTIONS] config_file" << endl << endl;
|
||||
cout << common << endl << general << endl;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
class mac_reader
|
||||
:public thread
|
||||
{
|
||||
public:
|
||||
mac_reader(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_)
|
||||
mac_reader(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_, uint32_t sdu_gen_delay_usec_)
|
||||
{
|
||||
rlc1 = rlc1_;
|
||||
rlc2 = rlc2_;
|
||||
fail_rate = fail_rate_;
|
||||
run_enable = true;
|
||||
running = false;
|
||||
sdu_gen_delay_usec = sdu_gen_delay_usec_;
|
||||
}
|
||||
|
||||
void stop()
|
||||
|
@ -82,7 +125,7 @@ private:
|
|||
if(((float)rand()/RAND_MAX > fail_rate) && read>0) {
|
||||
rlc2->write_pdu(1, pdu->msg, opp_size);
|
||||
}
|
||||
usleep(100);
|
||||
usleep(sdu_gen_delay_usec);
|
||||
}
|
||||
running = false;
|
||||
byte_buffer_pool::get_instance()->deallocate(pdu);
|
||||
|
@ -91,6 +134,7 @@ private:
|
|||
rlc_interface_mac *rlc1;
|
||||
rlc_interface_mac *rlc2;
|
||||
float fail_rate;
|
||||
uint32_t sdu_gen_delay_usec;
|
||||
|
||||
bool run_enable;
|
||||
bool running;
|
||||
|
@ -100,9 +144,9 @@ class mac_dummy
|
|||
:public srslte::mac_interface_timers
|
||||
{
|
||||
public:
|
||||
mac_dummy(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_)
|
||||
:r1(rlc1_, rlc2_, fail_rate_)
|
||||
,r2(rlc2_, rlc1_, fail_rate_)
|
||||
mac_dummy(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_, uint32_t sdu_gen_delay_usec_)
|
||||
:r1(rlc1_, rlc2_, fail_rate_, sdu_gen_delay_usec_)
|
||||
,r2(rlc2_, rlc1_, fail_rate_, sdu_gen_delay_usec_)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -191,7 +235,7 @@ private:
|
|||
pdu->N_bytes = 1500;
|
||||
pdu->msg[0] = sn++;
|
||||
rlc->write_sdu(1, pdu);
|
||||
usleep(100);
|
||||
usleep(10);
|
||||
}
|
||||
running = false;
|
||||
}
|
||||
|
@ -205,7 +249,7 @@ private:
|
|||
rlc_interface_pdcp *rlc;
|
||||
};
|
||||
|
||||
void stress_test()
|
||||
void stress_test(stress_test_args_t args)
|
||||
{
|
||||
srslte::log_filter log1("RLC_AM_1");
|
||||
srslte::log_filter log2("RLC_AM_2");
|
||||
|
@ -214,14 +258,12 @@ void stress_test()
|
|||
log1.set_hex_limit(-1);
|
||||
log2.set_hex_limit(-1);
|
||||
|
||||
float fail_rate = 0.1;
|
||||
|
||||
rlc rlc1;
|
||||
rlc rlc2;
|
||||
|
||||
rlc_am_tester tester1(&rlc1, "tester1");
|
||||
rlc_am_tester tester2(&rlc2, "tester2");
|
||||
mac_dummy mac(&rlc1, &rlc2, fail_rate);
|
||||
mac_dummy mac(&rlc1, &rlc2, args.error_rate, args.sdu_gen_delay_usec);
|
||||
ue_interface ue;
|
||||
|
||||
rlc1.init(&tester1, &tester1, &ue, &log1, &mac, 0);
|
||||
|
@ -245,7 +287,7 @@ void stress_test()
|
|||
tester2.start(7);
|
||||
mac.start();
|
||||
|
||||
usleep(100e6);
|
||||
usleep(args.test_duration_sec * 1e6);
|
||||
|
||||
tester1.stop();
|
||||
tester2.stop();
|
||||
|
@ -254,6 +296,9 @@ void stress_test()
|
|||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
stress_test();
|
||||
stress_test_args_t args;
|
||||
parse_args(&args, argc, argv);
|
||||
|
||||
stress_test(args);
|
||||
byte_buffer_pool::get_instance()->cleanup();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue