summaryrefslogtreecommitdiff
path: root/ui/qt/sctp_graph_byte_dialog.cpp
diff options
context:
space:
mode:
authorIrene RĂ¼ngeler <I.Ruengeler@fh-muenster.de>2013-12-13 07:25:30 +0000
committerIrene RĂ¼ngeler <I.Ruengeler@fh-muenster.de>2013-12-13 07:25:30 +0000
commit796bf409b0c286dd76e6ecd5c61d0d947d54b479 (patch)
tree42d21c7d8b1175adf0f155f5c0fb9f53feb795d5 /ui/qt/sctp_graph_byte_dialog.cpp
parent28e6aa4e8a06299895d7924508a32a895a5454ab (diff)
downloadwireshark-796bf409b0c286dd76e6ecd5c61d0d947d54b479.tar.gz
Add dialogs and graphs to analyse SCTP behavior similar to the GTK version.
svn path=/trunk/; revision=54026
Diffstat (limited to 'ui/qt/sctp_graph_byte_dialog.cpp')
-rw-r--r--ui/qt/sctp_graph_byte_dialog.cpp145
1 files changed, 145 insertions, 0 deletions
diff --git a/ui/qt/sctp_graph_byte_dialog.cpp b/ui/qt/sctp_graph_byte_dialog.cpp
new file mode 100644
index 0000000000..0574150010
--- /dev/null
+++ b/ui/qt/sctp_graph_byte_dialog.cpp
@@ -0,0 +1,145 @@
+#include "sctp_graph_byte_dialog.h"
+#include "ui_sctp_graph_byte_dialog.h"
+
+#include "sctp_graph_dialog.h"
+
+SCTPGraphByteDialog::SCTPGraphByteDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf, int dir) :
+ QDialog(parent),
+ ui(new Ui::SCTPGraphByteDialog),
+ selected_assoc(assoc),
+ cap_file_(cf),
+ direction(dir)
+{
+ ui->setupUi(this);
+ this->setWindowTitle(QString("SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3").arg(cf_get_display_name(cap_file_)).arg(selected_assoc->port1).arg(selected_assoc->port2));
+ if ((direction == 1 && selected_assoc->n_array_tsn1 == 0) || (direction == 2 && selected_assoc->n_array_tsn2 == 0)) {
+ QMessageBox msgBox;
+ msgBox.setText("No Data Chunks sent");
+ msgBox.exec();
+ return;
+ } else {
+ drawGraph();
+ }
+}
+
+SCTPGraphByteDialog::~SCTPGraphByteDialog()
+{
+ delete ui;
+}
+
+
+void SCTPGraphByteDialog::drawBytesGraph()
+{
+ GList *listTSN = NULL,*tlist;
+ tsn_t *tsn;
+ guint8 type;
+ guint32 minBytes, maxBytes;
+ long sumBytes = 0;
+ // printf("drawBytesGraph\n");
+ if (direction == 1) {
+ minBytes = 0; //selected_assoc->min_tsn1;
+ maxBytes = selected_assoc->n_data_bytes_ep1;
+ listTSN = g_list_last(selected_assoc->tsn1);
+ } else {
+ minBytes = 0; //selected_assoc->min_tsn2;
+ maxBytes = selected_assoc->n_data_bytes_ep2;
+ listTSN = g_list_last(selected_assoc->tsn2);
+ }
+
+
+ while (listTSN) {
+ tsn = (tsn_t*) (listTSN->data);
+ tlist = g_list_first(tsn->tsns);
+ guint16 length;
+ while (tlist)
+ {
+ type = ((struct chunk_header *)tlist->data)->type;
+ if (type == SCTP_DATA_CHUNK_ID) {
+ length = g_ntohs(((struct data_chunk_header *)tlist->data)->length);
+ sumBytes += length;
+ yb.append(sumBytes);
+ xb.append(tsn->secs + tsn->usecs/1000000.0);
+ // printf("x=%f y=%ld\n", tsn->secs + tsn->usecs/1000000.0, sumBytes);
+ fb.append(tsn->frame_number);
+ }
+ tlist = g_list_next(tlist);
+ }
+ listTSN = g_list_previous(listTSN);
+ }
+
+
+ QCPScatterStyle myScatter;
+ myScatter.setShape(QCPScatterStyle::ssCircle);
+ myScatter.setSize(3);
+
+ // create graph and assign data to it:
+
+ // Add Bytes graph
+ if (xb.size() > 0) {
+ QCPGraph *gr = ui->sctpPlot->addGraph(ui->sctpPlot->xAxis, ui->sctpPlot->yAxis);
+ gr->setName(QString("Bytes"));
+ myScatter.setPen(QPen(Qt::red));
+ myScatter.setBrush(Qt::red);
+ ui->sctpPlot->graph(0)->setScatterStyle(myScatter);
+ ui->sctpPlot->graph(0)->setLineStyle(QCPGraph::lsNone);
+ ui->sctpPlot->graph(0)->setData(xb, yb);
+ }
+ ui->sctpPlot->xAxis->setLabel("time [secs]");
+ ui->sctpPlot->yAxis->setLabel("Received Bytes");
+
+ // set axes ranges, so we see all data:
+ QCPRange myXByteRange(0, (selected_assoc->max_secs+1));
+ QCPRange myYByteRange(0, maxBytes);
+ ui->sctpPlot->xAxis->setRange(myXByteRange);
+ ui->sctpPlot->yAxis->setRange(myYByteRange);
+}
+
+
+void SCTPGraphByteDialog::drawGraph()
+{
+ ui->sctpPlot->clearGraphs();
+ drawBytesGraph();
+ ui->sctpPlot->setInteractions(QCP::iRangeZoom | QCP::iRangeDrag | QCP::iSelectPlottables);
+ connect(ui->sctpPlot, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*, QMouseEvent*)));
+ ui->sctpPlot->replot();
+}
+
+
+void SCTPGraphByteDialog::on_pushButton_4_clicked()
+{
+ ui->sctpPlot->xAxis->setRange(selected_assoc->min_secs+selected_assoc->min_usecs/1000000.0, selected_assoc->max_secs+selected_assoc->max_usecs/1000000.0);
+ if (direction == 1) {
+ ui->sctpPlot->yAxis->setRange(0, selected_assoc->n_data_bytes_ep1);
+ } else {
+ ui->sctpPlot->yAxis->setRange(0, selected_assoc->n_data_bytes_ep2);
+ }
+ ui->sctpPlot->replot();
+}
+
+void SCTPGraphByteDialog::graphClicked(QCPAbstractPlottable* plottable, QMouseEvent* event)
+{
+ if (plottable->name().contains("Bytes", Qt::CaseInsensitive)) {
+ double bytes = round(ui->sctpPlot->yAxis->pixelToCoord(event->pos().y()));
+ int i;
+ for (i = 0; i < yb.size(); i++) {
+ if (bytes <= yb.value(i)) {
+ frame_num = fb.at(i);
+ break;
+ }
+ }
+ if (cap_file_ && frame_num > 0) {
+ cf_goto_frame(cap_file_, frame_num);
+ }
+
+ ui->hintLabel->setText(QString("<small><i>Graph %1: Received bytes=%2 Time=%3 secs </i></small>")
+ .arg(plottable->name())
+ .arg(yb.value(i))
+ .arg(xb.value(i)));
+ }
+}
+
+
+void SCTPGraphByteDialog::on_saveButton_clicked()
+{
+ SCTPGraphDialog::save_graph(this, ui->sctpPlot);
+}