Send DRB PDUs as JSON to TTCN3

This commit is contained in:
Daniel Willmann 2020-05-29 11:29:46 +02:00 committed by Andre Puschmann
parent 31f1516d74
commit 0b88161b3c
2 changed files with 24 additions and 20 deletions

View File

@ -27,6 +27,7 @@
#include "srslte/mac/pdu.h" #include "srslte/mac/pdu.h"
#include "ttcn3_interfaces.h" #include "ttcn3_interfaces.h"
#include "ttcn3_port_handler.h" #include "ttcn3_port_handler.h"
#include <srslte/asn1/asn1_utils.h>
#include <srslte/interfaces/ue_interfaces.h> #include <srslte/interfaces/ue_interfaces.h>
using namespace srslte; using namespace srslte;
@ -49,11 +50,12 @@ public:
return port_listen(); return port_listen();
} }
void tx(unique_byte_buffer_t pdu) void tx(std::string out)
{ {
if (initialized) { if (initialized) {
log->info_hex(pdu->msg, pdu->N_bytes, "Sending %d B to Titan\n", pdu->N_bytes); log->info_hex(
send(pdu->msg, pdu->N_bytes); reinterpret_cast<const uint8_t*>(out.c_str()), out.length(), "Sending %ld B to Titan\n", out.length());
send(reinterpret_cast<const uint8_t*>(out.c_str()), out.length());
} else { } else {
log->error("Trying to transmit but port not connected.\n"); log->error("Trying to transmit but port not connected.\n");
} }

View File

@ -1023,27 +1023,29 @@ void ttcn3_syssim::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
cells[pcell_idx]->cell.id, cells[pcell_idx]->cell.id,
pdu->N_bytes); pdu->N_bytes);
// check cell ID
if (cells[pcell_idx]->cell.id > 256) {
log->error("Cell ID too large to fit in single byte.\n");
return;
}
// We don't handle RRC, prepend LCID
pdu->msg--;
*pdu->msg = lcid;
pdu->N_bytes++;
// prepend pcell PCID
pdu->msg--;
*pdu->msg = static_cast<uint8_t>(cells[pcell_idx]->cell.id);
pdu->N_bytes++;
// push content to Titan // push content to Titan
if (lcid <= 2) { if (lcid <= 2) {
// check cell ID
if (cells[pcell_idx]->cell.id > 256) {
log->error("Cell ID too large to fit in single byte.\n");
return;
}
// We don't handle RRC, prepend LCID
pdu->msg--;
*pdu->msg = lcid;
pdu->N_bytes++;
// prepend pcell PCID
pdu->msg--;
*pdu->msg = static_cast<uint8_t>(cells[pcell_idx]->cell.id);
pdu->N_bytes++;
srb.tx(std::move(pdu)); srb.tx(std::move(pdu));
} else { } else {
drb.tx(std::move(pdu)); std::string out = ttcn3_helpers::get_drb_common_ind_for_pdu(lcid, cells[pcell_idx]->name, std::move(pdu));
log->error("DRB send:\n%s", out.c_str());
drb.tx(out);
} }
} }