From 3dddae0566a6e8eefda35c71421196aa520bb732 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Feb 2018 12:18:29 +0100 Subject: [PATCH 01/16] rrc: check pool buffer allocation and handle error --- srsue/src/upper/rrc.cc | 43 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 1aecb273b..cade0e306 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -1529,10 +1529,13 @@ byte_buffer_t* rrc::byte_align_and_pack(byte_buffer_t *pdu) pdcp_buf = pool_allocate; } - srslte_bit_pack_vector(bit_buf.msg, pdcp_buf->msg, bit_buf.N_bits); - pdcp_buf->N_bytes = bit_buf.N_bits / 8; - pdcp_buf->set_timestamp(); - + if (pdcp_buf != NULL) { + srslte_bit_pack_vector(bit_buf.msg, pdcp_buf->msg, bit_buf.N_bits); + pdcp_buf->N_bytes = bit_buf.N_bits / 8; + pdcp_buf->set_timestamp(); + } else { + rrc_log->error("Fatal Error: Couldn't allocate PDU in byte_align_and_pack().\n"); + } return pdcp_buf; } @@ -1540,20 +1543,21 @@ void rrc::send_ul_ccch_msg(byte_buffer_t *pdu) { liblte_rrc_pack_ul_ccch_msg(&ul_ccch_msg, (LIBLTE_BIT_MSG_STRUCT *) &bit_buf); pdu = byte_align_and_pack(pdu); + if (pdu) { + // Set UE contention resolution ID in MAC + uint64_t uecri = 0; + uint8_t *ue_cri_ptr = (uint8_t *) &uecri; + uint32_t nbytes = 6; + for (uint32_t i = 0; i < nbytes; i++) { + ue_cri_ptr[nbytes - i - 1] = pdu->msg[i]; + } - // Set UE contention resolution ID in MAC - uint64_t uecri = 0; - uint8_t *ue_cri_ptr = (uint8_t *) &uecri; - uint32_t nbytes = 6; - for (uint32_t i = 0; i < nbytes; i++) { - ue_cri_ptr[nbytes - i - 1] = pdu->msg[i]; - } - - rrc_log->debug("Setting UE contention resolution ID: %d\n", uecri); - mac->set_contention_id(uecri); + rrc_log->debug("Setting UE contention resolution ID: %d\n", uecri); + mac->set_contention_id(uecri); - rrc_log->info("Sending %s\n", liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); - pdcp->write_sdu(RB_ID_SRB0, pdu); + rrc_log->info("Sending %s\n", liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); + pdcp->write_sdu(RB_ID_SRB0, pdu); + } } void rrc::send_ul_dcch_msg(byte_buffer_t *pdu) @@ -1561,9 +1565,10 @@ void rrc::send_ul_dcch_msg(byte_buffer_t *pdu) liblte_rrc_pack_ul_dcch_msg(&ul_dcch_msg, (LIBLTE_BIT_MSG_STRUCT *) &bit_buf); pdu = byte_align_and_pack(pdu); - - rrc_log->info("Sending %s\n", liblte_rrc_ul_dcch_msg_type_text[ul_dcch_msg.msg_type]); - pdcp->write_sdu(RB_ID_SRB1, pdu); + if (pdu) { + rrc_log->info("Sending %s\n", liblte_rrc_ul_dcch_msg_type_text[ul_dcch_msg.msg_type]); + pdcp->write_sdu(RB_ID_SRB1, pdu); + } } void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) { From a85288566bb7786856a058db44f0b4bf6c3d90e9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Feb 2018 13:51:20 +0100 Subject: [PATCH 02/16] print summary about allocated buffers when buffer pool is full --- lib/include/srslte/common/buffer_pool.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index e48144b6f..4edc50fc6 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include /******************************************************************************* @@ -76,8 +78,13 @@ public: { printf("%d buffers in queue\n", (int) used.size()); #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED + std::map buffer_cnt; for (uint32_t i=0;idebug_name)?used[i]->debug_name:"Undefined"); + buffer_cnt[strlen(used[i]->debug_name)?used[i]->debug_name:"Undefined"]++; + } + std::map::iterator it; + for (it = buffer_cnt.begin(); it != buffer_cnt.end(); it++) { + printf(" - %dx %s\n", it->second, it->first.c_str()); } #endif } From 507ce037bfa756e4c9843757fa104c7ee949ed4e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Feb 2018 14:07:27 +0100 Subject: [PATCH 03/16] parameterize RLC AM stress tester and add to ctest suite --- lib/test/upper/CMakeLists.txt | 3 +- lib/test/upper/rlc_am_stress_test.cc | 71 +++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/lib/test/upper/CMakeLists.txt b/lib/test/upper/CMakeLists.txt index 8793118e7..79bbb8331 100644 --- a/lib/test/upper/CMakeLists.txt +++ b/lib/test/upper/CMakeLists.txt @@ -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) diff --git a/lib/test/upper/rlc_am_stress_test.cc b/lib/test/upper/rlc_am_stress_test.cc index 137236b4a..c5cf4e877 100644 --- a/lib/test/upper/rlc_am_stress_test.cc +++ b/lib/test/upper/rlc_am_stress_test.cc @@ -31,23 +31,66 @@ #include "srslte/common/logger_stdout.h" #include "srslte/common/threads.h" #include "srslte/upper/rlc.h" +#include +#include #include -#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(&args->test_duration_sec)->default_value(10), "Duration (sec)") + ("sdu_gen_delay", bpo::value(&args->sdu_gen_delay_usec)->default_value(10), "SDU generation delay (usec)") + ("error_rate", bpo::value(&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(); } From 2c85da3e4ba41ec5d4f82532de8faf9e227a23e5 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:18:38 +0100 Subject: [PATCH 04/16] initilize variable in log_filter --- lib/src/common/log_filter.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index b498d466c..8b72a3c2b 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -40,6 +40,7 @@ log_filter::log_filter() do_tti = false; time_src = NULL; time_format = TIME; + logger_h = NULL; } log_filter::log_filter(std::string layer) From f60a9eab415ac08bb8c5e2e8591d3207d1abe058 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:20:34 +0100 Subject: [PATCH 05/16] initialize RF UHD handler in init --- lib/src/phy/rf/rf_uhd_imp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index 07eacbfb7..a1bec2657 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -334,11 +334,12 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels) perror("malloc"); return -1; } + bzero(handler, sizeof(rf_uhd_handler_t)); *h = handler; - + /* Set priority to UHD threads */ uhd_set_thread_priority(uhd_default_thread_priority, true); - + /* Find available devices */ uhd_string_vector_handle devices_str; uhd_string_vector_make(&devices_str); From 4a279150224c54cc5f76cd426613aef11a25cae0 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:21:58 +0100 Subject: [PATCH 06/16] bzero dft object during init, add call to fftw_cleanup in dft_exit --- lib/src/phy/dft/dft_fftw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/phy/dft/dft_fftw.c b/lib/src/phy/dft/dft_fftw.c index e6eb70ecf..ede6ce69b 100644 --- a/lib/src/phy/dft/dft_fftw.c +++ b/lib/src/phy/dft/dft_fftw.c @@ -58,10 +58,12 @@ void srslte_dft_exit() { #ifdef FFTW_WISDOM_FILE fftwf_export_wisdom_to_filename(FFTW_WISDOM_FILE); #endif + fftwf_cleanup(); } int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir, srslte_dft_mode_t mode) { + bzero(plan, sizeof(srslte_dft_plan_t)); if(mode == SRSLTE_DFT_COMPLEX){ return srslte_dft_plan_c(plan,dft_points,dir); } else { From 1efcea7e47f88e5fde2b06eec1ee81c3c6e347c8 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:29:10 +0100 Subject: [PATCH 07/16] call dft_exit in various tests --- lib/src/phy/dft/test/ofdm_test.c | 3 +++ lib/src/phy/utils/test/dft_test.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/src/phy/dft/test/ofdm_test.c b/lib/src/phy/dft/test/ofdm_test.c index e77fcd39e..c40be4d0a 100644 --- a/lib/src/phy/dft/test/ofdm_test.c +++ b/lib/src/phy/dft/test/ofdm_test.c @@ -171,5 +171,8 @@ int main(int argc, char **argv) { n_prb++; } + + srslte_dft_exit(); + exit(0); } diff --git a/lib/src/phy/utils/test/dft_test.c b/lib/src/phy/utils/test/dft_test.c index fd5a308a7..b880f8027 100644 --- a/lib/src/phy/utils/test/dft_test.c +++ b/lib/src/phy/utils/test/dft_test.c @@ -157,6 +157,8 @@ int main(int argc, char **argv) { if(test_dft(in) != 0) return -1; + srslte_dft_exit(); + free(in); printf("Done\n"); exit(0); From 57bb831f27c4eb005039b991ef9e80758e67d08d Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:32:21 +0100 Subject: [PATCH 08/16] fix RM turbo test --- lib/src/phy/fec/test/rm_turbo_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/phy/fec/test/rm_turbo_test.c b/lib/src/phy/fec/test/rm_turbo_test.c index 1c5b2abf5..c8a0a95b5 100644 --- a/lib/src/phy/fec/test/rm_turbo_test.c +++ b/lib/src/phy/fec/test/rm_turbo_test.c @@ -198,6 +198,8 @@ int main(int argc, char **argv) { } srslte_rm_turbo_free_tables(); + free(rm_bits_s); + free(rm_bits_f); free(rm_bits); free(rm_bits2); free(rm_bits2_bytes); From 281611b26aabb1bffc2407e5b80d20206bc0c065 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 13:45:49 +0100 Subject: [PATCH 09/16] allow n param in pss_usrp test --- lib/src/phy/sync/test/pss_usrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/sync/test/pss_usrp.c b/lib/src/phy/sync/test/pss_usrp.c index d82555c95..08afdd025 100644 --- a/lib/src/phy/sync/test/pss_usrp.c +++ b/lib/src/phy/sync/test/pss_usrp.c @@ -74,7 +74,7 @@ void usage(char *prog) { void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "adgetvsfil")) != -1) { + while ((opt = getopt(argc, argv, "adgetvnsfil")) != -1) { switch (opt) { case 'a': rf_args = argv[optind]; From f6ee0e1c8a49f53c0c27eacd902288ae14045349 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 15:47:14 +0100 Subject: [PATCH 10/16] move byte_buffer to UE base class --- srsue/hdr/ue.h | 2 -- srsue/hdr/ue_base.h | 5 ++++- srsue/src/ue.cc | 2 -- srsue/src/ue_base.cc | 6 ++++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index e36277461..e6c66b540 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -110,8 +110,6 @@ private: srslte::log_filter gw_log; srslte::log_filter usim_log; - srslte::byte_buffer_pool *pool; - all_args_t *args; bool started; diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index 256813d5f..201f63843 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -146,7 +146,7 @@ class ue_base { public: ue_base(); - virtual ~ue_base() {} + virtual ~ue_base(); static ue_base* get_instance(srsue_instance_type_t type); @@ -173,6 +173,9 @@ public: std::string get_build_mode(); std::string get_build_info(); std::string get_build_string(); + +private: + srslte::byte_buffer_pool *pool; }; } // namespace srsue diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 2f8fa5794..1de1ddbd0 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -40,12 +40,10 @@ namespace srsue{ ue::ue() :started(false) { - pool = byte_buffer_pool::get_instance(); } ue::~ue() { - byte_buffer_pool::cleanup(); } bool ue::init(all_args_t *args_) diff --git a/srsue/src/ue_base.cc b/srsue/src/ue_base.cc index 4b2c372ae..a4264a099 100644 --- a/srsue/src/ue_base.cc +++ b/srsue/src/ue_base.cc @@ -64,6 +64,12 @@ ue_base::ue_base() { // load FFTW wisdom srslte_dft_load(); + + pool = byte_buffer_pool::get_instance(); +} + +ue_base::~ue_base() { + byte_buffer_pool::cleanup(); } void ue_base::cleanup(void) From 8fcf25360eab03c6c70ceca2e091b92c020473c6 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 15:48:38 +0100 Subject: [PATCH 11/16] fix missing newline --- srsue/src/phy/phch_recv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index a6f1a5d84..81c964a7b 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -954,7 +954,7 @@ phch_recv::sfn_sync::ret_code phch_recv::sfn_sync::run_subframe(srslte_cell_t *c srslte_ue_sync_decode_sss_on_track(ue_sync, true); int ret = srslte_ue_sync_zerocopy_multi(ue_sync, buffer); if (ret < 0) { - Error("SYNC: Error calling ue_sync_get_buffer"); + Error("SYNC: Error calling ue_sync_get_buffer.\n"); return ERROR; } From 20e6ed102e03880dc702ba25d79845a431896d9b Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 15:50:22 +0100 Subject: [PATCH 12/16] fix when accessing uninitialized file --- lib/src/common/logger_file.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/common/logger_file.cc b/lib/src/common/logger_file.cc index 25155da08..a911ae20e 100644 --- a/lib/src/common/logger_file.cc +++ b/lib/src/common/logger_file.cc @@ -35,6 +35,7 @@ namespace srslte{ logger_file::logger_file() :inited(false) + ,logfile(NULL) ,not_done(true) ,cur_length(0) ,max_length(0) @@ -46,7 +47,9 @@ logger_file::~logger_file() { if(inited) { wait_thread_finish(); flush(); - fclose(logfile); + if (logfile) { + fclose(logfile); + } } } From 5cfffd11e102ef504cfa213d07316d5fd58242d9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Feb 2018 15:51:13 +0100 Subject: [PATCH 13/16] Revert "only reset SDU buffer in RLC AM/UM" This reverts commit 8d852ddfe5e4f6eedb80e247d62b8628f9643c2f. This commit was needed because the order in which objects where destructed on UE exit was such that the byte_buffer was deleted before RLC_AM dtor was called. --- lib/src/upper/rlc_am.cc | 8 ++++++++ lib/src/upper/rlc_um.cc | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index bc24f20bd..f4dced1ec 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -72,6 +72,14 @@ rlc_am::~rlc_am() { // reset RLC and dealloc SDUs stop(); + + if(rx_sdu) { + pool->deallocate(rx_sdu); + } + + if(tx_sdu) { + pool->deallocate(tx_sdu); + } } void rlc_am::init(srslte::log *log_, diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index 3fbcbaadf..a365a4501 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -136,11 +136,11 @@ void rlc_um::reset() vr_uh = 0; pdu_lost = false; if(rx_sdu) { - rx_sdu->reset(); + pool->deallocate(rx_sdu); } if(tx_sdu) { - tx_sdu->reset(); + pool->deallocate(tx_sdu); } if(mac_timers) { From 07c704b0ddb7b04da4b34f4defafc4bddb62ec33 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Feb 2018 15:43:40 +0100 Subject: [PATCH 14/16] extend RLC AM stress tester to mimic reestablishment --- lib/test/upper/rlc_am_stress_test.cc | 44 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/lib/test/upper/rlc_am_stress_test.cc b/lib/test/upper/rlc_am_stress_test.cc index c5cf4e877..bdee2248b 100644 --- a/lib/test/upper/rlc_am_stress_test.cc +++ b/lib/test/upper/rlc_am_stress_test.cc @@ -44,6 +44,8 @@ typedef struct { uint32_t test_duration_sec; float error_rate; uint32_t sdu_gen_delay_usec; + uint32_t pdu_tx_delay_usec; + bool reestablish; } stress_test_args_t; void parse_args(stress_test_args_t *args, int argc, char *argv[]) { @@ -58,9 +60,11 @@ void parse_args(stress_test_args_t *args, int argc, char *argv[]) { // Command line or config file options bpo::options_description common("Configuration options"); common.add_options() - ("duration", bpo::value(&args->test_duration_sec)->default_value(10), "Duration (sec)") + ("duration", bpo::value(&args->test_duration_sec)->default_value(10), "Duration (sec)") ("sdu_gen_delay", bpo::value(&args->sdu_gen_delay_usec)->default_value(10), "SDU generation delay (usec)") - ("error_rate", bpo::value(&args->error_rate)->default_value(0.1), "Rate at which RLC PDUs are dropped"); + ("pdu_tx_delay", bpo::value(&args->pdu_tx_delay_usec)->default_value(10), "Delay in MAC for transfering PDU from tx'ing RLC to rx'ing RLC (usec)") + ("error_rate", bpo::value(&args->error_rate)->default_value(0.1), "Rate at which RLC PDUs are dropped") + ("reestablish", bpo::value(&args->reestablish)->default_value(false), "Mimic RLC reestablish during execution"); // these options are allowed on the command line bpo::options_description cmdline_options; @@ -83,14 +87,14 @@ class mac_reader :public thread { public: - mac_reader(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_, uint32_t sdu_gen_delay_usec_) + mac_reader(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_, uint32_t pdu_tx_delay_usec_) { rlc1 = rlc1_; rlc2 = rlc2_; fail_rate = fail_rate_; run_enable = true; running = false; - sdu_gen_delay_usec = sdu_gen_delay_usec_; + pdu_tx_delay_usec = pdu_tx_delay_usec_; } void stop() @@ -125,7 +129,7 @@ private: if(((float)rand()/RAND_MAX > fail_rate) && read>0) { rlc2->write_pdu(1, pdu->msg, opp_size); } - usleep(sdu_gen_delay_usec); + usleep(pdu_tx_delay_usec); } running = false; byte_buffer_pool::get_instance()->deallocate(pdu); @@ -134,7 +138,7 @@ private: rlc_interface_mac *rlc1; rlc_interface_mac *rlc2; float fail_rate; - uint32_t sdu_gen_delay_usec; + uint32_t pdu_tx_delay_usec; bool run_enable; bool running; @@ -144,9 +148,9 @@ class mac_dummy :public srslte::mac_interface_timers { public: - 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_) + mac_dummy(rlc_interface_mac *rlc1_, rlc_interface_mac *rlc2_, float fail_rate_, uint32_t pdu_tx_delay) + :r1(rlc1_, rlc2_, fail_rate_, pdu_tx_delay) + ,r2(rlc2_, rlc1_, fail_rate_, pdu_tx_delay) { } @@ -184,12 +188,13 @@ class rlc_am_tester ,public thread { public: - rlc_am_tester(rlc_interface_pdcp *rlc_, std::string name_=""){ + rlc_am_tester(rlc_interface_pdcp *rlc_, std::string name_, uint32_t sdu_gen_delay_usec_){ rlc = rlc_; run_enable = true; running = false; rx_pdus = 0; name = name_; + sdu_gen_delay_usec = sdu_gen_delay_usec_; } void stop() @@ -235,7 +240,7 @@ private: pdu->N_bytes = 1500; pdu->msg[0] = sn++; rlc->write_sdu(1, pdu); - usleep(10); + usleep(sdu_gen_delay_usec); } running = false; } @@ -246,6 +251,8 @@ private: std::string name; + uint32_t sdu_gen_delay_usec; + rlc_interface_pdcp *rlc; }; @@ -261,9 +268,9 @@ void stress_test(stress_test_args_t args) rlc rlc1; rlc rlc2; - rlc_am_tester tester1(&rlc1, "tester1"); - rlc_am_tester tester2(&rlc2, "tester2"); - mac_dummy mac(&rlc1, &rlc2, args.error_rate, args.sdu_gen_delay_usec); + rlc_am_tester tester1(&rlc1, "tester1", args.sdu_gen_delay_usec); + rlc_am_tester tester2(&rlc2, "tester2", args.sdu_gen_delay_usec); + mac_dummy mac(&rlc1, &rlc2, args.error_rate, args.pdu_tx_delay_usec); ue_interface ue; rlc1.init(&tester1, &tester1, &ue, &log1, &mac, 0); @@ -287,7 +294,14 @@ void stress_test(stress_test_args_t args) tester2.start(7); mac.start(); - usleep(args.test_duration_sec * 1e6); + for (uint32_t i = 0; i < args.test_duration_sec; i++) { + // if enabled, mimic reestablishment every second + if (args.reestablish) { + rlc1.reestablish(); + rlc2.reestablish(); + } + usleep(1e6); + } tester1.stop(); tester2.stop(); From c198547728d95fc6b058b8d97e1e738cdfce850c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 23 Feb 2018 13:23:04 +0100 Subject: [PATCH 15/16] add new RF RX error type and make the UHD driver issue that if anything unexpected happens --- lib/include/srslte/phy/rf/rf.h | 1 + lib/src/phy/rf/rf_uhd_imp.c | 22 ++++++++++++++++++++-- srsue/src/ue.cc | 7 ++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/include/srslte/phy/rf/rf.h b/lib/include/srslte/phy/rf/rf.h index 44bde9943..da1600b66 100644 --- a/lib/include/srslte/phy/rf/rf.h +++ b/lib/include/srslte/phy/rf/rf.h @@ -60,6 +60,7 @@ typedef struct { SRSLTE_RF_ERROR_LATE, SRSLTE_RF_ERROR_UNDERFLOW, SRSLTE_RF_ERROR_OVERFLOW, + SRSLTE_RF_ERROR_RX, SRSLTE_RF_ERROR_OTHER } type; int opt; diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index a1bec2657..0370fa700 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -96,6 +96,19 @@ static void log_underflow(rf_uhd_handler_t *h) { } } +static void log_rx_error(rf_uhd_handler_t *h) { + if (h->uhd_error_handler) { + char error_string[512]; + uhd_usrp_last_error(h->usrp, error_string, 512); + fprintf(stderr, "USRP reported the following error: %s\n", error_string); + + srslte_rf_error_t error; + bzero(&error, sizeof(srslte_rf_error_t)); + error.type = SRSLTE_RF_ERROR_RX; + h->uhd_error_handler(error); + } +} + static void* async_thread(void *h) { rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; uhd_async_metadata_handle md; @@ -740,6 +753,7 @@ int rf_uhd_recv_with_time_multi(void *h, num_rx_samples, md, 1.0, false, &rxd_samples); if (error) { fprintf(stderr, "Error receiving from UHD: %d\n", error); + log_rx_error(handler); return -1; } @@ -762,8 +776,12 @@ int rf_uhd_recv_with_time_multi(void *h, } } } else { - return uhd_rx_streamer_recv(handler->rx_stream, data, - nsamples, md, 0.0, false, &rxd_samples); + uhd_error error = uhd_rx_streamer_recv(handler->rx_stream, data, nsamples, md, 0.0, false, &rxd_samples); + if (error) { + fprintf(stderr, "Error receiving from UHD: %d\n", error); + log_rx_error(handler); + return -1; + } } if (secs && frac_secs) { uhd_rx_metadata_time_spec(handler->rx_md_first, secs, frac_secs); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 1de1ddbd0..23175fa46 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -304,8 +304,13 @@ void ue::rf_msg(srslte_rf_error_t error) { ue_base *ue = ue_base::get_instance(LTE); ue->handle_rf_msg(error); - if(error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW) { + if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW) { ue->radio_overflow(); + } else + if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_RX) { + ue->stop(); + ue->cleanup(); + exit(-1); } } From 067d76a5c8cc5e4ef0619d28b96e28777c20f1b2 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 5 Mar 2018 11:22:02 +0100 Subject: [PATCH 16/16] enable buffer pool log --- lib/include/srslte/common/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/include/srslte/common/common.h b/lib/include/srslte/common/common.h index 41a89fb36..ddd558016 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srslte/common/common.h @@ -63,7 +63,7 @@ #define SRSLTE_MAX_BUFFER_SIZE_BYTES 12756 #define SRSLTE_BUFFER_HEADER_OFFSET 1024 -//#define SRSLTE_BUFFER_POOL_LOG_ENABLED +#define SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #define pool_allocate (pool->allocate(__FUNCTION__))