Commit ae8c0ef4 authored by Cedric Roux's avatar Cedric Roux

nr: add MAC PDU traces for wireshark

The T tracer macpdu2wireshark has been modified to handle the new traces.
The usage is the same as for LTE.

In NR the RACH is logged as an LTE RACH. Maybe we'll change that in the
future. Looking at the source code of wireshark, I could not find any
way to report NR RACH. Maybe they forgot it. Or I did not search correctly...
parent b7067177
......@@ -85,6 +85,10 @@ ID = ENB_PHY_MIB
DESC = MIB data
GROUP = ALL:PHY:ENB:WIRESHARK
FORMAT = int,eNB_ID : int,frame : int,subframe : buffer,data
ID = GNB_PHY_MIB
DESC = NR MIB data
GROUP = ALL:PHY:GNB:WIRESHARK
FORMAT = int,gNB_ID : int,frame : int,slot : buffer,data
#MAC logs
ID = ENB_MAC_UE_DL_SDU
......@@ -131,6 +135,18 @@ ID = ENB_MAC_UE_DL_RAR_PDU_WITH_DATA
DESC = MAC downlink PDU for an UE
GROUP = ALL:MAC:ENB:WIRESHARK
FORMAT = int,eNB_ID : int,CC_id : int,rnti : int,frame : int,subframe : int,harq_pid : buffer,data
ID = GNB_MAC_DL_PDU_WITH_DATA
DESC = NR MAC downlink PDU for an UE
GROUP = ALL:MAC:GNB:WIRESHARK
FORMAT = int,gNB_ID : int,CC_id : int,rnti : int,frame : int,slot : int,harq_pid : buffer,data
ID = GNB_MAC_UL_PDU_WITH_DATA
DESC = NR MAC uplink PDU for an UE
GROUP = ALL:MAC:GNB:WIRESHARK
FORMAT = int,gNB_ID : int,CC_id : int,rnti : int,frame : int,slot : int,harq_pid : buffer,data
ID = GNB_MAC_DL_RAR_PDU_WITH_DATA
DESC = NR MAC downlink PDU for RAR
GROUP = ALL:MAC:GNB:WIRESHARK
FORMAT = int,gNB_ID : int,CC_id : int,rnti : int,frame : int,slot : int,harq_pid : buffer,data
#RLC logs
ID = ENB_RLC_DL
......
......@@ -23,6 +23,8 @@ typedef struct {
int socket;
struct sockaddr_in to;
OBUF buf;
/* LTE traces */
/* ul */
int ul_rnti;
int ul_frame;
......@@ -46,6 +48,28 @@ typedef struct {
int rar_frame;
int rar_subframe;
int rar_data;
/* NR traces */
/* NR ul */
int nr_ul_rnti;
int nr_ul_frame;
int nr_ul_slot;
int nr_ul_data;
/* NR dl */
int nr_dl_rnti;
int nr_dl_frame;
int nr_dl_slot;
int nr_dl_data;
/* NR mib */
int nr_mib_frame;
int nr_mib_slot;
int nr_mib_data;
/* NR RAR */
int nr_rar_rnti;
int nr_rar_frame;
int nr_rar_slot;
int nr_rar_data;
/* config */
int no_mib;
int no_sib;
......@@ -58,8 +82,13 @@ typedef struct {
int cur_sib;
} ev_data;
void trace(ev_data *d, int direction, int rnti_type, int rnti,
int frame, int subframe, void *buf, int bufsize, int preamble) {
/****************************************************************************/
/* LTE */
/****************************************************************************/
void trace_lte(ev_data *d, int direction, int rnti_type, int rnti,
int frame, int subframe, void *buf, int bufsize, int preamble)
{
ssize_t ret;
int fsf;
int i;
......@@ -100,15 +129,17 @@ void trace(ev_data *d, int direction, int rnti_type, int rnti,
if (ret != d->buf.osize) abort();
}
void ul(void *_d, event e) {
void ul(void *_d, event e)
{
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, C_RNTI, e.e[d->ul_rnti].i,
trace_lte(d, DIRECTION_UPLINK, C_RNTI, e.e[d->ul_rnti].i,
e.e[d->ul_frame].i, e.e[d->ul_subframe].i,
e.e[d->ul_data].b, e.e[d->ul_data].bsize,
NO_PREAMBLE);
}
void dl(void *_d, event e) {
void dl(void *_d, event e)
{
ev_data *d = _d;
if (e.e[d->dl_rnti].i == 0xffff) {
......@@ -119,14 +150,15 @@ void dl(void *_d, event e) {
d->cur_sib++;
}
trace(d, DIRECTION_DOWNLINK,
trace_lte(d, DIRECTION_DOWNLINK,
e.e[d->dl_rnti].i != 0xffff ? C_RNTI : SI_RNTI, e.e[d->dl_rnti].i,
e.e[d->dl_frame].i, e.e[d->dl_subframe].i,
e.e[d->dl_data].b, e.e[d->dl_data].bsize,
NO_PREAMBLE);
}
void mib(void *_d, event e) {
void mib(void *_d, event e)
{
ev_data *d = _d;
if (d->no_mib) return;
......@@ -134,30 +166,141 @@ void mib(void *_d, event e) {
if (d->max_mib && d->cur_mib == d->max_mib) return;
d->cur_mib++;
trace(d, DIRECTION_DOWNLINK, NO_RNTI, 0,
trace_lte(d, DIRECTION_DOWNLINK, NO_RNTI, 0,
e.e[d->mib_frame].i, e.e[d->mib_subframe].i,
e.e[d->mib_data].b, e.e[d->mib_data].bsize,
NO_PREAMBLE);
}
void preamble(void *_d, event e) {
void preamble(void *_d, event e)
{
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, NO_RNTI, 0,
trace_lte(d, DIRECTION_UPLINK, NO_RNTI, 0,
e.e[d->preamble_frame].i, e.e[d->preamble_subframe].i,
NULL, 0,
e.e[d->preamble_preamble].i);
}
void rar(void *_d, event e) {
void rar(void *_d, event e)
{
ev_data *d = _d;
trace(d, DIRECTION_DOWNLINK, RA_RNTI, e.e[d->rar_rnti].i,
trace_lte(d, DIRECTION_DOWNLINK, RA_RNTI, e.e[d->rar_rnti].i,
e.e[d->rar_frame].i, e.e[d->rar_subframe].i,
e.e[d->rar_data].b, e.e[d->rar_data].bsize,
NO_PREAMBLE);
}
/****************************************************************************/
/* NR */
/****************************************************************************/
#define MAC_NR_START_STRING "mac-nr"
#define MAC_NR_PAYLOAD_TAG 0x01
#define MAC_NR_RNTI_TAG 0x02
#define MAC_NR_FRAME_SLOT_TAG 0x07
#define NR_FDD_RADIO 1
#define NR_TDD_RADIO 2
#define NR_DIRECTION_UPLINK 0
#define NR_DIRECTION_DOWNLINK 1
#define NR_NO_RNTI 0
#define NR_RA_RNTI 2
#define NR_C_RNTI 3
void trace_nr(ev_data *d, int direction, int rnti_type, int rnti,
int frame, int slot, void *buf, int bufsize, int preamble)
{
ssize_t ret;
int i;
d->buf.osize = 0;
PUTS(&d->buf, MAC_NR_START_STRING);
PUTC(&d->buf, NR_TDD_RADIO);
PUTC(&d->buf, direction);
PUTC(&d->buf, rnti_type);
if (rnti_type == NR_C_RNTI || rnti_type == NR_RA_RNTI) {
PUTC(&d->buf, MAC_NR_RNTI_TAG);
PUTC(&d->buf, (rnti>>8) & 255);
PUTC(&d->buf, rnti & 255);
}
#if 0
/* for old versions of wireshark; not sure if correct */
int fsf = (frame << 4) + slot;
PUTC(&d->buf, 4 /* MAC_NR_FRAME_SUBFRAME_TAG */);
PUTC(&d->buf, (fsf>>8) & 255);
PUTC(&d->buf, fsf & 255);
#else
PUTC(&d->buf, MAC_NR_FRAME_SLOT_TAG);
PUTC(&d->buf, (frame>>8) & 255);
PUTC(&d->buf, frame & 255);
PUTC(&d->buf, (slot>>8) & 255);
PUTC(&d->buf, slot & 255);
#endif
PUTC(&d->buf, MAC_NR_PAYLOAD_TAG);
for (i = 0; i < bufsize; i++)
PUTC(&d->buf, ((char *)buf)[i]);
ret = sendto(d->socket, d->buf.obuf, d->buf.osize, 0,
(struct sockaddr *)&d->to, sizeof(struct sockaddr_in));
if (ret != d->buf.osize) abort();
}
void nr_ul(void *_d, event e)
{
ev_data *d = _d;
trace_nr(d, NR_DIRECTION_UPLINK, NR_C_RNTI, e.e[d->nr_ul_rnti].i,
e.e[d->nr_ul_frame].i, e.e[d->nr_ul_slot].i,
e.e[d->nr_ul_data].b, e.e[d->nr_ul_data].bsize, NO_PREAMBLE);
}
void nr_dl(void *_d, event e)
{
ev_data *d = _d;
trace_nr(d, NR_DIRECTION_DOWNLINK, NR_C_RNTI, e.e[d->nr_dl_rnti].i,
e.e[d->nr_dl_frame].i, e.e[d->nr_dl_slot].i,
e.e[d->nr_dl_data].b, e.e[d->nr_dl_data].bsize, NO_PREAMBLE);
}
void nr_mib(void *_d, event e)
{
ev_data *d = _d;
if (d->no_mib) return;
if (d->max_mib && d->cur_mib == d->max_mib) return;
d->cur_mib++;
trace_nr(d, NR_DIRECTION_DOWNLINK, NR_NO_RNTI, 0,
e.e[d->nr_mib_frame].i, e.e[d->nr_mib_slot].i,
e.e[d->nr_mib_data].b, e.e[d->nr_mib_data].bsize, NO_PREAMBLE);
}
void nr_rar(void *_d, event e)
{
ev_data *d = _d;
trace_nr(d, NR_DIRECTION_DOWNLINK, NR_RA_RNTI, e.e[d->nr_rar_rnti].i,
e.e[d->nr_rar_frame].i, e.e[d->nr_rar_slot].i,
e.e[d->nr_rar_data].b, e.e[d->nr_rar_data].bsize, NO_PREAMBLE);
}
/****************************************************************************/
/****************************************************************************/
void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
int preamble_id, int rar_id) {
int preamble_id, int rar_id,
int nr_ul_id, int nr_dl_id, int nr_mib_id, int nr_rar_id)
{
database_event_format f;
int i;
d->ul_rnti = -1;
......@@ -178,6 +321,23 @@ void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
d->rar_frame = -1;
d->rar_subframe = -1;
d->rar_data = -1;
d->nr_ul_rnti = -1;
d->nr_ul_frame = -1;
d->nr_ul_slot = -1;
d->nr_ul_data = -1;
d->nr_dl_rnti = -1;
d->nr_dl_frame = -1;
d->nr_dl_slot = -1;
d->nr_dl_data = -1;
d->nr_mib_frame = -1;
d->nr_mib_slot = -1;
d->nr_mib_data = -1;
d->nr_rar_rnti = -1;
d->nr_rar_frame = -1;
d->nr_rar_slot = -1;
d->nr_rar_data = -1;
#define G(var_name, var_type, var) \
if (!strcmp(f.name[i], var_name)) { \
if (strcmp(f.type[i], var_type)) goto error; \
......@@ -247,6 +407,60 @@ void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
if (d->rar_rnti == -1 || d->rar_frame == -1 || d->rar_subframe == -1 ||
d->rar_data == -1) goto error;
/* NR ul: rnti, frame, slot, data */
f = get_format(database, nr_ul_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->nr_ul_rnti);
G("frame", "int", d->nr_ul_frame);
G("slot", "int", d->nr_ul_slot);
G("data", "buffer", d->nr_ul_data);
}
if (d->nr_ul_rnti == -1 || d->nr_ul_frame == -1 || d->nr_ul_slot == -1 ||
d->nr_ul_data == -1)
goto error;
/* NR dl: rnti, frame, slot, data */
f = get_format(database, nr_dl_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->nr_dl_rnti);
G("frame", "int", d->nr_dl_frame);
G("slot", "int", d->nr_dl_slot);
G("data", "buffer", d->nr_dl_data);
}
if (d->nr_dl_rnti == -1 || d->nr_dl_frame == -1 || d->nr_dl_slot == -1 ||
d->nr_dl_data == -1)
goto error;
/* NR MIB: frame, slot, data */
f = get_format(database, nr_mib_id);
for (i = 0; i < f.count; i++) {
G("frame", "int", d->nr_mib_frame);
G("slot", "int", d->nr_mib_slot);
G("data", "buffer", d->nr_mib_data);
}
if (d->nr_mib_frame == -1 || d->nr_mib_slot== -1 || d->nr_mib_data == -1)
goto error;
/* NR RAR: rnti, frame, slot, data */
f = get_format(database, nr_rar_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->nr_rar_rnti);
G("frame", "int", d->nr_rar_frame);
G("slot", "int", d->nr_rar_slot);
G("data", "buffer", d->nr_rar_data);
}
if (d->nr_rar_rnti == -1 || d->nr_rar_frame == -1 || d->nr_rar_slot == -1 ||
d->nr_rar_data == -1)
goto error;
#undef G
return;
error:
......@@ -254,7 +468,8 @@ error:
abort();
}
void *receiver(void *_d) {
void *receiver(void *_d)
{
ev_data *d = _d;
int s;
char buf[100000];
......@@ -279,7 +494,8 @@ void *receiver(void *_d) {
return 0;
}
void usage(void) {
void usage(void)
{
printf(
"options:\n"
" -d <database file> this option is mandatory\n"
......@@ -304,14 +520,16 @@ void usage(void) {
exit(1);
}
int main(int n, char **v) {
int main(int n, char **v)
{
char *database_filename = NULL;
char *input_filename = NULL;
void *database;
event_handler *h;
int in;
int i;
int ul_id, dl_id, mib_id = -1, preamble_id, rar_id;
int ul_id, dl_id, mib_id, preamble_id, rar_id;
int nr_ul_id, nr_dl_id, nr_mib_id, nr_rar_id;
ev_data d;
char *ip = DEFAULT_IP;
int port = DEFAULT_PORT;
......@@ -382,6 +600,11 @@ int main(int n, char **v) {
on_off(database, "ENB_PHY_INITIATE_RA_PROCEDURE", is_on, 1);
on_off(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA", is_on, 1);
on_off(database, "GNB_MAC_UL_PDU_WITH_DATA", is_on, 1);
on_off(database, "GNB_MAC_DL_PDU_WITH_DATA", is_on, 1);
on_off(database, "GNB_PHY_MIB", is_on, 1);
on_off(database, "GNB_MAC_DL_RAR_PDU_WITH_DATA", is_on, 1);
/* activate selected traces */
if (socket_send(in, &mt, 1) == -1 ||
socket_send(in, &number_of_events, sizeof(int)) == -1 ||
......@@ -398,12 +621,26 @@ int main(int n, char **v) {
mib_id = event_id_from_name(database, "ENB_PHY_MIB");
preamble_id = event_id_from_name(database, "ENB_PHY_INITIATE_RA_PROCEDURE");
rar_id = event_id_from_name(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA");
setup_data(&d, database, ul_id, dl_id, mib_id, preamble_id, rar_id);
nr_ul_id = event_id_from_name(database, "GNB_MAC_UL_PDU_WITH_DATA");
nr_dl_id = event_id_from_name(database, "GNB_MAC_DL_PDU_WITH_DATA");
nr_mib_id = event_id_from_name(database, "GNB_PHY_MIB");
nr_rar_id = event_id_from_name(database, "GNB_MAC_DL_RAR_PDU_WITH_DATA");
setup_data(&d, database, ul_id, dl_id, mib_id, preamble_id, rar_id,
nr_ul_id, nr_dl_id, nr_mib_id, nr_rar_id);
register_handler_function(h, ul_id, ul, &d);
register_handler_function(h, dl_id, dl, &d);
register_handler_function(h, mib_id, mib, &d);
register_handler_function(h, preamble_id, preamble, &d);
register_handler_function(h, rar_id, rar, &d);
register_handler_function(h, nr_ul_id, nr_ul, &d);
register_handler_function(h, nr_dl_id, nr_dl, &d);
register_handler_function(h, nr_mib_id, nr_mib, &d);
register_handler_function(h, nr_rar_id, nr_rar, &d);
d.socket = socket(AF_INET, SOCK_DGRAM, 0);
if (d.socket == -1) {
......@@ -425,7 +662,9 @@ int main(int n, char **v) {
if (e.type == -1) break;
if (!(e.type == ul_id || e.type == dl_id || e.type == mib_id ||
e.type == preamble_id || e.type == rar_id)) continue;
e.type == preamble_id || e.type == rar_id ||
e.type == nr_ul_id || e.type == nr_dl_id ||
e.type == nr_mib_id || e.type == nr_rar_id)) continue;
handle_event(h, e);
}
......
......@@ -114,6 +114,14 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
else
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[0][ssb_index&7],&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
if (T_ACTIVE(T_GNB_PHY_MIB)) {
unsigned char bch[3];
bch[0] = gNB->ssb_pdu.ssb_pdu_rel15.bchPayload & 0xff;
bch[1] = (gNB->ssb_pdu.ssb_pdu_rel15.bchPayload >> 8) & 0xff;
bch[2] = (gNB->ssb_pdu.ssb_pdu_rel15.bchPayload >> 16) & 0xff;
T(T_GNB_PHY_MIB, T_INT(0) /* module ID */, T_INT(frame), T_INT(slot), T_BUFFER(bch, 3));
}
nr_generate_pbch(&gNB->pbch,
&gNB->ssb_pdu,
gNB->nr_pbch_interleaver,
......
......@@ -921,6 +921,10 @@ void nr_generate_Msg2(module_id_t module_idP,
nr_mac->TX_req[CC_id].Slot = slotP;
memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&cc[CC_id].RAR_pdu.payload[0], tx_req->TLVs[0].length);
T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id),
T_INT(RA_rnti), T_INT(frameP), T_INT(slotP), T_INT(0) /* harq pid, meaningful? */,
T_BUFFER(&cc[CC_id].RAR_pdu.payload[0], tx_req->TLVs[0].length));
/* mark the corresponding RBs as used */
uint8_t *vrb_map = cc[CC_id].vrb_map;
for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++)
......
......@@ -804,6 +804,9 @@ void nr_schedule_ue_spec(module_id_t module_id,
retInfo->mcs = sched_ctrl->mcs;
retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData;
T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(buf, TBS));
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
if (frame%100 == 0) {
LOG_I(MAC,
......
......@@ -324,6 +324,12 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[0];
if (sduP != NULL) {
T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP),
T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */,
T_BUFFER(sduP, sdu_lenP));
}
// random access pusch with TC-RNTI
if (ra->state == WAIT_Msg3) {
if (sduP != NULL) { // if the CRC passed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment