|
|
@ -13,21 +13,59 @@
|
|
|
|
#ifndef SRSRAN_TEST_PCAP_H
|
|
|
|
#ifndef SRSRAN_TEST_PCAP_H
|
|
|
|
#define SRSRAN_TEST_PCAP_H
|
|
|
|
#define SRSRAN_TEST_PCAP_H
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_PCAP
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Helper class for tests that wish to dump RRC, PDCP or MAC SDUs into PCAP files in order to inspect them with
|
|
|
|
|
|
|
|
* Wireshark.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Depending on the layer of interest, the class adds the protocol header for the layers below so that Wireshark can
|
|
|
|
|
|
|
|
* disect them. For RRC for example, both PDCP and RLC AM dummy headers are added.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* There is an EUTRA and NR version for the helper methods.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "srsran/common/mac_pcap.h"
|
|
|
|
#include "srsran/common/mac_pcap.h"
|
|
|
|
#include "srsran/mac/mac_sch_pdu_nr.h"
|
|
|
|
#include "srsran/mac/mac_sch_pdu_nr.h"
|
|
|
|
static std::unique_ptr<srsran::mac_pcap> pcap_handle = nullptr;
|
|
|
|
static std::unique_ptr<srsran::mac_pcap> pcap_handle = nullptr;
|
|
|
|
#define PCAP_CRNTI (0x1001)
|
|
|
|
#define PCAP_CRNTI (0x1001)
|
|
|
|
#define PCAP_TTI (666)
|
|
|
|
#define PCAP_TTI (666)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace srsran {
|
|
|
|
namespace srsran {
|
|
|
|
|
|
|
|
|
|
|
|
int write_mac_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint32_t len);
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Writes a MAC SDU of a gives LCID for NR
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param lcid The logical channel ID of the SDU
|
|
|
|
|
|
|
|
* @param payload Pointer to payload
|
|
|
|
|
|
|
|
* @param len Length
|
|
|
|
|
|
|
|
* @return int
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int write_mac_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint32_t len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
|
|
|
byte_buffer_t tx_buffer;
|
|
|
|
|
|
|
|
srsran::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_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, 0, PCAP_TTI);
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int write_rlc_am_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint32_t len)
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Writes a PDCP SDU (e.g. RRC DL-DCCH PDU)
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Both PDCP and RLC AM header (dummy for SN=0) are added.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param lcid The logical channel ID of the SDU
|
|
|
|
|
|
|
|
* @param payload Pointer to payload
|
|
|
|
|
|
|
|
* @param len Length
|
|
|
|
|
|
|
|
* @return int
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int write_pdcp_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint32_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if HAVE_PCAP
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
if (pcap_handle) {
|
|
|
|
byte_buffer_t mac_sdu;
|
|
|
|
byte_buffer_t mac_sdu;
|
|
|
|
// Add dummy RLC AM PDU header
|
|
|
|
// Add dummy RLC AM PDU header
|
|
|
@ -43,23 +81,6 @@ int write_rlc_am_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint3
|
|
|
|
mac_sdu.N_bytes += len;
|
|
|
|
mac_sdu.N_bytes += len;
|
|
|
|
return write_mac_sdu_nr(lcid, mac_sdu.msg, mac_sdu.N_bytes);
|
|
|
|
return write_mac_sdu_nr(lcid, mac_sdu.msg, mac_sdu.N_bytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAVE_PCAP
|
|
|
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int write_mac_sdu_nr(const uint32_t lcid, const uint8_t* payload, const uint32_t len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAVE_PCAP
|
|
|
|
|
|
|
|
if (pcap_handle) {
|
|
|
|
|
|
|
|
byte_buffer_t tx_buffer;
|
|
|
|
|
|
|
|
srsran::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_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, 0, PCAP_TTI);
|
|
|
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAVE_PCAP
|
|
|
|
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
return SRSRAN_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|