Added test to test out of order COUNT wraparoung. Added setters to help with the testers.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent 727436ec0b
commit 517ce8a220

@ -61,6 +61,12 @@ public:
// RLC interface // RLC interface
void write_pdu(unique_byte_buffer_t pdu); void write_pdu(unique_byte_buffer_t pdu);
// State variable settters (should be used only for testing)
void set_tx_next(uint32_t tx_next_) { tx_next = tx_next_; }
void set_rx_next(uint32_t rx_next_) { rx_next = rx_next_; }
void set_rx_deliv(uint32_t rx_deliv_) { rx_deliv = rx_deliv_; }
void set_rx_reord(uint32_t rx_reord_) { rx_reord = rx_reord_; }
private: private:
srsue::rlc_interface_pdcp* rlc = nullptr; srsue::rlc_interface_pdcp* rlc = nullptr;
srsue::rrc_interface_pdcp* rrc = nullptr; srsue::rrc_interface_pdcp* rrc = nullptr;
@ -90,18 +96,22 @@ private:
void deliver_all_consecutive_counts(); void deliver_all_consecutive_counts();
void pass_to_upper_layers(unique_byte_buffer_t pdu); void pass_to_upper_layers(unique_byte_buffer_t pdu);
// Reordering callback (t-Reordering) // Reodering callback (t-Reordering)
class reordering_callback : public timer_callback class reordering_callback;
{ std::unique_ptr<reordering_callback> reordering_fnc;
public: };
/*
* Timer callbacks
*/
// Reordering callback (t-Reordering)
class pdcp_entity_nr::reordering_callback : public timer_callback
{
public:
reordering_callback(pdcp_entity_nr* parent_) { parent = parent_; }; reordering_callback(pdcp_entity_nr* parent_) { parent = parent_; };
virtual void timer_expired(uint32_t timer_id) final; virtual void timer_expired(uint32_t timer_id) final;
private:
private:
pdcp_entity_nr* parent; pdcp_entity_nr* parent;
};
reordering_callback reordering_fnc;
}; };
inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu) inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu)

@ -25,7 +25,7 @@
namespace srslte { namespace srslte {
pdcp_entity_nr::pdcp_entity_nr() : reordering_fnc(this) {} pdcp_entity_nr::pdcp_entity_nr() : reordering_fnc(new pdcp_entity_nr::reordering_callback(this)) {}
pdcp_entity_nr::~pdcp_entity_nr() {} pdcp_entity_nr::~pdcp_entity_nr() {}
@ -53,7 +53,7 @@ void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_,
// Timers // Timers
reordering_timer_id = timers->get_unique_id(); reordering_timer_id = timers->get_unique_id();
reordering_timer = timers->get(reordering_timer_id); reordering_timer = timers->get(reordering_timer_id);
reordering_timer->set(&reordering_fnc, (uint32_t)cfg.t_reordering); reordering_timer->set(reordering_fnc.get(), (uint32_t)cfg.t_reordering);
} }
// Reestablishment procedure: 38.323 5.2 // Reestablishment procedure: 38.323 5.2

