rlc_um_nr_pdu_test: add 12bit SN unpack test

This commit is contained in:
Andre Puschmann 2021-02-24 11:02:20 +01:00
parent 06e7f169c6
commit 5e93a6f5bd
2 changed files with 39 additions and 8 deletions

View File

@ -45,7 +45,7 @@ target_link_libraries(rlc_common_test srslte_upper srslte_phy)
add_test(rlc_common_test rlc_common_test)
add_executable(rlc_um_nr_pdu_test rlc_um_nr_pdu_test.cc)
target_link_libraries(rlc_um_nr_pdu_test srslte_upper srslte_phy)
target_link_libraries(rlc_um_nr_pdu_test srslte_upper srslte_mac srslte_phy)
add_nr_test(rlc_um_nr_pdu_test rlc_um_nr_pdu_test)
add_executable(rlc_um_nr_test rlc_um_nr_test.cc)

View File

@ -27,16 +27,16 @@
} \
}
#define PCAP 0
#define PCAP 1
#define PCAP_CRNTI (0x1001)
#define PCAP_TTI (666)
using namespace srslte;
#if PCAP
#include "srslte/common/mac_nr_pcap.h"
#include "srslte/mac/mac_nr_pdu.h"
static std::unique_ptr<srslte::mac_nr_pcap> pcap_handle = nullptr;
#include "srslte/common/mac_pcap.h"
#include "srslte/mac/mac_sch_pdu_nr.h"
static std::unique_ptr<srslte::mac_pcap> pcap_handle = nullptr;
#endif
int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_t len)
@ -44,11 +44,11 @@ int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_
#if PCAP
if (pcap_handle) {
byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu;
srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, len + 10);
tx_pdu.add_sdu(lcid, payload, len);
tx_pdu.pack();
pcap_handle->write_dl_crnti(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
return SRSLTE_SUCCESS;
}
#endif
@ -195,10 +195,32 @@ int rlc_um_nr_pdu_unpack_test5()
return SRSLTE_SUCCESS;
}
// Unpack RLC UM 12bit SN PDU with PDCP and ICMP
int rlc_um_nr_pdu_unpack_test6()
{
std::array<uint8_t, 88> tv = {
0x00, 0x80, 0x00, 0x01, 0x45, 0x00, 0x00, 0x54, 0x34, 0xee, 0x40, 0x00, 0x40, 0x01, 0x80, 0x67, 0xc0, 0xa8,
0x02, 0x01, 0xc0, 0xa8, 0x02, 0x02, 0x08, 0x00, 0xf0, 0x38, 0x56, 0x9b, 0x00, 0x02, 0x74, 0x40, 0x35, 0x60,
0x00, 0x00, 0x00, 0x00, 0x3e, 0xb6, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37};
srslte::byte_buffer_t pdu = make_pdu_and_log(tv);
// unpack PDU
rlc_um_nr_pdu_header_t header = {};
TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size12bits, &header) != 0);
TESTASSERT(header.si == rlc_nr_si_field_t::full_sdu);
TESTASSERT(header.so == 0);
TESTASSERT(header.sn == 0);
return SRSLTE_SUCCESS;
}
int main(int argc, char** argv)
{
#if PCAP
pcap_handle = std::unique_ptr<srslte::mac_nr_pcap>(new srslte::mac_nr_pcap());
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::nr));
pcap_handle->open("rlc_um_nr_pdu_test.pcap");
#endif
@ -229,5 +251,14 @@ int main(int argc, char** argv)
return SRSLTE_ERROR;
}
if (rlc_um_nr_pdu_unpack_test6()) {
fprintf(stderr, "rlc_um_nr_pdu_unpack_test6() failed.\n");
return SRSLTE_ERROR;
}
#if PCAP
pcap_handle->close();
#endif
return SRSLTE_SUCCESS;
}