lib,rlc_am_nr: fixed tx_mod_base_nr(). Added unit test for inside_tx_window().

master
Pedro Alvarez 3 years ago
parent ab8577ff43
commit b425316936

@ -100,12 +100,14 @@ public:
void stop() final; void stop() final;
bool inside_tx_window(uint32_t sn);
private: private:
rlc_am* parent = nullptr; rlc_am* parent = nullptr;
rlc_am_nr_rx* rx = nullptr; rlc_am_nr_rx* rx = nullptr;
uint32_t mod_nr = 4096; uint32_t mod_nr = 4096;
inline int32_t tx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)st.tx_next_ack) % mod_nr; } inline uint32_t tx_mod_base_nr(uint32_t sn) const;
/**************************************************************************** /****************************************************************************
* Configurable parameters * Configurable parameters

@ -381,6 +381,11 @@ uint8_t rlc_am_nr_tx::get_pdu_poll()
return poll; return poll;
} }
bool rlc_am_nr_tx::do_status()
{
return rx->get_do_status();
}
void rlc_am_nr_tx::reestablish() void rlc_am_nr_tx::reestablish()
{ {
stop(); stop();
@ -395,12 +400,20 @@ bool rlc_am_nr_tx::sdu_queue_is_full()
void rlc_am_nr_tx::empty_queue() {} void rlc_am_nr_tx::empty_queue() {}
bool rlc_am_nr_tx::do_status() void rlc_am_nr_tx::stop() {}
/*
* Window helpers
*/
uint32_t rlc_am_nr_tx::tx_mod_base_nr(uint32_t sn) const
{ {
return rx->get_do_status(); return (sn - st.tx_next_ack) % mod_nr;
} }
void rlc_am_nr_tx::stop() {} bool rlc_am_nr_tx::inside_tx_window(uint32_t sn)
{
// TX_Next_Ack <= SN < TX_Next_Ack + AM_Window_Size
return tx_mod_base_nr(sn) < RLC_AM_NR_WINDOW_SIZE;
}
/**************************************************************************** /****************************************************************************
* Rx subclass implementation * Rx subclass implementation

@ -82,6 +82,10 @@ int window_checker_test()
TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above)); TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above));
TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below));
TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above));
TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_below));
TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_above));
TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_below));
TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_above));
} }
rlc_am_nr_rx_state_t rx_st = {}; rlc_am_nr_rx_state_t rx_st = {};
@ -102,6 +106,10 @@ int window_checker_test()
TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above)); TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above));
TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below));
TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above));
TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_below));
TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_above));
TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_below));
TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_above));
} }
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save