Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions srsue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# and at http://www.gnu.org/licenses/.
#

find_package(SCTP REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed for the UE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know why it is required (maybe to send the capture over the network?) but without linking with SCTP the build fails with:

[ 78%] Linking CXX executable srsue
/usr/bin/ld: ../../lib/src/common/libsrsran_common.a(network_utils.cc.o): in function `srsran::task_details::heap_table_t<srsran::sctp_recvmsg_pdu_task, bool, int>::call(void*, int) const':
network_utils.cc:(.text._ZNK6srsran12task_details12heap_table_tINS_21sctp_recvmsg_pdu_taskEbJiEE4callEPvi[_ZNK6srsran12task_details12heap_table_tINS_21sctp_recvmsg_pdu_taskEbJiEE4callEPvi]+0xe6): undefined reference to `sctp_recvmsg'
collect2: error: ld returned 1 exit status
make[2]: *** [srsue/src/CMakeFiles/srsue.dir/build.make:181: srsue/src/srsue] Error 1
make[1]: *** [CMakeFiles/Makefile2:10845: srsue/src/CMakeFiles/srsue.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh, maybe the network utils need to be stripped to have a version without SCTP that can be used in srsUE. I have to say that we are reluctant to do this change now. I'd leave the PR open in case it's useful for others like it is.


########################################################################
# Boost is required
########################################################################
Expand Down
3 changes: 3 additions & 0 deletions srsue/hdr/stack/mac/dl_harq.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "demux.h"
#include "dl_sps.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/common/mac_pcap_net.h"
#include "srsran/common/timers.h"
#include "srsue/hdr/stack/mac_common/mac_common.h"

Expand All @@ -40,6 +41,7 @@ class dl_harq_entity
bool init(ue_rnti* rntis, demux* demux_unit);
void reset();
void start_pcap(srsran::mac_pcap* pcap_);
void start_pcap_net(srsran::mac_pcap_net* pcap_net_);

/***************** PHY->MAC interface for DL processes **************************/
void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action);
Expand Down Expand Up @@ -123,6 +125,7 @@ class dl_harq_entity
demux* demux_unit = nullptr;
srslog::basic_logger& logger;
srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr;
ue_rnti* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
int si_window_start = 0;
Expand Down
2 changes: 2 additions & 0 deletions srsue/hdr/stack/mac/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class mac : public mac_interface_phy_lte,
void process_pdus();

void start_pcap(srsran::mac_pcap* pcap);
void start_pcap_net(srsran::mac_pcap_net* pcap_net_);

// Timer callback interface
void timer_expired(uint32_t timer_id);
Expand Down Expand Up @@ -158,6 +159,7 @@ class mac : public mac_interface_phy_lte,

// pointer to MAC PCAP object
srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr;
std::atomic<bool> is_first_ul_grant{false};

std::mutex metrics_mutex = {};
Expand Down
3 changes: 3 additions & 0 deletions srsue/hdr/stack/mac/proc_ra.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "demux.h"
#include "mux.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/common/mac_pcap_net.h"
#include "srsran/common/timers.h"
#include "srsran/mac/pdu.h"
#include "srsue/hdr/stack/mac_common/mac_common.h"
Expand Down Expand Up @@ -71,6 +72,7 @@ class ra_proc : public srsran::timer_callback
bool contention_resolution_id_received(uint64_t rx_contention_id);

void start_pcap(srsran::mac_pcap* pcap);
void start_pcap_net(srsran::mac_pcap_net* pcap_net);

bool is_idle() const { return state == IDLE; }

Expand Down Expand Up @@ -143,6 +145,7 @@ class ra_proc : public srsran::timer_callback
srslog::basic_logger& logger;
mux* mux_unit = nullptr;
srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr;
rrc_interface_mac* rrc = nullptr;
srsran::ext_task_sched_handle* task_sched = nullptr;
srsran::task_multiqueue::queue_handle task_queue;
Expand Down
3 changes: 3 additions & 0 deletions srsue/hdr/stack/mac/ul_harq.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "proc_ra.h"
#include "srsran/common/interfaces_common.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/common/mac_pcap_net.h"
#include "srsran/common/timers.h"
#include "ul_sps.h"

Expand All @@ -45,6 +46,7 @@ class ul_harq_entity
void set_config(srsran::ul_harq_cfg_t& harq_cfg);

void start_pcap(srsran::mac_pcap* pcap_);
void start_pcap_net(srsran::mac_pcap_net* pcap_net_);

/***************** PHY->MAC interface for UL processes **************************/
void new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant, mac_interface_phy_lte::tb_action_ul_t* action);
Expand Down Expand Up @@ -152,6 +154,7 @@ class ul_harq_entity

