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("\n"); + stats_tables += QString("").arg(commonStats_.max_ul_ues_in_tti); + stats_tables += QString("\n").arg(commonStats_.max_dl_ues_in_tti); - stats_tables += QString("

System broadcast: MIBs=%1 ").arg(common_stats.mib_frames); - stats_tables += QString("SIBs=%1 (%2 bytes) ").arg(common_stats.sib_frames).arg(common_stats.sib_bytes); - stats_tables += QString("

RACH: RARs=%1 frames (%2 RARs) ").arg(common_stats.rar_frames).arg(common_stats.rar_entries); - stats_tables += QString("

Paging: PCH=%1 (%2 bytes, %3 IDs) "). - arg(common_stats.pch_frames). - arg(common_stats.pch_bytes). - arg(common_stats.pch_paging_ids); + stats_tables += QString("

").arg(commonStats_.mib_frames); + stats_tables += QString("\n").arg(commonStats_.sib_frames).arg(commonStats_.sib_bytes); + + stats_tables += QString("\n"). + arg(commonStats_.rar_frames). + arg(commonStats_.rar_entries); + + stats_tables += QString("\n"). + arg(commonStats_.pch_frames). + arg(commonStats_.pch_bytes). + arg(commonStats_.pch_paging_ids); + + stats_tables += QString("
System Max UL UEs/TTI=%1Max DL UEs/TTI=%1
System broadcastMIBs=%1SIBs=%1 (%2 bytes)
RACHRARs=%1 frames (%2 RARs)
PagingPCH=%1 (%2 bytes, %3 IDs)
\n"); stats_tables += "\n"; - commonStatsLabel->setText(stats_tables); + commonStatsLabel_->setText(stats_tables); - commonStatsCurrent = true; + commonStatsCurrent_ = true; } } void LteMacStatisticsDialog::clearCommonStats() { - memset(&common_stats, 0, sizeof(common_stats)); + memset(&commonStats_, 0, sizeof(commonStats_)); } void LteMacStatisticsDialog::tapReset(void *ws_dlg_ptr) @@ -675,7 +736,7 @@ gboolean LteMacStatisticsDialog::tapPacket(void *ws_dlg_ptr, struct _packet_info // Return total number of frames tapped. unsigned LteMacStatisticsDialog::getFrameCount() { - return common_stats.all_frames; + return commonStats_.all_frames; } void LteMacStatisticsDialog::tapDraw(void *ws_dlg_ptr) @@ -699,6 +760,8 @@ void LteMacStatisticsDialog::tapDraw(void *ws_dlg_ptr) mac_ue_ti->draw(); } + ws_dlg->drawCommonStats(); + // Update title ws_dlg->setWindowSubtitle(QString("LTE Mac Statistics (%1 UEs, %2 frames)"). arg(ws_dlg->statsTreeWidget()->topLevelItemCount()).arg(ws_dlg->getFrameCount())); @@ -707,15 +770,18 @@ void LteMacStatisticsDialog::tapDraw(void *ws_dlg_ptr) const QString LteMacStatisticsDialog::filterExpression() { QString filter_expr; + if (statsTreeWidget()->selectedItems().count() > 0) { QTreeWidgetItem *ti = statsTreeWidget()->selectedItems()[0]; if (ti->type() == mac_whole_ue_row_type_) { MacUETreeWidgetItem *mac_ue_ti = static_cast(ti); - filter_expr = mac_ue_ti->filterExpression(); + filter_expr = mac_ue_ti->filterExpression(showSRFilterCheckBox_->checkState() > Qt::Unchecked, + showRACHFilterCheckBox_->checkState() > Qt::Unchecked); } else { MacULDLTreeWidgetItem *mac_channels_ti = static_cast(ti); - filter_expr = mac_channels_ti->filterExpression(); + filter_expr = mac_channels_ti->filterExpression(showSRFilterCheckBox_->checkState() > Qt::Unchecked, + showRACHFilterCheckBox_->checkState() > Qt::Unchecked); } } return filter_expr; diff --git a/ui/qt/lte_mac_statistics_dialog.h b/ui/qt/lte_mac_statistics_dialog.h index 1f36aa9ac5..d6fd762b42 100644 --- a/ui/qt/lte_mac_statistics_dialog.h +++ b/ui/qt/lte_mac_statistics_dialog.h @@ -25,6 +25,7 @@ #include "tap_parameter_dialog.h" #include +#include // Common channel stats @@ -52,12 +53,15 @@ public: LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter); ~LteMacStatisticsDialog(); - QLabel *commonStatsLabel; + // Extra controls needed for this dialog. + QLabel *commonStatsLabel_; + QCheckBox *showSRFilterCheckBox_; + QCheckBox *showRACHFilterCheckBox_; protected: private: - mac_lte_common_stats common_stats; - bool commonStatsCurrent; + mac_lte_common_stats commonStats_; + bool commonStatsCurrent_; // Callbacks for register_tap_listener static void tapReset(void *ws_dlg_ptr); @@ -67,6 +71,7 @@ private: virtual const QString filterExpression(); void updateCommonStats(const struct mac_lte_tap_info *mlt_info); + void drawCommonStats(); void clearCommonStats(); unsigned getFrameCount();