diff --git a/lib/include/srsran/interfaces/enb_command_interface.h b/lib/include/srsran/interfaces/enb_command_interface.h index 3f9325b30..70bf82e7a 100644 --- a/lib/include/srsran/interfaces/enb_command_interface.h +++ b/lib/include/srsran/interfaces/enb_command_interface.h @@ -25,6 +25,8 @@ public: * @param gain Relative gain */ virtual void cmd_cell_gain(uint32_t cell_id, float gain) = 0; + + virtual void toggle_padding() = 0; }; } // namespace srsenb diff --git a/lib/include/srsran/interfaces/enb_mac_interfaces.h b/lib/include/srsran/interfaces/enb_mac_interfaces.h index f3cac8286..19c2b7fc0 100644 --- a/lib/include/srsran/interfaces/enb_mac_interfaces.h +++ b/lib/include/srsran/interfaces/enb_mac_interfaces.h @@ -21,6 +21,7 @@ namespace srsenb { struct mac_args_t { uint32_t nof_prb; ///< Needed to dimension MAC softbuffers for all cells sched_interface::sched_args_t sched; + int lcid_padding; int nr_tb_size = -1; uint32_t nof_prealloc_ues; ///< Number of UE resources to pre-allocate at eNB startup uint32_t max_nof_kos; diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index ca2654dbf..54aa83ae7 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -332,6 +332,7 @@ enable = false #max_prach_offset_us = 30 #nof_prealloc_ues = 8 #rlf_release_timer_ms = 4000 +#lcid_padding = 3 #eea_pref_list = EEA0, EEA2, EEA1 #eia_pref_list = EIA2, EIA1, EIA0 #gtpu_tunnel_timeout = 0 diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index eece0fb9e..e3ccfca0b 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -137,6 +137,8 @@ public: // eNodeB command interface void cmd_cell_gain(uint32_t cell_id, float gain) override; + void toggle_padding() override; + private: const static int ENB_POOL_SIZE = 1024 * 10; diff --git a/srsenb/hdr/stack/enb_stack_base.h b/srsenb/hdr/stack/enb_stack_base.h index 0d92b2d88..44375e12a 100644 --- a/srsenb/hdr/stack/enb_stack_base.h +++ b/srsenb/hdr/stack/enb_stack_base.h @@ -92,6 +92,7 @@ public: virtual void stop() = 0; + virtual void toggle_padding() = 0; // eNB metrics interface virtual bool get_metrics(stack_metrics_t* metrics) = 0; }; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 3caa5c927..41f5419f3 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -91,6 +91,7 @@ public: { mac.set_sched_dl_tti_mask(tti_mask, nof_sfs); } + void toggle_padding() override { mac.toggle_padding(); } void tti_clock() override; private: diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index 43baf0473..931891e1d 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -71,6 +71,8 @@ public: // MAC interface to trigger processing of received PDUs void process_pdus() final; + void toggle_padding() { srsran::console("padding not available for NR\n"); } + private: void run_thread() final; void run_tti_impl(uint32_t tti); diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 3461e09d8..585b2c6aa 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -94,6 +94,11 @@ public: bool process_pdus(); void get_metrics(mac_metrics_t& metrics); + + void toggle_padding(); + + void add_padding(); + void write_mcch(const srsran::sib2_mbms_t* sib2_, const srsran::sib13_t* sib13_, const srsran::mcch_msg_t* mcch_, @@ -176,8 +181,9 @@ private: uint8_t mtch_payload_buffer[mtch_payload_len] = {}; // pointer to MAC PCAP object - srsran::mac_pcap* pcap = nullptr; - srsran::mac_pcap_net* pcap_net = nullptr; + srsran::mac_pcap* pcap = nullptr; + srsran::mac_pcap_net* pcap_net = nullptr; + bool do_padding = false; // Number of rach preambles detected for a cc. std::vector detected_rachs; diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 2fd9db884..d7e201794 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -144,6 +144,7 @@ public: void start_ta() { ta_fsm.start(); }; uint32_t set_ta_us(float ta_us) { return ta_fsm.push_value(ta_us); }; void tic(); + void trigger_padding(int lcid); uint8_t* generate_pdu(uint32_t ue_cc_idx, uint32_t harq_pid, diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 4c903babd..004f81025 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -227,4 +227,9 @@ std::string enb::get_build_string() return ss.str(); } +void enb::toggle_padding() +{ + stack->toggle_padding(); +} + } // namespace srsenb diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index bc79431d3..dfee4780b 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -216,6 +216,7 @@ void parse_args(all_args_t* args, int argc, char* argv[]) ("expert.eea_pref_list", bpo::value(&args->general.eea_pref_list)->default_value("EEA0, EEA2, EEA1"), "Ordered preference list for the selection of encryption algorithm (EEA) (default: EEA0, EEA2, EEA1).") ("expert.eia_pref_list", bpo::value(&args->general.eia_pref_list)->default_value("EIA2, EIA1, EIA0"), "Ordered preference list for the selection of integrity algorithm (EIA) (default: EIA2, EIA1, EIA0).") ("expert.nof_prealloc_ues", bpo::value(&args->stack.mac.nof_prealloc_ues)->default_value(8), "Number of UE resources to preallocate during eNB initialization") + ("expert.lcid_padding", bpo::value(&args->stack.mac.lcid_padding)->default_value(3), "LCID on which to put MAC padding") ("expert.max_mac_dl_kos", bpo::value(&args->general.max_mac_dl_kos)->default_value(100), "Maximum number of consecutive KOs in DL before triggering the UE's release") ("expert.max_mac_ul_kos", bpo::value(&args->general.max_mac_ul_kos)->default_value(100), "Maximum number of consecutive KOs in UL before triggering the UE's release") ("expert.gtpu_tunnel_timeout", bpo::value(&args->stack.gtpu_indirect_tunnel_timeout_msec)->default_value(0), "Maximum time that GTPU takes to release indirect forwarding tunnel since the last received GTPU PDU. (0 for infinity)") @@ -428,6 +429,7 @@ void parse_args(all_args_t* args, int argc, char* argv[]) } static bool do_metrics = false; +static bool do_padding = false; static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* control) { @@ -452,6 +454,14 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* cout << "Enter t to restart trace." << endl; } metrics->toggle_print(do_metrics); + } else if (cmd[0] == "p") { + do_padding = !do_padding; + if (do_padding) { + cout << "Enter p to stop padding." << endl; + } else { + cout << "Enter p to restart padding." << endl; + } + control->toggle_padding(); } else if (cmd[0] == "q") { raise(SIGTERM); } else if (cmd[0] == "cell_gain") { @@ -471,6 +481,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* cout << " t: starts console trace" << endl; cout << " q: quit srsenb" << endl; cout << " cell_gain: set relative cell gain" << endl; + cout << " p: starts MAC padding" << endl; cout << endl; } } diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 6b4a271c4..328ff1ae0 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -285,6 +285,21 @@ void mac::get_metrics(mac_metrics_t& metrics) metrics.cc_rach_counter = detected_rachs; } +void mac::toggle_padding() +{ + do_padding = !do_padding; +} + +void mac::add_padding() +{ + for (auto it = ue_db.begin(); it != ue_db.end(); ++it) { + uint16_t cur_rnti = it->first; + auto ue = it; + scheduler.dl_rlc_buffer_state(ue->first, args.lcid_padding, 20e6, 0); + ue->second->trigger_padding(args.lcid_padding); + } +} + /******************************************************** * * PHY interface @@ -594,6 +609,9 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) trace_complete_event("mac::get_dl_sched", "total_time"); logger.set_context(TTI_SUB(tti_tx_dl, FDD_HARQ_DELAY_UL_MS)); + if (do_padding) { + add_padding(); + } for (uint32_t enb_cc_idx = 0; enb_cc_idx < cell_config.size(); enb_cc_idx++) { // Run scheduler with current info diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 94d32898c..9e5153a1a 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -732,4 +732,9 @@ void ue::tic() } } +void ue::trigger_padding(int lcid) +{ + sched->ul_bsr(rnti, lcid, 20e6); +} + } // namespace srsenb