|
|
|
@ -247,6 +247,28 @@ int mac_dl_sch_pdu_pack_test5()
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mac_dl_sch_pdu_unpack_test6()
|
|
|
|
|
{
|
|
|
|
|
// MAC PDU with DL-SCH subheader reserved LCID
|
|
|
|
|
// Bit 1-8
|
|
|
|
|
// | | | | | | | | |
|
|
|
|
|
// | R |F=1| LCID | Octet 1
|
|
|
|
|
// | L | Octet 2
|
|
|
|
|
|
|
|
|
|
// TV2 - MAC PDU with reserved LCID (46=0x2e)
|
|
|
|
|
uint8_t mac_dl_sch_pdu_2[] = {0x2e, 0x04, 0x11, 0x22, 0x33, 0x44};
|
|
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
pcap_handle->write_dl_crnti(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte::mac_nr_sch_pdu pdu;
|
|
|
|
|
pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2));
|
|
|
|
|
TESTASSERT(pdu.get_num_subpdus() == 0);
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mac_ul_sch_pdu_unpack_test1()
|
|
|
|
|
{
|
|
|
|
|
// UL-SCH MAC PDU with fixed-size CE and DL-SCH subheader with 16-bit length field
|
|
|
|
@ -337,6 +359,117 @@ int mac_ul_sch_pdu_unpack_and_pack_test2()
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mac_ul_sch_pdu_unpack_and_pack_test3()
|
|
|
|
|
{
|
|
|
|
|
// MAC PDU with UL-SCH (with normal LCID) subheader for short SDU
|
|
|
|
|
// Bit 1-8
|
|
|
|
|
// | | | | | | | | |
|
|
|
|
|
// | R |F=0| LCID | Octet 1
|
|
|
|
|
// | L | Octet 2
|
|
|
|
|
|
|
|
|
|
// TV1 - MAC PDU with short subheader for CCCH, MAC SDU length is 8 B, total PDU is 10 B
|
|
|
|
|
uint8_t mac_ul_sch_pdu_1[] = {0x02, 0x0a, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa};
|
|
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte::mac_nr_sch_pdu pdu(true);
|
|
|
|
|
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
|
|
|
|
|
TESTASSERT(pdu.get_num_subpdus() == 1);
|
|
|
|
|
|
|
|
|
|
mac_nr_sch_subpdu subpdu = pdu.get_subpdu(0);
|
|
|
|
|
TESTASSERT(subpdu.get_total_length() == 12);
|
|
|
|
|
TESTASSERT(subpdu.get_sdu_length() == 10);
|
|
|
|
|
TESTASSERT(subpdu.get_lcid() == 2);
|
|
|
|
|
|
|
|
|
|
// pack PDU again
|
|
|
|
|
byte_buffer_t tx_buffer;
|
|
|
|
|
|
|
|
|
|
srslte::mac_nr_sch_pdu tx_pdu;
|
|
|
|
|
tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true);
|
|
|
|
|
|
|
|
|
|
// Add SDU part of TV from above
|
|
|
|
|
tx_pdu.add_sdu(2, &mac_ul_sch_pdu_1[2], 10);
|
|
|
|
|
|
|
|
|
|
TESTASSERT(tx_pdu.get_remaing_len() == 0);
|
|
|
|
|
TESTASSERT(tx_buffer.N_bytes == sizeof(mac_ul_sch_pdu_1));
|
|
|
|
|
TESTASSERT(memcmp(tx_buffer.msg, mac_ul_sch_pdu_1, tx_buffer.N_bytes) == 0);
|
|
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
pcap_handle->write_ul_crnti(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte::log_filter log("MAC");
|
|
|
|
|
log.set_level(srslte::LOG_LEVEL_DEBUG);
|
|
|
|
|
log.set_hex_limit(100000);
|
|
|
|
|
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mac_ul_sch_pdu_pack_test4()
|
|
|
|
|
{
|
|
|
|
|
// MAC PDU with UL-SCH (with normal LCID) subheader for long SDU
|
|
|
|
|
// Bit 1-8
|
|
|
|
|
// | | | | | | | | |
|
|
|
|
|
// | R |F=1| LCID | Octet 1
|
|
|
|
|
// | L | Octet 2
|
|
|
|
|
// | L | Octet 3
|
|
|
|
|
|
|
|
|
|
uint8_t sdu[512] = {};
|
|
|
|
|
|
|
|
|
|
// populate SDU payload
|
|
|
|
|
for (uint32_t i = 0; i < 512; i++) {
|
|
|
|
|
sdu[i] = i % 256;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// pack PDU again
|
|
|
|
|
byte_buffer_t tx_buffer;
|
|
|
|
|
|
|
|
|
|
srslte::mac_nr_sch_pdu tx_pdu;
|
|
|
|
|
tx_pdu.init_tx(&tx_buffer, sizeof(sdu) + 3, true);
|
|
|
|
|
|
|
|
|
|
// Add SDU part of TV from above
|
|
|
|
|
tx_pdu.add_sdu(2, sdu, sizeof(sdu));
|
|
|
|
|
|
|
|
|
|
TESTASSERT(tx_pdu.get_remaing_len() == 0);
|
|
|
|
|
TESTASSERT(tx_buffer.N_bytes == sizeof(sdu) + 3);
|
|
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
pcap_handle->write_ul_crnti(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte::log_filter log("MAC");
|
|
|
|
|
log.set_level(srslte::LOG_LEVEL_DEBUG);
|
|
|
|
|
log.set_hex_limit(100000);
|
|
|
|
|
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int mac_ul_sch_pdu_unpack_test5()
|
|
|
|
|
{
|
|
|
|
|
// MAC PDU with UL-SCH (with normal LCID) subheader for short SDU but reserved LCID
|
|
|
|
|
// Bit 1-8
|
|
|
|
|
// | | | | | | | | |
|
|
|
|
|
// | R |F=0| LCID | Octet 1
|
|
|
|
|
// | L | Octet 2
|
|
|
|
|
|
|
|
|
|
// TV1 - MAC PDU with short subheader but reserved LCID for UL-SCH (LCID=33)
|
|
|
|
|
uint8_t mac_ul_sch_pdu_1[] = {0x21, 0x0a, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa};
|
|
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte::mac_nr_sch_pdu pdu(true);
|
|
|
|
|
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
|
|
|
|
|
TESTASSERT(pdu.get_num_subpdus() == 0);
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
#if PCAP
|
|
|
|
@ -369,6 +502,11 @@ int main(int argc, char** argv)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mac_dl_sch_pdu_unpack_test6()) {
|
|
|
|
|
fprintf(stderr, "mac_dl_sch_pdu_unpack_test6() failed.\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mac_ul_sch_pdu_unpack_test1()) {
|
|
|
|
|
fprintf(stderr, "mac_ul_sch_pdu_unpack_test1() failed.\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
@ -379,5 +517,20 @@ int main(int argc, char** argv)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mac_ul_sch_pdu_unpack_and_pack_test3()) {
|
|
|
|
|
fprintf(stderr, "mac_ul_sch_pdu_unpack_and_pack_test3() failed.\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mac_ul_sch_pdu_pack_test4()) {
|
|
|
|
|
fprintf(stderr, "mac_ul_sch_pdu_pack_test4() failed.\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mac_ul_sch_pdu_unpack_test5()) {
|
|
|
|
|
fprintf(stderr, "mac_ul_sch_pdu_unpack_test5() failed.\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|