summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/Makefile.in10
-rw-r--r--compat/Thread.c8
-rw-r--r--compat/delay.c9
-rw-r--r--compat/error.c156
-rw-r--r--compat/gettcpinfo.c36
5 files changed, 205 insertions, 14 deletions
diff --git a/compat/Makefile.in b/compat/Makefile.in
index 5d5bbcd..bb7af61 100644
--- a/compat/Makefile.in
+++ b/compat/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.2 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -171,8 +171,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -187,6 +185,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
@@ -197,6 +197,7 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
@@ -439,7 +440,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
diff --git a/compat/Thread.c b/compat/Thread.c
index 307535e..4189a64 100644
--- a/compat/Thread.c
+++ b/compat/Thread.c
@@ -136,7 +136,13 @@ static int __log(const char *level, const char *format, va_list args) {
char logformat[]="%s(%ld):[%s] %s\n";
__gettimestamp(timestamp);
- #if HAVE_GETTID_SYSCALL
+
+ #if HAVE_DECL_PTHREAD_THREADID_NP
+ uint64_t tid;
+ if (pthread_threadid_np(NULL, &tid) != 0) {
+ tid = -1;
+ }
+ #elif HAVE_GETTID_SYSCALL
unsigned long tid = syscall(SYS_gettid);
#else
unsigned long tid = -1;
diff --git a/compat/delay.c b/compat/delay.c
index 95bde3e..78ca00c 100644
--- a/compat/delay.c
+++ b/compat/delay.c
@@ -140,14 +140,7 @@ int clock_usleep (struct timeval *request) {
#else
struct timeval now;
struct timeval next = *request;
-#ifdef HAVE_CLOCK_GETTIME
- struct timespec t1;
- clock_gettime(CLOCK_REALTIME, &t1);
- now.tv_sec = t1.tv_sec;
- now.tv_usec = t1.tv_nsec / 1000;
-#else
- gettimeofday(&now, NULL);
-#endif
+ TimeGetNow(now);
double delta_usecs;
if ((delta_usecs = TimeDifference(next, now)) > 0.0) {
delay_loop(delta_usecs);
diff --git a/compat/error.c b/compat/error.c
index 53d1727..da6ff4d 100644
--- a/compat/error.c
+++ b/compat/error.c
@@ -53,6 +53,147 @@
#include "headers.h"
#include "util.h"
+/*---------------------------------------------------------------
+ * Linux errors per [root@fedora iperf-2.1.9-rc2]# uname -r
+ * 5.11.12-300.fc34.x86_64
+ *
+ * [root@fedora iperf-2.1.9-rc2]# errno -l
+ * EPERM 1 Operation not permitted
+ * ENOENT 2 No such file or directory
+ * ESRCH 3 No such process
+ * EINTR 4 Interrupted system call
+ * EIO 5 Input/output error
+ * ENXIO 6 No such device or address
+ * E2BIG 7 Argument list too long
+ * ENOEXEC 8 Exec format error
+ * EBADF 9 Bad file descriptor
+ * ECHILD 10 No child processes
+ * EAGAIN 11 Resource temporarily unavailable
+ * ENOMEM 12 Cannot allocate memory
+ * EACCES 13 Permission denied
+ * EFAULT 14 Bad address
+ * ENOTBLK 15 Block device required
+ * EBUSY 16 Device or resource busy
+ * EEXIST 17 File exists
+ * EXDEV 18 Invalid cross-device link
+ * ENODEV 19 No such device
+ * ENOTDIR 20 Not a directory
+ * EISDIR 21 Is a directory
+ * EINVAL 22 Invalid argument
+ * ENFILE 23 Too many open files in system
+ * EMFILE 24 Too many open files
+ * ENOTTY 25 Inappropriate ioctl for device
+ * ETXTBSY 26 Text file busy
+ * EFBIG 27 File too large
+ * ENOSPC 28 No space left on device
+ * ESPIPE 29 Illegal seek
+ * EROFS 30 Read-only file system
+ * EMLINK 31 Too many links
+ * EPIPE 32 Broken pipe
+ * EDOM 33 Numerical argument out of domain
+ * ERANGE 34 Numerical result out of range
+ * EDEADLK 35 Resource deadlock avoided
+ * ENAMETOOLONG 36 File name too long
+ * ENOLCK 37 No locks available
+ * ENOSYS 38 Function not implemented
+ * ENOTEMPTY 39 Directory not empty
+ * ELOOP 40 Too many levels of symbolic links
+ * EWOULDBLOCK 11 Resource temporarily unavailable
+ * ENOMSG 42 No message of desired type
+ * EIDRM 43 Identifier removed
+ * ECHRNG 44 Channel number out of range
+ * EL2NSYNC 45 Level 2 not synchronized
+ * EL3HLT 46 Level 3 halted
+ * EL3RST 47 Level 3 reset
+ * ELNRNG 48 Link number out of range
+ * EUNATCH 49 Protocol driver not attached
+ * ENOCSI 50 No CSI structure available
+ * EL2HLT 51 Level 2 halted
+ * EBADE 52 Invalid exchange
+ * EBADR 53 Invalid request descriptor
+ * EXFULL 54 Exchange full
+ * ENOANO 55 No anode
+ * EBADRQC 56 Invalid request code
+ * EBADSLT 57 Invalid slot
+ * EDEADLOCK 35 Resource deadlock avoided
+ * EBFONT 59 Bad font file format
+ * ENOSTR 60 Device not a stream
+ * ENODATA 61 No data available
+ * ETIME 62 Timer expired
+ * ENOSR 63 Out of streams resources
+ * ENONET 64 Machine is not on the network
+ * ENOPKG 65 Package not installed
+ * EREMOTE 66 Object is remote
+ * ENOLINK 67 Link has been severed
+ * EADV 68 Advertise error
+ * ESRMNT 69 Srmount error
+ * ECOMM 70 Communication error on send
+ * EPROTO 71 Protocol error
+ * EMULTIHOP 72 Multihop attempted
+ * EDOTDOT 73 RFS specific error
+ * EBADMSG 74 Bad message
+ * EOVERFLOW 75 Value too large for defined data type
+ * ENOTUNIQ 76 Name not unique on network
+ * EBADFD 77 File descriptor in bad state
+ * EREMCHG 78 Remote address changed
+ * ELIBACC 79 Can not access a needed shared library
+ * ELIBBAD 80 Accessing a corrupted shared library
+ * ELIBSCN 81 .lib section in a.out corrupted
+ * ELIBMAX 82 Attempting to link in too many shared libraries
+ * ELIBEXEC 83 Cannot exec a shared library directly
+ * EILSEQ 84 Invalid or incomplete multibyte or wide character
+ * ERESTART 85 Interrupted system call should be restarted
+ * ESTRPIPE 86 Streams pipe error
+ * EUSERS 87 Too many users
+ * ENOTSOCK 88 Socket operation on non-socket
+ * EDESTADDRREQ 89 Destination address required
+ * EMSGSIZE 90 Message too long
+ * EPROTOTYPE 91 Protocol wrong type for socket
+ * ENOPROTOOPT 92 Protocol not available
+ * EPROTONOSUPPORT 93 Protocol not supported
+ * ESOCKTNOSUPPORT 94 Socket type not supported
+ * EOPNOTSUPP 95 Operation not supported
+ * EPFNOSUPPORT 96 Protocol family not supported
+ * EAFNOSUPPORT 97 Address family not supported by protocol
+ * EADDRINUSE 98 Address already in use
+ * EADDRNOTAVAIL 99 Cannot assign requested address
+ * ENETDOWN 100 Network is down
+ * ENETUNREACH 101 Network is unreachable
+ * ENETRESET 102 Network dropped connection on reset
+ * ECONNABORTED 103 Software caused connection abort
+ * ECONNRESET 104 Connection reset by peer
+ * ENOBUFS 105 No buffer space available
+ * EISCONN 106 Transport endpoint is already connected
+ * ENOTCONN 107 Transport endpoint is not connected
+ * ESHUTDOWN 108 Cannot send after transport endpoint shutdown
+ * ETOOMANYREFS 109 Too many references: cannot splice
+ * ETIMEDOUT 110 Connection timed out
+ * ECONNREFUSED 111 Connection refused
+ * EHOSTDOWN 112 Host is down
+ * EHOSTUNREACH 113 No route to host
+ * EALREADY 114 Operation already in progress
+ * EINPROGRESS 115 Operation now in progress
+ * ESTALE 116 Stale file handle
+ * EUCLEAN 117 Structure needs cleaning
+ * ENOTNAM 118 Not a XENIX named type file
+ * ENAVAIL 119 No XENIX semaphores available
+ * EISNAM 120 Is a named type file
+ * EREMOTEIO 121 Remote I/O error
+ * EDQUOT 122 Disk quota exceeded
+ * ENOMEDIUM 123 No medium found
+ * EMEDIUMTYPE 124 Wrong medium type
+ * ECANCELED 125 Operation canceled
+ * ENOKEY 126 Required key not available
+ * EKEYEXPIRED 127 Key has expired
+ * EKEYREVOKED 128 Key has been revoked
+ * EKEYREJECTED 129 Key was rejected by service
+ * EOWNERDEAD 130 Owner died
+ * ENOTRECOVERABLE 131 State not recoverable
+ * ERFKILL 132 Operation not possible due to RF-kill
+ * EHWPOISON 133 Memory page has hardware error
+ * ENOTSUP 95 Operation not supported
+ * ------------------------------------------------------------------- */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -205,6 +346,21 @@ void warn_errno( const char *inMessage, const char *inFile, int inLine ) {
#endif
} /* end warn_errno */
+int errno_decode (char *text, size_t len) {
+ int my_err;
+ const char* my_str;
+ /* get platform's errno and error message */
+#ifdef WIN32
+ my_err = WSAGetLastError();
+ my_str = winsock_strerror( my_err );
+#else
+ my_err = errno;
+ my_str = strerror( my_err );
+#endif
+ strncpy(text, my_str, len);
+ return my_err;
+}
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
diff --git a/compat/gettcpinfo.c b/compat/gettcpinfo.c
index 11f92fe..f7067e9 100644
--- a/compat/gettcpinfo.c
+++ b/compat/gettcpinfo.c
@@ -42,6 +42,16 @@
* gettcpinfo.c
* Suppport for tcp info in a portable way
*
+ * Hi Bob,
+ *
+ * I would suggest that the most interesting metrics from tcp_info would be:
+ *
+ * double ecn_mark_rate = (double)tcpi_delivered_ce / (double)tcpi_delivered
+ * double retransmit_rate = (double)(tcpi_total_retrans - tcpi_dsack_dups) / (double)tcpi_data_segs_out
+ * double smoothed_rtt = tcpi_rtt
+ *
+ * neal
+ *
* by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
* -------------------------------------------------------------------
*/
@@ -59,11 +69,29 @@ inline void gettcpinfo (int sock, struct iperf_tcpstats *stats) {
struct tcp_info tcp_info_buf;
socklen_t tcp_info_length = sizeof(struct tcp_info);
if ((sock > 0) && !(getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tcp_info_buf, &tcp_info_length) < 0)) {
+#if HAVE_STRUCT_TCP_INFO_TCPI_SND_CWND
+ stats->cwnd_packets = tcp_info_buf.tcpi_snd_cwnd;
+#else
+ stats->cwnd_packets = -1;
+#endif
+#if HAVE_STRUCT_TCP_INFO_TCPI_SND_CWND && HAVE_STRUCT_TCP_INFO_TCPI_SND_MSS
stats->cwnd = tcp_info_buf.tcpi_snd_cwnd * tcp_info_buf.tcpi_snd_mss / 1024;
+#else
+ stats->cwnd = -1;
+#endif
stats->rtt = tcp_info_buf.tcpi_rtt;
stats->rttvar = tcp_info_buf.tcpi_rttvar;
stats->retry_tot = tcp_info_buf.tcpi_total_retrans;
+#if HAVE_STRUCT_TCP_INFO_TCPI_SND_MSS
stats->mss_negotiated = tcp_info_buf.tcpi_snd_mss;
+#else
+ stats->mss_negotiated = -1;
+#endif
+#if HAVE_TCP_INFLIGHT
+ stats->packets_in_flight = (tcp_info_buf.tcpi_unacked - tcp_info_buf.tcpi_sacked - \
+ tcp_info_buf.tcpi_lost + tcp_info_buf.tcpi_retrans);
+ stats->bytes_in_flight = stats->packets_in_flight * tcp_info_buf.tcpi_snd_mss / 1024;
+#endif
stats->isValid = true;
#elif HAVE_DECL_TCP_CONNECTION_INFO
struct tcp_connection_info tcp_info_buf;
@@ -71,8 +99,10 @@ inline void gettcpinfo (int sock, struct iperf_tcpstats *stats) {
if ((sock > 0) && !(getsockopt(sock, IPPROTO_TCP, TCP_CONNECTION_INFO, &tcp_info_buf, &tcp_info_length) < 0)) {
#ifdef __APPLE__
stats->cwnd = tcp_info_buf.tcpi_snd_cwnd / 1024;
+ stats->cwnd_packets = -1;
#else
stats->cwnd = tcp_info_buf.tcpi_snd_cwnd * tcp_info_buf.tcpi_maxseg / 1024;
+ stats->cwnd_packets = tcp_info_buf.tcpi_snd_cwnd;
#endif
stats->rtt = tcp_info_buf.tcpi_rttcur * 1000; // OS X units is ms
stats->rttvar = tcp_info_buf.tcpi_rttvar;
@@ -87,12 +117,18 @@ inline void gettcpinfo (int sock, struct iperf_tcpstats *stats) {
}
inline void tcpstats_copy (struct iperf_tcpstats *stats_dst, struct iperf_tcpstats *stats_src) {
stats_dst->cwnd = stats_src->cwnd;
+ stats_dst->cwnd_packets = stats_src->cwnd_packets;
stats_dst->rtt = stats_src->rtt;
stats_dst->rttvar = stats_src->rttvar;
stats_dst->mss_negotiated = stats_src->mss_negotiated;
stats_dst->retry_tot = stats_src->retry_tot;
stats_dst->connecttime = stats_src->connecttime;
stats_dst->isValid = stats_src->isValid;
+#if HAVE_TCP_INFLIGHT
+ stats_dst->packets_in_flight = stats_src->packets_in_flight;
+ stats_dst->bytes_in_flight = stats_src->bytes_in_flight;
+#endif
+
}
#else
#if WIN32