2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/common/test_common.h"
|
|
|
|
#include "srsran/upper/rlc_am_lte.h"
|
2017-05-18 03:52:29 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
// Simple status PDU
|
2020-07-06 13:34:26 -07:00
|
|
|
int simple_status_pdu_test1()
|
2019-12-16 07:04:22 -08:00
|
|
|
{
|
2020-07-06 13:34:26 -07:00
|
|
|
uint8_t pdu1[] = {0x00, 0x78};
|
|
|
|
uint32_t PDU1_LEN = 2;
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::rlc_status_pdu_t s1;
|
|
|
|
srsran::byte_buffer_t b1, b2;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
memcpy(b1.msg, &pdu1[0], PDU1_LEN);
|
|
|
|
b1.N_bytes = PDU1_LEN;
|
2019-04-15 07:43:44 -07:00
|
|
|
rlc_am_read_status_pdu(&b1, &s1);
|
2020-07-06 13:34:26 -07:00
|
|
|
TESTASSERT(s1.ack_sn == 30);
|
|
|
|
TESTASSERT(s1.N_nack == 0);
|
2019-04-15 07:43:44 -07:00
|
|
|
rlc_am_write_status_pdu(&s1, &b2);
|
2020-07-06 13:34:26 -07:00
|
|
|
TESTASSERT(b2.N_bytes == PDU1_LEN);
|
|
|
|
for (uint32_t i = 0; i < b2.N_bytes; i++) {
|
|
|
|
TESTASSERT(b2.msg[i] == b1.msg[i]);
|
|
|
|
}
|
2021-03-05 09:10:04 -08:00
|
|
|
TESTASSERT(rlc_am_is_valid_status_pdu(s1));
|
2021-03-19 03:45:56 -07:00
|
|
|
return SRSRAN_SUCCESS;
|
2020-07-06 13:34:26 -07:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2020-07-06 13:34:26 -07:00
|
|
|
// Status PDU with 4 NACKs
|
|
|
|
int status_pdu_with_nacks_test1()
|
|
|
|
{
|
|
|
|
uint8_t pdu2[] = {0x00, 0x22, 0x00, 0x40, 0x0C, 0x01, 0xC0, 0x20};
|
|
|
|
uint32_t PDU2_LEN = 8;
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::rlc_status_pdu_t s2;
|
|
|
|
srsran::byte_buffer_t b1, b2;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
memcpy(b1.msg, &pdu2[0], PDU2_LEN);
|
|
|
|
b1.N_bytes = PDU2_LEN;
|
2019-04-15 07:43:44 -07:00
|
|
|
rlc_am_read_status_pdu(&b1, &s2);
|
2020-07-06 13:34:26 -07:00
|
|
|
TESTASSERT(s2.ack_sn == 8);
|
|
|
|
TESTASSERT(s2.N_nack == 4);
|
|
|
|
TESTASSERT(s2.nacks[0].nack_sn == 0);
|
|
|
|
TESTASSERT(s2.nacks[1].nack_sn == 1);
|
|
|
|
TESTASSERT(s2.nacks[2].nack_sn == 3);
|
|
|
|
TESTASSERT(s2.nacks[3].nack_sn == 4);
|
2019-04-15 07:43:44 -07:00
|
|
|
rlc_am_write_status_pdu(&s2, &b2);
|
2020-07-06 13:34:26 -07:00
|
|
|
TESTASSERT(b2.N_bytes == PDU2_LEN);
|
|
|
|
for (uint32_t i = 0; i < b2.N_bytes; i++) {
|
|
|
|
TESTASSERT(b2.msg[i] == b1.msg[i]);
|
|
|
|
}
|
2021-03-05 09:10:04 -08:00
|
|
|
|
|
|
|
TESTASSERT(rlc_am_is_valid_status_pdu(s2));
|
2021-03-19 03:45:56 -07:00
|
|
|
return SRSRAN_SUCCESS;
|
2021-03-05 09:10:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int malformed_status_pdu_test()
|
|
|
|
{
|
|
|
|
uint8_t pdu[] = {0x0b, 0x77, 0x6d, 0xd6, 0xe5, 0x6f, 0x56, 0xf8};
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::rlc_status_pdu_t s1;
|
|
|
|
srsran::byte_buffer_t b1, b2;
|
2021-03-05 09:10:04 -08:00
|
|
|
|
|
|
|
memcpy(b1.msg, pdu, sizeof(pdu));
|
|
|
|
b1.N_bytes = sizeof(pdu);
|
|
|
|
rlc_am_read_status_pdu(&b1, &s1);
|
|
|
|
TESTASSERT(rlc_am_is_valid_status_pdu(s1) == false);
|
2021-03-19 03:45:56 -07:00
|
|
|
return SRSRAN_SUCCESS;
|
2020-07-06 13:34:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2021-02-10 04:16:53 -08:00
|
|
|
srslog::init();
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
TESTASSERT(simple_status_pdu_test1() == SRSRAN_SUCCESS);
|
|
|
|
TESTASSERT(status_pdu_with_nacks_test1() == SRSRAN_SUCCESS);
|
|
|
|
TESTASSERT(malformed_status_pdu_test() == SRSRAN_SUCCESS);
|
2020-07-06 13:34:26 -07:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
return SRSRAN_SUCCESS;
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|