mux* mux_unit = nullptr;
srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr;
srslog::basic_logger& logger;

ue_rnti* rntis = nullptr;
Expand Down
9 changes: 9 additions & 0 deletions srsue/hdr/stack/ue_stack_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ typedef struct {
std::string filename;
} pcap_args_t;

typedef struct {
bool enable;
std::string client_ip;
std::string bind_ip;
uint16_t client_port;
uint16_t bind_port;
} pcap_net_args_t;

typedef struct {
std::string enable;
pcap_args_t mac_pcap;
pcap_net_args_t mac_pcap_net;
pcap_args_t mac_nr_pcap;
pcap_args_t nas_pcap;
} pkt_trace_args_t;
Expand Down
2 changes: 2 additions & 0 deletions srsue/hdr/stack/ue_stack_lte.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "rrc_nr/rrc_nr.h"
#include "srsran/common/bearer_manager.h"
#include "srsran/common/buffer_pool.h"
#include "srsran/common/mac_pcap_net.h"
#include "srsran/common/multiqueue.h"
#include "srsran/common/string_helpers.h"
#include "srsran/common/task_scheduler.h"
Expand Down Expand Up @@ -229,6 +230,7 @@ class ue_stack_lte final : public ue_stack_base,

// tracing
srsran::mac_pcap mac_pcap;
srsran::mac_pcap_net mac_pcap_net;
srsran::mac_pcap mac_nr_pcap;
srsran::nas_pcap nas_pcap;

Expand Down
3 changes: 2 additions & 1 deletion srsue/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ target_link_libraries(srsue ${SRSUE_SOURCES}
${SRSRAN_SOURCES}
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${ATOMIC_LIBS})
${ATOMIC_LIBS}
${SCTP_LIBRARIES})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be needed for the UE


if (RPATH)
set_target_properties(srsue PROPERTIES INSTALL_RPATH ".")
Expand Down
5 changes: 5 additions & 0 deletions srsue/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ static int parse_args(all_args_t* args, int argc, char* argv[])
("pcap.mac_filename", bpo::value<string>(&args->stack.pkt_trace.mac_pcap.filename)->default_value("/tmp/ue_mac.pcap"), "MAC layer capture filename")
("pcap.mac_nr_filename", bpo::value<string>(&args->stack.pkt_trace.mac_nr_pcap.filename)->default_value("/tmp/ue_mac_nr.pcap"), "MAC_NR layer capture filename")
("pcap.nas_filename", bpo::value<string>(&args->stack.pkt_trace.nas_pcap.filename)->default_value("/tmp/ue_nas.pcap"), "NAS layer capture filename")
("pcap.mac_net_enable", bpo::value<bool>(&args->stack.pkt_trace.mac_pcap_net.enable)->default_value(false), "Enable MAC network captures")
("pcap.bind_ip", bpo::value<string>(&args->stack.pkt_trace.mac_pcap_net.bind_ip)->default_value("0.0.0.0"), "Bind IP address for MAC network trace")
("pcap.bind_port", bpo::value<uint16_t>(&args->stack.pkt_trace.mac_pcap_net.bind_port)->default_value(5687), "Bind port for MAC network trace")
("pcap.client_ip", bpo::value<string>(&args->stack.pkt_trace.mac_pcap_net.client_ip)->default_value("127.0.0.1"), "Client IP address for MAC network trace")
("pcap.client_port", bpo::value<uint16_t>(&args->stack.pkt_trace.mac_pcap_net.client_port)->default_value(5847), "Enable MAC network captures")

