rlc_stress_test: fix PCAP support

expose actual RLC configuration to PCAP object
master
Andre Puschmann 4 years ago
parent 1c7bfde404
commit 96726a03e0

@ -23,6 +23,7 @@
#define RLCPCAP_H
#include "srslte/common/pcap.h"
#include "srslte/interfaces/rlc_interface_types.h"
#include <stdint.h>
namespace srslte {
@ -30,25 +31,22 @@ namespace srslte {
class rlc_pcap
{
public:
rlc_pcap()
{
enable_write = false;
ue_id = 0;
pcap_file = NULL;
};
rlc_pcap() {}
void enable(bool en);
void open(const char* filename, uint32_t ue_id = 0);
void open(const char* filename, rlc_config_t config);
void close();
void set_ue_id(uint16_t ue_id);
void write_dl_am_ccch(uint8_t* pdu, uint32_t pdu_len_bytes);
void write_ul_am_ccch(uint8_t* pdu, uint32_t pdu_len_bytes);
void write_dl_ccch(uint8_t* pdu, uint32_t pdu_len_bytes);
void write_ul_ccch(uint8_t* pdu, uint32_t pdu_len_bytes);
private:
bool enable_write;
FILE* pcap_file;
uint32_t ue_id;
bool enable_write = false;
FILE* pcap_file = nullptr;
uint32_t ue_id = 0;
uint8_t mode = 0;
uint8_t sn_length = 0;
void pack_and_write(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint8_t mode,

@ -167,7 +167,7 @@ int LTE_PCAP_NAS_WritePDU(FILE* fd, NAS_Context_Info_t* context, const unsigned
int LTE_PCAP_RLC_WritePDU(FILE* fd, RLC_Context_Info_t* context, const unsigned char* PDU, unsigned int length)
{
pcaprec_hdr_t packet_header;
char context_header[256];
char context_header[256] = {};
int offset = 0;
uint16_t tmp16;
@ -185,9 +185,12 @@ int LTE_PCAP_RLC_WritePDU(FILE* fd, RLC_Context_Info_t* context, const unsigned
context_header[offset++] = 0xbe;
context_header[offset++] = 0xef;
// length
tmp16 = length + 12;
memcpy(context_header + offset, &tmp16, 2);
offset += 2;
tmp16 = length + 30;
if (context->rlcMode == RLC_UM_MODE) {
tmp16 += 2; // RLC UM requires two bytes more for SN length (see below
}
context_header[offset++] = (tmp16 & 0xff00) >> 8;
context_header[offset++] = (tmp16 & 0xff);
// dummy CRC
context_header[offset++] = 0xde;
context_header[offset++] = 0xad;

@ -30,12 +30,26 @@ void rlc_pcap::enable(bool en)
{
enable_write = true;
}
void rlc_pcap::open(const char* filename, uint32_t ue_id)
void rlc_pcap::open(const char* filename, rlc_config_t config)
{
fprintf(stdout, "Opening RLC PCAP with DLT=%d\n", UDP_DLT);
pcap_file = LTE_PCAP_Open(UDP_DLT, filename);
this->ue_id = ue_id;
enable_write = true;
if (config.rlc_mode == rlc_mode_t::am) {
mode = RLC_AM_MODE;
sn_length = AM_SN_LENGTH_10_BITS;
} else if (config.rlc_mode == rlc_mode_t::um) {
mode = RLC_UM_MODE;
if (config.um.rx_sn_field_length == rlc_umd_sn_size_t::size5bits) {
sn_length = UM_SN_LENGTH_5_BITS;
} else {
sn_length = UM_SN_LENGTH_10_BITS;
}
} else {
mode = RLC_TM_MODE;
}
}
void rlc_pcap::close()
{
@ -43,14 +57,14 @@ void rlc_pcap::close()
LTE_PCAP_Close(pcap_file);
}
void rlc_pcap::set_ue_id(uint16_t ue_id)
void rlc_pcap::set_ue_id(uint16_t ue_id_)
{
this->ue_id = ue_id;
ue_id = ue_id_;
}
void rlc_pcap::pack_and_write(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint8_t mode,
uint8_t mode_,
uint8_t direction,
uint8_t priority,
uint8_t seqnumberlength,
@ -60,7 +74,7 @@ void rlc_pcap::pack_and_write(uint8_t* pdu,
{
if (enable_write) {
RLC_Context_Info_t context;
context.rlcMode = mode;
context.rlcMode = mode_;
context.direction = direction;
context.priority = priority;
context.sequenceNumberLength = seqnumberlength;
@ -74,36 +88,19 @@ void rlc_pcap::pack_and_write(uint8_t* pdu,
}
}
void rlc_pcap::write_dl_am_ccch(uint8_t* pdu, uint32_t pdu_len_bytes)
void rlc_pcap::write_dl_ccch(uint8_t* pdu, uint32_t pdu_len_bytes)
{
uint8_t priority = 0;
uint8_t seqnumberlength = 0; // normal length of 10bit
uint8_t channel_id = 0;
pack_and_write(pdu,
pdu_len_bytes,
RLC_AM_MODE,
DIRECTION_DOWNLINK,
priority,
seqnumberlength,
ue_id,
CHANNEL_TYPE_CCCH,
channel_id);
uint8_t priority = 0;
uint8_t channel_id = CHANNEL_TYPE_DRB;
pack_and_write(
pdu, pdu_len_bytes, mode, DIRECTION_DOWNLINK, priority, sn_length, ue_id, CHANNEL_TYPE_CCCH, channel_id);
}
void rlc_pcap::write_ul_am_ccch(uint8_t* pdu, uint32_t pdu_len_bytes)
void rlc_pcap::write_ul_ccch(uint8_t* pdu, uint32_t pdu_len_bytes)
{
uint8_t priority = 0;
uint8_t seqnumberlength = 0; // normal length of 10bit
uint8_t channel_id = 0;
pack_and_write(pdu,
pdu_len_bytes,
RLC_AM_MODE,
DIRECTION_UPLINK,
priority,
seqnumberlength,
ue_id,
CHANNEL_TYPE_CCCH,
channel_id);
uint8_t priority = 0;
uint8_t channel_id = CHANNEL_TYPE_DRB;
pack_and_write(pdu, pdu_len_bytes, mode, DIRECTION_UPLINK, priority, sn_length, ue_id, CHANNEL_TYPE_CCCH, channel_id);
}
} // namespace srslte

@ -166,7 +166,8 @@ public:
log("MAC "),
thread("MAC_DUMMY"),
real_dist(0.0, 1.0),
mt19937(1234)
mt19937(1234),
pool(byte_buffer_pool::get_instance())
{
log.set_level(static_cast<LOG_LEVEL_ENUM>(args.log_level));
log.set_hex_limit(LOG_HEX_LIMIT);
@ -185,9 +186,6 @@ private:
{
// Generate A number of MAC PDUs
for (uint32_t i = 0; i < args.nof_pdu_tti; i++) {
// Get PDU pool
byte_buffer_pool* pool = byte_buffer_pool::get_instance();
// Create PDU unique buffer
unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, __PRETTY_FUNCTION__, true);
if (!pdu) {
@ -246,11 +244,11 @@ private:
rx_rlc->write_pdu(lcid, pdu->msg, pdu_len);
// Write PCAP
write_pdu_to_pcap(is_dl, 4, pdu->msg, pdu_len);
write_pdu_to_pcap(is_dl, 4, pdu->msg, pdu_len); // Only handles NR rat
if (is_dl) {
pcap->write_dl_am_ccch(pdu->msg, pdu_len);
pcap->write_dl_ccch(pdu->msg, pdu_len);
} else {
pcap->write_ul_am_ccch(pdu->msg, pdu_len);
pcap->write_ul_ccch(pdu->msg, pdu_len);
}
} else {
log.warning_hex(pdu->msg, pdu->N_bytes, "Dropping RLC PDU (%d B)\n", pdu->N_bytes);
@ -318,6 +316,7 @@ private:
std::mt19937 mt19937;
std::uniform_real_distribution<float> real_dist;
byte_buffer_pool* pool = nullptr;
};
class rlc_tester : public pdcp_interface_rlc, public rrc_interface_rlc, public thread
@ -445,7 +444,7 @@ void stress_test(stress_test_args_t args)
#if PCAP
if (args.write_pcap) {
pcap.open("rlc_stress_test.pcap", 0);
pcap.open("rlc_stress_test.pcap", cnfg_);
}
#endif

Loading…
Cancel
Save