Disable rat assignment in pcap class

master
David Rupprecht 4 years ago committed by Andre Puschmann
parent 24bea9a860
commit 5a95cbdfae

@ -27,7 +27,7 @@ namespace srslte {
class mac_pcap : srslte::thread
{
public:
mac_pcap(srslte_rat_t rat);
mac_pcap();
~mac_pcap();
void enable(bool enable);
uint32_t open(std::string filename, uint32_t ue_id = 0);
@ -63,7 +63,6 @@ public:
private:
srslog::basic_logger& logger;
bool running = false;
srslte_rat_t rat = srslte_rat_t::nulltype;
uint32_t dlt = 0; // The DLT used for the PCAP file
std::string filename;
FILE* pcap_file = nullptr;
@ -87,6 +86,7 @@ private:
typedef struct {
// Different PCAP context for both RATs
srslte::srslte_rat_t rat;
MAC_Context_Info_t context;
mac_nr_context_info_t context_nr;
unique_byte_buffer_t pdu;

@ -17,9 +17,7 @@
namespace srslte {
mac_pcap::mac_pcap(srslte_rat_t rat_) :
logger(srslog::fetch_basic_logger("MAC")), thread("PCAP_WRITER_" + to_string(rat_)), rat(rat_)
{}
mac_pcap::mac_pcap() : logger(srslog::fetch_basic_logger("MAC")), thread("PCAP_WRITER_MAC") {}
mac_pcap::~mac_pcap()
{
@ -41,18 +39,7 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_)
}
// set DLT for selected RAT
switch (rat) {
case srslte_rat_t::lte:
dlt = UDP_DLT;
break;
case srslte_rat_t::nr:
dlt = UDP_DLT;
break;
default:
logger.error("Error opening PCAP. Unsupported RAT selected.");
return SRSLTE_ERROR;
}
pcap_file = LTE_PCAP_Open(dlt, filename_.c_str());
if (pcap_file == nullptr) {
logger.error("Couldn't open %s to write PCAP", filename_.c_str());
@ -88,7 +75,7 @@ uint32_t mac_pcap::close()
// close file handle
{
std::lock_guard<std::mutex> lock(mutex);
srslte::console("Saving %s MAC PCAP (DLT=%d) to %s\n", to_string(rat).c_str(), dlt, filename.c_str());
srslte::console("Saving MAC PCAP (DLT=%d) to %s\n", dlt, filename.c_str());
LTE_PCAP_Close(pcap_file);
pcap_file = nullptr;
}
@ -99,7 +86,7 @@ uint32_t mac_pcap::close()
void mac_pcap::write_pdu(pcap_pdu_t& pdu)
{
if (pdu.pdu != nullptr) {
switch (rat) {
switch (pdu.rat) {
case srslte_rat_t::lte:
LTE_PCAP_MAC_UDP_WritePDU(pcap_file, &pdu.context, pdu.pdu->msg, pdu.pdu->N_bytes);
break;
@ -150,6 +137,7 @@ void mac_pcap::pack_and_queue(uint8_t* payload,
{
if (running && payload != nullptr) {
pcap_pdu_t pdu = {};
pdu.rat = srslte::srslte_rat_t::lte;
pdu.context.radioType = FDD_RADIO;
pdu.context.direction = direction;
pdu.context.rntiType = rnti_type;
@ -185,6 +173,7 @@ void mac_pcap::pack_and_queue_nr(uint8_t* payload,
{
if (running && payload != nullptr) {
pcap_pdu_t pdu = {};
pdu.rat = srslte_rat_t::nr;
pdu.context_nr.radioType = FDD_RADIO;
pdu.context_nr.direction = direction;
pdu.context_nr.rntiType = rnti_type;

@ -53,8 +53,7 @@ int mac_pcap_eutra_test()
uint32_t num_threads = 10;
uint32_t num_pdus_per_thread = 100;
std::unique_ptr<srslte::mac_pcap> pcap_handle =
std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::lte));
std::unique_ptr<srslte::mac_pcap> pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") == SRSLTE_SUCCESS);
TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") != SRSLTE_SUCCESS); // open again will fail
@ -82,8 +81,7 @@ int mac_pcap_nr_test()
uint32_t num_threads = 10;
uint32_t num_pdus_per_thread = 100;
std::unique_ptr<srslte::mac_pcap> pcap_handle =
std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::nr));
std::unique_ptr<srslte::mac_pcap> pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") == SRSLTE_SUCCESS);
TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") != SRSLTE_SUCCESS); // open again will fail

@ -608,7 +608,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test6()
int main(int argc, char** argv)
{
#if PCAP
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::nr));
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
pcap_handle->open("mac_nr_pdu_test.pcap");
#endif

@ -222,7 +222,7 @@ int rlc_um_nr_pdu_unpack_test6()
int main(int argc, char** argv)
{
#if PCAP
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::nr));
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
pcap_handle->open("rlc_um_nr_pdu_test.pcap");
#endif

@ -36,7 +36,7 @@ enb_stack_lte::enb_stack_lte(srslte::logger* logger_, srslog::sink& log_sink) :
s1ap(&task_sched, s1ap_logger),
rrc(&task_sched),
logger(logger_),
mac_pcap(srslte_rat_t::lte)
mac_pcap()
{
get_background_workers().set_nof_workers(2);
enb_task_queue = task_sched.make_task_queue();

@ -54,7 +54,7 @@ int mac_nr::init(const mac_nr_args_t& args_,
log_h->set_hex_limit(args.log_hex_limit);
if (args.pcap.enable) {
pcap = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap(srslte::srslte_rat_t::nr));
pcap = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
pcap->open(args.pcap.filename);
}

@ -33,8 +33,8 @@ ue_stack_lte::ue_stack_lte() :
rrc_logger(srslog::fetch_basic_logger("RRC", false)),
usim_logger(srslog::fetch_basic_logger("USIM", false)),
nas_logger(srslog::fetch_basic_logger("NAS", false)),
mac_pcap(srslte_rat_t::lte),
mac_nr_pcap(srslte_rat_t::nr),
mac_pcap(),
mac_nr_pcap(),
usim(nullptr),
phy(nullptr),
rlc("RLC"),

Loading…
Cancel
Save