("gui.enable", bpo::value<bool>(&args->gui.enable)->default_value(false), "Enable GUI plots")

Expand Down
14 changes: 14 additions & 0 deletions srsue/src/stack/mac/dl_harq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ void dl_harq_entity::start_pcap(srsran::mac_pcap* pcap_)
pcap = pcap_;
}

void dl_harq_entity::start_pcap_net(srsran::mac_pcap_net* pcap_net_)
{
pcap_net = pcap_net_;
}

void dl_harq_entity::set_si_window_start(int si_window_start_)
{
si_window_start = si_window_start_;
Expand Down Expand Up @@ -328,13 +333,22 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph
harq_entity->pcap->write_dl_sirnti(
payload_buffer_ptr, cur_grant.tb[tid].tbs, ack, cur_grant.tti, harq_entity->cc_idx);
}
if (harq_entity->pcap_net) {
harq_entity->pcap_net->write_dl_sirnti(
payload_buffer_ptr, cur_grant.tb[tid].tbs, ack, cur_grant.tti, harq_entity->cc_idx);
}
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (BCCH)", cur_grant.tb[tid].tbs);
harq_entity->demux_unit->push_pdu_bcch(payload_buffer_ptr, cur_grant.tb[tid].tbs);
} else {
if (harq_entity->pcap) {
harq_entity->pcap->write_dl_crnti(
payload_buffer_ptr, cur_grant.tb[tid].tbs, cur_grant.rnti, ack, cur_grant.tti, harq_entity->cc_idx);
}
if (harq_entity->pcap_net) {
harq_entity->pcap_net->write_dl_crnti(
payload_buffer_ptr, cur_grant.tb[tid].tbs, cur_grant.rnti, ack, cur_grant.tti, harq_entity->cc_idx);
}

if (cur_grant.rnti == harq_entity->rntis->get_temp_rnti()) {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI)", cur_grant.tb[tid].tbs);
harq_entity->demux_unit->push_pdu_temp_crnti(payload_buffer_ptr, cur_grant.tb[tid].tbs);
Expand Down
31 changes: 31 additions & 0 deletions srsue/src/stack/mac/mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ void mac::start_pcap(srsran::mac_pcap* pcap_)
ra_procedure.start_pcap(pcap);
}

void mac::start_pcap_net(srsran::mac_pcap_net* pcap_net_)
{
pcap_net = pcap_net_;
for (auto& r : dl_harq) {
if (r != nullptr) {
r->start_pcap_net(pcap_net);
}
}
for (auto& r : ul_harq) {
if (r != nullptr) {
r->start_pcap_net(pcap_net);
}
}
ra_procedure.start_pcap_net(pcap_net);
}

// TODO: Change the function name and implement reconfiguration as in specs
// Implement Section 5.8
void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable)
Expand Down Expand Up @@ -259,6 +275,10 @@ void mac::set_ho_rnti(uint16_t crnti, uint16_t target_pci)
if (pcap) {
pcap->set_ue_id(target_pci);
}

if (pcap_net) {
pcap_net->set_ue_id(target_pci);
}
}

uint16_t mac::get_ul_sched_rnti(uint32_t tti)
Expand Down Expand Up @@ -329,6 +349,10 @@ void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len)
if (pcap) {
pcap->write_dl_bch(payload, len, true, phy_h->get_current_tti(), cc_idx);
}

if (pcap_net) {
pcap_net->write_dl_bch(payload, len, true, phy_h->get_current_tti(), cc_idx);
}
}

