tcp: add more connection stats
Type:feature
Change-Id: If02884d0f1f26bfe31ec609ea9611cb27b699868
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 5a215b6..adff77c 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -670,6 +670,8 @@
if (tc->flags & TCP_CONN_RATE_SAMPLE)
tcp_bt_init (tc);
+
+ tc->start_ts = tcp_time_now_us (tc->c_thread_index);
}
static int
@@ -864,6 +866,27 @@
}
static u8 *
+format_tcp_stats (u8 * s, va_list * args)
+{
+ tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
+ u32 indent = format_get_indent (s);
+ s = format (s, "in segs %lu dsegs %lu bytes %lu dupacks %u\n",
+ tc->segs_in, tc->data_segs_in, tc->bytes_in, tc->dupacks_in);
+ s = format (s, "%Uout segs %lu dsegs %lu bytes %lu dupacks %u\n",
+ format_white_space, indent, tc->segs_out,
+ tc->data_segs_out, tc->bytes_out, tc->dupacks_out);
+ s = format (s, "%Ufr %u tr %u rxt segs %lu bytes %lu duration %.3f\n",
+ format_white_space, indent, tc->fr_occurences,
+ tc->tr_occurences, tc->segs_retrans, tc->bytes_retrans,
+ tcp_time_now_us (tc->c_thread_index) - tc->start_ts);
+ s = format (s, "%Uerr wnd data below %u above %u ack below %u above %u",
+ format_white_space, indent, tc->errors.below_data_wnd,
+ tc->errors.above_data_wnd, tc->errors.below_ack_wnd,
+ tc->errors.above_ack_wnd);
+ return s;
+}
+
+static u8 *
format_tcp_vars (u8 * s, va_list * args)
{
tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
@@ -896,6 +919,7 @@
{
s = format (s, " sboard: %U\n", format_tcp_scoreboard, &tc->sack_sb,
tc);
+ s = format (s, " stats: %U\n", format_tcp_stats, tc);
}
if (vec_len (tc->snd_sacks))
s = format (s, " sacks tx: %U\n", format_tcp_sacks, tc);