aboutsummaryrefslogtreecommitdiff
path: root/src/tcp_info.c
diff options
context:
space:
mode:
authorBruce A. Mah <bmah@es.net>2013-12-18 15:09:46 -0800
committerBruce A. Mah <bmah@es.net>2013-12-18 15:09:46 -0800
commit5cdc6a4ac8f723b23e78f231d62eb7208b0fbb8e (patch)
treee04f92c21d854dfe231ee3762d862d94f92912ed /src/tcp_info.c
parentcfe8c5fb470efa0b5fc8b9d53d618cb0eda051dc (diff)
downloadiperf3-5cdc6a4ac8f723b23e78f231d62eb7208b0fbb8e.tar.gz
Keep track of SACKs and snd_cwnd from tcp_info (Linux only for now).
Committing this WIP so we can get some experimentation done with it.
Diffstat (limited to 'src/tcp_info.c')
-rw-r--r--src/tcp_info.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/tcp_info.c b/src/tcp_info.c
index d0cd7da..0676e8d 100644
--- a/src/tcp_info.c
+++ b/src/tcp_info.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2011, The Regents of the University of California,
+ * Copyright (c) 2009-2013, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@@ -96,6 +96,11 @@ get_total_retransmits(int socket)
return -1;
#if defined(linux) && defined(TCP_MD5SIG)
+#if 0
+ printf("tcpi_sacked %d\n", ti.tcpi_sacked);
+ printf("tcpi_snd_cwnd %d\n", ti.tcpi_snd_cwnd);
+ printf("tcpi_total_retrans %d\n", ti.tcpi_total_retrans);
+#endif
return ti.tcpi_total_retrans;
#else
#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
@@ -110,6 +115,58 @@ get_total_retransmits(int socket)
#endif
}
+/*************************************************************/
+long
+get_sacks(int socket)
+{
+#if defined(linux) || defined(__FreeBSD__)
+ struct tcp_info ti;
+ socklen_t l = sizeof(ti);
+
+ if (getsockopt(socket, IPPROTO_TCP, TCP_INFO, (void *)&ti, &l) < 0)
+ return -1;
+
+#if defined(linux) && defined(TCP_MD5SIG)
+ return ti.tcpi_sacked;
+#else
+#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
+ return ti.__tcpi_sacked;
+#else
+ return -1;
+#endif
+#endif
+
+#else
+ return -1;
+#endif
+}
+
+/*************************************************************/
+long
+get_snd_cwnd(int socket)
+{
+#if defined(linux) || defined(__FreeBSD__)
+ struct tcp_info ti;
+ socklen_t l = sizeof(ti);
+
+ if (getsockopt(socket, IPPROTO_TCP, TCP_INFO, (void *)&ti, &l) < 0)
+ return -1;
+
+#if defined(linux) && defined(TCP_MD5SIG)
+ return ti.tcpi_snd_cwnd;
+#else
+#if defined(__FreeBSD__) && __FreeBSD_version >= 600000
+ return ti.tcpi_snd_cwnd;
+#else
+ return -1;
+#endif
+#endif
+
+#else
+ return -1;
+#endif
+}
+
#ifdef notdef
/*************************************************************/
//print_tcpinfo(struct iperf_interval_results *r)