void mac::mch_decoded(uint32_t len, bool crc, uint8_t* payload)
Expand Down Expand Up @@ -356,6 +380,9 @@ void mac::mch_decoded(uint32_t len, bool crc, uint8_t* payload)
if (pcap) {
pcap->write_dl_mch(payload, len, true, phy_h->get_current_tti(), 0);
}
if (pcap_net) {
pcap_net->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti(), 0);
}

std::lock_guard<std::mutex> lock(metrics_mutex);
metrics[0].rx_brate += len * 8;
Expand Down Expand Up @@ -396,6 +423,10 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_
if (pcap) {
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);
}

if (pcap_net) {
pcap_net->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);
}
} else {
// Assert DL HARQ entity
if (dl_harq.at(cc_idx) == nullptr) {
Expand Down
9 changes: 9 additions & 0 deletions srsue/src/stack/mac/proc_ra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void ra_proc::start_pcap(srsran::mac_pcap* pcap_)
pcap = pcap_;
}

void ra_proc::start_pcap_net(srsran::mac_pcap_net* pcap_net_)
{
pcap_net = pcap_net_;
}

// RRC calls to set a new PRACH configuration.
// The configuration is applied by initialization() function.
void ra_proc::set_config(srsran::rach_cfg_t& rach_cfg_)
Expand Down Expand Up @@ -379,6 +384,10 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
pcap->write_dl_ranti(rar_pdu_buffer, rar_grant_nbytes, ra_rnti, true, tti, cc_idx);
}

if (pcap_net) {
pcap_net->write_dl_ranti(rar_pdu_buffer, rar_grant_nbytes, ra_rnti, true, tti, cc_idx);
}

rar_pdu_msg.init_rx(rar_grant_nbytes);
if (rar_pdu_msg.parse_packet(rar_pdu_buffer) != SRSRAN_SUCCESS) {
rError("Error decoding RAR PDU");
Expand Down
14 changes: 14 additions & 0 deletions srsue/src/stack/mac/ul_harq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ void ul_harq_entity::start_pcap(srsran::mac_pcap* pcap_)
pcap = pcap_;
}

void ul_harq_entity::start_pcap_net(srsran::mac_pcap_net* pcap_net_)
{
pcap_net = pcap_net_;
}

/***************** PHY->MAC interface for UL processes **************************/
void ul_harq_entity::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant,
mac_interface_phy_lte::tb_action_ul_t* action)
Expand Down Expand Up @@ -275,6 +280,15 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
}
harq_entity->pcap->write_ul_crnti(pdu_ptr, grant.tb.tbs, rnti, get_nof_retx(), grant.tti_tx, harq_entity->cc_idx);
}
if (harq_entity->pcap_net) {
uint16_t rnti;
if (grant.rnti == harq_entity->rntis->get_temp_rnti() && harq_entity->rntis->get_temp_rnti()) {
rnti = harq_entity->rntis->get_temp_rnti();
} else {
rnti = harq_entity->rntis->get_crnti();
}
harq_entity->pcap_net->write_ul_crnti(pdu_ptr, grant.tb.tbs, rnti, get_nof_retx(), grant.tti_tx, harq_entity->cc_idx);
}
} else if (has_grant()) {
// Non-Adaptive Re-Tx
generate_retx(grant, action);
Expand Down
8 changes: 8 additions & 0 deletions srsue/src/stack/ue_stack_lte.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ int ue_stack_lte::init(const stack_args_t& args_)
}
}

if (args.pkt_trace.mac_pcap_net.enable) {
mac_pcap_net.open(args.pkt_trace.mac_pcap_net.client_ip,
args.pkt_trace.mac_pcap_net.bind_ip,
args.pkt_trace.mac_pcap_net.client_port,
args.pkt_trace.mac_pcap_net.bind_port);
mac.start_pcap_net(&mac_pcap_net);
}

// Init USIM first to allow early exit in case reader couldn't be found
usim = usim_base::get_instance(&args.usim, usim_logger);
if (usim->init(&args.usim)) {
Expand Down