@ -38,20 +38,14 @@ pdcp_security_cfg sec_cfg = {
// Test SDUs for tx // Test SDUs for tx
uint8_t sdu1[] = {0x18, 0xE2}; uint8_t sdu1[] = {0x18, 0xE2};
uint8_t sdu2[] = {0xde, 0xad}; uint8_t sdu2[] = {0xde, 0xad};
// Test PDUs for rx (generated from SDU1) // Test PDUs for rx (generated from SDU1)
uint8_t pdu1[] = {0x80, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92}; uint8_t pdu1[] = {0x80, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92};
uint8_t pdu2[] = {0x88, 0x00, 0x8d, 0x2c, 0x47, 0x5e, 0xb1, 0x5b}; uint8_t pdu2[] = {0x88, 0x00, 0x8d, 0x2c, 0x47, 0x5e, 0xb1, 0x5b};
uint8_t pdu3[] = {0x80, 0x00, 0x97, 0xbe, 0xa3, 0x32, 0xfa, 0x61}; uint8_t pdu3[] = {0x80, 0x00, 0x97, 0xbe, 0xa3, 0x32, 0xfa, 0x61};
uint8_t pdu4[] = {0x80, 0x00, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92}; uint8_t pdu4[] = {0x80, 0x00, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92};
uint8_t pdu5[] = {0x82, 0x00, 0x00, 0x15, 0x01, 0xf4, 0xb0, 0xfc, 0xc5}; uint8_t pdu5[] = {0x82, 0x00, 0x00, 0x15, 0x01, 0xf4, 0xb0, 0xfc, 0xc5};
uint8_t pdu6[] = {0x80, 0x00, 0x00, 0xc2, 0x47, 0xa8, 0xdd, 0xc0, 0x73}; uint8_t pdu6[] = {0x80, 0x00, 0x00, 0xc2, 0x47, 0xa8, 0xdd, 0xc0, 0x73};
// Test PDUs for rx (generated from SDU2) // Test PDUs for rx (generated from SDU2)
@ -304,14 +298,11 @@ int test_rx_out_of_order(uint64_t n_packets, uint8_t pdcp_sn_len, srslte::byte_b
pdcp_rx->write_pdu(std::move(pdu)); pdcp_rx->write_pdu(std::move(pdu));
} }
// Write PDUs into tx entity to get expected PDUs // Allocate buffers for later comparison.
srslte::unique_byte_buffer_t tx_sdu_out2 = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool);
tx_sdu_out2->append_bytes(sdu2, sizeof(sdu2)); srslte::unique_byte_buffer_t sdu_exp = allocate_unique_buffer(*pool);
pdcp_tx->write_sdu(std::move(tx_sdu_out2), true);
srslte::unique_byte_buffer_t tx_pdu_out2 = allocate_unique_buffer(*pool);
rlc_tx->get_last_sdu(tx_pdu_out2);
// Write PDUs into tx entity to get expected PDUs
srslte::unique_byte_buffer_t tx_sdu_out1 = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t tx_sdu_out1 = allocate_unique_buffer(*pool);
tx_sdu_out1->append_bytes(sdu1, sizeof(sdu1)); tx_sdu_out1->append_bytes(sdu1, sizeof(sdu1));
pdcp_tx->write_sdu(std::move(tx_sdu_out1), true); pdcp_tx->write_sdu(std::move(tx_sdu_out1), true);
@ -319,15 +310,24 @@ int test_rx_out_of_order(uint64_t n_packets, uint8_t pdcp_sn_len, srslte::byte_b
srslte::unique_byte_buffer_t tx_pdu_out1 = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t tx_pdu_out1 = allocate_unique_buffer(*pool);
rlc_tx->get_last_sdu(tx_pdu_out1); rlc_tx->get_last_sdu(tx_pdu_out1);
srslte::unique_byte_buffer_t tx_sdu_out2 = allocate_unique_buffer(*pool);
tx_sdu_out2->append_bytes(sdu2, sizeof(sdu2));
*sdu_exp = *tx_sdu_out2; // save expected SDU
pdcp_tx->write_sdu(std::move(tx_sdu_out2), true);
srslte::unique_byte_buffer_t tx_pdu_out2 = allocate_unique_buffer(*pool);
rlc_tx->get_last_sdu(tx_pdu_out2);
// Write PDUs out-of-order into rx entity to see if re-ordering is OK. // Write PDUs out-of-order into rx entity to see if re-ordering is OK.
pdcp_rx->write_pdu(std::move(tx_pdu_out1));
pdcp_rx->write_pdu(std::move(tx_pdu_out2)); pdcp_rx->write_pdu(std::move(tx_pdu_out2));
pdcp_rx->write_pdu(std::move(tx_pdu_out1));
// Test actual reception // Test actual reception
srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool); TESTASSERT(gw_rx->rx_count == n_packets);
gw_rx->get_last_pdu(sdu_act); gw_rx->get_last_pdu(sdu_act);
TESTASSERT(compare_two_packets(sdu_act, tx_sdu_out2) == 0); log->info_hex(sdu_act->msg, sdu_act->N_bytes, "SDU act");
TESTASSERT(compare_two_packets(sdu_act, sdu_exp) == 0);
return 0; return 0;
} }
/* /*
@ -406,39 +406,43 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
{ {
/* /*
* RX Test 1: PDCP Entity with SN LEN = 12 * RX Test 1: PDCP Entity with SN LEN = 12
* Test In-sequence reception of 4097 packets * Test in-sequence reception of 4097 packets.
* This tests correct handling of HFN in the case of SN wraparound
*/ */
// TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, log) == 0); TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, log) == 0);
/* /*
* RX Test 2: PDCP Entity with SN LEN = 12 * RX Test 2: PDCP Entity with SN LEN = 12
* Test In-sequence reception of 4294967297 packets. This tests SN wrap-around * Test in-sequence reception of 4294967297 packets.
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound
*/ */
// // TESTASSERT(test_rx_in_sequence(4294967297, srslte::PDCP_SN_LEN_12, pool, &log) == 0); // // TESTASSERT(test_rx_in_sequence(4294967297, srslte::PDCP_SN_LEN_12, pool, &log) == 0);
/* /*
* RX Test 3: PDCP Entity with SN LEN = 18 * RX Test 3: PDCP Entity with SN LEN = 18
* Test In-sequence reception of 262145 packets. * Test In-sequence reception of 262145 packets.
* This tests correct handling of HFN in the case of SN wraparound
*/ */
// TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, log) == 0); TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, log) == 0);
/* /*
* RX Test 4: PDCP Entity with SN LEN = 12 * RX Test 4: PDCP Entity with SN LEN = 12
* Test Reception of one out-of-order packet. * Test Reception of one out-of-order packet.
*/ */
TESTASSERT(test_rx_out_of_order(srslte::PDCP_SN_LEN_12, pool, log) == 0); //TESTASSERT(test_rx_out_of_order(srslte::PDCP_SN_LEN_12, pool, log) == 0);
TESTASSERT(test_rx_out_of_order(2, srslte::PDCP_SN_LEN_12, pool, log) == 0);
/* /*
* RX Test 5: PDCP Entity with SN LEN = 12 * RX Test 5: PDCP Entity with SN LEN = 12
* Test timeout of t-Reordering when one packet is lost. * Test timeout of t-Reordering when one packet is lost.
*/ */
//TESTASSERT(test_rx_out_of_order_timeout(srslte::PDCP_SN_LEN_12, pool, log) == 0); TESTASSERT(test_rx_out_of_order_timeout(srslte::PDCP_SN_LEN_12, pool, log) == 0);
/* /*
* RX Test 5: PDCP Entity with SN LEN = 12 * RX Test 5: PDCP Entity with SN LEN = 12
* Test timeout of t-Reordering when one packet is lost. * Test timeout of t-Reordering when one packet is lost.
*/ */
TESTASSERT(test_rx_out_of_order(2, srslte::PDCP_SN_LEN_12, pool, log) == 0); //TESTASSERT(test_rx_out_of_order(4294967297, srslte::PDCP_SN_LEN_12, pool, log) == 0);
return 0; return 0;
} }
// Setup all tests // Setup all tests
@ -449,9 +453,8 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
log.set_level(srslte::LOG_LEVEL_DEBUG); log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128); log.set_hex_limit(128);
//TESTASSERT(test_tx_all(pool, &log) == 0); TESTASSERT(test_tx_all(pool, &log) == 0);
TESTASSERT(test_rx_all(pool, &log) == 0); TESTASSERT(test_rx_all(pool, &log) == 0);
// TESTASSERT(test_rx_out_of_order_wraparound(srslte::PDCP_SN_LEN_12, pool, &log) == 0);
return 0; return 0;
} }

Loading…
Cancel
Save