diff --git a/srsapps/ue/mac/src/dl_harq.cc b/srsapps/ue/mac/src/dl_harq.cc index 42e83d711..f84e0f586 100644 --- a/srsapps/ue/mac/src/dl_harq.cc +++ b/srsapps/ue/mac/src/dl_harq.cc @@ -174,7 +174,7 @@ void dl_harq_entity::dl_harq_process::receive_data(uint32_t tti, srslte::ue::dl_ } } } else { - Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n"); + Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n", pid); } if (pid == HARQ_BCCH_PID || harq_entity->timers_db->get(mac::TIME_ALIGNMENT)->is_expired()) { // Do not generate ACK @@ -203,13 +203,24 @@ void dl_harq_entity::dl_harq_process::receive_data(uint32_t tti, srslte::ue::dl_ void dl_harq_entity::dl_harq_process::set_harq_info(srslte::ue::dl_sched_grant* new_grant) { bool is_new_transmission = false; - if ((new_grant->get_ndi() != cur_grant.get_ndi() && new_grant->get_tbs() == cur_grant.get_tbs()) || // NDI toggled for same TB (assume TB is identified by TBS) - (pid == HARQ_BCCH_PID && new_grant->get_rv() == 0) || // Broadcast PID and 1st TX (RV=0) - (new_grant->get_tbs() != cur_grant.get_tbs())) // First transmission for this TB + bool is_new_tb = true; + if (srslte_tti_interval(new_grant->get_tti(), cur_grant.get_tti()) <= 8 && + new_grant->get_tbs() == cur_grant.get_tbs()) + { + is_new_tb = false; + } + + if ((new_grant->get_ndi() != cur_grant.get_ndi() && !is_new_tb) || // NDI toggled for same TB + is_new_tb || // is new TB + (pid == HARQ_BCCH_PID && new_grant->get_rv() == 0)) // Broadcast PID and 1st TX (RV=0) { is_new_transmission = true; Debug("Set HARQ Info for new transmission\n"); } else { + if (!is_new_tb) { + Info("old_tbs=%d, new_tbs=%d, old_tti=%d new_tti=%d\n", cur_grant.get_tbs(), new_grant->get_tbs(), + cur_grant.get_tti(), new_grant->get_tti()); + } is_new_transmission = false; Debug("Set HARQ Info for retransmission\n"); } diff --git a/srsapps/ue/mac/src/proc_ra.cc b/srsapps/ue/mac/src/proc_ra.cc index 0405a8bd0..b2f849275 100644 --- a/srsapps/ue/mac/src/proc_ra.cc +++ b/srsapps/ue/mac/src/proc_ra.cc @@ -152,14 +152,6 @@ bool ra_proc::is_error() { return state == RA_PROBLEM; } -uint32_t interval(uint32_t x1, uint32_t x2) { - if (x1 > x2) { - return x1-x2; - } else { - return 10240-x2+x1; - } -} - const char* state_str[11] = {"Idle", "RA Initializat.: ", "RA Initial.Wait: ", @@ -277,7 +269,7 @@ void ra_proc::step_response_reception() { ra_rnti = 1+ra_tti%10; // f_id=0 for FDD dl_sched_grant rar_grant(ra_rnti); - uint32_t interval_ra = interval(tti, ra_tti); + uint32_t interval_ra = srslte_tti_interval(tti, ra_tti); // Try to decode RAR only within the RA response window if (interval_ra >= 3 && interval_ra <= 3+responseWindowSize) { @@ -402,7 +394,7 @@ void ra_proc::step_response_error() { } void ra_proc::step_backoff_wait() { - if (interval(tti, backoff_interval_start) >= backoff_inteval) { + if (srslte_tti_interval(tti, backoff_interval_start) >= backoff_inteval) { state = RESOURCE_SELECTION; } } diff --git a/srsapps/ue/phy/include/srsapps/ue/phy/sched_grant.h b/srsapps/ue/phy/include/srsapps/ue/phy/sched_grant.h index 85e2c047b..8933a9a61 100644 --- a/srsapps/ue/phy/include/srsapps/ue/phy/sched_grant.h +++ b/srsapps/ue/phy/include/srsapps/ue/phy/sched_grant.h @@ -80,6 +80,12 @@ namespace ue { bool is_tpc_rnti() { return (rnti_type == RNTI_TYPE_TPC_PUSCH || rnti_type == RNTI_TYPE_TPC_PUCCH); } + uint32_t get_tti() { + return tti; + } + void set_tti(uint32_t tti_) { + tti = tti_; + } virtual uint32_t get_rv() = 0; virtual void set_rv(uint32_t rv) = 0; virtual bool get_ndi() = 0; @@ -89,6 +95,7 @@ namespace ue { protected: uint16_t rnti; rnti_type_t rnti_type; + uint32_t tti; }; } diff --git a/srsapps/ue/phy/src/dl_buffer.cc b/srsapps/ue/phy/src/dl_buffer.cc index b8685a548..cd655eda7 100644 --- a/srsapps/ue/phy/src/dl_buffer.cc +++ b/srsapps/ue/phy/src/dl_buffer.cc @@ -117,6 +117,8 @@ bool dl_buffer::get_ul_grant(ul_sched_grant *grant) return false; } + grant->set_tti(tti); + Info("PDCCH: UL DCI Format0 cce_index=%d, n_data_bits=%d\n", ue_dl.last_n_cce, dci_msg.nof_bits); return grant->create_from_dci(&dci_msg, cell, params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET)); @@ -167,7 +169,9 @@ bool dl_buffer::get_dl_grant(dl_sched_grant *grant) if (srslte_ue_dl_find_dl_dci(&ue_dl, &dci_msg, cfi, tti%10, grant->get_rnti()) != 1) { return false; } - + + grant->set_tti(tti); + Info("PDCCH: DL DCI %s cce_index=%d, n_data_bits=%d\n", grant->get_dciformat_string(), ue_dl.last_n_cce, dci_msg.nof_bits); return grant->create_from_dci(&dci_msg, cell.nof_prb, srslte_ue_dl_get_ncce(&ue_dl)); diff --git a/srsapps/ue/phy/src/ul_buffer.cc b/srsapps/ue/phy/src/ul_buffer.cc index e8b4e6357..ae8212f13 100644 --- a/srsapps/ue/phy/src/ul_buffer.cc +++ b/srsapps/ue/phy/src/ul_buffer.cc @@ -299,7 +299,7 @@ void ul_buffer::set_tx_params(float cfo_, float time_adv_sec, srslte_timestamp_t void ul_buffer::set_end_of_burst() { - Info("Is end of burst\n"); + Info("TTI %d Is end of burst\n", tti); tti_is_end_of_burst = true; } diff --git a/srslte/include/srslte/common/phy_common.h b/srslte/include/srslte/common/phy_common.h index ea26bea45..799f434ce 100644 --- a/srslte/include/srslte/common/phy_common.h +++ b/srslte/include/srslte/common/phy_common.h @@ -244,6 +244,7 @@ SRSLTE_API int srslte_band_get_fd_region(enum band_geographical_area region, SRSLTE_API int srslte_str2mimotype(char *mimo_type_str, srslte_mimo_type_t *type); - +SRSLTE_API uint32_t srslte_tti_interval(uint32_t tti1, + uint32_t tti2); #endif diff --git a/srslte/lib/common/src/phy_common.c b/srslte/lib/common/src/phy_common.c index 52c226832..b4fe4b34c 100644 --- a/srslte/lib/common/src/phy_common.c +++ b/srslte/lib/common/src/phy_common.c @@ -422,3 +422,14 @@ int srslte_band_get_fd_region(enum band_geographical_area region, srslte_earfcn_ return nof_fd; } + +/* Returns the interval tti1-tti2 mod 10240 */ +uint32_t srslte_tti_interval(uint32_t tti1, uint32_t tti2) { + if (tti1 > tti2) { + return tti1-tti2; + } else { + return 10240-tti2+tti1; + } +} + +