diff options
author | Kevin Hogan <kwabena@google.com> | 2017-01-17 16:53:42 -0800 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-01-19 10:00:23 +0000 |
commit | 259a3e508f37bb3c9b6d18cdacf7a18aa6dbd8f8 (patch) | |
tree | fcd04fb31b00a6f78b23c6131b0929ea47fdf4d3 /ui | |
parent | c397adda8a7af8374ba1355f8c221f48abfac42a (diff) | |
download | wireshark-259a3e508f37bb3c9b6d18cdacf7a18aa6dbd8f8.tar.gz |
Qt: add graph of unacked (outstanding) bytes to window scale graph
This metric is commonly used as an estimate of the sender's congestion window.
[ when examining a capture taken from the sender ]
Change-Id: I812d5556cef477c08ef1e5d396fbdddda9a6751e
Reviewed-on: https://code.wireshark.org/review/19661
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/tcp_stream_dialog.cpp | 47 | ||||
-rw-r--r-- | ui/tap-tcp-stream.h | 15 |
2 files changed, 52 insertions, 10 deletions
diff --git a/ui/qt/tcp_stream_dialog.cpp b/ui/qt/tcp_stream_dialog.cpp index 800b02adcb..4230b3820f 100644 --- a/ui/qt/tcp_stream_dialog.cpp +++ b/ui/qt/tcp_stream_dialog.cpp @@ -931,23 +931,50 @@ void TCPStreamDialog::fillWindowScale() title_->setText(dlg_title); QCustomPlot *sp = ui->streamPlot; - base_graph_->setLineStyle(QCPGraph::lsLine); + // use base_graph_ to represent unacked window size + // (estimate of congestion window) + base_graph_->setLineStyle(QCPGraph::lsStepLeft); + // use rwin_graph_ here to show rwin window scale + // (derived from ACK packets) + rwin_graph_->setVisible(true); QVector<double> rel_time, win_size; + QVector<double> cwnd_time, cwnd_size; + guint32 last_ack = 0; + bool found_first_ack = false; for (struct segment *seg = graph_.segments; seg != NULL; seg = seg->next) { - if (!compareHeaders(seg)) { - continue; - } - double ts = seg->rel_secs + seg->rel_usecs / 1000000.0; - guint16 flags = seg->th_flags; - if ((flags & (TH_SYN|TH_RST)) == 0) { - rel_time.append(ts - ts_offset_); - win_size.append(seg->th_win); + // The receive window that applies to this flow comes + // from packets in the opposite direction + if (compareHeaders(seg)) { + // compute bytes_in_flight for cwnd graph + guint32 end_seq = seg->th_seq + seg->th_seglen; + if (found_first_ack && + tcp_seq_eq_or_after(end_seq, last_ack)) { + cwnd_time.append(ts - ts_offset_); + cwnd_size.append((double)(end_seq - last_ack)); + } + } else { + // packet in opposite direction - has advertised rwin + guint16 flags = seg->th_flags; + + if ((flags & (TH_SYN|TH_RST)) == 0) { + rel_time.append(ts - ts_offset_); + win_size.append(seg->th_win); + } + if ((flags & (TH_ACK)) != 0) { + // use this to update last_ack + if (!found_first_ack || + tcp_seq_eq_or_after(seg->th_ack, last_ack)) { + last_ack = seg->th_ack; + found_first_ack = true; + } + } } } - base_graph_->setData(rel_time, win_size); + base_graph_->setData(cwnd_time, cwnd_size); + rwin_graph_->setData(rel_time, win_size); sp->yAxis->setLabel(window_size_label_); } diff --git a/ui/tap-tcp-stream.h b/ui/tap-tcp-stream.h index f430fa5fa5..360f4af016 100644 --- a/ui/tap-tcp-stream.h +++ b/ui/tap-tcp-stream.h @@ -114,6 +114,21 @@ struct unack *rtt_get_new_unack(double , unsigned int ); void rtt_put_unack_on_list(struct unack ** , struct unack * ); void rtt_delete_unack_from_list(struct unack ** , struct unack * ); +static inline int +tcp_seq_before(guint32 s1, guint32 s2) { + return (gint32)(s1 - s2) < 0; +} + +static inline int +tcp_seq_eq_or_after(guint32 s1, guint32 s2) { + return !tcp_seq_before(s1, s2); +} + +static inline int +tcp_seq_after(guint32 s1, guint32 s2) { + return (s1 != s2) && !tcp_seq_before(s1, s2); +} + #ifdef __cplusplus } |