pcap: add CC index when writing PCAP

master
Andre Puschmann 5 years ago
parent df31a5c4cc
commit 664170fec6

@ -38,15 +38,16 @@ public:
void set_ue_id(uint16_t ue_id);
void write_ul_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, uint32_t reTX, uint32_t tti);
void write_dl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, bool crc_ok, uint32_t tti);
void write_dl_ranti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t ranti, bool crc_ok, uint32_t tti);
void
write_ul_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, uint32_t reTX, uint32_t tti, uint8_t cc_idx);
void write_dl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, bool crc_ok, uint32_t tti, uint8_t cc_idx);
void write_dl_ranti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t ranti, bool crc_ok, uint32_t tti, uint8_t cc_idx);
// SI and BCH only for DL
void write_dl_sirnti(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti);
void write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti);
void write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti);
void write_dl_mch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti);
void write_dl_sirnti(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx);
void write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx);
void write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx);
void write_dl_mch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx);
void write_ul_rrc_pdu(const uint8_t* input, const int32_t input_len);
@ -58,6 +59,7 @@ private:
uint32_t pdu_len_bytes,
uint32_t reTX,
bool crc_ok,
uint8_t cc_idx,
uint32_t tti,
uint16_t crnti_,
uint8_t direction,

@ -75,6 +75,7 @@ typedef struct pcaprec_hdr_s {
#define MAC_LTE_PREDFINED_DATA_TAG 0x05
#define MAC_LTE_RETX_TAG 0x06
#define MAC_LTE_CRC_STATUS_TAG 0x07
#define MAC_LTE_CARRIER_ID_TAG 0x0A
#define MAC_LTE_NB_MODE_TAG 0x0F
/* Context information for every MAC PDU that will be logged */
@ -86,6 +87,7 @@ typedef struct MAC_Context_Info_t {
unsigned short ueid;
unsigned char isRetx;
unsigned char crcStatusOK;
unsigned char cc_idx;
unsigned short sysFrameNumber;
unsigned short subFrameNumber;

@ -399,7 +399,7 @@ public:
virtual void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) = 0;
/* Indicate successful decoding of BCH TB through PBCH */
virtual void bch_decoded_ok(uint8_t* payload, uint32_t len) = 0;
virtual void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) = 0;
/* Indicate successful decoding of MCH TB through PMCH */
virtual void mch_decoded(uint32_t len, bool crc) = 0;

@ -63,56 +63,72 @@ void mac_pcap::pack_and_write(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint32_t reTX,
bool crc_ok,
uint8_t cc_idx,
uint32_t tti,
uint16_t crnti,
uint8_t direction,
uint8_t rnti_type)
{
if (enable_write) {
MAC_Context_Info_t context = {
FDD_RADIO,
direction,
rnti_type,
crnti, /* RNTI */
(uint16_t)ue_id, /* UEId */
(uint8_t)reTX, /* Retx */
crc_ok, /* CRC Stsatus (i.e. OK) */
(uint16_t)(tti / 10), /* Sysframe number */
(uint16_t)(tti % 10) /* Subframe number */
};
MAC_Context_Info_t context = {};
context.radioType = FDD_RADIO;
context.direction = direction;
context.rntiType = rnti_type;
context.rnti = crnti;
context.ueid = (uint16_t)ue_id;
context.isRetx = (uint8_t)reTX;
context.crcStatusOK = crc_ok;
context.cc_idx = cc_idx;
context.sysFrameNumber = (uint16_t)(tti / 10);
context.subFrameNumber = (uint16_t)(tti % 10);
if (pdu) {
LTE_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes);
}
}
}
void mac_pcap::write_dl_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_crnti(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint16_t rnti,
bool crc_ok,
uint32_t tti,
uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, rnti, DIRECTION_DOWNLINK, C_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, rnti, DIRECTION_DOWNLINK, C_RNTI);
}
void mac_pcap::write_dl_ranti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_ranti(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint16_t rnti,
bool crc_ok,
uint32_t tti,
uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, rnti, DIRECTION_DOWNLINK, RA_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, rnti, DIRECTION_DOWNLINK, RA_RNTI);
}
void mac_pcap::write_ul_crnti(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint32_t reTX, uint32_t tti)
void mac_pcap::write_ul_crnti(uint8_t* pdu,
uint32_t pdu_len_bytes,
uint16_t rnti,
uint32_t reTX,
uint32_t tti,
uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, reTX, true, tti, rnti, DIRECTION_UPLINK, C_RNTI);
pack_and_write(pdu, pdu_len_bytes, reTX, true, cc_idx, tti, rnti, DIRECTION_UPLINK, C_RNTI);
}
void mac_pcap::write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, 0, DIRECTION_DOWNLINK, NO_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, 0, DIRECTION_DOWNLINK, NO_RNTI);
}
void mac_pcap::write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, SRSLTE_PRNTI, DIRECTION_DOWNLINK, P_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, SRSLTE_PRNTI, DIRECTION_DOWNLINK, P_RNTI);
}
void mac_pcap::write_dl_mch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_mch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, SRSLTE_MRNTI, DIRECTION_DOWNLINK, M_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, SRSLTE_MRNTI, DIRECTION_DOWNLINK, M_RNTI);
}
void mac_pcap::write_dl_sirnti(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti)
void mac_pcap::write_dl_sirnti(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx)
{
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, tti, SRSLTE_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI);
pack_and_write(pdu, pdu_len_bytes, 0, crc_ok, cc_idx, tti, SRSLTE_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI);
}
void mac_pcap::write_ul_rrc_pdu(const uint8_t* input, const int32_t input_len)
@ -185,6 +201,6 @@ void mac_pcap::write_ul_rrc_pdu(const uint8_t* input, const int32_t input_len)
memcpy(pdu_ptr, &pad, 1);
pdu_ptr += 1;
write_ul_crnti(pdu, pdu_ptr - pdu, 14931, true, 0);
write_ul_crnti(pdu, pdu_ptr - pdu, 14931, true, 0, 0);
}
} // namespace srslte

