From 5d9211158616cc4666ab772a0e82c4f3dcdb9825 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 5 Dec 2019 10:35:18 +0100 Subject: [PATCH] pcap: adding SL-SCH support --- lib/include/srslte/common/mac_pcap.h | 3 +++ lib/include/srslte/common/pcap.h | 4 ++++ lib/src/common/mac_pcap.cc | 11 +++++++++++ lib/test/mac/pdu_test.cc | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/lib/include/srslte/common/mac_pcap.h b/lib/include/srslte/common/mac_pcap.h index 6cb1a5655..cb920e962 100644 --- a/lib/include/srslte/common/mac_pcap.h +++ b/lib/include/srslte/common/mac_pcap.h @@ -51,6 +51,9 @@ public: void write_ul_rrc_pdu(const uint8_t* input, const int32_t input_len); + // Sidelink + void write_sl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint32_t reTX, uint32_t tti, uint8_t cc_idx); + private: bool enable_write; FILE* pcap_file; diff --git a/lib/include/srslte/common/pcap.h b/lib/include/srslte/common/pcap.h index 39caa43bd..6cdc44f88 100644 --- a/lib/include/srslte/common/pcap.h +++ b/lib/include/srslte/common/pcap.h @@ -66,6 +66,10 @@ typedef struct pcaprec_hdr_s { #define SI_RNTI 4 #define SPS_RNTI 5 #define M_RNTI 6 +#define SL_BCH_RNTI 7 +#define SL_RNTI 8 +#define SC_RNTI 9 +#define G_RNTI 10 #define MAC_LTE_START_STRING "mac-lte" #define MAC_LTE_PAYLOAD_TAG 0x01 diff --git a/lib/src/common/mac_pcap.cc b/lib/src/common/mac_pcap.cc index bf0fcb5fd..e43e2e051 100644 --- a/lib/src/common/mac_pcap.cc +++ b/lib/src/common/mac_pcap.cc @@ -114,6 +114,17 @@ void mac_pcap::write_ul_crnti(uint8_t* pdu, { pack_and_write(pdu, pdu_len_bytes, reTX, true, cc_idx, tti, rnti, DIRECTION_UPLINK, C_RNTI); } + +void mac_pcap::write_sl_crnti(uint8_t* pdu, + uint32_t pdu_len_bytes, + uint16_t rnti, + uint32_t reTX, + uint32_t tti, + uint8_t cc_idx) +{ + pack_and_write(pdu, pdu_len_bytes, reTX, true, cc_idx, tti, rnti, DIRECTION_UPLINK, SL_RNTI); +} + void mac_pcap::write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx) { pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, 0, DIRECTION_DOWNLINK, NO_RNTI); diff --git a/lib/test/mac/pdu_test.cc b/lib/test/mac/pdu_test.cc index b3aa0d414..70e928c74 100644 --- a/lib/test/mac/pdu_test.cc +++ b/lib/test/mac/pdu_test.cc @@ -730,6 +730,26 @@ int mac_sch_pdu_unpack_test2() return SRSLTE_SUCCESS; } +int mac_slsch_pdu_unpack_test1() +{ + // SL-SCH PDU captures from UXM 5G CV2X + static uint8_t tv[] = {0x30, 0xED, 0x0E, 0x03, 0x00, 0x00, 0x01, 0x21, 0x2B, 0x1F, 0x9F, 0x75, 0x76, + 0x87, 0x00, 0x00, 0x8E, 0x9E, 0xA5, 0xFD, 0xA1, 0xA3, 0xA7, 0xA9, 0x7F, 0x68, + 0x6C, 0xB8, 0xBF, 0x0F, 0x96, 0x89, 0x2E, 0xDC, 0x80, 0x64, 0x06, 0x40, 0x00, + 0x18, 0x6A, 0x07, 0x20, 0x7C, 0xE1, 0xE0, 0x04, 0x40, 0x02, 0x04, 0x80, 0x60, + 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + srslte::log_filter mac_log("MAC"); + mac_log.set_level(srslte::LOG_LEVEL_DEBUG); + mac_log.set_hex_limit(100000); + +#if HAVE_PCAP + pcap_handle->write_sl_crnti(tv, sizeof(tv), CRNTI, true, 1); +#endif + + return SRSLTE_SUCCESS; +} + int main(int argc, char** argv) { #if HAVE_PCAP @@ -820,5 +840,7 @@ int main(int argc, char** argv) TESTASSERT(mac_sch_pdu_pack_test8() == SRSLTE_SUCCESS); + TESTASSERT(mac_slsch_pdu_unpack_test1() == SRSLTE_SUCCESS); + return SRSLTE_SUCCESS; }