mirror of https://github.com/pvnis/srsRAN_4G.git
mac_pcap: refactor MAC PCAP and include NR RAT into same object
after adding the thread-safe PCAP writer functionality to the EUTRA MAC object it became clear that we don't wont to replicate the same for the NR object. This patch therefore refactors the class that now supports both EUTRA and NR rats. The old mac_nr_pcap.[h/cc] has been deleted. All test-cases and usages now use the new object that needs to pass the RAT type in the ctor. this patch addresses the last open point of #2160master
parent
199f1c953e
commit
8e13f04684
@ -1,54 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2020 Software Radio Systems Limited
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SRSLTE_MAC_NR_PCAP_H
|
||||
#define SRSLTE_MAC_NR_PCAP_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace srslte {
|
||||
|
||||
class mac_nr_pcap
|
||||
{
|
||||
public:
|
||||
mac_nr_pcap();
|
||||
~mac_nr_pcap();
|
||||
void enable(const bool& enable_);
|
||||
void open(const std::string& filename, const uint16_t& ue_id = 0);
|
||||
void close();
|
||||
|
||||
void set_ue_id(const uint16_t& ue_id);
|
||||
|
||||
void write_dl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, uint8_t harqid, uint32_t tti);
|
||||
void write_ul_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti);
|
||||
void write_dl_ra_rnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti);
|
||||
void write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti);
|
||||
void write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti);
|
||||
void write_dl_si_rnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti);
|
||||
|
||||
private:
|
||||
bool enable_write = false;
|
||||
std::string filename;
|
||||
FILE* pcap_file = nullptr;
|
||||
uint32_t ue_id = 0;
|
||||
void pack_and_write(uint8_t* pdu,
|
||||
uint32_t pdu_len_bytes,
|
||||
uint32_t tti,
|
||||
uint16_t crnti_,
|
||||
uint8_t harqid,
|
||||
uint8_t direction,
|
||||
uint8_t rnti_type);
|
||||
};
|
||||
|
||||
} // namespace srslte
|
||||
|
||||
#endif // SRSLTE_MAC_NR_PCAP_H
|
@ -1,108 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2020 Software Radio Systems Limited
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "srslte/common/mac_nr_pcap.h"
|
||||
#include "srslte/common/pcap.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace srslte {
|
||||
|
||||
mac_nr_pcap::mac_nr_pcap() {}
|
||||
|
||||
mac_nr_pcap::~mac_nr_pcap()
|
||||
{
|
||||
if (pcap_file) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void mac_nr_pcap::enable(const bool& enable_)
|
||||
{
|
||||
enable_write = enable_;
|
||||
}
|
||||
void mac_nr_pcap::open(const std::string& filename_, const uint16_t& ue_id_)
|
||||
{
|
||||
fprintf(stdout, "Opening MAC-NR PCAP with DLT=%d\n", UDP_DLT);
|
||||
filename = filename_;
|
||||
pcap_file = LTE_PCAP_Open(UDP_DLT, filename.c_str());
|
||||
ue_id = ue_id_;
|
||||
enable_write = true;
|
||||
}
|
||||
void mac_nr_pcap::close()
|
||||
{
|
||||
enable_write = false;
|
||||
fprintf(stdout, "Saving MAC-NR PCAP to %s\n", filename.c_str());
|
||||
LTE_PCAP_Close(pcap_file);
|
||||
pcap_file = nullptr;
|
||||
}
|
||||
|
||||
void mac_nr_pcap::set_ue_id(const uint16_t& ue_id_)
|
||||
{
|
||||
ue_id = ue_id_;
|
||||
}
|
||||
|
||||
void mac_nr_pcap::pack_and_write(uint8_t* pdu,
|
||||
uint32_t pdu_len_bytes,
|
||||
uint32_t tti,
|
||||
uint16_t crnti,
|
||||
uint8_t harqid,
|
||||
uint8_t direction,
|
||||
uint8_t rnti_type)
|
||||
{
|
||||
if (enable_write) {
|
||||
mac_nr_context_info_t context = {};
|
||||
context.radioType = FDD_RADIO;
|
||||
context.direction = direction;
|
||||
context.rntiType = rnti_type;
|
||||
context.rnti = crnti;
|
||||
context.ueid = ue_id;
|
||||
context.harqid = harqid;
|
||||
context.system_frame_number = tti / 10;
|
||||
context.sub_frame_number = tti % 10;
|
||||
|
||||
if (pdu) {
|
||||
NR_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_dl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_DOWNLINK, C_RNTI);
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_ul_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_UPLINK, C_RNTI);
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_dl_ra_rnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_DOWNLINK, RA_RNTI);
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_DOWNLINK, NO_RNTI);
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_DOWNLINK, P_RNTI);
|
||||
}
|
||||
|
||||
void mac_nr_pcap::write_dl_si_rnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti)
|
||||
{
|
||||
pack_and_write(pdu, pdu_len_bytes, tti, rnti, harqid, DIRECTION_DOWNLINK, SI_RNTI);
|
||||
}
|
||||
|
||||
} // namespace srslte
|
Loading…
Reference in New Issue