@ -102,6 +102,10 @@ int LTE_PCAP_MAC_WritePDU(FILE* fd, MAC_Context_Info_t* context, const unsigned
context_header[offset++] = MAC_LTE_CRC_STATUS_TAG;
context_header[offset++] = context->crcStatusOK;
/* CC index */
context_header[offset++] = MAC_LTE_CARRIER_ID_TAG;
context_header[offset++] = context->cc_idx;
/* NB-IoT mode tag */
context_header[offset++] = MAC_LTE_NB_MODE_TAG;
context_header[offset++] = context->nbiotMode;

@ -143,6 +143,8 @@ private:
// Mutexes
pthread_mutex_t mutex;
const uint8_t UL_CC_IDX = 0; ///< Passed to write CC index in PCAP (TODO: use actual CC idx)
};
} // namespace srsenb

@ -524,7 +524,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
}
if (pcap) {
pcap->write_dl_crnti(dl_sched_res->pdsch[n].data[tb], sched_result.data[i].tbs[tb], rnti, true, tti);
pcap->write_dl_crnti(dl_sched_res->pdsch[n].data[tb], sched_result.data[i].tbs[tb], rnti, true, tti, 0);
}
} else {
@ -555,7 +555,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
if (pcap) {
pcap->write_dl_ranti(
dl_sched_res->pdsch[n].data[0], sched_result.rar[i].tbs, dl_sched_res->pdsch[n].dci.rnti, true, tti);
dl_sched_res->pdsch[n].data[0], sched_result.rar[i].tbs, dl_sched_res->pdsch[n].dci.rnti, true, tti, 0);
}
n++;
@ -572,7 +572,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
dl_sched_res->pdsch[n].data[0] = assemble_si(sched_result.bc[i].index);
#ifdef WRITE_SIB_PCAP
if (pcap) {
pcap->write_dl_sirnti(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti);
pcap->write_dl_sirnti(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti, 0);
}
#endif
} else {
@ -581,7 +581,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
rlc_h->read_pdu_pcch(pcch_payload_buffer, pcch_payload_buffer_len);
if (pcap) {
pcap->write_dl_pch(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti);
pcap->write_dl_pch(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti, 0);
}
}

@ -189,7 +189,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
mac_msg_ul.parse_packet(pdu);
if (pcap) {
pcap->write_ul_crnti(pdu, nof_bytes, rnti, true, last_tti);
pcap->write_ul_crnti(pdu, nof_bytes, rnti, true, last_tti, UL_CC_IDX);
}
pdus.deallocate(pdu);

@ -359,6 +359,8 @@ private:
float dl_freq = -1;
float ul_freq = -1;
const uint8_t SYNC_CC_IDX = 0; ///< From the sync POV, the CC idx is always the first
};
} // namespace srsue

@ -65,7 +65,7 @@ public:
void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action);
void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action);
void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]);
void bch_decoded_ok(uint8_t* payload, uint32_t len);
void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len);
uint16_t get_dl_sched_rnti(uint32_t tti);
uint16_t get_ul_sched_rnti(uint32_t tti);

