|
|
|
@ -230,11 +230,11 @@ int rlc_am_nr_pdu_test6()
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///< Control PDU tests
|
|
|
|
|
///< Control PDU tests (12bit SN)
|
|
|
|
|
// Status PDU for 12bit SN with ACK_SN=2065 and no further NACK_SN (E1 bit not set)
|
|
|
|
|
int rlc_am_nr_control_pdu_test1()
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test1()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU test 1");
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test 1");
|
|
|
|
|
const int len = 3;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x08, 0x11, 0x00};
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
@ -242,10 +242,10 @@ int rlc_am_nr_control_pdu_test1()
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu = {};
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 2065);
|
|
|
|
|
TESTASSERT(status_pdu.N_nack == 0);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 0);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
@ -262,9 +262,9 @@ int rlc_am_nr_control_pdu_test1()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 12bit SN with ACK_SN=2065 and NACK_SN=273 (E1 bit set)
|
|
|
|
|
int rlc_am_nr_control_pdu_test2()
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test2()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU test 2");
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test 2");
|
|
|
|
|
const int len = 5;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x08, 0x11, 0x80, 0x11, 0x10};
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
@ -272,10 +272,10 @@ int rlc_am_nr_control_pdu_test2()
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu = {};
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 2065);
|
|
|
|
|
TESTASSERT(status_pdu.N_nack == 1);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 1);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 273);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
@ -283,7 +283,7 @@ int rlc_am_nr_control_pdu_test2()
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
// TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
|
|
|
|
@ -294,9 +294,9 @@ int rlc_am_nr_control_pdu_test2()
|
|
|
|
|
|
|
|
|
|
// Status PDU for 12bit SN with ACK_SN=2065, NACK_SN=273, SO_START=2, SO_END=5, NACK_SN=275, SO_START=5, SO_END=0xFFFF
|
|
|
|
|
// E1 and E2 bit set on first NACK, only E2 on second.
|
|
|
|
|
int rlc_am_nr_control_pdu_test3()
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test3()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU test 3");
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test 3");
|
|
|
|
|
const int len = 15;
|
|
|
|
|
std::array<uint8_t, len> tv = {
|
|
|
|
|
0x08, 0x11, 0x80, 0x11, 0x1c, 0x00, 0x02, 0x00, 0x05, 0x11, 0x34, 0x00, 0x05, 0xFF, 0xFF};
|
|
|
|
@ -305,10 +305,10 @@ int rlc_am_nr_control_pdu_test3()
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu = {};
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 2065);
|
|
|
|
|
TESTASSERT(status_pdu.N_nack == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 273);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_start == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_end == 5);
|
|
|
|
@ -331,9 +331,9 @@ int rlc_am_nr_control_pdu_test3()
|
|
|
|
|
|
|
|
|
|
// Status PDU for 12bit SN with ACK_SN=2065, NACK_SN=273, SO_START=2, SO_END=5, NACK_SN=275
|
|
|
|
|
// E1 and E2 bit set on first NACK, neither E1 or E2 on the second.
|
|
|
|
|
int rlc_am_nr_control_pdu_test4()
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test4()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU test 4");
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test 4");
|
|
|
|
|
const int len = 11;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x08, 0x11, 0x80, 0x11, 0x1c, 0x00, 0x02, 0x00, 0x05, 0x11, 0x30};
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
@ -341,10 +341,10 @@ int rlc_am_nr_control_pdu_test4()
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu = {};
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 2065);
|
|
|
|
|
TESTASSERT(status_pdu.N_nack == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 273);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_start == 2);
|
|
|
|
@ -368,9 +368,9 @@ int rlc_am_nr_control_pdu_test4()
|
|
|
|
|
// Malformed Status PDU, with E1 still set at the end of the PDU
|
|
|
|
|
// 12bit SN with ACK_SN=2065, NACK_SN=273, SO_START=2, SO_END=5, NACK_SN=275, SO_START=5, SO_END=0xFFFF
|
|
|
|
|
// E1 and E2 bit set on first NACK, only E2 on second.
|
|
|
|
|
int rlc_am_nr_control_pdu_test5()
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test5()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU test 5");
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test 5");
|
|
|
|
|
const int len = 15;
|
|
|
|
|
std::array<uint8_t, len> tv = {
|
|
|
|
|
0x08, 0x11, 0x80, 0x11, 0x1c, 0x00, 0x02, 0x00, 0x05, 0x11, 0x3c, 0x00, 0x05, 0xFF, 0xFF};
|
|
|
|
@ -379,12 +379,562 @@ int rlc_am_nr_control_pdu_test5()
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu = {};
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 12bit SN with ACK_SN=2065,
|
|
|
|
|
// NACK range0: 3 full SDUs, NACK_SN=273..275
|
|
|
|
|
// NACK range1: missing segment sequence across 4 SDUs
|
|
|
|
|
// starting at NACK_SN=276, SO_START=2,
|
|
|
|
|
// ending at NACK_SN=279, SO_END=5
|
|
|
|
|
// E1 and E3 bit set on first NACK, E2 and E3 bit set on the second.
|
|
|
|
|
int rlc_am_nr_control_pdu_12bit_sn_test_nack_range()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (12bit SN) test NACK range");
|
|
|
|
|
const int len = 13;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x08, // D/C | 3CPT | 4ACK_SN_upper
|
|
|
|
|
0x11, // 8ACK_SN_lower
|
|
|
|
|
0x80, // E1 | 7R
|
|
|
|
|
0x11, // 8NACK_SN_upper
|
|
|
|
|
0x1a, // 4NACK_SN_lower | E1 | E2 | E3 | R
|
|
|
|
|
0x03, // 8NACK_range
|
|
|
|
|
0x11, // 8NACK_SN_upper
|
|
|
|
|
0x46, // 4NACK_SN_lower | E1 | E2 | E3 | R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x02, // 8SO_START_lower
|
|
|
|
|
0x00, // 8SO_END_upper
|
|
|
|
|
0x05, // 8SO_END_lower
|
|
|
|
|
0x04}; // 8NACK_range
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size12bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 2065);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 273);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_so == false);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_nack_range == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_range == 3);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_sn == 276);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_start == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_end == 5);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_nack_range == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_range == 4);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test status PDU for correct trimming and estimation of packed size
|
|
|
|
|
// 1) Test init, copy and reset
|
|
|
|
|
// 2) Test step-wise growth and trimming of status PDU while covering several corner cases
|
|
|
|
|
int rlc_am_nr_control_pdu_test_trimming(rlc_am_nr_sn_size_t sn_size)
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU ({} bit SN) test trimming", to_number(sn_size));
|
|
|
|
|
|
|
|
|
|
// status PDU with no NACKs
|
|
|
|
|
{
|
|
|
|
|
constexpr uint32_t min_size = 3;
|
|
|
|
|
srsran::byte_buffer_t pdu;
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(sn_size);
|
|
|
|
|
|
|
|
|
|
status_pdu.ack_sn = 99;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, min_size); // minimum size
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, min_size);
|
|
|
|
|
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu_copy = status_pdu;
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.ack_sn, 99);
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.packed_size, min_size); // minimum size
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu_copy, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, min_size);
|
|
|
|
|
|
|
|
|
|
status_pdu.reset();
|
|
|
|
|
|
|
|
|
|
status_pdu.ack_sn = 77;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, min_size); // should still have minimum size
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, min_size);
|
|
|
|
|
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.ack_sn, 99); // shouldn't have changed
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.packed_size, min_size); // minimum size
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu_copy, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, min_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// status PDU with multiple NACKs
|
|
|
|
|
// expect: ACK=77, NACKs=[12][14][17 50:99][17 150:199][17 250:299][19][21 333:111 r5][27 444:666 r3]
|
|
|
|
|
{
|
|
|
|
|
constexpr uint32_t min_size = 3;
|
|
|
|
|
const uint32_t nack_size = sn_size == rlc_am_nr_sn_size_t::size12bits ? 2 : 3;
|
|
|
|
|
constexpr uint32_t so_size = 4;
|
|
|
|
|
constexpr uint32_t range_size = 1;
|
|
|
|
|
uint32_t expected_size = min_size;
|
|
|
|
|
srsran::byte_buffer_t pdu;
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(sn_size);
|
|
|
|
|
|
|
|
|
|
status_pdu.ack_sn = 77;
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 12;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 14;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 17;
|
|
|
|
|
nack.has_so = true;
|
|
|
|
|
nack.so_start = 50;
|
|
|
|
|
nack.so_end = 99;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size + so_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 17;
|
|
|
|
|
nack.has_so = true;
|
|
|
|
|
nack.so_start = 150;
|
|
|
|
|
nack.so_end = 199;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size + so_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 17;
|
|
|
|
|
nack.has_so = true;
|
|
|
|
|
nack.so_start = 250;
|
|
|
|
|
nack.so_end = 299;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size + so_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 19;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 21;
|
|
|
|
|
nack.has_so = true;
|
|
|
|
|
nack.so_start = 333;
|
|
|
|
|
nack.so_end = 111;
|
|
|
|
|
nack.has_nack_range = true;
|
|
|
|
|
nack.nack_range = 5;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size + so_size + range_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
{
|
|
|
|
|
rlc_status_nack_t nack;
|
|
|
|
|
nack.nack_sn = 27;
|
|
|
|
|
nack.has_so = true;
|
|
|
|
|
nack.so_start = 444;
|
|
|
|
|
nack.so_end = 666;
|
|
|
|
|
nack.has_nack_range = true;
|
|
|
|
|
nack.nack_range = 3;
|
|
|
|
|
status_pdu.push_nack(nack);
|
|
|
|
|
}
|
|
|
|
|
expected_size += nack_size + so_size + range_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 77);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=77, NACKs=[12][14][17 50:99][17 150:199][17 250:299][19][21 333:111 r5][27 444:666 r3]
|
|
|
|
|
|
|
|
|
|
// create a copy, check content
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu_copy = status_pdu;
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.ack_sn, 77);
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu_copy, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=77, NACKs=[12][14][17 50:99][17 150:199][17 250:299][19][21 333:111 r5][27 444:666 r3]
|
|
|
|
|
|
|
|
|
|
// trim to much larger size: nothing should change
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size * 2), true);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 77);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// trim to exact size: nothing should change
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size), true);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 77);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// trim to (expected_size - 1): this should remove the last NACK and update ACK accordingly
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size - 1), true);
|
|
|
|
|
expected_size -= nack_size + so_size + range_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 27);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=27, NACKs=[12][14][17 50:99][17 150:199][17 250:299][19][21 333:111 r5]
|
|
|
|
|
|
|
|
|
|
// trim to (expected_size - last two NACKs): this should remove the last NACK and update ACK accordingly
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size - (2 * nack_size + so_size + range_size)), true);
|
|
|
|
|
expected_size -= 2 * nack_size + so_size + range_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 19);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=19, NACKs=[12][14][17 50:99][17 150:199][17 250:299]
|
|
|
|
|
|
|
|
|
|
// trim to (expected_size - 1): this should remove the last NACK and all other NACKs with the same SN
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size - 1), true);
|
|
|
|
|
expected_size -= 3 * (nack_size + so_size);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 17);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=17, NACKs=[12][14]
|
|
|
|
|
|
|
|
|
|
// trim to impossible size = 1: this should report a failure without changes of the PDU
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(1), false);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 17);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=17, NACKs=[12][14]
|
|
|
|
|
|
|
|
|
|
// trim to minimum size: this should remove all NACKs and update ACK to the SN of the first NACK
|
|
|
|
|
expected_size = min_size;
|
|
|
|
|
TESTASSERT_EQ(status_pdu.trim(expected_size), true);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.ack_sn, 12);
|
|
|
|
|
TESTASSERT_EQ(status_pdu.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
|
|
|
|
|
// current state: ACK=12, NACKs empty
|
|
|
|
|
|
|
|
|
|
// check the copy again - should be unchanged if not a shallow copy
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.ack_sn, 77);
|
|
|
|
|
TESTASSERT_EQ(status_pdu_copy.packed_size, expected_size);
|
|
|
|
|
TESTASSERT_EQ(rlc_am_nr_write_status_pdu(status_pdu_copy, sn_size, &pdu), SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT_EQ(pdu.N_bytes, expected_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///< Control PDU tests (18bit SN)
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=235929=0x39999=0b11 1001 1001 1001 1001 and no further NACK_SN (E1 bit not set)
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test1()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test 1");
|
|
|
|
|
const int len = 3;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x0E, 0x66, 0x64};
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 235929);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 0);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=235929=0x39999=0b11 1001 1001 1001 1001 (E1 bit set)
|
|
|
|
|
// and NACK_SN=222822=0x36666=0b11 0110 0110 0110 0110
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test2()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test 2");
|
|
|
|
|
const int len = 6;
|
|
|
|
|
std::array<uint8_t, len> tv = {0x0E, 0x66, 0x66, 0xD9, 0x99, 0x80};
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 235929);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 1);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 222822);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=235929=0x39999=0b11 1001 1001 1001 1001 (E1 bit set),
|
|
|
|
|
// NACK_SN=222822=0x36666=0b11 0110 0110 0110 0110 (E1 and E2 bit set),
|
|
|
|
|
// SO_START=2, SO_END=5,
|
|
|
|
|
// NACK_SN=222975=0x366ff=0b11 0110 0110 1111 1111 (E2 bit set),
|
|
|
|
|
// SO_START=5, SO_END=0xFFFF
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test3()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test 3");
|
|
|
|
|
const int len = 17;
|
|
|
|
|
std::array<uint8_t, len> tv = {0b00001110, // D/C | 3CPT | 4ACK_SN_upper
|
|
|
|
|
0b01100110, // 8ACK_SN_center
|
|
|
|
|
0b01100110, // 6ACK_SN_lower | E1 | R
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10011001, // 8NACK_SN_center
|
|
|
|
|
0b10110000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x02, // 8SO_START_lower
|
|
|
|
|
0x00, // 8SO_END_upper
|
|
|
|
|
0x05, // 8SO_END_lower
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10111111, // 8NACK_SN_center
|
|
|
|
|
0b11010000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x05, // 8SO_START_lower
|
|
|
|
|
0xFF, // 8SO_END_upper
|
|
|
|
|
0xFF}; // 8SO_END_lower
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 235929);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 222822);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_start == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_end == 5);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_sn == 222975);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_start == 5);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_end == 0xFFFF);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=235929=0x39999=0b11 1001 1001 1001 1001 (E1 bit set),
|
|
|
|
|
// NACK_SN=222822=0x36666=0b11 0110 0110 0110 0110 (E1 and E2 bit set),
|
|
|
|
|
// SO_START=2, SO_END=5,
|
|
|
|
|
// NACK_SN=222975=0x366ff=0b11 0110 0110 1111 1111 (E1 and E2 bit not set),
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test4()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test 4");
|
|
|
|
|
const int len = 13;
|
|
|
|
|
std::array<uint8_t, len> tv = {0b00001110, // D/C | 3CPT | 4ACK_SN_upper
|
|
|
|
|
0b01100110, // 8ACK_SN_center
|
|
|
|
|
0b01100110, // 6ACK_SN_lower | E1 | R
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10011001, // 8NACK_SN_center
|
|
|
|
|
0b10110000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x02, // 8SO_START_lower
|
|
|
|
|
0x00, // 8SO_END_upper
|
|
|
|
|
0x05, // 8SO_END_lower
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10111111, // 8NACK_SN_center
|
|
|
|
|
0b11000000}; // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 235929);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 222822);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_start == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].so_end == 5);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_sn == 222975);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_so == false);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Malformed Status PDU, similar to test3 but with E1 still set at the end of the PDU
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=235929=0x39999=0b11 1001 1001 1001 1001 (E1 bit set),
|
|
|
|
|
// NACK_SN=222822=0x36666=0b11 0110 0110 0110 0110 (E1 and E2 bit set),
|
|
|
|
|
// SO_START=2, SO_END=5,
|
|
|
|
|
// NACK_SN=222975=0x366ff=0b11 0110 0110 1111 1111 ([!E1!] and E2 bit set),
|
|
|
|
|
// SO_START=5, SO_END=0xFFFF
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test5()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test 5");
|
|
|
|
|
const int len = 17;
|
|
|
|
|
std::array<uint8_t, len> tv = {0b00001110, // D/C | 3CPT | 4ACK_SN_upper
|
|
|
|
|
0b01100110, // 8ACK_SN_center
|
|
|
|
|
0b01100110, // 6ACK_SN_lower | E1 | R
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10011001, // 8NACK_SN_center
|
|
|
|
|
0b10110000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x02, // 8SO_START_lower
|
|
|
|
|
0x00, // 8SO_END_upper
|
|
|
|
|
0x05, // 8SO_END_lower
|
|
|
|
|
0b11011001, // 8NACK_SN_upper
|
|
|
|
|
0b10111111, // 8NACK_SN_center
|
|
|
|
|
0b11110000, // 2NACK_SN_lower | [!E1!] | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x05, // 8SO_START_lower
|
|
|
|
|
0xFF, // 8SO_END_upper
|
|
|
|
|
0xFF}; // 8SO_END_lower
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Status PDU for 18bit SN with ACK_SN=200977=0x31111=0b11 0001 0001 0001 0001,
|
|
|
|
|
// NACK range0: 3 full SDUs, NACK_SN=69905=0x11111=0b01 0001 0001 0001 0001
|
|
|
|
|
// NACK range1: missing segment sequence across 4 SDUs
|
|
|
|
|
// starting at NACK_SN=69913=0x11119=0b01 0001 0001 0001 1001, SO_START=2,
|
|
|
|
|
// ending at NACK_SN=69916, SO_END=5
|
|
|
|
|
// E1 and E3 bit set on first NACK, E2 and E3 bit set on the second.
|
|
|
|
|
int rlc_am_nr_control_pdu_18bit_sn_test_nack_range()
|
|
|
|
|
{
|
|
|
|
|
test_delimit_logger delimiter("Control PDU (18bit SN) test NACK range");
|
|
|
|
|
const int len = 15;
|
|
|
|
|
std::array<uint8_t, len> tv = {0b00001100, // D/C | 3CPT | 4ACK_SN_upper
|
|
|
|
|
0b01000100, // 8ACK_SN_center
|
|
|
|
|
0b01000110, // 6ACK_SN_lower | E1 | R
|
|
|
|
|
0b01000100, // 8NACK_SN_upper
|
|
|
|
|
0b01000100, // 8NACK_SN_center
|
|
|
|
|
0b01101000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x03, // 8NACK_range
|
|
|
|
|
0b01000100, // 8NACK_SN_upper
|
|
|
|
|
0b01000110, // 8NACK_SN_center
|
|
|
|
|
0b01011000, // 2NACK_SN_lower | E1 | E2 | E3 | 3R
|
|
|
|
|
0x00, // 8SO_START_upper
|
|
|
|
|
0x02, // 8SO_START_lower
|
|
|
|
|
0x00, // 8SO_END_upper
|
|
|
|
|
0x05, // 8SO_END_lower
|
|
|
|
|
0x04}; // 8NACK_range
|
|
|
|
|
srsran::byte_buffer_t pdu = make_pdu_and_log(tv);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true);
|
|
|
|
|
|
|
|
|
|
// unpack PDU
|
|
|
|
|
rlc_am_nr_status_pdu_t status_pdu(srsran::rlc_am_nr_sn_size_t::size18bits);
|
|
|
|
|
TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &status_pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(status_pdu.ack_sn == 200977);
|
|
|
|
|
TESTASSERT(status_pdu.nacks.size() == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_sn == 69905);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_so == false);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].has_nack_range == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[0].nack_range == 3);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_sn == 69913);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_so == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_start == 2);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].so_end == 5);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].has_nack_range == true);
|
|
|
|
|
TESTASSERT(status_pdu.nacks[1].nack_range == 4);
|
|
|
|
|
|
|
|
|
|
// reset status PDU
|
|
|
|
|
pdu.clear();
|
|
|
|
|
|
|
|
|
|
// pack again
|
|
|
|
|
TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &pdu) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(pdu.N_bytes == tv.size());
|
|
|
|
|
|
|
|
|
|
write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes);
|
|
|
|
|
TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
static const struct option long_options[] = {{"pcap", no_argument, nullptr, 'p'}, {nullptr, 0, nullptr, 0}};
|
|
|
|
@ -441,28 +991,73 @@ int main(int argc, char** argv)
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test1()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test1() failed.\n");
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test1()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test1() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test2()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test2() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test3()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test3() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test4()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test4() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test5()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test5() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_12bit_sn_test_nack_range()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_12bit_sn_test_nack_range() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test_trimming(rlc_am_nr_sn_size_t::size12bits)) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test_trimming(size12bits) failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test1()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test1() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test2()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test2() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test3()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test3() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test2()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test2() failed.\n");
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test4()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test4() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test3()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test3() failed.\n");
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test5()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test5() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test4()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test4() failed.\n");
|
|
|
|
|
if (rlc_am_nr_control_pdu_18bit_sn_test_nack_range()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_18bit_sn_test_nack_range() failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rlc_am_nr_control_pdu_test5()) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test5() failed.\n");
|
|
|
|
|
if (rlc_am_nr_control_pdu_test_trimming(rlc_am_nr_sn_size_t::size18bits)) {
|
|
|
|
|
fprintf(stderr, "rlc_am_nr_control_pdu_test_trimming(size18bits) failed.\n");
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|