Commit 4a263eb6 authored by hardy's avatar hardy

Merge remote-tracking branch 'origin/wireshark-T-hack-ueid' into integration_2021_wk04_b

parents 6e12f8f8 40f985a9
......@@ -129,7 +129,7 @@ ID = ENB_MAC_UE_DL_PDU_WITH_DATA
FORMAT = int,eNB_ID : int,CC_id : int,rnti : int,frame : int,subframe : int,harq_pid : buffer,data
ID = ENB_MAC_SCHEDULING_REQUEST
DESC = MAC scheduling request detected for an UE
GROUP = ALL:MAC:ENB
GROUP = ALL:MAC:ENB:WIRESHARK
FORMAT = int,eNB_ID : int,CC_id : int,frame : int,subframe : int,rnti
ID = ENB_MAC_UE_DL_RAR_PDU_WITH_DATA
DESC = MAC downlink PDU for an UE
......
......@@ -18,6 +18,7 @@
#define DEFAULT_LIVE_PORT 2021
#define NO_PREAMBLE -1
#define NO_SR_RNTI -1
typedef struct {
int socket;
......@@ -48,6 +49,10 @@ typedef struct {
int rar_frame;
int rar_subframe;
int rar_data;
/* SR */
int sr_rnti;
int sr_frame;
int sr_subframe;
/* NR traces */
/* NR ul */
......@@ -80,6 +85,15 @@ typedef struct {
/* runtime vars */
int cur_mib;
int cur_sib;
/* hack to report UE id:
* each time we see a rnti, we allocate the next ue_id
* (two separate versions for lte and nr)
*/
int lte_rnti_to_ueid[65536];
int lte_next_ue_id;
int nr_rnti_to_ueid[65536];
int nr_next_ue_id;
} ev_data;
/****************************************************************************/
......@@ -87,7 +101,8 @@ typedef struct {
/****************************************************************************/
void trace_lte(ev_data *d, int direction, int rnti_type, int rnti,
int frame, int subframe, void *buf, int bufsize, int preamble)
int frame, int subframe, void *buf, int bufsize, int preamble,
int sr_rnti)
{
ssize_t ret;
int fsf;
......@@ -102,6 +117,18 @@ void trace_lte(ev_data *d, int direction, int rnti_type, int rnti,
PUTC(&d->buf, MAC_LTE_RNTI_TAG);
PUTC(&d->buf, (rnti>>8) & 255);
PUTC(&d->buf, rnti & 255);
/* put UE id */
if (rnti < 0 || rnti > 65535) { printf("bad rnti!\n"); exit(1); }
/* if no UE id allocated for this rnti then allocate the next one */
if (d->lte_rnti_to_ueid[rnti] == -1) {
d->lte_rnti_to_ueid[rnti] = d->lte_next_ue_id;
d->lte_next_ue_id++;
}
PUTC(&d->buf, MAC_LTE_UEID_TAG);
PUTC(&d->buf, (d->lte_rnti_to_ueid[rnti]>>8) & 255);
PUTC(&d->buf, d->lte_rnti_to_ueid[rnti] & 255);
}
/* for newer version of wireshark? */
......@@ -118,6 +145,25 @@ void trace_lte(ev_data *d, int direction, int rnti_type, int rnti,
PUTC(&d->buf, 0); /* rach attempt - always 0 for us (not sure of this) */
}
if (sr_rnti != NO_SR_RNTI) {
PUTC(&d->buf, MAC_LTE_SR_TAG);
PUTC(&d->buf, 0); /* number of items byte 1 */
PUTC(&d->buf, 1); /* number of items byte 2 */
/* put UE id */
if (sr_rnti < 0 || sr_rnti > 65535) { printf("bad sr rnti!\n"); exit(1); }
/* if no UE id allocated for this rnti then allocate the next one */
if (d->lte_rnti_to_ueid[sr_rnti] == -1) {
d->lte_rnti_to_ueid[sr_rnti] = d->lte_next_ue_id;
d->lte_next_ue_id++;
}
PUTC(&d->buf, (d->lte_rnti_to_ueid[sr_rnti]>>8) & 255);
PUTC(&d->buf, d->lte_rnti_to_ueid[sr_rnti] & 255);
PUTC(&d->buf, (sr_rnti>>8) & 255);
PUTC(&d->buf, sr_rnti & 255);
}
PUTC(&d->buf, MAC_LTE_PAYLOAD_TAG);
for (i = 0; i < bufsize; i++)
......@@ -135,7 +181,7 @@ void ul(void *_d, event e)
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);
NO_PREAMBLE, NO_SR_RNTI);
}
void dl(void *_d, event e)
......@@ -154,7 +200,7 @@ void dl(void *_d, event e)
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);
NO_PREAMBLE, NO_SR_RNTI);
}
void mib(void *_d, event e)
......@@ -169,7 +215,7 @@ void mib(void *_d, event e)
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);
NO_PREAMBLE, NO_SR_RNTI);
}
void preamble(void *_d, event e)
......@@ -178,7 +224,7 @@ void preamble(void *_d, event e)
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);
e.e[d->preamble_preamble].i, NO_SR_RNTI);
}
void rar(void *_d, event e)
......@@ -187,7 +233,16 @@ void rar(void *_d, event e)
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);
NO_PREAMBLE, NO_SR_RNTI);
}
void sr(void *_d, event e)
{
ev_data *d = _d;
trace_lte(d, DIRECTION_UPLINK, NO_RNTI, 0,
e.e[d->sr_frame].i, e.e[d->sr_subframe].i,
NULL, 0,
NO_PREAMBLE, e.e[d->sr_rnti].i);
}
/****************************************************************************/
......@@ -198,6 +253,7 @@ void rar(void *_d, event e)
#define MAC_NR_PAYLOAD_TAG 0x01
#define MAC_NR_RNTI_TAG 0x02
#define MAC_NR_UEID_TAG 0x03
#define MAC_NR_FRAME_SLOT_TAG 0x07
#define NR_FDD_RADIO 1
......@@ -225,6 +281,18 @@ void trace_nr(ev_data *d, int direction, int rnti_type, int rnti,
PUTC(&d->buf, MAC_NR_RNTI_TAG);
PUTC(&d->buf, (rnti>>8) & 255);
PUTC(&d->buf, rnti & 255);
/* put UE id */
if (rnti < 0 || rnti > 65535) { printf("bad rnti!\n"); exit(1); }
/* if no UE id allocated for this rnti then allocate the next one */
if (d->nr_rnti_to_ueid[rnti] == -1) {
d->nr_rnti_to_ueid[rnti] = d->nr_next_ue_id;
d->nr_next_ue_id++;
}
PUTC(&d->buf, MAC_NR_UEID_TAG);
PUTC(&d->buf, (d->nr_rnti_to_ueid[rnti]>>8) & 255);
PUTC(&d->buf, d->nr_rnti_to_ueid[rnti] & 255);
}
#if 0
......@@ -298,7 +366,7 @@ void nr_rar(void *_d, event e)
/****************************************************************************/
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 sr_id,
int nr_ul_id, int nr_dl_id, int nr_mib_id, int nr_rar_id)
{
database_event_format f;
......@@ -321,6 +389,9 @@ 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->sr_rnti = -1;
d->sr_frame = -1;
d->sr_subframe = -1;
d->nr_ul_rnti = -1;
d->nr_ul_frame = -1;
......@@ -407,6 +478,18 @@ 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;
/* sr: rnti, frame, subframe */
f = get_format(database, sr_id);
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->sr_rnti);
G("frame", "int", d->sr_frame);
G("subframe", "int", d->sr_subframe);
}
if (d->sr_rnti == -1 || d->sr_frame == -1 || d->sr_subframe == -1)
goto error;
/* NR ul: rnti, frame, slot, data */
f = get_format(database, nr_ul_id);
......@@ -530,6 +613,7 @@ int main(int n, char **v)
int i;
int ul_id, dl_id, mib_id, preamble_id, rar_id;
int nr_ul_id, nr_dl_id, nr_mib_id, nr_rar_id;
int sr_id;
ev_data d;
char *ip = DEFAULT_IP;
int port = DEFAULT_PORT;
......@@ -538,6 +622,11 @@ int main(int n, char **v)
int live = 0;
memset(&d, 0, sizeof(ev_data));
for (i = 0; i < 65536; i++) {
d.lte_rnti_to_ueid[i] = -1;
d.nr_rnti_to_ueid[i] = -1;
}
for (i = 1; i < n; i++) {
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
if (!strcmp(v[i], "-d")) { if(i>n-2)usage(); database_filename = v[++i]; continue; }
......@@ -599,6 +688,7 @@ int main(int n, char **v)
on_off(database, "ENB_PHY_MIB", is_on, 1);
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, "ENB_MAC_SCHEDULING_REQUEST", 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);
......@@ -621,13 +711,14 @@ 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");
sr_id = event_id_from_name(database, "ENB_MAC_SCHEDULING_REQUEST");
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,
setup_data(&d, database, ul_id, dl_id, mib_id, preamble_id, rar_id, sr_id,
nr_ul_id, nr_dl_id, nr_mib_id, nr_rar_id);
register_handler_function(h, ul_id, ul, &d);
......@@ -635,6 +726,7 @@ int main(int n, char **v)
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, sr_id, sr, &d);
register_handler_function(h, nr_ul_id, nr_ul, &d);
register_handler_function(h, nr_dl_id, nr_dl, &d);
......@@ -662,7 +754,7 @@ 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 ||
e.type == preamble_id || e.type == rar_id || e.type == sr_id ||
e.type == nr_ul_id || e.type == nr_dl_id ||
e.type == nr_mib_id || e.type == nr_rar_id)) continue;
......
......@@ -11,26 +11,7 @@
*
* Copyright (C) 2009 Martin Mathieson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef __COMMON_UTILS_T_TRACER_PACKET_MAC_LTE__H__
......@@ -69,7 +50,7 @@
/* these headers and send LTE MAC PDUs on a UDP socket is */
/* provided at https://wiki.wireshark.org/MAC-LTE */
/* */
/* A heuristic dissecter (enabled by a preference) will */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/*****************************************************************/
......@@ -126,18 +107,25 @@
MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte),
HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL 0x0C
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG 0x0C
/* 0 byte */
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL 0x0D
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D
/* 0 byte */
#define MAC_LTE_CE_MODE 0x0E
#define MAC_LTE_CE_MODE_TAG 0x0E
/* 1 byte containing mac_lte_ce_mode enum value */
#define MAC_LTE_NB_MODE 0x0F
#define MAC_LTE_NB_MODE_TAG 0x0F
/* 1 byte containing mac_lte_nb_mode enum value */
#define MAC_LTE_N_UL_RB_TAG 0x10
/* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */
#define MAC_LTE_SR_TAG 0x11
/* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */
/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
continues until the end of the frame) */
#define MAC_LTE_PAYLOAD_TAG 0x01
......
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