@ -90,7 +90,7 @@ public:
void pdcch_to_crnti(bool is_new_uplink_transmission);
void timer_expired(uint32_t timer_id);
void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action);
void tb_decoded_ok(const uint32_t tti);
void tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti);
void start_noncont(uint32_t preamble_index, uint32_t prach_mask);
bool contention_resolution_id_received(uint64_t uecri);

@ -99,7 +99,7 @@ public:
mac.tb_decoded(cc_idx, grant, ack);
}
void bch_decoded_ok(uint8_t* payload, uint32_t len) { mac.bch_decoded_ok(payload, len); }
void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) { mac.bch_decoded_ok(cc_idx, payload, len); }
void mch_decoded(uint32_t len, bool crc) { mac.mch_decoded(len, crc); }

@ -386,7 +386,7 @@ void sync::run_thread()
return;
}
for (uint32_t i = 0; i < nof_rf_channels; i++) {
dummy_buffer[i] = (cf_t*)srslte_vec_cf_malloc(3 * SRSLTE_SF_LEN_PRB(100));
dummy_buffer[i] = srslte_vec_cf_malloc(3 * SRSLTE_SF_LEN_PRB(100));
}
uint32_t prach_nof_sf = 0;
@ -413,7 +413,7 @@ void sync::run_thread()
*/
cell_search_ret = search_p.run(&cell, mib);
if (cell_search_ret == search::CELL_FOUND) {
stack->bch_decoded_ok(mib.data(), mib.size() / 8);
stack->bch_decoded_ok(SYNC_CC_IDX, mib.data(), mib.size() / 8);
}
phy_state.state_exit();
break;

@ -327,14 +327,15 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph
if (ack) {
if (is_bcch) {
if (harq_entity->pcap) {
harq_entity->pcap->write_dl_sirnti(payload_buffer_ptr, cur_grant.tb[tid].tbs, ack, cur_grant.tti);
harq_entity->pcap->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)\n", 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);
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->temp_rnti) {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI)\n", cur_grant.tb[tid].tbs);

@ -357,13 +357,13 @@ uint16_t mac::get_dl_sched_rnti(uint32_t tti)
return SRSLTE_INVALID_RNTI;
}
void mac::bch_decoded_ok(uint8_t* payload, uint32_t len)
void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len)
{
// Send MIB to RLC
rlc_h->write_pdu_bcch_bch(payload, len);
if (pcap) {
pcap->write_dl_bch(payload, len, true, phy_h->get_current_tti());
pcap->write_dl_bch(payload, len, true, phy_h->get_current_tti(), cc_idx);
}
}
@ -389,7 +389,7 @@ void mac::mch_decoded(uint32_t len, bool crc)
demux_unit.push_pdu_mch(mch_payload_buffer, len);
stack_h->process_pdus();
if (pcap) {
pcap->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti());
pcap->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti(), 0);
}
metrics[0].rx_brate += len * 8;
} else {
@ -402,14 +402,14 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_
{
if (SRSLTE_RNTI_ISRAR(grant.rnti)) {
if (ack[0]) {
ra_procedure.tb_decoded_ok(grant.tti);
ra_procedure.tb_decoded_ok(cc_idx, grant.tti);
}
} else if (grant.rnti == SRSLTE_PRNTI) {
// Send PCH payload to RLC
rlc_h->write_pdu_pcch(pch_payload_buffer, grant.tb[0].tbs);
if (pcap) {
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti);
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);
}
} else {

@ -401,10 +401,10 @@ void ra_proc::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_inte
/* Called upon the successful decoding of a TB addressed to RA-RNTI.
* Processes the reception of a RAR as defined in 5.1.4
*/
void ra_proc::tb_decoded_ok(const uint32_t tti)
void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
{
if (pcap) {
pcap->write_dl_ranti(rar_pdu_buffer, rar_grant_nbytes, ra_rnti, true, tti);
pcap->write_dl_ranti(rar_pdu_buffer, rar_grant_nbytes, ra_rnti, true, tti, cc_idx);
}
rDebug("RAR decoded successfully TBS=%d\n", rar_grant_nbytes);

@ -276,7 +276,7 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
} else {
rnti = harq_entity->rntis->crnti;
}
harq_entity->pcap->write_ul_crnti(pdu_ptr, grant.tb.tbs, rnti, get_nof_retx(), grant.tti_tx);
harq_entity->pcap->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

@ -104,7 +104,7 @@ private:
}
}
void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool* ack) override {}
void bch_decoded_ok(uint8_t* payload, uint32_t len) override {}
void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) override {}
void mch_decoded(uint32_t len, bool crc) override {}
void new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action) override {}
void set_mbsfn_config(uint32_t nof_mbsfn_services) override {}

Loading…
Cancel
Save