diff --git a/ui/qt/lte_mac_statistics_dialog.cpp b/ui/qt/lte_mac_statistics_dialog.cpp index 59b08cc641..f57073bf14 100644 --- a/ui/qt/lte_mac_statistics_dialog.cpp +++ b/ui/qt/lte_mac_statistics_dialog.cpp @@ -36,7 +36,6 @@ #include "wireshark_application.h" // To do: -// - Tidy up common stats. Use HTML tables to line up counters? // - Add missing controls (RACH, SR checkboxes) // Whole-UE headings. @@ -125,19 +124,34 @@ public: lcids[lcid] += value; } - // TODO: not currently used. Delete? - void update(const mac_lte_tap_info *) { - } - - // TODO: when SR and RACH checkboxes added, check state and add to expression. - const QString filterExpression() { + // Generate expression for this UE and direction, also filter for SRs and RACH if indicated. + const QString filterExpression(bool showSR, bool showRACH) { int direction = (type() == mac_dlsch_packet_count_row_type) || (type() == mac_dlsch_byte_count_row_type); - // Create an expression to match with all traffic for this UE, but only in the - // direction of this row. - QString filter_expr = - QString("mac-lte.ueid==%1 && mac-lte.rnti==%2 && mac-lte.direction==%3"). - arg(ueid_).arg(rnti_).arg(direction); + + QString filter_expr; + + if (showSR) { + filter_expr = QString("(mac-lte.sr-req and mac-lte.ueid == %1) or (").arg(ueid_); + } + + if (showRACH) { + filter_expr += QString("(mac-lte.rar or (mac-lte.preamble-sent and mac-lte.ueid == %1)) or (").arg(ueid_); + } + + // Main expression matching this UE and direction + filter_expr += QString("mac-lte.ueid==%1 && mac-lte.rnti==%2 && mac-lte.direction==%3"). + arg(ueid_).arg(rnti_).arg(direction); + + // Close () if open because of SR + if (showSR) { + filter_expr += QString(")"); + } + // Close () if open because of RACH + if (showRACH) { + filter_expr += QString(")"); + } + return filter_expr; } @@ -366,11 +380,30 @@ public: return QTreeWidgetItem::operator< (other); } - // TODO: when SR and RACH checkboxes added, check state and add to expression. - const QString filterExpression() { - // Create an expression to match with all traffic for this UE. - QString filter_expr = - QString("mac-lte.ueid==%1 && mac-lte.rnti==%2").arg(ueid_).arg(rnti_); + // Generate expression for this UE, also filter for SRs and RACH if indicated. + const QString filterExpression(bool showSR, bool showRACH) { + QString filter_expr; + + if (showSR) { + filter_expr = QString("(mac-lte.sr-req and mac-lte.ueid == %1) or (").arg(ueid_); + } + + if (showRACH) { + filter_expr += QString("(mac-lte.rar or (mac-lte.preamble-sent and mac-lte.ueid == %1)) or (").arg(ueid_); + } + + // Main expression matching this UE + filter_expr += QString("mac-lte.ueid==%1 && mac-lte.rnti==%2").arg(ueid_).arg(rnti_); + + // Close () if open because of SR + if (showSR) { + filter_expr += QString(")"); + } + // Close () if open because of RACH + if (showRACH) { + filter_expr += QString(")"); + } + return filter_expr; } @@ -435,7 +468,7 @@ static const QStringList mac_channel_counts_labels = QStringList() // Constructor. LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter) : TapParameterDialog(parent, cf, HELP_STATS_LTE_MAC_TRAFFIC_DIALOG), - commonStatsCurrent(false) + commonStatsCurrent_(false) { setWindowSubtitle(tr("LTE Mac Statistics")); @@ -444,6 +477,7 @@ LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf, // Create common_stats_grid to appear just above the filter area. int statstree_layout_idx = verticalLayout()->indexOf(filterLayout()->widget()); QGridLayout *common_stats_grid = new QGridLayout(); + // Insert into the vertical layout verticalLayout()->insertLayout(statstree_layout_idx, common_stats_grid); int one_em = fontMetrics().height(); common_stats_grid->setColumnMinimumWidth(2, one_em * 2); @@ -451,13 +485,29 @@ LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf, common_stats_grid->setColumnMinimumWidth(5, one_em * 2); common_stats_grid->setColumnStretch(5, 1); - // Create statistics label. - commonStatsLabel = new QLabel(this); - commonStatsLabel ->setObjectName("statisticsLabel"); - commonStatsLabel ->setTextFormat(Qt::RichText); - commonStatsLabel ->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse); - common_stats_grid->addWidget(commonStatsLabel); + commonStatsLabel_ = new QLabel(this); + commonStatsLabel_->setObjectName("statisticsLabel"); + commonStatsLabel_->setTextFormat(Qt::RichText); + commonStatsLabel_->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse); + common_stats_grid->addWidget(commonStatsLabel_); + + + // Create a grid for filtering-related widgetsto also appear in layout. + int filter_controls_layout_idx = verticalLayout()->indexOf(filterLayout()->widget()); + QGridLayout *filter_controls_grid = new QGridLayout(); + // Insert into the vertical layout + verticalLayout()->insertLayout(filter_controls_layout_idx, filter_controls_grid); + filter_controls_grid->setColumnMinimumWidth(2, one_em * 2); + filter_controls_grid->setColumnStretch(2, 1); + filter_controls_grid->setColumnMinimumWidth(5, one_em * 2); + filter_controls_grid->setColumnStretch(5, 1); + + // Add individual controls into the grid + showSRFilterCheckBox_ = new QCheckBox(tr("Include SR frames in filter")); + filter_controls_grid->addWidget(showSRFilterCheckBox_); + showRACHFilterCheckBox_ = new QCheckBox(tr("Include RACH frames in filter")); + filter_controls_grid->addWidget(showRACHFilterCheckBox_); // XXX Use recent settings instead @@ -539,29 +589,29 @@ LteMacStatisticsDialog::~LteMacStatisticsDialog() // Update system/common counters, and redraw if changed. void LteMacStatisticsDialog::updateCommonStats(const mac_lte_tap_info *tap_info) { - common_stats.all_frames++; + commonStats_.all_frames++; // For common channels, just update global counters switch (tap_info->rntiType) { case P_RNTI: - common_stats.pch_frames++; - common_stats.pch_bytes += tap_info->single_number_of_bytes; - common_stats.pch_paging_ids += tap_info->number_of_paging_ids; - commonStatsCurrent = false; + commonStats_.pch_frames++; + commonStats_.pch_bytes += tap_info->single_number_of_bytes; + commonStats_.pch_paging_ids += tap_info->number_of_paging_ids; + commonStatsCurrent_ = false; break; case SI_RNTI: - common_stats.sib_frames++; - common_stats.sib_bytes += tap_info->single_number_of_bytes; - commonStatsCurrent = false; + commonStats_.sib_frames++; + commonStats_.sib_bytes += tap_info->single_number_of_bytes; + commonStatsCurrent_ = false; break; case NO_RNTI: - common_stats.mib_frames++; - commonStatsCurrent = false; + commonStats_.mib_frames++; + commonStatsCurrent_ = false; break; case RA_RNTI: - common_stats.rar_frames++; - common_stats.rar_entries += tap_info->number_of_rars; - commonStatsCurrent = false; + commonStats_.rar_frames++; + commonStats_.rar_entries += tap_info->number_of_rars; + commonStatsCurrent_ = false; break; case C_RNTI: case SPS_RNTI: @@ -576,42 +626,53 @@ void LteMacStatisticsDialog::updateCommonStats(const mac_lte_tap_info *tap_info) // Check max UEs/tti counter switch (tap_info->direction) { case DIRECTION_UPLINK: - if (tap_info->ueInTTI > common_stats.max_ul_ues_in_tti) { - common_stats.max_ul_ues_in_tti = tap_info->ueInTTI; - commonStatsCurrent = false; + if (tap_info->ueInTTI > commonStats_.max_ul_ues_in_tti) { + commonStats_.max_ul_ues_in_tti = tap_info->ueInTTI; + commonStatsCurrent_ = false; } break; case DIRECTION_DOWNLINK: - if (tap_info->ueInTTI > common_stats.max_dl_ues_in_tti) { - common_stats.max_dl_ues_in_tti = tap_info->ueInTTI; - commonStatsCurrent = false; + if (tap_info->ueInTTI > commonStats_.max_dl_ues_in_tti) { + commonStats_.max_dl_ues_in_tti = tap_info->ueInTTI; + commonStatsCurrent_ = false; } break; } +} - if (!commonStatsCurrent) { +// Draw current common statistics by regenerating label with current values. +void LteMacStatisticsDialog::drawCommonStats() +{ + if (!commonStatsCurrent_) { QString stats_tables = "
\n"; - stats_tables += QString("System: Max UL UEs/TTI=%1 ").arg(common_stats.max_ul_ues_in_tti); - stats_tables += QString("Max DL UEs/TTI=%1\n").arg(common_stats.max_dl_ues_in_tti); + stats_tables += QString("
System | Max UL UEs/TTI=%1 | ").arg(commonStats_.max_ul_ues_in_tti); + stats_tables += QString("Max DL UEs/TTI=%1 |
---|---|---|
System broadcast | MIBs=%1 | ").arg(commonStats_.mib_frames); + stats_tables += QString("SIBs=%1 (%2 bytes) |
RACH | RARs=%1 frames (%2 RARs) | |
Paging | PCH=%1 (%2 bytes, %3 IDs) |