summaryrefslogtreecommitdiffstats
path: root/ui/cli/tap-macltestat.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui/cli/tap-macltestat.c187
1 files changed, 85 insertions, 102 deletions
diff --git a/ui/cli/tap-macltestat.c b/ui/cli/tap-macltestat.c
index ffe78ad7..88785b70 100644
--- a/ui/cli/tap-macltestat.c
+++ b/ui/cli/tap-macltestat.c
@@ -26,6 +26,7 @@ void register_tap_listener_mac_lte_stat(void);
/* Table column identifiers and title strings */
enum {
+ RAT_COLUMN,
RNTI_COLUMN,
RNTI_TYPE_COLUMN,
UEID_COLUMN,
@@ -39,97 +40,93 @@ enum {
DL_BW_COLUMN,
DL_PADDING_PERCENT_COLUMN,
DL_CRC_FAILED_COLUMN,
- DL_CRC_HIGH_CODE_RATE_COLUMN,
- DL_CRC_PDSCH_LOST_COLUMN,
- DL_CRC_DUPLICATE_NONZERO_RV_COLUMN,
DL_RETX_FRAMES_COLUMN,
NUM_UE_COLUMNS
};
-static const gchar *ue_titles[] = { " RNTI", " Type", "UEId",
+static const char *ue_titles[] = { "RAT", " RNTI", " Type", "UEId",
"UL Frames", "UL Bytes", "UL Mb/sec", " UL Pad %", "UL ReTX",
- "DL Frames", "DL Bytes", "DL Mb/sec", " DL Pad %", "DL CRC Fail", "DL CRC HCR", "DL CRC PDSCH Lost", "DL CRC DupNonZeroRV", "DL ReTX"};
+ "DL Frames", "DL Bytes", "DL Mb/sec", " DL Pad %", "DL CRC Fail", "DL ReTX"};
/* Stats for one UE */
-typedef struct mac_lte_row_data {
+typedef struct mac_lte_nr_row_data {
/* Key for matching this row */
- guint16 rnti;
- guint8 rnti_type;
- guint16 ueid;
+ uint8_t rat;
+ uint16_t rnti;
+ uint8_t rnti_type;
+ uint16_t ueid;
- gboolean is_predefined_data;
+ bool is_predefined_data;
- guint32 UL_frames;
- guint32 UL_raw_bytes; /* all bytes */
- guint32 UL_total_bytes; /* payload */
+ uint32_t UL_frames;
+ uint32_t UL_raw_bytes; /* all bytes */
+ uint32_t UL_total_bytes; /* payload */
nstime_t UL_time_start;
nstime_t UL_time_stop;
- guint32 UL_padding_bytes;
- guint32 UL_CRC_errors;
- guint32 UL_retx_frames;
+ uint32_t UL_padding_bytes;
+ uint32_t UL_CRC_errors;
+ uint32_t UL_retx_frames;
- guint32 DL_frames;
- guint32 DL_raw_bytes; /* all bytes */
- guint32 DL_total_bytes;
+ uint32_t DL_frames;
+ uint32_t DL_raw_bytes; /* all bytes */
+ uint32_t DL_total_bytes;
nstime_t DL_time_start;
nstime_t DL_time_stop;
- guint32 DL_padding_bytes;
+ uint32_t DL_padding_bytes;
- guint32 DL_CRC_failures;
- guint32 DL_CRC_high_code_rate;
- guint32 DL_CRC_PDSCH_lost;
- guint32 DL_CRC_Duplicate_NonZero_RV;
- guint32 DL_retx_frames;
+ uint32_t DL_CRC_failures;
+ uint32_t DL_retx_frames;
-} mac_lte_row_data;
+} mac_lte_nr_row_data;
-/* One row/UE in the UE table */
+/* One row/UE list item in the UE table */
typedef struct mac_lte_ep {
struct mac_lte_ep *next;
- struct mac_lte_row_data stats;
+ struct mac_lte_nr_row_data stats;
} mac_lte_ep_t;
-/* Common channel stats */
+/* Common channel stats (i.e. independent of UEs) */
typedef struct mac_lte_common_stats {
- guint32 all_frames;
- guint32 mib_frames;
- guint32 sib_frames;
- guint32 sib_bytes;
- guint32 pch_frames;
- guint32 pch_bytes;
- guint32 pch_paging_ids;
- guint32 rar_frames;
- guint32 rar_entries;
-
- guint16 max_ul_ues_in_tti;
- guint16 max_dl_ues_in_tti;
+ uint32_t all_frames;
+ uint32_t mib_frames;
+ uint32_t sib_frames;
+ uint32_t sib_bytes;
+ uint32_t pch_frames;
+ uint32_t pch_bytes;
+ uint32_t pch_paging_ids;
+ uint32_t rar_frames;
+ uint32_t rar_entries;
+
+ uint16_t max_ul_ues_in_tti;
+ uint16_t max_dl_ues_in_tti;
} mac_lte_common_stats;
/* Top-level struct for MAC LTE statistics */
-typedef struct mac_lte_stat_t {
+typedef struct mac_lte_nr_stat_t {
/* Common stats */
mac_lte_common_stats common_stats;
- /* Keep track of unique rntis & ueids */
- guint8 used_ueids[65535];
- guint8 used_rntis[65535];
- guint16 number_of_ueids;
- guint16 number_of_rntis;
+ /* Keep track of unique rntis & ueids. N.B. only used for counting number of UEs - not for lookup */
+ uint8_t used_ueids[65535];
+ uint8_t used_rntis[65535];
+ uint16_t number_of_ueids;
+ uint16_t number_of_rntis;
+ /* List of UE entries */
mac_lte_ep_t *ep_list;
-} mac_lte_stat_t;
+} mac_lte_nr_stat_t;
/* Reset the statistics window */
static void
mac_lte_stat_reset(void *phs)
{
- mac_lte_stat_t *mac_lte_stat = (mac_lte_stat_t *)phs;
+ mac_lte_nr_stat_t *mac_lte_stat = (mac_lte_nr_stat_t *)phs;
mac_lte_ep_t *list = mac_lte_stat->ep_list;
/* Reset counts of unique ueids & rntis */
@@ -150,7 +147,7 @@ mac_lte_stat_reset(void *phs)
/* Allocate a mac_lte_ep_t struct to store info for new UE */
-static mac_lte_ep_t *alloc_mac_lte_ep(const struct mac_lte_tap_info *si, packet_info *pinfo _U_)
+static mac_lte_ep_t *alloc_mac_lte_ep(const struct mac_3gpp_tap_info *si, packet_info *pinfo _U_)
{
mac_lte_ep_t *ep;
@@ -180,9 +177,6 @@ static mac_lte_ep_t *alloc_mac_lte_ep(const struct mac_lte_tap_info *si, packet_
ep->stats.UL_CRC_errors = 0;
ep->stats.DL_CRC_failures = 0;
- ep->stats.DL_CRC_high_code_rate = 0;
- ep->stats.DL_CRC_PDSCH_lost = 0;
- ep->stats.DL_CRC_Duplicate_NonZero_RV = 0;
ep->stats.UL_retx_frames = 0;
ep->stats.DL_retx_frames = 0;
@@ -193,14 +187,19 @@ static mac_lte_ep_t *alloc_mac_lte_ep(const struct mac_lte_tap_info *si, packet_
/* Update counts of unique rntis & ueids */
-static void update_ueid_rnti_counts(guint16 rnti, guint16 ueid, mac_lte_stat_t *hs)
+static void update_ueid_rnti_counts(uint16_t rnti, uint16_t ueid, mac_lte_nr_stat_t *hs)
{
+ if (hs->number_of_ueids == 65535 || hs->number_of_rntis == 65535) {
+ /* Arrays are already full! */
+ return;
+ }
+
if (!hs->used_ueids[ueid]) {
- hs->used_ueids[ueid] = TRUE;
+ hs->used_ueids[ueid] = true;
hs->number_of_ueids++;
}
if (!hs->used_rntis[rnti]) {
- hs->used_rntis[rnti] = TRUE;
+ hs->used_rntis[rnti] = true;
hs->number_of_rntis++;
}
}
@@ -212,12 +211,12 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
const void *phi, tap_flags_t flags _U_)
{
/* Get reference to stat window instance */
- mac_lte_stat_t *hs = (mac_lte_stat_t *)phs;
+ mac_lte_nr_stat_t *hs = (mac_lte_nr_stat_t*)phs;
mac_lte_ep_t *tmp = NULL, *te = NULL;
int i;
/* Cast tap info struct */
- const struct mac_lte_tap_info *si = (const struct mac_lte_tap_info *)phi;
+ const struct mac_3gpp_tap_info *si = (const struct mac_3gpp_tap_info *)phi;
if (!hs) {
return TAP_PACKET_DONT_REDRAW;
@@ -253,7 +252,7 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
return TAP_PACKET_DONT_REDRAW;
}
- /* Check max UEs/tti counter */
+ /* Check/update max UEs/tti counter */
switch (si->direction) {
case DIRECTION_UPLINK:
hs->common_stats.max_ul_ues_in_tti =
@@ -276,16 +275,18 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
update_ueid_rnti_counts(si->rnti, si->ueid, hs);
} else {
/* Look among existing rows for this RNTI */
- for (tmp = hs->ep_list;(tmp != NULL); tmp = tmp->next) {
- /* Match only by RNTI and UEId together */
- if ((tmp->stats.rnti == si->rnti) &&
+ /* TODO: with different data structures, could avoid this linear search */
+ for (tmp = hs->ep_list; tmp != NULL; tmp = tmp->next) {
+ /* Match only by RAT, RNTI and UEId together */
+ if ((tmp->stats.rat == si->rat) &&
+ (tmp->stats.rnti == si->rnti) &&
(tmp->stats.ueid == si->ueid)) {
te = tmp;
break;
}
}
- /* Not found among existing, so create a new one anyway */
+ /* Not found among existing, so create a new one now */
if (te == NULL) {
if ((te = alloc_mac_lte_ep(si, pinfo))) {
/* Add new item to end of list */
@@ -308,6 +309,7 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
}
/* Update entry with details from si */
+ te->stats.rat = si->rat;
te->stats.rnti = si->rnti;
te->stats.is_predefined_data = si->isPredefinedData;
@@ -325,9 +327,9 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
/* Update time range */
if (te->stats.UL_frames == 0) {
- te->stats.UL_time_start = si->mac_lte_time;
+ te->stats.UL_time_start = si->mac_time;
}
- te->stats.UL_time_stop = si->mac_lte_time;
+ te->stats.UL_time_stop = si->mac_time;
te->stats.UL_frames++;
@@ -338,7 +340,7 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
te->stats.UL_total_bytes += si->single_number_of_bytes;
}
else {
- for (i = 0; i < MAC_LTE_DATA_LCID_COUNT_MAX; i++) {
+ for (i = 0; i < MAC_3GPP_DATA_LCID_COUNT_MAX; i++) {
te->stats.UL_total_bytes += si->bytes_for_lcid[i];
}
}
@@ -352,32 +354,15 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
}
if (si->crcStatusValid && (si->crcStatus != crc_success)) {
- switch (si->crcStatus) {
- case crc_fail:
- te->stats.DL_CRC_failures++;
- break;
- case crc_high_code_rate:
- te->stats.DL_CRC_high_code_rate++;
- break;
- case crc_pdsch_lost:
- te->stats.DL_CRC_PDSCH_lost++;
- break;
- case crc_duplicate_nonzero_rv:
- te->stats.DL_CRC_Duplicate_NonZero_RV++;
- break;
-
- default:
- /* Something went wrong! */
- break;
- }
+ te->stats.DL_CRC_failures++;
return TAP_PACKET_REDRAW;
}
/* Update time range */
if (te->stats.DL_frames == 0) {
- te->stats.DL_time_start = si->mac_lte_time;
+ te->stats.DL_time_start = si->mac_time;
}
- te->stats.DL_time_stop = si->mac_lte_time;
+ te->stats.DL_time_stop = si->mac_time;
te->stats.DL_frames++;
@@ -388,7 +373,7 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
te->stats.DL_total_bytes += si->single_number_of_bytes;
}
else {
- for (i = 0; i < MAC_LTE_DATA_LCID_COUNT_MAX; i++) {
+ for (i = 0; i < MAC_3GPP_DATA_LCID_COUNT_MAX; i++) {
te->stats.DL_total_bytes += si->bytes_for_lcid[i];
}
}
@@ -400,11 +385,11 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
/* Calculate and return a bandwidth figure, in Mbs */
-static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 bytes)
+static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, uint32_t bytes)
{
/* Can only calculate bandwidth if have time delta */
if (memcmp(start_time, stop_time, sizeof(nstime_t)) != 0) {
- float elapsed_ms = (((float)stop_time->secs - (float)start_time->secs) * 1000) +
+ float elapsed_ms = (((float)stop_time->secs - (float)start_time->secs) * 1000) +
(((float)stop_time->nsecs - (float)start_time->nsecs) / 1000000);
/* Only really meaningful if have a few frames spread over time...
@@ -425,11 +410,11 @@ static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 byt
static void
mac_lte_stat_draw(void *phs)
{
- gint i;
- guint16 number_of_ues = 0;
+ int i;
+ uint16_t number_of_ues = 0;
/* Deref the struct */
- mac_lte_stat_t *hs = (mac_lte_stat_t *)phs;
+ mac_lte_nr_stat_t *hs = (mac_lte_nr_stat_t*)phs;
mac_lte_ep_t *list = hs->ep_list, *tmp = 0;
/* System data */
@@ -475,7 +460,8 @@ mac_lte_stat_draw(void *phs)
&tmp->stats.DL_time_stop,
tmp->stats.DL_total_bytes);
- printf("%5u %7s %5u %10u %9u %10f %10f %8u %10u %9u %10f %10f %12u %11u %18u %20u %8u\n",
+ printf("%s %5u %7s %5u %10u %9u %10f %10f %8u %10u %9u %10f %10f %12u %8u\n",
+ (tmp->stats.rat == MAC_RAT_LTE) ? "LTE " : "NR ",
tmp->stats.rnti,
(tmp->stats.rnti_type == C_RNTI) ? "C-RNTI" : "SPS-RNTI",
tmp->stats.ueid,
@@ -493,9 +479,6 @@ mac_lte_stat_draw(void *phs)
(((float)tmp->stats.DL_padding_bytes / (float)tmp->stats.DL_raw_bytes) * 100.0) :
0.0,
tmp->stats.DL_CRC_failures,
- tmp->stats.DL_CRC_high_code_rate,
- tmp->stats.DL_CRC_PDSCH_lost,
- tmp->stats.DL_CRC_Duplicate_NonZero_RV,
tmp->stats.DL_retx_frames);
}
}
@@ -503,14 +486,14 @@ mac_lte_stat_draw(void *phs)
/* Create a new MAC LTE stats struct */
static void mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
{
- mac_lte_stat_t *hs;
+ mac_lte_nr_stat_t *hs;
const char *filter = NULL;
GString *error_string;
/* Check for a filter string */
- if (strncmp(opt_arg, "mac-lte,stat,", 13) == 0) {
+ if (strncmp(opt_arg, "mac-3gpp,stat,", 14) == 0) {
/* Skip those characters from filter to display */
- filter = opt_arg + 13;
+ filter = opt_arg + 14;
}
else {
/* No filter */
@@ -518,10 +501,10 @@ static void mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
}
/* Create struct */
- hs = g_new0(mac_lte_stat_t, 1);
+ hs = g_new0(mac_lte_nr_stat_t, 1);
hs->ep_list = NULL;
- error_string = register_tap_listener("mac-lte", hs,
+ error_string = register_tap_listener("mac-3gpp", hs,
filter, 0,
mac_lte_stat_reset,
mac_lte_stat_packet,
@@ -537,7 +520,7 @@ static void mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
static stat_tap_ui mac_lte_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
- "mac-lte,stat",
+ "mac-3gpp,stat",
mac_lte_stat_init,
0,
NULL