diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 0213ca601..024707f75 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -82,6 +82,15 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu, bool blocking) (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); + // Check for COUNT overflow + if (tx_overflow) { + log->warning("TX_NEXT has overflowed. Droping packet\n"); + return; + } + if (tx_next + 1 == 0) { + tx_overflow = true; + } + // Start discard timer TODO // Perform header compression TODO @@ -100,10 +109,6 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu, bool blocking) // Increment TX_NEXT tx_next++; - if (tx_next == 0 or tx_overflow) { - tx_overflowasdfdsaf = true; - log->warning("TX_NEXT has overflowed. Droping packet\n"); - } // Check if PDCP is associated with more than on RLC entity TODO // Write to lower layers diff --git a/lib/test/upper/pdcp_nr_test.cc b/lib/test/upper/pdcp_nr_test.cc index b310bacd9..6bab15e2b 100644 --- a/lib/test/upper/pdcp_nr_test.cc +++ b/lib/test/upper/pdcp_nr_test.cc @@ -92,6 +92,7 @@ int test_tx(uint32_t n_packets, srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; + pdcp_hlp.set_pdcp_initial_state(init_state); // Run test for (uint32_t i = 0; i < n_packets; ++i) { @@ -104,6 +105,7 @@ int test_tx(uint32_t n_packets, srslte::unique_byte_buffer_t pdu_act = allocate_unique_buffer(*pool); rlc->get_last_sdu(pdu_act); + std::cout << "Actual RX pdus" << rlc->rx_count << "Rcvd pdus " << n_pdus_exp << "\n"; TESTASSERT(rlc->rx_count == n_pdus_exp); TESTASSERT(compare_two_packets(pdu_act, pdu_exp) == 0); return 0;