diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 06dfa54ce..1242485af 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -199,7 +199,6 @@ public: plmn_search_completed(const rrc_interface_nas::found_plmn_t found_plmns[rrc_interface_nas::MAX_FOUND_PLMNS], int nof_plmns) = 0; virtual bool connection_request_completed(bool outcome) = 0; - virtual void run_tti(uint32_t tti) = 0; }; // NAS interface for UE @@ -386,9 +385,6 @@ public: /* Communicate the number of mbsfn services available */ virtual void set_mbsfn_config(uint32_t nof_mbsfn_services) = 0; - - /* Indicate new TTI */ - virtual void run_tti(const uint32_t tti) = 0; }; /* Interface RRC -> MAC shared between different RATs */ @@ -622,6 +618,9 @@ public: // Combined interface for PHY to access stack (MAC and RRC) class stack_interface_phy_lte : public mac_interface_phy_lte, public rrc_interface_phy_lte { +public: + /* Indicate new TTI */ + virtual void run_tti(const uint32_t tti, const uint32_t tti_jump) = 0; }; // Combined interface for stack (MAC and RRC) to access PHY diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 14c3fd173..bc9a30aa5 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -325,7 +325,7 @@ public: // MAC interface void ho_ra_completed(bool ra_successful); void release_pucch_srs(); - void run_tti(uint32_t tti); + void run_tti(); void ra_problem(); // GW interface diff --git a/srsue/hdr/stack/rrc/rrc_meas.h b/srsue/hdr/stack/rrc/rrc_meas.h index fae8be6e4..983440f63 100644 --- a/srsue/hdr/stack/rrc/rrc_meas.h +++ b/srsue/hdr/stack/rrc/rrc_meas.h @@ -45,7 +45,7 @@ public: void init(rrc* rrc_ptr); void reset(); bool parse_meas_config(const rrc_conn_recfg_r8_ies_s* meas_config, bool is_ho_reest = false, uint32_t src_earfcn = 0); - void run_tti(const uint32_t tti); + void run_tti(); void update_phy(); float rsrp_filter(const float new_value, const float avg_value); float rsrq_filter(const float new_value, const float avg_value); diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 0581a2190..5d0661e03 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -68,12 +68,12 @@ public: int init(const stack_args_t& args_, srslte::logger* logger_); int init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); bool switch_on() final; - bool switch_off(); + bool switch_off() final; bool enable_data(); bool disable_data(); - void stop(); + void stop() final; - bool get_metrics(stack_metrics_t* metrics); + bool get_metrics(stack_metrics_t* metrics) final; bool is_rrc_connected(); // RRC interface for PHY @@ -82,33 +82,36 @@ public: void new_cell_meas(const std::vector& meas) override { rrc.new_cell_meas(meas); } // MAC Interface for PHY - uint16_t get_dl_sched_rnti(uint32_t tti) { return mac.get_dl_sched_rnti(tti); } - uint16_t get_ul_sched_rnti(uint32_t tti) { return mac.get_ul_sched_rnti(tti); } + uint16_t get_dl_sched_rnti(uint32_t tti) final { return mac.get_dl_sched_rnti(tti); } + uint16_t get_ul_sched_rnti(uint32_t tti) final { return mac.get_ul_sched_rnti(tti); } - void new_grant_ul(uint32_t cc_idx, mac_grant_ul_t grant, tb_action_ul_t* action) + void new_grant_ul(uint32_t cc_idx, mac_grant_ul_t grant, tb_action_ul_t* action) final { mac.new_grant_ul(cc_idx, grant, action); } - void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action) + void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action) final { mac.new_grant_dl(cc_idx, grant, action); } - void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) + void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) final { mac.tb_decoded(cc_idx, grant, ack); } - void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) { mac.bch_decoded_ok(cc_idx, payload, len); } + void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) final + { + mac.bch_decoded_ok(cc_idx, payload, len); + } - void mch_decoded(uint32_t len, bool crc) { mac.mch_decoded(len, crc); } + void mch_decoded(uint32_t len, bool crc) final { mac.mch_decoded(len, crc); } - void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) { mac.new_mch_dl(phy_grant, action); } + void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) final { mac.new_mch_dl(phy_grant, action); } - void set_mbsfn_config(uint32_t nof_mbsfn_services) { mac.set_mbsfn_config(nof_mbsfn_services); } + void set_mbsfn_config(uint32_t nof_mbsfn_services) final { mac.set_mbsfn_config(nof_mbsfn_services); } - void run_tti(uint32_t tti) final; + void run_tti(uint32_t tti, uint32_t tti_jump) final; // Interface for GW void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking) final; @@ -128,9 +131,10 @@ public: srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); } private: - void run_thread() final; - void run_tti_impl(uint32_t tti); - void stop_impl(); + void run_thread() final; + void run_tti_impl(uint32_t tti, uint32_t tti_jump); + void calc_tti_stats(const uint32_t duration_us);; + void stop_impl(); const uint32_t TTI_STAT_PERIOD = 1024; const std::chrono::milliseconds TTI_WARN_THRESHOLD_MS{5}; diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index 992a10075..f8fa61913 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -43,7 +43,7 @@ public: nas(srslte::timer_handler* timers_); void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_); void stop(); - void run_tti(uint32_t tti) final; + void run_tti(); void get_metrics(nas_metrics_t* m); emm_state_t get_state(); @@ -130,9 +130,9 @@ private: // timers srslte::timer_handler* timers = nullptr; - srslte::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411 - srslte::timer_handler::unique_timer t3411; // started when attach failed - srslte::timer_handler::unique_timer t3421; // started when detach request is sent + srslte::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411 + srslte::timer_handler::unique_timer t3411; // started when attach failed + srslte::timer_handler::unique_timer t3421; // started when detach request is sent srslte::timer_handler::unique_timer reattach_timer; // started to trigger delayed re-attach // Values according to TS 24.301 Sec 10.2 diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 27e5d9c91..95a02dae7 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -883,12 +883,14 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, uint32_t nsamples, srslte_ti srslte_timestamp_copy(&radio_ts, rx_time); // Advance stack in time - while (srslte_timestamp_compare(rx_time, &tti_ts) > 0) { + if (srslte_timestamp_compare(rx_time, &tti_ts) > 0) { + uint32_t tti_jump = ceil((srslte_timestamp_real(rx_time) - srslte_timestamp_real(&tti_ts)) / 1.0e-3); + // Run stack - stack->run_tti(tti); + stack->run_tti(tti, tti_jump); - // Increase one millisecond - srslte_timestamp_add(&tti_ts, 0, 1.0e-3f); + // Increase by the number of tti jumps detected + srslte_timestamp_add(&tti_ts, 0, tti_jump * 1.0e-3f); } if (channel_emulator && rx_time) { diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index fe0cb3534..f55fd71a8 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -219,14 +219,12 @@ bool rrc::have_drb() * RRC State Machine * */ -void rrc::run_tti(uint32_t tti) +void rrc::run_tti() { if (!initiated) { return; } - rrc_log->step(tti); - if (simulate_rlf) { radio_link_failure(); simulate_rlf = false; @@ -259,7 +257,7 @@ void rrc::run_tti(uint32_t tti) } break; case RRC_STATE_CONNECTED: - measurements->run_tti(tti); + measurements->run_tti(); break; default: break; diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index 53a5790d4..7a1c7edf2 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -103,7 +103,7 @@ bool rrc::rrc_meas::parse_meas_config(const rrc_conn_recfg_r8_ies_s* mob_reconf_ return ret; } -void rrc::rrc_meas::run_tti(const uint32_t tti) +void rrc::rrc_meas::run_tti() { std::lock_guard lock(meas_cfg_mutex); diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 76dbae796..fbc64ed4a 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -298,22 +298,25 @@ void ue_stack_lte::out_of_sync() pending_tasks.push(sync_queue_id, [this]() { rrc.out_of_sync(); }); } -void ue_stack_lte::run_tti(uint32_t tti) +void ue_stack_lte::run_tti(uint32_t tti, uint32_t tti_jump) { - pending_tasks.push(sync_queue_id, [this, tti]() { run_tti_impl(tti); }); + pending_tasks.push(sync_queue_id, [this, tti, tti_jump]() { run_tti_impl(tti, tti_jump); }); } -void ue_stack_lte::run_tti_impl(uint32_t tti) +void ue_stack_lte::run_tti_impl(uint32_t tti, uint32_t tti_jump) { if (args.have_tti_time_stats) { tti_tprof.start(); } // perform tasks in this TTI - mac.run_tti(tti); - rrc.run_tti(tti); - nas.run_tti(tti); - timers.step_all(); + for (uint32_t i = 0; i < tti_jump; ++i) { + uint32_t next_tti = TTI_SUB(tti, (tti_jump - i - 1)); + mac.run_tti(next_tti); + rrc.run_tti(); + nas.run_tti(); + timers.step_all(); + } if (args.have_tti_time_stats) { std::chrono::nanoseconds dur = tti_tprof.stop(); diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index a798c7f13..de4ffd3bb 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -239,7 +239,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_ usim = usim_; rrc = rrc_; gw = gw_; - state = EMM_STATE_DEREGISTERED; + state = EMM_STATE_DEREGISTERED; if (!usim->get_home_plmn_id(&home_plmn)) { nas_log->error("Getting Home PLMN Id from USIM. Defaulting to 001-01\n"); @@ -310,7 +310,7 @@ emm_state_t nas::get_state() return state; } -void nas::run_tti(uint32_t tti) +void nas::run_tti() { callbacks.run(); } diff --git a/srsue/test/phy/ue_phy_test.cc b/srsue/test/phy/ue_phy_test.cc index dc481920c..7ee96a9ff 100644 --- a/srsue/test/phy/ue_phy_test.cc +++ b/srsue/test/phy/ue_phy_test.cc @@ -108,7 +108,7 @@ private: void mch_decoded(uint32_t len, bool crc) override {} void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) override {} void set_mbsfn_config(uint32_t nof_mbsfn_services) override {} - void run_tti(const uint32_t tti) override + void run_tti(const uint32_t tti, const uint32_t tti_jump) override { notify_run_tti(); log_h.info("Run TTI %d\n", tti); diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index 4b416998f..99e118a3b 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -403,7 +403,7 @@ void lte_ttcn3_phy::run_tti() sr_tx_tti = current_tti; } - stack->run_tti(current_tti); + stack->run_tti(current_tti, 1); } void lte_ttcn3_phy::set_cells_to_meas(uint32_t earfcn, const std::set& pci) {} diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index 78a534154..e302c50aa 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -161,10 +161,9 @@ public: bool is_lcid_enabled(uint32_t lcid) { return pdcp->is_lcid_enabled(lcid); } void run_thread() { - running = true; - uint32_t counter = 0; + running = true; while (running) { - nas->run_tti(counter++); + nas->run_tti(); } } void stop() diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index b9ae9a62f..9c9ee0555 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -181,7 +181,7 @@ public: void run_tti(uint32_t tti_) { timers->step_all(); - rrc::run_tti(tti_); + rrc::run_tti(); } // Set RRC in state RRC_CONNECTED