summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Client.hpp147
-rw-r--r--include/Condition.h209
-rw-r--r--include/Extractor.h123
-rw-r--r--include/Listener.hpp101
-rw-r--r--include/Locale.h437
-rw-r--r--include/Makefile.am2
-rw-r--r--include/Makefile.in430
-rw-r--r--include/Mutex.h112
-rw-r--r--include/PerfSocket.hpp80
-rw-r--r--include/Reporter.h584
-rw-r--r--include/Server.hpp127
-rw-r--r--include/Settings.hpp665
-rw-r--r--include/SocketAddr.h119
-rw-r--r--include/Thread.h176
-rw-r--r--include/Timestamp.hpp308
-rw-r--r--include/active_hosts.h95
-rw-r--r--include/checksums.h62
-rw-r--r--include/config.win32.h82
-rw-r--r--include/delay.h78
-rw-r--r--include/dscp.h58
-rw-r--r--include/gettcpinfo.h82
-rw-r--r--include/gettimeofday.h83
-rw-r--r--include/gnu_getopt.h136
-rw-r--r--include/headers.h302
-rw-r--r--include/histogram.h82
-rw-r--r--include/inet_aton.h108
-rw-r--r--include/iperf_formattime.h69
-rw-r--r--include/isochronous.hpp88
-rw-r--r--include/packet_ring.h127
-rw-r--r--include/payloads.h622
-rw-r--r--include/pdfs.h60
-rw-r--r--include/snprintf.h40
-rw-r--r--include/util.h281
-rw-r--r--include/version.h27
34 files changed, 6102 insertions, 0 deletions
diff --git a/include/Client.hpp b/include/Client.hpp
new file mode 100644
index 0000000..3848e92
--- /dev/null
+++ b/include/Client.hpp
@@ -0,0 +1,147 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ * Client.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * A client thread initiates a connect to the server and handles
+ * sending and receiving data, then closes the socket.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef CLIENT_H
+#define CLIENT_H
+
+#include "Settings.hpp"
+#include "Timestamp.hpp"
+#include "isochronous.hpp"
+#include "Mutex.h"
+
+/* ------------------------------------------------------------------- */
+class Client {
+public:
+ // stores server hostname, port, UDP/TCP mode, and UDP rate
+ Client( thread_Settings *inSettings );
+
+ // destroy the client object
+ ~Client();
+
+ // Set up the traffic thread and invokes
+ // appropriate traffic loop per the protocol
+ // and type of traffic
+ void Run( void );
+
+ // For things like dual tests a server needs to be started by the client,
+ // The code in src/launch.cpp will invoke this
+ int StartSynch(void);
+ void TxDelay(void);
+ void ConnectPeriodic(void);
+ bool my_connect(bool close_on_fail);
+ void mySockInit(void);
+ bool isConnected(void) const;
+ int SendFirstPayload(void);
+ int BarrierClient(struct BarrierMutex *);
+ void RunBounceBackTCP(void);
+ struct ReportHeader *myJob;
+
+private:
+ inline void WritePacketID(intmax_t);
+ inline void WriteTcpTxHdr(struct ReportStruct *, int, int);
+ inline void WriteTcpTxBBHdr(struct ReportStruct *, uint32_t, int);
+ inline double get_delay_target(void);
+ void InitTrafficLoop(void);
+ void SetReportStartTime(void);
+ inline void SetFullDuplexReportStartTime(void);
+ void FinishTrafficActions(void);
+ void AwaitServerFinPacket(void);
+ bool InProgress(void);
+ void PostNullEvent(void);
+ void PostNullEvent(bool isFirst);
+ void AwaitServerCloseEvent(void);
+ inline void tcp_shutdown(void);
+ bool connected;
+ ReportStruct scratchpad;
+ ReportStruct *reportstruct;
+ double delay_lower_bounds;
+ intmax_t totLen;
+ bool one_report;
+ bool apply_first_udppkt_delay;
+ int udp_payload_minimum;
+ void myReportPacket(void);
+ // TCP plain
+ void RunTCP(void);
+ // TCP version which supports rate limiting per -b
+ void RunRateLimitedTCP(void);
+ void RunNearCongestionTCP(void);
+#if HAVE_DECL_TCP_NOTSENT_LOWAT
+ bool AwaitWriteSelectEventTCP(void);
+ void RunWriteEventsTCP(void);
+#endif
+ // UDP traffic with isochronous and vbr support
+ void RunUDPIsochronous(void);
+ // UDP plain
+ void RunUDP(void);
+ // client connect
+ void PeerXchange(void);
+ thread_Settings *mSettings;
+#if WIN32
+ SOCKET mySocket;
+#else
+ int mySocket;
+#endif
+ struct ReporterData *myReport;
+ Timestamp mEndTime;
+ Timestamp lastPacketTime;
+ Timestamp now;
+ char* readAt;
+ Timestamp connect_done, connect_start;
+ Isochronous::FrameCounter *framecounter;
+ bool isburst;
+ bool mysock_init_done;
+ bool peerclose;
+ Timestamp write_start;
+}; // end class Client
+
+#endif // CLIENT_H
diff --git a/include/Condition.h b/include/Condition.h
new file mode 100644
index 0000000..6968b29
--- /dev/null
+++ b/include/Condition.h
@@ -0,0 +1,209 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Condition.h
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * An abstract class for waiting on a condition variable. If
+ * threads are not available, this does nothing.
+ * ------------------------------------------------------------------- */
+
+#ifndef CONDITION_H
+#define CONDITION_H
+
+#include "headers.h"
+#include "Mutex.h"
+#include "util.h"
+
+#if defined( HAVE_POSIX_THREAD )
+struct Condition {
+ pthread_cond_t mCondition;
+ pthread_mutex_t mMutex;
+};
+#elif defined( HAVE_WIN32_THREAD )
+struct Condition {
+ HANDLE mCondition;
+ HANDLE mMutex;
+};
+#else
+struct Condition {
+ int mCondition;
+ int mMutex;
+};
+#endif
+
+struct AwaitMutex {
+ struct Condition await;
+ int ready;
+};
+
+struct BarrierMutex {
+ struct Condition await;
+ struct timeval release_time;
+ int count;
+ int timeout;
+};
+
+struct ReferenceMutex {
+ Mutex lock;
+ int count;
+ int maxcount;
+};
+
+#define Condition_Lock( Cond ) Mutex_Lock( &Cond.mMutex )
+
+#define Condition_Unlock( Cond ) Mutex_Unlock( &Cond.mMutex )
+
+ // initialize condition
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_Initialize( Cond ) do { \
+ Mutex_Initialize( &(Cond)->mMutex ); \
+ pthread_cond_init( &(Cond)->mCondition, NULL ); \
+ } while ( 0 )
+#elif defined( HAVE_WIN32_THREAD )
+ // set all conditions to be broadcast
+ // unfortunately in Win32 you have to know at creation
+ // whether the signal is broadcast or not.
+ #define Condition_Initialize( Cond ) do { \
+ Mutex_Initialize( &(Cond)->mMutex ); \
+ (Cond)->mCondition = CreateEvent( NULL, 1, 0, NULL ); \
+ } while ( 0 )
+#else
+ #define Condition_Initialize( Cond )
+#endif
+
+ // destroy condition
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_Destroy( Cond ) do { \
+ pthread_cond_destroy( &(Cond)->mCondition ); \
+ Mutex_Destroy( &(Cond)->mMutex ); \
+ } while ( 0 )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Condition_Destroy( Cond ) do { \
+ CloseHandle( (Cond)->mCondition ); \
+ Mutex_Destroy( &(Cond)->mMutex ); \
+ } while ( 0 )
+#else
+ #define Condition_Destroy( Cond )
+#endif
+
+#define Condition_Destroy_Reference(Ref) do { \
+ Mutex_Destroy(&(Ref)->lock); \
+ } while ( 0 )
+
+#if defined (HAVE_CLOCK_GETTIME)
+ #define SETABSTIME(ts, seconds) do { \
+ clock_gettime(CLOCK_REALTIME, &ts); \
+ ts.tv_sec += seconds; \
+} while (0)
+#else
+ #define SETABSTIME(ts, seconds) do { \
+ struct timeval t1; \
+ gettimeofday(&t1, NULL);
+ ts.tv_sec = t1.tv_sec + inSeconds; \
+ ts.tv_nsec = t1.tv_sec * 1000; \
+} while (0)
+#endif
+
+ // sleep this thread, waiting for condition signal
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_Wait( Cond ) pthread_cond_wait( &(Cond)->mCondition, &(Cond)->mMutex )
+#elif defined( HAVE_WIN32_THREAD )
+ // atomically release mutex and wait on condition,
+ // then re-acquire the mutex
+ #define Condition_Wait( Cond ) do { \
+ SignalObjectAndWait( (Cond)->mMutex, (Cond)->mCondition, INFINITE, 0 ); \
+ Mutex_Lock( &(Cond)->mMutex ); \
+ } while ( 0 )
+#else
+ #define Condition_Wait( Cond )
+#endif
+
+ // sleep this thread, waiting for condition signal,
+ // but bound sleep time by the relative time inSeconds.
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_TimedWait( Cond, inSeconds ) do { \
+ struct timespec absTimeout; \
+ SETABSTIME(absTimeout, inSeconds); \
+ pthread_cond_timedwait( &(Cond)->mCondition, &(Cond)->mMutex, &absTimeout ); \
+ } while ( 0 )
+ #define Condition_TimedLock( Cond, inSeconds ) do { \
+ struct timespec absTimeout; \
+ SETABSTIME(absTimeout, inSeconds); \
+ pthread_mutex_timedlock(&Cond.mMutex, &absTimeout); \
+ } while ( 0 )
+#elif defined( HAVE_WIN32_THREAD )
+ // atomically release mutex and wait on condition,
+ // then re-acquire the mutex
+#define Condition_TimedWait( Cond, inSeconds ) do { \
+ SignalObjectAndWait( (Cond)->mMutex, (Cond)->mCondition, inSeconds*1000, false ); \
+ Mutex_Lock( &(Cond)->mMutex ); \
+ } while ( 0 )
+#else
+ #define Condition_TimedWait( Cond, inSeconds )
+#endif
+
+ // send a condition signal to wake one thread waiting on condition
+ // in Win32, this actually wakes up all threads, same as Broadcast
+ // use PulseEvent to auto-reset the signal after waking all threads
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_Signal( Cond ) pthread_cond_signal( &(Cond)->mCondition )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Condition_Signal( Cond ) PulseEvent( (Cond)->mCondition )
+#else
+ #define Condition_Signal( Cond )
+#endif
+
+ // send a condition signal to wake all threads waiting on condition
+#if defined( HAVE_POSIX_THREAD )
+ #define Condition_Broadcast( Cond ) pthread_cond_broadcast( &(Cond)->mCondition )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Condition_Broadcast( Cond ) PulseEvent( (Cond)->mCondition )
+#else
+ #define Condition_Broadcast( Cond )
+#endif
+
+#endif // CONDITION_H
diff --git a/include/Extractor.h b/include/Extractor.h
new file mode 100644
index 0000000..e017532
--- /dev/null
+++ b/include/Extractor.h
@@ -0,0 +1,123 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Extractor.h
+ * by Ajay Tirumala (tirumala@ncsa.uiuc.edu)
+ * -------------------------------------------------------------------
+ * Extract data from a file, used to measure the transfer rates
+ * for various stream formats.
+ *
+ * E.g. Use a gzipped file to measure the transfer rates for
+ * compressed data
+ * Use an MPEG file to measure the transfer rates of
+ * Multimedia data formats
+ * Use a plain BMP file to measure the transfer rates of
+ * Uncompressed data
+ *
+ * This is beneficial especially in measuring bandwidth across WAN
+ * links where data compression takes place before data transmission
+ * ------------------------------------------------------------------- */
+
+#ifndef _EXTRACTOR_H
+#define _EXTRACTOR_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "Settings.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * Constructor
+ * @arg fileName Name of the file
+ * @arg size Block size for reading
+ */
+ void Extractor_Initialize( char *fileName, int size, struct thread_Settings *mSettings );
+
+ /**
+ * Constructor
+ * @arg fp File Pointer
+ * @arg size Block size for reading
+ */
+ void Extractor_InitializeFile( FILE *fp, int size, struct thread_Settings *mSettings );
+
+
+ /*
+ * Fetches the next data block from
+ * the file
+ * @arg block Pointer to the data read
+ * @return Number of bytes read
+ */
+ int Extractor_getNextDataBlock( char *data, struct thread_Settings *mSettings );
+
+
+ /**
+ * Function which determines whether
+ * the file stream is still readable
+ * @return true, if readable; false, if not
+ */
+ int Extractor_canRead( struct thread_Settings *mSettings );
+
+ /**
+ * This is used to reduce the read size
+ * Used in UDP transfer to accomodate the
+ * the header (timestamp)
+ * @arg delta Size to reduce
+ */
+ void Extractor_reduceReadSize( int delta, struct thread_Settings *mSettings );
+
+ /**
+ * Destructor
+ */
+ void Extractor_Destroy( struct thread_Settings *mSettings );
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif
+
diff --git a/include/Listener.hpp b/include/Listener.hpp
new file mode 100644
index 0000000..92baad7
--- /dev/null
+++ b/include/Listener.hpp
@@ -0,0 +1,101 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Listener.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * Listener sets up a socket listening on the server host. For each
+ * connected socket that accept() returns, this creates a Server
+ * socket and spawns a thread for it.
+ * ------------------------------------------------------------------- */
+
+#ifndef LISTENER_H
+#define LISTENER_H
+
+#include "Thread.h"
+#include "Settings.hpp"
+#include "Timestamp.hpp"
+
+class Listener;
+
+class Listener {
+public:
+ // stores server port and TCP/UDP mode
+ Listener(thread_Settings *inSettings);
+ // destroy the server object
+ ~Listener();
+ // accepts connections and starts Servers
+ void Run(void);
+
+private:
+ int mClients;
+ struct ether_header *eth_hdr;
+ struct iphdr *ip_hdr;
+ struct udphdr *udp_hdr;
+ thread_Settings *mSettings;
+ thread_Settings *server;
+ Timestamp mEndTime;
+ bool apply_client_settings_udp(thread_Settings *server);
+ bool apply_client_settings_tcp(thread_Settings *server);
+ bool apply_client_settings(thread_Settings *server);
+ int client_test_ack(thread_Settings *server);
+ void my_multicast_join(void);
+ void my_listen(void);
+ int my_accept(thread_Settings *server);
+ int udp_accept(thread_Settings *server);
+ int tuntap_accept(thread_Settings *server);
+ bool L2_setup(thread_Settings *server, int sockfd);
+ bool tap_setup(thread_Settings *server, int sockfd);
+ void UDPSingleServer(thread_Settings *server);
+ bool test_permit_key(uint32_t flags, thread_Settings *server, int keyoffset);
+#if WIN32
+ SOCKET ListenSocket;
+#else
+ int ListenSocket;
+#endif
+}; // end class Listener
+
+#endif // LISTENER_H
diff --git a/include/Locale.h b/include/Locale.h
new file mode 100644
index 0000000..65e547e
--- /dev/null
+++ b/include/Locale.h
@@ -0,0 +1,437 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Locale.h
+ * by Ajay Tirumala <tirumala@ncsa.uiuc.edu>
+ * & Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * Strings and other stuff that is locale specific.
+ * ------------------------------------------------------------------- */
+
+#ifndef LOCALE_H
+#define LOCALE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define HEADING_FLAG(HEADING) __ ## HEADING ## _print_done
+#define HEADING_HDR(HEADING) HEADING ## _header
+#define HEADING_PRINT_COND(HEADING) \
+ do { \
+ if (!HEADING_FLAG(HEADING)) { \
+ printf("%s", HEADING_HDR(HEADING)); \
+ HEADING_FLAG(HEADING) = 1; \
+ } \
+ } while(0)
+
+/* -------------------------------------------------------------------
+ * usage
+ * ------------------------------------------------------------------- */
+
+extern const char usage_short[];
+
+extern const char usage_long1[];
+extern const char usage_long2[];
+
+extern const char version[];
+
+/* -------------------------------------------------------------------
+ * settings
+ * ------------------------------------------------------------------- */
+
+extern const char separator_line[];
+
+extern const char server_port[];
+
+extern const char client_port[];
+
+extern const char client_report_epoch_start[];
+
+extern const char client_report_epoch_start_current[];
+
+extern const char server_pid_port[];
+
+extern const char server_pid_portrange[];
+
+extern const char client_pid_port[];
+
+extern const char client_pid_port_dev[];
+
+extern const char bind_address[];
+
+extern const char bind_address_iface[];
+
+extern const char bind_address_iface_taptun[];
+
+extern const char multicast_ttl[];
+
+extern const char join_multicast[];
+
+extern const char join_multicast_sg[];
+
+extern const char join_multicast_sg_dev[];
+
+extern const char join_multicast_starg_dev[];
+
+extern const char client_datagram_size[];
+
+extern const char client_datagram_size_tx_sync[];
+
+extern const char client_datagram_size_kalman[];
+
+extern const char server_datagram_size[];
+
+extern const char tcp_window_size[];
+
+extern const char udp_buffer_size[];
+
+extern const char window_default[];
+
+extern const char wait_server_threads[];
+
+extern const char client_isochronous[];
+
+extern const char client_burstperiod[];
+
+extern const char client_burstperiodcount[];
+
+extern const char client_bounceback[];
+
+extern const char client_bounceback_noqack[];
+
+extern const char server_burstperiod[];
+
+extern const char client_fq_pacing[];
+/* -------------------------------------------------------------------
+ * Legacy reports
+ * ------------------------------------------------------------------- */
+
+extern const char report_bw_header[];
+
+extern const char report_sumcnt_bw_header[];
+
+extern const char report_bw_format[];
+
+extern const char report_sum_bw_format[];
+
+extern const char report_sumcnt_bw_format[];
+
+extern const char report_bw_read_format[];
+
+extern const char report_bw_jitter_loss_header[];
+
+extern const char report_bw_jitter_loss_format[];
+
+extern const char report_sum_bw_jitter_loss_format[];
+
+extern const char report_sumcnt_bw_jitter_loss_header[];
+
+extern const char report_sumcnt_bw_jitter_loss_format[];
+
+/* -------------------------------------------------------------------
+ * Enhanced reports (per -e)
+ * ------------------------------------------------------------------- */
+
+extern const char client_write_size[];
+
+extern const char server_read_size[];
+
+extern const char report_bw_enhanced_format[];
+
+extern const char report_write_enhanced_isoch_format[];
+
+extern const char report_write_enhanced_isoch_header[];
+
+extern const char report_write_enhanced_isoch_nocwnd_format[];
+
+extern const char report_sum_bw_enhanced_format[];
+
+extern const char report_bw_read_enhanced_header[];
+
+extern const char report_bw_read_enhanced_netpwr_header[];
+
+extern const char report_bw_read_enhanced_netpwr_format[];
+
+extern const char report_bw_read_enhanced_format[];
+
+extern const char report_sum_bw_read_enhanced_format[];
+
+extern const char report_sumcnt_bw_read_enhanced_header[];
+
+extern const char report_sumcnt_bw_read_enhanced_format[];
+
+extern const char report_sumcnt_bw_read_triptime_header[];
+
+extern const char report_sumcnt_bw_read_triptime_format[];
+
+extern const char report_sumcnt_bw_pps_enhanced_header[];
+
+extern const char report_sumcnt_bw_pps_enhanced_format[];
+
+extern const char report_triptime_enhanced_format[];
+
+extern const char report_bw_write_enhanced_header[];
+
+extern const char report_bw_write_enhanced_header[];
+
+extern const char report_sumcnt_write_enhanced_write_header[];
+
+extern const char report_bw_write_enhanced_format[];
+
+extern const char report_write_enhanced_write_header[];
+
+extern const char report_write_enhanced_write_format[];
+
+extern const char report_write_enhanced_nocwnd_write_format[];
+
+extern const char report_bw_write_enhanced_nocwnd_format[];
+
+extern const char report_sum_bw_write_enhanced_format[];
+
+extern const char report_sumcnt_bw_write_enhanced_header[];
+
+extern const char report_sumcnt_bw_write_enhanced_format[];
+
+extern const char report_bw_pps_enhanced_header[];
+
+extern const char report_bw_pps_enhanced_format[];
+
+extern const char report_bw_pps_enhanced_isoch_header[];
+
+extern const char report_bw_pps_enhanced_isoch_format[];
+
+extern const char report_sum_bw_pps_enhanced_format[];
+
+extern const char report_bw_jitter_loss_pps_header[];
+
+extern const char report_bw_jitter_loss_pps_format[];
+
+extern const char report_bw_jitter_loss_enhanced_header[];
+
+extern const char report_bw_jitter_loss_enhanced_format[];
+
+extern const char report_bw_jitter_loss_enhanced_isoch_header[];
+
+extern const char report_bw_jitter_loss_enhanced_isoch_format[];
+
+extern const char report_bw_jitter_loss_enhanced_triptime_header[];
+
+extern const char report_bw_jitter_loss_enhanced_triptime_format[];
+
+extern const char report_bw_jitter_loss_enhanced_isoch_triptime_header[];
+
+extern const char report_bw_jitter_loss_enhanced_isoch_triptime_format[];
+
+extern const char report_bw_jitter_loss_suppress_enhanced_format[];
+
+extern const char report_sum_bw_jitter_loss_enhanced_format[];
+
+extern const char report_sumcnt_bw_jitter_loss_enhanced_format[];
+
+extern const char report_bw_sum_fullduplex_format[];
+
+extern const char report_bw_sum_fullduplex_enhanced_format[];
+
+extern const char report_frame_jitter_loss_enhanced_header[];
+
+extern const char report_frame_jitter_loss_enhanced_format[];
+
+extern const char report_frame_jitter_loss_suppress_enhanced_format[];
+
+extern const char report_frame_tcp_enhanced_header[];
+
+extern const char report_burst_read_tcp_header[];
+
+extern const char report_burst_read_tcp_format[];
+
+extern const char report_burst_read_tcp_final_format[];
+
+extern const char report_burst_write_tcp_header[];
+
+extern const char report_burst_write_tcp_format[];
+
+extern const char report_burst_write_tcp_nocwnd_format[];
+
+extern const char report_burst_write_tcp_final_format[];
+
+extern const char report_udp_fullduplex_header[];
+
+extern const char report_udp_fullduplex_format[];
+
+extern const char report_udp_fullduplex_sum_format[];
+
+extern const char report_udp_fullduplex_enhanced_format[];
+
+extern const char report_sumcnt_udp_fullduplex_header[];
+
+extern const char report_sumcnt_udp_fullduplex_format[];
+
+extern const char report_client_bb_bw_header[];
+
+extern const char report_client_bb_bw_format[];
+
+extern const char report_client_bb_bw_triptime_format[];
+
+extern const char report_bw_isoch_enhanced_netpwr_header[];
+
+extern const char report_bw_isoch_enhanced_netpwr_format[];
+
+extern const char report_sumcnt_udp_enhanced_header[];
+
+extern const char report_sumcnt_udp_enhanced_format[];
+
+extern const char report_sumcnt_udp_triptime_header[];
+
+extern const char report_sumcnt_udp_triptime_format[];
+
+/* -------------------------------------------------------------------
+ * Misc reports
+ * ------------------------------------------------------------------- */
+
+extern const char report_outoforder[];
+
+extern const char report_sumcnt_outoforder[];
+
+extern const char report_l2statistics[];
+
+extern const char report_sum_outoforder[];
+
+extern const char report_peer[];
+
+extern const char report_peer_dev[];
+
+extern const char report_peer_fail[];
+
+extern const char report_mss_unsupported[];
+
+extern const char report_mss[];
+
+extern const char report_default_mss[];
+
+extern const char report_datagrams[];
+
+extern const char report_sumcnt_datagrams[];
+
+extern const char report_sum_datagrams[];
+
+extern const char server_reporting[];
+
+extern const char reportCSV_peer[];
+
+extern const char reportCSV_bw_format[];
+
+extern const char reportCSV_bw_read_enhanced_format[];
+
+extern const char reportCSV_bw_write_enhanced_format[];
+
+extern const char reportCSV_bw_jitter_loss_format[];
+
+extern const char reportCSV_bw_jitter_loss_pps_format[];
+
+/* -------------------------------------------------------------------
+ * warnings
+ * ------------------------------------------------------------------- */
+
+extern const char warn_window_requested[];
+
+extern const char warn_window_small[];
+
+extern const char warn_delay_large[];
+
+extern const char warn_no_pathmtu[];
+
+extern const char warn_no_ack[];
+
+extern const char warn_ack_failed[];
+
+extern const char warn_fileopen_failed[];
+
+extern const char unable_to_change_win[];
+
+extern const char opt_estimate[];
+
+extern const char report_interval_small[];
+
+extern const char warn_invalid_server_option[];
+
+extern const char warn_invalid_client_option[];
+
+extern const char warn_invalid_compatibility_option[];
+
+extern const char warn_implied_udp[];
+
+extern const char warn_implied_compatibility[];
+
+extern const char warn_buffer_too_small[];
+
+extern const char warn_invalid_single_threaded[];
+
+extern const char warn_invalid_report_style[];
+
+extern const char warn_invalid_report[];
+
+extern const char warn_server_old[];
+
+extern const char warn_test_exchange_failed[];
+
+extern const char warn_len_too_small_peer_exchange[];
+
+extern const char warn_compat_and_peer_exchange[];
+
+extern const char warn_seqno_wrap[];
+
+extern const char warn_start_before_now[];
+
+extern const char error_starttime_exceeds[];
+
+extern const char error_delaytime_exceeds[];
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+#endif // LOCALE_H
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..033fbd3
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = Client.hpp Condition.h Extractor.h active_hosts.h packet_ring.h Listener.hpp Locale.h Makefile.am Mutex.h PerfSocket.hpp Reporter.h Server.hpp Settings.hpp SocketAddr.h Thread.h Timestamp.hpp config.win32.h delay.h gettimeofday.h gnu_getopt.h headers.h inet_aton.h service.h snprintf.h util.h version.h histogram.h isochronous.hpp pdfs.h checksums.h payloads.h gettcpinfo.h dscp.h iperf_formattime.h
+DISTCLEANFILES = $(top_builddir)/include/iperf-int.h
diff --git a/include/Makefile.in b/include/Makefile.in
new file mode 100644
index 0000000..ae4ef10
--- /dev/null
+++ b/include/Makefile.in
@@ -0,0 +1,430 @@
+# Makefile.in generated by automake 1.16.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = include
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/dast.m4 $(top_srcdir)/m4/ax_pthread.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+STRIP_BEGIN = @STRIP_BEGIN@
+STRIP_DUMMY = @STRIP_DUMMY@
+STRIP_END = @STRIP_END@
+VERSION = @VERSION@
+WEB100_CFLAGS = @WEB100_CFLAGS@
+WEB100_CONFIG = @WEB100_CONFIG@
+WEB100_LIBS = @WEB100_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_pthread_config = @ax_pthread_config@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = Client.hpp Condition.h Extractor.h active_hosts.h packet_ring.h Listener.hpp Locale.h Makefile.am Mutex.h PerfSocket.hpp Reporter.h Server.hpp Settings.hpp SocketAddr.h Thread.h Timestamp.hpp config.win32.h delay.h gettimeofday.h gnu_getopt.h headers.h inet_aton.h service.h snprintf.h util.h version.h histogram.h isochronous.hpp pdfs.h checksums.h payloads.h gettcpinfo.h dscp.h iperf_formattime.h
+DISTCLEANFILES = $(top_builddir)/include/iperf-int.h
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu include/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
+ ctags-am distclean distclean-generic distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+ pdf-am ps ps-am tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/include/Mutex.h b/include/Mutex.h
new file mode 100644
index 0000000..2d22dc3
--- /dev/null
+++ b/include/Mutex.h
@@ -0,0 +1,112 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Mutex.h
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * An abstract class for locking a mutex (mutual exclusion). If
+ * threads are not available, this does nothing.
+ * ------------------------------------------------------------------- */
+#ifndef MUTEX_H
+#define MUTEX_H
+
+#include "headers.h"
+
+#if defined( HAVE_POSIX_THREAD )
+ typedef pthread_mutex_t Mutex;
+#elif defined( HAVE_WIN32_THREAD )
+ typedef HANDLE Mutex;
+#else
+ typedef int Mutex;
+#endif
+
+/* ------------------------------------------------------------------- *
+class Mutex {
+public:*/
+
+ // initialize mutex
+#if defined( HAVE_POSIX_THREAD )
+ #define Mutex_Initialize( MutexPtr ) pthread_mutex_init( MutexPtr, NULL )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Mutex_Initialize( MutexPtr ) *MutexPtr = CreateMutex( NULL, 0, NULL )
+#else
+ #define Mutex_Initialize( MutexPtr )
+#endif
+
+ // lock the mutex variable
+#if defined( HAVE_POSIX_THREAD )
+ #define Mutex_Lock( MutexPtr ) pthread_mutex_lock( MutexPtr )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Mutex_Lock( MutexPtr ) WaitForSingleObject( *MutexPtr, INFINITE )
+#else
+ #define Mutex_Lock( MutexPtr )
+#endif
+
+ // unlock the mutex variable
+#if defined( HAVE_POSIX_THREAD )
+ #define Mutex_Unlock( MutexPtr ) pthread_mutex_unlock( MutexPtr )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Mutex_Unlock( MutexPtr ) ReleaseMutex( *MutexPtr )
+#else
+ #define Mutex_Unlock( MutexPtr )
+#endif
+
+ // destroy, making sure mutex is unlocked
+#if defined( HAVE_POSIX_THREAD )
+ #define Mutex_Destroy( MutexPtr ) do { \
+ int rc = pthread_mutex_destroy( MutexPtr ); \
+ if ( rc == EBUSY ) { \
+ Mutex_Unlock( MutexPtr ); \
+ pthread_mutex_destroy( MutexPtr ); \
+ } \
+ } while ( 0 )
+#elif defined( HAVE_WIN32_THREAD )
+ #define Mutex_Destroy( MutexPtr ) CloseHandle( *MutexPtr )
+#else
+ #define Mutex_Destroy( MutexPtr )
+#endif
+
+#endif // MUTEX_H
diff --git a/include/PerfSocket.hpp b/include/PerfSocket.hpp
new file mode 100644
index 0000000..0214c08
--- /dev/null
+++ b/include/PerfSocket.hpp
@@ -0,0 +1,80 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * PerfSocket.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * & Ajay Tirumala <tirumala@ncsa.uiuc.edu>
+ * -------------------------------------------------------------------
+ * Changes in version 1.6
+ * Incorporates class declarations for fetching data from files
+ * ------------------------------------------------------------------- */
+
+
+#ifndef PERFSOCKET_H
+#define PERFSOCKET_H
+
+#include "Mutex.h"
+#include "Settings.hpp"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// int timer units is micorseconds
+void SetSocketOptions(struct thread_Settings *inSettings);
+void SetSocketOptionsSendTimeout(struct thread_Settings *mSettings, int timer);
+void SetSocketOptionsReceiveTimeout(struct thread_Settings *mSettings, int timer);
+void SetSocketOptionsIPTos (struct thread_Settings *mSettings, int tos);
+void setsock_tcp_mss(int inSock, int inMSS);
+int getsock_tcp_mss(int inSock);
+#ifdef DEFAULT_PAYLOAD_LEN_PER_MTU_DISCOVERY
+void checksock_max_udp_payload (struct thread_Settings *inSettings);
+#endif
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif // PERFSOCKET_H
diff --git a/include/Reporter.h b/include/Reporter.h
new file mode 100644
index 0000000..6f97418
--- /dev/null
+++ b/include/Reporter.h
@@ -0,0 +1,584 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Reporter.h
+ * by Kevin Gibbs <kgibbs@nlanr.net>
+ *
+ * Since version 2.0 this handles all reporting.
+ * ________________________________________________________________ */
+
+#ifndef REPORTER_H
+#define REPORTER_H
+
+#include "headers.h"
+#include "Mutex.h"
+#include "histogram.h"
+#include "packet_ring.h"
+#include "gettcpinfo.h"
+
+// forward declarations found in Settings.hpp
+struct thread_Settings;
+struct server_hdr;
+
+#include "Settings.hpp"
+
+#define NUM_REPORT_STRUCTS 10000
+#define PEERVERBUFSIZE 256
+#define NETPOWERCONSTANT 1e-6
+#define REPORTTXTMAX 80
+#define MINBARRIERTIMEOUT 3
+#define PARTIALPERCENT 0.25 // used to decide if a final partial report should be displayed
+// If the minimum latency exceeds the boundaries below
+// assume the clocks are not synched and suppress the
+// latency output. Units are seconds
+#define UNREALISTIC_LATENCYMINMIN -0.01*1e6
+#define UNREALISTIC_LATENCYMINMAX 60*1e6
+#define JITTER_BINCNT 1000000 // 1 million
+#define JITTER_BINWIDTH 100 // 100 usecs
+#define JITTER_UNITS 1e6 // usecs
+#define JITTER_LCI 5 // 5%
+#define JITTER_UCI 95 // 95%
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct Condition ReportCond;
+extern struct Condition ReportsPending;
+extern Mutex transferid_mutex;
+
+/*
+ *
+ * Used for end/end latency measurements
+ *
+ */
+
+struct MeanMinMaxStats {
+ double max;
+ double min;
+ double sum;
+ double last;
+ double mean;
+ double m2;
+ double vd;
+ intmax_t cnt;
+ intmax_t err;
+};
+
+#define TCPREADBINCOUNT 8
+struct ReadStats {
+ intmax_t cntRead;
+ intmax_t totcntRead;
+ int bins[TCPREADBINCOUNT];
+ int totbins[TCPREADBINCOUNT];
+ int binsize;
+};
+
+struct WriteStats {
+ intmax_t WriteCnt;
+ intmax_t WriteErr;
+ intmax_t totWriteCnt;
+ intmax_t totWriteErr;
+ intmax_t totWriteWarn;
+ struct iperf_tcpstats tcpstats;
+};
+
+/*
+ * This struct contains all important information from the sending or
+ * recieving thread.
+ */
+#define L2UNKNOWN 0x01
+#define L2LENERR 0x02
+#define L2CSUMERR 0x04
+
+enum WriteErrType {
+ WriteNoErr = 0,
+ WriteErrAccount,
+ WriteErrFatal,
+ WriteErrNoAccount
+};
+
+struct L2Stats {
+ intmax_t cnt;
+ intmax_t unknown;
+ intmax_t udpcsumerr;
+ intmax_t lengtherr;
+ intmax_t tot_cnt;
+ intmax_t tot_unknown;
+ intmax_t tot_udpcsumerr;
+ intmax_t tot_lengtherr;
+};
+
+struct RunningMMMStats {
+ struct MeanMinMaxStats current;
+ struct MeanMinMaxStats total;
+};
+/*
+ * The type field of ReporterData is a bitmask
+ * with one or more of the following
+ */
+enum ReportType {
+ DATA_REPORT = 1,
+ SUM_REPORT,
+ SETTINGS_REPORT,
+ CONNECTION_REPORT,
+ SERVER_RELAY_REPORT
+};
+
+enum ReportSubType {
+ FULLDUPLEXSUM_REPORT = 1,
+ HOSTSUM_REPORT,
+ TOTALSUM_REPORT
+};
+
+union SendReadStats {
+ struct ReadStats read;
+ struct WriteStats write;
+};
+
+// This attributes are shared by all reports
+// deep copies are made when creating a new report
+// rather than using references
+struct ReportCommon {
+ enum ThreadMode ThreadMode;
+ enum ReportMode ReportMode;
+ bool KeyCheck;
+ int flags;
+ int flags_extend;
+ int flags_extend2;
+ int threads;
+ unsigned short Port;
+ unsigned short PortLast;
+ unsigned short BindPort;
+ unsigned short ListenPort;
+ intmax_t AppRate; // -b or -u
+ uint32_t BurstSize;
+ int AppRateUnits;
+ char Format;
+ int TTL;
+ int BufLen;
+ int MSS;
+ int TCPWin;
+ int TOS;
+ int RTOS;
+#if HAVE_DECL_TCP_WINDOW_CLAMP
+ int ClampSize;
+#endif
+#if HAVE_DECL_TCP_NOTSENT_LOWAT
+ int WritePrefetch;
+#endif
+ int winsize_requested;
+ unsigned int FQPacingRate;
+ int HistBins;
+ int HistBinsize;
+ int HistUnits;
+ double pktIPG;
+ iperf_sockaddr peer;
+ Socklen_t size_peer;
+ iperf_sockaddr local;
+ Socklen_t size_local;
+ char* Host; // -c
+ char* HideHost;
+ char* Localhost; // -B
+ char* Ifrname;
+ char* Ifrnametx;
+ char* SSMMulticastStr;
+ char* Congestion;
+ char* transferIDStr;
+ char* PermitKey;
+ int transferID;
+ double rtt_weight;
+ double ListenerTimeout;
+ double FPS;
+ int bbsize;
+ int bbhold;
+ int bbcount;
+ int jitter_binwidth;
+#if WIN32
+ SOCKET socket;
+#else
+ int socket;
+#if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET)
+ int socketdrop;
+#endif
+#endif
+};
+
+struct ConnectionInfo {
+ struct ReportCommon *common;
+ struct timeval connect_timestamp;
+ struct timeval txholdbacktime;
+ struct timeval epochStartTime;
+ int winsize;
+ char peerversion[PEERVERBUFSIZE];
+ struct MeanMinMaxStats connect_times;
+ struct iperf_tcpstats tcpinitstats;
+};
+
+struct ShiftIntCounter {
+ intmax_t current;
+ intmax_t prev;
+};
+
+struct ShiftUintCounter {
+ uintmax_t current;
+ uintmax_t prev;
+};
+
+struct ShiftCounters {
+ struct ShiftUintCounter Bytes;
+ struct ShiftIntCounter Lost;
+ struct ShiftIntCounter OutofOrder;
+ struct ShiftIntCounter Datagrams;
+ struct ShiftIntCounter IPG;
+};
+
+struct IsochStats {
+ double mFPS; //frames per second
+ double mMean; //variable bit rate mean
+ double mVariance; //vbr variance
+ int mJitterBufSize; //Server jitter buffer size, units is frames
+ uintmax_t cntFrames;
+ uintmax_t cntFramesMissed;
+ uintmax_t cntSlips;
+ struct ShiftUintCounter slipcnt;
+ struct ShiftUintCounter framecnt;
+ struct ShiftUintCounter framelostcnt;
+ unsigned int mBurstInterval;
+ unsigned int mBurstIPG; //IPG of packets within the burst
+ uint32_t frameID;
+ struct RunningMMMStats transit;
+ int newburst;
+};
+
+struct ReportSettings {
+ struct ReportCommon *common;
+ iperf_sockaddr peer;
+ Socklen_t size_peer;
+ iperf_sockaddr local;
+ Socklen_t size_local;
+ int pid;
+ int sockmaxseg;
+ struct IsochStats isochstats;
+ void (*output_handler) (struct ReportSettings *settings);
+};
+
+// Timestamps
+enum TimeStampType {
+ INTERVAL = 0,
+ FINALPARTIAL,
+ TOTAL,
+ INTERVALPARTIAL
+};
+
+struct ReportTimeStamps {
+ double iStart;
+ double iEnd;
+ double significant_partial;
+ struct timeval startTime;
+ struct timeval matchTime;
+ struct timeval packetTime;
+ struct timeval prevpacketTime;
+ struct timeval prevsendTime;
+ struct timeval nextTime;
+ struct timeval intervalTime;
+ struct timeval IPGstart;
+ struct timeval nextTCPSampleTime;
+};
+
+struct TransferInfo {
+ struct ReportCommon *common;
+ struct ReportTimeStamps ts;
+ void (*output_handler) (struct TransferInfo *stats);
+ int groupID;
+ int threadcnt;
+ bool isMaskOutput;
+ uintmax_t cntBytes;
+ intmax_t cntError;
+ intmax_t cntOutofOrder;
+ intmax_t cntDatagrams;
+ intmax_t cntIPG;
+ intmax_t PacketID;
+ double jitter;
+ double IPGsum;
+ struct ShiftCounters total; // Shift counters used to calculate interval reports and hold totals
+ union SendReadStats sock_callstats;
+ struct IsochStats isochstats;
+ struct histogram *latency_histogram;
+ struct histogram *jitter_histogram;
+ struct RunningMMMStats transit;
+ struct RunningMMMStats inline_jitter; // per RTP inline calc
+ struct histogram *framelatency_histogram;
+ struct RunningMMMStats frame; // isochronous frame or msg burst
+ struct histogram *bbrtt_histogram;
+ struct RunningMMMStats bbrtt;
+ struct RunningMMMStats bbowdto;
+ struct RunningMMMStats bbowdfro;
+ struct RunningMMMStats bbasym;
+ struct MeanMinMaxStats schedule_error;
+ struct L2Stats l2counts;
+ // Packet and frame state info
+ uint32_t matchframeID;
+ uint32_t frameID;
+ char csv_peer[CSVPEERLIMIT];
+ bool final;
+ bool burstid_transition;
+ bool isEnableTcpInfo;
+ struct RunningMMMStats write_mmm;
+ struct histogram *write_histogram;
+ double iBBrunning;
+ double fBBrunning;
+ double iInP;
+ double fInP;
+ double iInPVar;
+ double fInPVar;
+};
+
+struct SumReport {
+ struct ReferenceMutex reference;
+ int threads;
+ int threads_cntr_fsum;
+ struct TransferInfo info;
+ void (*transfer_protocol_sum_handler) (struct TransferInfo *stats, int final);
+ struct BarrierMutex fullduplex_barrier;
+ int sum_fd_set;
+ bool sum_reverse_set;
+};
+
+struct ReporterData {
+ // function pointer for per packet processing
+ void (*packet_handler_pre_report) (struct ReporterData *data, struct ReportStruct *packet);
+ void (*packet_handler_post_report) (struct ReporterData *data, struct ReportStruct *packet);
+ void (*transfer_protocol_handler) (struct ReporterData *data, int final);
+ int (*transfer_interval_handler) (struct ReporterData *data, struct ReportStruct *packet);
+
+ struct PacketRing *packetring;
+ int reporter_thread_suspends; // used to detect CPU bound systems
+
+ // group sum and full duplext reports
+ struct SumReport *GroupSumReport;
+ struct SumReport *FullDuplexReport;
+ struct TransferInfo info;
+};
+
+struct ServerRelay {
+ struct TransferInfo info;
+ iperf_sockaddr peer;
+ Socklen_t size_peer;
+ iperf_sockaddr local;
+ Socklen_t size_local;
+};
+
+struct ReportHeader {
+ enum ReportType type;
+ enum ReportMode ReportMode;
+ void *this_report;
+ struct ReportHeader *next;
+};
+
+typedef void* (* report_connection)( struct ConnectionInfo*, int );
+typedef void (* report_settings)( struct ReporterData* );
+typedef void (* report_statistics)( struct TransferInfo* );
+typedef void (* report_serverstatistics)( struct ConnectionInfo *, struct TransferInfo* );
+
+void SetSumHandlers (struct thread_Settings *inSettings, struct SumReport* sumreport);
+struct SumReport* InitSumReport(struct thread_Settings *inSettings, int inID, int fullduplex);
+struct ReportHeader* InitIndividualReport(struct thread_Settings *inSettings);
+struct ReportHeader* InitConnectionReport(struct thread_Settings *inSettings);
+struct ConnectionInfo* InitConnectOnlyReport(struct thread_Settings *thread);
+struct ReportHeader *InitSettingsReport(struct thread_Settings *inSettings);
+struct ReportHeader* InitServerRelayUDPReport(struct thread_Settings *inSettings, struct server_hdr *server);
+void PostReport(struct ReportHeader *reporthdr);
+bool ReportPacket (struct ReporterData* data, struct ReportStruct *packet);
+int EndJob(struct ReportHeader *reporthdr, struct ReportStruct *packet);
+void FreeReport(struct ReportHeader *reporthdr);
+void FreeSumReport (struct SumReport *sumreport);
+void FreeConnectionReport(struct ConnectionInfo *reporthdr);
+void ReportServerUDP(struct thread_Settings *inSettings, struct server_hdr *server);
+void ReportConnections(struct thread_Settings *inSettings );
+void reporter_dump_job_queue(void);
+void IncrSumReportRefCounter(struct SumReport *sumreport);
+int DecrSumReportRefCounter(struct SumReport *sumreport);
+
+extern struct AwaitMutex reporter_state;
+extern struct AwaitMutex threads_start;
+
+extern report_connection connection_reports[];
+extern report_settings settings_reports[];
+extern report_statistics statistics_reports[];
+extern report_serverstatistics serverstatistics_reports[];
+extern report_statistics multiple_reports[];
+
+
+// The packet or read/write accounting routines used by the reporter thread
+// They're function vectors called from the reporter loop via
+// this_ireport->packet_handler_pre_report or this_ireport->packet_handler_post_report
+// The vectors are set during report instantiation in Reports.c
+// Note that client packet handling is the same for TCP and UDP
+void reporter_handle_packet_null(struct ReporterData *data, struct ReportStruct *packet);
+void reporter_handle_packet_client(struct ReporterData *data, struct ReportStruct *packet);
+void reporter_handle_packet_server_udp(struct ReporterData *data, struct ReportStruct *packet);
+void reporter_handle_packet_server_tcp(struct ReporterData *data, struct ReportStruct *packet);
+void reporter_handle_packet_bb_client(struct ReporterData *data, struct ReportStruct *packet);
+void reporter_handle_packet_bb_server(struct ReporterData *data, struct ReportStruct *packet);
+
+// Reporter thread's conditional prints of interval reports
+// Invoked from the Reporter thread per function vector this_ireport->transfer_interval_handler
+// This is set during Report instantiation (found in Reports.c)
+// These conditionally, e.g per a sample interval, invoke the transfer protocol handlers
+int reporter_condprint_time_interval_report(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_frame_interval_report_client_udp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_frame_interval_report_server_udp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_frame_interval_report_server_tcp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_frame_interval_report_client_tcp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_burst_interval_report_client_udp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_burst_interval_report_server_udp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_burst_interval_report_server_tcp(struct ReporterData *data, struct ReportStruct *packet);
+int reporter_condprint_burst_interval_report_client_tcp(struct ReporterData *data, struct ReportStruct *packet);
+
+// Each report type needs specialized updating prior to printing its report
+// These functions realize that updating. They are called by the transfer protocol handler,
+// e.g. (*data->transfer_protocol_handler)(data, 0) found in src/Reporter.c
+// These update the TransferInfo stats struct which is used during output (e.g. the output handler)
+void reporter_transfer_protocol_null(struct ReporterData *data, int final);
+void reporter_transfer_protocol_client_tcp(struct ReporterData *data, int final);
+void reporter_transfer_protocol_client_bb_tcp(struct ReporterData *data, int final);
+void reporter_transfer_protocol_client_udp(struct ReporterData *data, int final);
+void reporter_transfer_protocol_server_tcp(struct ReporterData *data, int final);
+void reporter_transfer_protocol_server_bb_tcp(struct ReporterData *data, int final);
+void reporter_transfer_protocol_server_udp(struct ReporterData *data, int final);
+// Function vectors to suppport sum reports
+void reporter_transfer_protocol_sum_client_tcp(struct TransferInfo *stats, int final);
+void reporter_transfer_protocol_sum_server_tcp(struct TransferInfo *stats, int final);
+void reporter_transfer_protocol_sum_client_udp(struct TransferInfo *stats, int final);
+void reporter_transfer_protocol_sum_server_udp(struct TransferInfo *stats, int final);
+void reporter_transfer_protocol_fullduplex_tcp(struct TransferInfo *stats, int final);
+void reporter_transfer_protocol_fullduplex_udp(struct TransferInfo *stats, int final);
+
+// Report output print routines invoked by the transfer_protocol handler
+// Bound in Report instantiation and invoked by the transfer protocol
+// handler, using (*stats->output_handler)(stats)
+// TCP server
+void tcp_output_read(struct TransferInfo *stats);
+void tcp_output_read_enhanced(struct TransferInfo *stats);
+void tcp_output_read_triptime(struct TransferInfo *stats);
+void tcp_output_sum_read(struct TransferInfo *stats);
+void tcp_output_sum_read_enhanced(struct TransferInfo *stats);
+void tcp_output_sumcnt_read(struct TransferInfo *stats);
+void tcp_output_sumcnt_read_enhanced (struct TransferInfo *stats);
+void tcp_output_sumcnt_read_triptime (struct TransferInfo *stats);
+void tcp_output_frame_read(struct TransferInfo *stats);
+void tcp_output_frame_read_triptime(struct TransferInfo *stats);
+void tcp_output_burst_read(struct TransferInfo *stats);
+void tcp_output_read_enhanced_isoch(struct TransferInfo *stats);
+// TCP client
+void tcp_output_write(struct TransferInfo *stats);
+void tcp_output_burst_write(struct TransferInfo *stats);
+void tcp_output_sum_write(struct TransferInfo *stats);
+void tcp_output_sumcnt_write(struct TransferInfo *stats);
+void tcp_output_write_enhanced (struct TransferInfo *stats);
+void tcp_output_write_enhanced_isoch (struct TransferInfo *stats);
+void tcp_output_sum_write_enhanced (struct TransferInfo *stats);
+void tcp_output_sumcnt_write_enhanced (struct TransferInfo *stats);
+void tcp_output_write_enhanced_write (struct TransferInfo *stats);
+void tcp_output_write_bb(struct TransferInfo *stats);
+// TCP fullduplex
+void tcp_output_fullduplex(struct TransferInfo *stats);
+void tcp_output_fullduplex_enhanced(struct TransferInfo *stats);
+void tcp_output_fullduplex_sum (struct TransferInfo *stats);
+// UDP server
+void udp_output_read(struct TransferInfo *stats);
+void udp_output_read_enhanced(struct TransferInfo *stats);
+void udp_output_read_triptime(struct TransferInfo *stats);
+void udp_output_read_triptime_isoch(struct TransferInfo *stats);
+void udp_output_sum_read(struct TransferInfo *stats);
+void udp_output_sum_read_enhanced (struct TransferInfo *stats);
+void udp_output_sumcnt(struct TransferInfo *stats);
+void udp_output_sumcnt_read_enhanced (struct TransferInfo *stats);
+//UDP client
+void udp_output_write(struct TransferInfo *stats);
+void udp_output_sum_write(struct TransferInfo *stats);
+void udp_output_write_enhanced(struct TransferInfo *stats);
+void udp_output_write_enhanced_isoch(struct TransferInfo *stats);
+void udp_output_sum_write_enhanced (struct TransferInfo *stats);
+void udp_output_sumcnt_write(struct TransferInfo *stats);
+void udp_output_sumcnt_write_enhanced (struct TransferInfo *stats);
+void udp_output_sumcnt_enhanced(struct TransferInfo *stats);
+void udp_output_sumcnt_read_triptime(struct TransferInfo *stats);
+// UDP full duplex
+void udp_output_fullduplex(struct TransferInfo *stats);
+void udp_output_fullduplex_enhanced(struct TransferInfo *stats);
+void udp_output_fullduplex_sum(struct TransferInfo *stats);
+
+// CSV output
+void udp_output_basic_csv(struct TransferInfo *stats);
+void udp_output_enhanced_csv(struct TransferInfo *stats);
+void tcp_output_basic_csv(struct TransferInfo *stats);
+void tcp_output_read_enhanced_csv(struct TransferInfo *stats);
+void tcp_output_write_enhanced_csv(struct TransferInfo *stats);
+
+// The report output routines that are simpler and aren't related to stats
+void reporter_print_connection_report(struct ConnectionInfo *report);
+void reporter_print_settings_report(struct ReportSettings *report);
+void reporter_print_server_relay_report(struct ServerRelay *report);
+void reporter_peerversion (struct ConnectionInfo *report, uint32_t upper, uint32_t lower);
+void PrintMSS(struct ReporterData *data);
+void reporter_default_heading_flags(int);
+void reporter_connect_printf_tcp_final(struct ConnectionInfo *report);
+
+void write_UDP_AckFIN(struct TransferInfo *stats, int len);
+
+int reporter_process_transfer_report (struct ReporterData *this_ireport);
+int reporter_process_report (struct ReportHeader *reporthdr);
+
+void setTransferID(struct thread_Settings *inSettings, int role_reversal);
+void format_ips_port_string (struct TransferInfo *stats, bool sum);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif // REPORTER_H
diff --git a/include/Server.hpp b/include/Server.hpp
new file mode 100644
index 0000000..cca386a
--- /dev/null
+++ b/include/Server.hpp
@@ -0,0 +1,127 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Server.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * A server thread is initiated for each connection accept() returns.
+ * Handles sending and receiving data, and then closes socket.
+ * ------------------------------------------------------------------- */
+
+#ifndef SERVER_H
+#define SERVER_H
+
+
+#include "Settings.hpp"
+#include "util.h"
+#include "Timestamp.hpp"
+
+/* ------------------------------------------------------------------- */
+class Server {
+public:
+ // stores server socket, port and TCP/UDP mode
+ Server(thread_Settings *inSettings);
+
+ // destroy the server object
+ ~Server();
+
+ // accepts connection and receives data
+ void RunUDP(void);
+ void RunTCP(void);
+ void RunBounceBackTCP(void);
+ static void Sig_Int(int inSigno);
+
+private:
+ thread_Settings *mSettings;
+ Timestamp mEndTime;
+ Timestamp now;
+ ReportStruct scratchpad;
+ ReportStruct *reportstruct;
+
+ void InitKernelTimeStamping(void);
+ bool InitTrafficLoop(void);
+ inline void SetFullDuplexReportStartTime(void);
+ inline void SetReportStartTime();
+ bool ReadBBWithRXTimestamp ();
+ int ReadWithRxTimestamp(void);
+ bool ReadPacketID(int);
+ void L2_processing(void);
+ int L2_quintuple_filter(void);
+ void udp_isoch_processing(int);
+ bool InProgress(void);
+ int SkipFirstPayload(void);
+ void ClientReverseFirstRead(void);
+ void PostNullEvent(void);
+ Timestamp connect_done;
+ bool peerclose;
+ bool isburst;
+#if WIN32
+ SOCKET mySocket;
+ SOCKET myDropSocket;
+#else
+ int mySocket;
+ int myDropSocket;
+#endif
+ struct ReportHeader *myJob;
+ struct ReporterData *myReport;
+
+#if HAVE_DECL_SO_TIMESTAMP
+ // Structures needed for recvmsg
+ // Use to get kernel timestamps of packets
+ struct sockaddr_storage srcaddr;
+ struct iovec iov[1];
+ struct msghdr message;
+ char ctrl[CMSG_SPACE(sizeof(struct timeval))];
+ struct cmsghdr *cmsg;
+#endif
+#if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET)
+ struct ether_header *eth_hdr;
+ struct iphdr *ip_hdr;
+ struct udphdr *udp_hdr;
+#endif
+}; // end class Server
+
+#endif // SERVER_H
diff --git a/include/Settings.hpp b/include/Settings.hpp
new file mode 100644
index 0000000..250d3a7
--- /dev/null
+++ b/include/Settings.hpp
@@ -0,0 +1,665 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Settings.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * & Ajay Tirumala <tirumala@ncsa.uiuc.edu>
+ * -------------------------------------------------------------------
+ * Stores and parses the initial values for all the global variables.
+ * -------------------------------------------------------------------
+ * headers
+ * uses
+ * <stdlib.h>
+ * <assert.h>
+ * ------------------------------------------------------------------- */
+
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#include "headers.h"
+#include "Thread.h"
+#include "Condition.h"
+#include "packet_ring.h"
+
+/* -------------------------------------------------------------------
+ * constants
+ * ------------------------------------------------------------------- */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Smallest report interval supported. Units is microseconds */
+#ifndef HAVE_FASTSAMPLING
+#define SMALLEST_INTERVAL 5000 // 5ms
+#define SMALLEST_INTERVAL_SEC 0.005 // 5ms
+#else
+#define SMALLEST_INTERVAL 100 // 100 usec
+#define SMALLEST_INTERVAL_SEC 0.0001 // 5ms
+#endif
+
+#define SLOPSECS 2
+// maximum difference allowed between the tx (client) start time and the
+// the first receive time (units seconds, requires --trip-times on client)
+#define MAXDIFFTIMESTAMPSECS 600
+// maximum difference in seconds to bound --txstart-time
+#define MAXDIFFTXSTART 3600
+// maximum difference in seconds to bound --txdelay-time,
+// if this is too large and w/o keep-alives the connect may drop
+#define MAXDIFFTXDELAY 3600
+// maximum inter packet gap (or write delay) for UDP packets
+#define MAXIPGSECS 60
+#define CSVPEERLIMIT ((REPORT_ADDRLEN * 2) + 40)
+#define NEARCONGEST_DEFAULT 0.5
+#define DEFAULT_PERMITKEY_LIFE 20.0 // units is seconds
+#define TESTEXCHANGETIMEOUT (4 * 1000000) // 4 secs, units is microseconds
+#ifndef MAXTTL
+#define MAXTTL 255
+#endif
+#define DEFAULT_BOUNCEBACK_BYTES 100
+#define SMALL_WRITE_PREFETCH (1024 * 16)
+
+#define SHALLOW_COPY 1
+#define DEEP_COPY 1
+// server/client mode
+enum ThreadMode {
+ kMode_Unknown = 0,
+ kMode_Server,
+ kMode_Client,
+ kMode_Reporter,
+ kMode_ReporterClient,
+ kMode_WriteAckServer,
+ kMode_WriteAckClient,
+ kMode_Listener
+};
+
+// report mode
+enum ReportMode {
+ kReport_Default = 0,
+ kReport_CSV
+};
+
+// test mode
+enum TestMode {
+ kTest_Normal = 0,
+ kTest_DualTest,
+ kTest_TradeOff,
+ kTest_Unknown
+};
+
+// interval reporting mode
+enum IntervalMode {
+ kInterval_None = 0,
+ kInterval_Time,
+ kInterval_Frames
+};
+
+// rate request units
+enum RateUnits {
+ kRate_BW = 0,
+ kRate_PPS
+};
+
+#include "Reporter.h"
+#include "payloads.h"
+
+/*
+ * The thread_Settings is a structure that holds all
+ * options for a given execution of either a client
+ * or server. By using this structure rather than
+ * a global structure or class we can have multiple
+ * clients or servers running with different settings.
+ * In version 2.0 and above this structure contains
+ * all the information needed for a thread to execute
+ * and contains only C elements so it can be manipulated
+ * by either C or C++.
+ */
+struct thread_Settings {
+ // Pointers
+ char* mFileName; // -F
+ char* mHost; // -c
+ char* mHideHost;
+ char* mLocalhost; // -B
+ char* mOutputFileName; // -o
+ char* mIfrname; // %<device> name (for rx)
+ char* mIfrnametx; // %<device> name (for tx)
+ char* mSSMMulticastStr; // --ssm-host
+ char* mIsochronousStr; // --isochronous
+ char* mHistogramStr; // --histograms (packets)
+ char* mTransferIDStr; //
+ char* mBuf;
+ FILE* Extractor_file;
+
+ struct ReportHeader* reporthdr;
+ struct SumReport* mSumReport;
+ struct SumReport* mFullDuplexReport;
+ struct thread_Settings *runNow;
+ struct thread_Settings *runNext;
+ // int's
+ int mThreads; // -P
+ int mTOS; // -S
+ int mRTOS; // reflected TOS
+ int mTransferID;
+ int mConnectRetries;
+#if WIN32
+ SOCKET mSock;
+#else
+ int mSock;
+#endif
+#if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET)
+ int mSockDrop;
+#endif
+ int Extractor_size;
+ int mBufLen; // -l
+ int mWriteAckLen; // --write-ack
+ int mMSS; // -M
+ int mTCPWin; // -w
+ /* flags is a BitMask of old bools
+ bool mBufLenSet; // -l
+ bool mCompat; // -C
+ bool mDaemon; // -D
+ bool mDomain; // -V
+ bool mFileInput; // -F or -I
+ bool mNodelay; // -N
+ bool mPrintMSS; // -m
+ bool mRemoveService; // -R
+ bool mStdin; // -I
+ bool mStdout; // -o
+ bool mSuggestWin; // -W
+ bool mUDP; // -u
+ bool mMode_time;
+ bool mReportSettings;
+ bool mMulticast;
+ bool mNoSettingsReport; // -x s
+ bool mNoConnectionReport; // -x c
+ bool mNoDataReport; // -x d
+ bool mNoServerReport; // -x
+ bool mNoMultReport; // -x m
+ bool mSinlgeClient; // -1 */
+ int flags;
+ int flags_extend;
+ int flags_extend2;
+ // enums (which should be special int's)
+ enum ThreadMode mThreadMode; // -s or -c
+ enum ReportMode mReportMode;
+ enum TestMode mMode; // -r or -d
+ bool clientListener; // set to True if client mode listener per -r or -d
+ // Hopefully int64_t's
+ uintmax_t mAppRate; // -b or -u
+ char mAppRateUnits; // -b is either bw or pps
+ uintmax_t mAmount; // -n or -t time unit is 10 ms
+ unsigned int mInterval; // -i integer time units is usec
+ enum IntervalMode mIntervalMode;
+ // shorts
+ unsigned short mListenPort; // -L
+ unsigned short mPort; // -p
+ unsigned short mPortLast; // -p last port, e.g. when -p 6001-6010
+ unsigned short mBindPort; // -B
+ // chars
+ char mFormat; // -f
+ int mTTL; // -T
+ char pad1[2];
+ // structs or miscellaneous
+ iperf_sockaddr peer;
+ Socklen_t size_peer;
+ iperf_sockaddr local;
+ Socklen_t size_local;
+ nthread_t mTID;
+ int incrdstip;
+ int incrsrcip;
+ int incrsrcport;
+ int connectonly_count;
+ char* mCongestion;
+ int mHistBins;
+ int mHistBinsize;
+ int mHistUnits;
+ double mHistci_lower;
+ double mHistci_upper;
+#if defined(HAVE_WIN32_THREAD)
+ HANDLE mHandle;
+#endif
+ double mFPS; //frames per second
+ double mMean; //variable bit rate mean
+ uint32_t mBurstSize; //number of bytes in a burst
+ int mJitterBufSize; //Server jitter buffer size, units is frames
+ double mBurstIPG; //Interpacket gap
+ int l4offset; // used in l2 mode to offset the raw packet
+ int l4payloadoffset;
+ int recvflags; // used to set recv flags,e.g. MSG_TRUNC with L
+ double mVariance; //vbr variance
+ uintmax_t mFQPacingRate;
+ struct timeval txholdback_timer;
+ struct timeval txstart_epoch;
+ struct timeval accept_time;
+ struct timeval sent_time;
+ struct Condition awake_me;
+ struct PacketRing *ackring;
+ struct BarrierMutex *connects_done;
+ int numreportstructs;
+ int32_t peer_version_u;
+ int32_t peer_version_l;
+ double connecttime;
+ double rtt_nearcongest_weight_factor;
+ char mPermitKey[MAX_PERMITKEY_LEN + 1]; //add some space for timestamp
+ struct timeval mPermitKeyTime;
+ bool mKeyCheck;
+ double mListenerTimeout;
+ int tuntapdev;
+ int firstreadbytes;
+ int mBounceBackBytes;
+ int mBounceBackBurst;
+ int mWorkingLoadThreads; // number of congest threads
+ uint32_t mBounceBackHold; // units of usecs
+ struct iperf_tcpstats tcpinitstats;
+#if HAVE_DECL_TCP_WINDOW_CLAMP
+ int mClampSize;
+#endif
+#if HAVE_DECL_TCP_NOTSENT_LOWAT
+ int mWritePrefetch;
+#endif
+ int jitter_binwidth;
+};
+
+/*
+ * Thread based flags
+ *
+ * Due to the use of thread_Settings in C and C++
+ * we are unable to use bool values. To provide
+ * the functionality of bools we use the following
+ * bitmask over an assumed 32 bit int. This will
+ * work fine on 64bit machines we will just be ignoring
+ * the upper 32bits.
+ *
+ * To add a flag simply define it as the next bit then
+ * add the 3 support functions below.
+ */
+#define FLAG_BUFLENSET 0x00000001
+#define FLAG_COMPAT 0x00000002
+#define FLAG_DAEMON 0x00000004
+#define FLAG_DOMAINV6 0x00000008
+#define FLAG_FILEINPUT 0x00000010
+#define FLAG_NODELAY 0x00000020
+#define FLAG_PRINTMSS 0x00000040
+#define FLAG_REMOVESERVICE 0x00000080
+#define FLAG_STDIN 0x00000100
+#define FLAG_STDOUT 0x00000200
+#define FLAG_SUGGESTWIN 0x00000400
+#define FLAG_UDP 0x00000800
+#define FLAG_MODETIME 0x00001000
+#define FLAG_REPORTSETTINGS 0x00002000
+#define FLAG_MULTICAST 0x00004000
+#define FLAG_NOSETTREPORT 0x00008000
+#define FLAG_NOCONNREPORT 0x00010000
+#define FLAG_NODATAREPORT 0x00020000
+#define FLAG_NOSERVREPORT 0x00040000
+#define FLAG_NOMULTREPORT 0x00080000
+#define FLAG_SINGLECLIENT 0x00100000
+#define FLAG_SINGLEUDP 0x00200000
+#define FLAG_CONGESTION 0x00400000
+#define FLAG_REALTIME 0x00800000
+#define FLAG_BWSET 0x01000000
+#define FLAG_ENHANCEDREPORT 0x02000000
+#define FLAG_SERVERMODETIME 0x04000000
+#define FLAG_SSM_MULTICAST 0x08000000
+/*
+ * Extended flags
+ */
+#define FLAG_PEERVER 0x00000001
+#define FLAG_SEQNO64 0x00000002
+#define FLAG_REVERSE 0x00000004
+#define FLAG_ISOCHRONOUS 0x00000008
+#define FLAG_UDPUNUSED 0x00000010
+#define FLAG_HISTOGRAM 0x00000020
+#define FLAG_L2LENGTHCHECK 0x00000100
+#define FLAG_TXSTARTTIME 0x00000200
+#define FLAG_INCRDSTIP 0x00000400
+#define FLAG_VARYLOAD 0x00000800
+#define FLAG_FQPACING 0x00001000
+#define FLAG_TRIPTIME 0x00002000
+#define FLAG_TXHOLDBACK 0x00004000
+#define FLAG_UNUSED 0x00008000
+#define FLAG_MODEINFINITE 0x00010000
+#define FLAG_CONNECTONLY 0x00020000
+#define FLAG_SERVERREVERSE 0x00040000
+#define FLAG_FULLDUPLEX 0x00080000
+#define FLAG_WRITEACK 0x00100000
+#define FLAG_NOUDPFIN 0x00200000
+#define FLAG_NOCONNECTSYNC 0x00400000
+#define FLAG_SUMONLY 0x00800000
+#define FLAG_FRAMEINTERVAL 0x01000000
+#define FLAG_IPG 0x02000000
+#define FLAG_DONTROUTE 0x04000000
+#define FLAG_NEARCONGEST 0x08000000
+#define FLAG_PERMITKEY 0x10000000
+#define FLAG_SETTCPMSS 0x20000000
+#define FLAG_INCRDSTPORT 0x40000000
+#define FLAG_INCRSRCIP 0x80000000
+
+/*
+ * More extended flags
+ */
+#define FLAG_PERIODICBURST 0x00000001
+#define FLAG_SUMDSTIP 0x00000002
+#define FLAG_SMALLTRIPTIME 0x00000004
+#define FLAG_RXCLAMP 0x00000008
+#define FLAG_WRITEPREFETCH 0x00000010
+#define FLAG_TUNDEV 0x00000020
+#define FLAG_TAPDEV 0x00000040
+#define FLAG_HIDEIPS 0x00000080
+#define FLAG_BOUNCEBACK 0x00000100
+#define FLAG_TCPWRITETIMES 0x00000200
+#define FLAG_INCRSRCPORT 0x00000400
+#define FLAG_OVERRIDETOS 0x00000800
+#define FLAG_TCPQUICKACK 0x00001000
+#define FLAG_WORKING_LOAD_DOWN 0x00002000
+#define FLAG_WORKING_LOAD_UP 0x00004000
+#define FLAG_DOMAINV4 0x00008000
+#define FLAG_JITTER_HISTOGRAM 0x00010000
+#define FLAG_UTC 0x00020000
+
+#define isBuflenSet(settings) ((settings->flags & FLAG_BUFLENSET) != 0)
+#define isCompat(settings) ((settings->flags & FLAG_COMPAT) != 0)
+#define isDaemon(settings) ((settings->flags & FLAG_DAEMON) != 0)
+#define isIPV6(settings) ((settings->flags & FLAG_DOMAINV6) != 0)
+#define isIPV4(settings) ((settings->flags_extend2 & FLAG_DOMAINV4) != 0)
+#define isFileInput(settings) ((settings->flags & FLAG_FILEINPUT) != 0)
+#define isNoDelay(settings) ((settings->flags & FLAG_NODELAY) != 0)
+#define isPrintMSS(settings) ((settings->flags & FLAG_PRINTMSS) != 0)
+#define isRemoveService(settings) ((settings->flags & FLAG_REMOVESERVICE) != 0)
+#define isSTDIN(settings) ((settings->flags & FLAG_STDIN) != 0)
+#define isSTDOUT(settings) ((settings->flags & FLAG_STDOUT) != 0)
+#define isSuggestWin(settings) ((settings->flags & FLAG_SUGGESTWIN) != 0)
+#define isUDP(settings) ((settings->flags & FLAG_UDP) != 0)
+#define isModeTime(settings) ((settings->flags & FLAG_MODETIME) != 0)
+#define isReport(settings) ((settings->flags & FLAG_REPORTSETTINGS) != 0)
+#define isMulticast(settings) ((settings->flags & FLAG_MULTICAST) != 0)
+#define isSSMMulticast(settings) ((settings->flags & FLAG_SSM_MULTICAST) != 0)
+// Active Low for Reports
+#define isSettingsReport(settings) ((settings->flags & FLAG_NOSETTREPORT) == 0)
+#define isConnectionReport(settings) ((settings->flags & FLAG_NOCONNREPORT) == 0)
+#define isDataReport(settings) ((settings->flags & FLAG_NODATAREPORT) == 0)
+#define isServerReport(settings) ((settings->flags & FLAG_NOSERVREPORT) == 0)
+#define isMultipleReport(settings) ((settings->flags & FLAG_NOMULTREPORT) == 0)
+// end Active Low
+#define isSingleClient(settings) ((settings->flags & FLAG_SINGLECLIENT) != 0)
+#define isSingleUDP(settings) ((settings->flags & FLAG_SINGLEUDP) != 0)
+#define isCongestionControl(settings) ((settings->flags & FLAG_CONGESTION) != 0)
+#define isRealtime(settings) ((settings->flags & FLAG_REALTIME) != 0)
+#define isBWSet(settings) ((settings->flags & FLAG_BWSET) != 0)
+#define isEnhanced(settings) ((settings->flags & FLAG_ENHANCEDREPORT) != 0)
+#define isServerModeTime(settings) ((settings->flags & FLAG_SERVERMODETIME) != 0)
+#define isPeerVerDetect(settings) ((settings->flags_extend & FLAG_PEERVER) != 0)
+#define isSeqNo64b(settings) ((settings->flags_extend & FLAG_SEQNO64) != 0)
+#define isReverse(settings) ((settings->flags_extend & FLAG_REVERSE) != 0)
+#define isFullDuplex(settings) ((settings->flags_extend & FLAG_FULLDUPLEX) != 0)
+#define isServerReverse(settings) ((settings->flags_extend & FLAG_SERVERREVERSE) != 0)
+#define isIsochronous(settings) ((settings->flags_extend & FLAG_ISOCHRONOUS) != 0)
+#define isHistogram(settings) ((settings->flags_extend & FLAG_HISTOGRAM) != 0)
+#define isL2LengthCheck(settings) ((settings->flags_extend & FLAG_L2LENGTHCHECK) != 0)
+#define isIncrDstIP(settings) ((settings->flags_extend & FLAG_INCRDSTIP) != 0)
+#define isIncrSrcIP(settings) ((settings->flags_extend & FLAG_INCRSRCIP) != 0)
+#define isIncrDstPort(settings) ((settings->flags_extend & FLAG_INCRDSTPORT) != 0)
+#define isIncrSrcPort(settings) ((settings->flags_extend2 & FLAG_INCRSRCPORT) != 0)
+#define isTxStartTime(settings) ((settings->flags_extend & FLAG_TXSTARTTIME) != 0)
+#define isTxHoldback(settings) ((settings->flags_extend & FLAG_TXHOLDBACK) != 0)
+#define isVaryLoad(settings) ((settings->flags_extend & FLAG_VARYLOAD) != 0)
+#define isFQPacing(settings) ((settings->flags_extend & FLAG_FQPACING) != 0)
+#define isTripTime(settings) ((settings->flags_extend & FLAG_TRIPTIME) != 0)
+#define isSmallTripTime(settings) ((settings->flags_extend2 & FLAG_SMALLTRIPTIME) != 0)
+#define isModeInfinite(settings) ((settings->flags_extend & FLAG_MODEINFINITE) != 0)
+#define isModeAmount(settings) (!isModeTime(settings) && !isModeInfinite(settings))
+#define isConnectOnly(settings) ((settings->flags_extend & FLAG_CONNECTONLY) != 0)
+#define isWriteAck(settings) ((settings->flags_extend & FLAG_WRITEACK) != 0)
+#define isNoUDPfin(settings) ((settings->flags_extend & FLAG_NOUDPFIN) != 0)
+#define isNoConnectSync(settings) ((settings->flags_extend & FLAG_NOCONNECTSYNC) != 0)
+#define isSumOnly(settings) ((settings->flags_extend & FLAG_SUMONLY) != 0)
+#define isFrameInterval(settings) ((settings->flags_extend & FLAG_FRAMEINTERVAL) != 0)
+#define isIPG(settings) ((settings->flags_extend & FLAG_IPG) != 0)
+#define isDontRoute(settings) ((settings->flags_extend & FLAG_DONTROUTE) != 0)
+#define isNearCongest(settings) ((settings->flags_extend & FLAG_NEARCONGEST) != 0)
+#define isPermitKey(settings) ((settings->flags_extend & FLAG_PERMITKEY) != 0)
+#define isTCPMSS(settings) ((settings->flags_extend & FLAG_SETTCPMSS) != 0)
+#define isPeriodicBurst(settings) ((settings->flags_extend2 & FLAG_PERIODICBURST) != 0)
+#define isSumServerDstIP(settings) ((settings->flags_extend2 & FLAG_SUMDSTIP) != 0)
+#define isRxClamp(settings) ((settings->flags_extend2 & FLAG_RXCLAMP) != 0)
+#define isWritePrefetch(settings) ((settings->flags_extend2 & FLAG_WRITEPREFETCH) != 0)
+#define isTapDev(settings) ((settings->flags_extend2 & FLAG_TAPDEV) != 0)
+#define isTunDev(settings) ((settings->flags_extend2 & FLAG_TUNDEV) != 0)
+#define isHideIPs(settings) ((settings->flags_extend2 & FLAG_HIDEIPS) != 0)
+#define isBounceBack(settings) ((settings->flags_extend2 & FLAG_BOUNCEBACK) != 0)
+#define isTcpWriteTimes(settings) ((settings->flags_extend2 & FLAG_TCPWRITETIMES) != 0)
+#define isOverrideTOS(settings) ((settings->flags_extend2 & FLAG_OVERRIDETOS) != 0)
+#define isTcpQuickAck(settings) ((settings->flags_extend2 & FLAG_TCPQUICKACK) != 0)
+#define isWorkingLoadUp(settings) ((settings->flags_extend2 & FLAG_WORKING_LOAD_UP) != 0)
+#define isWorkingLoadDown(settings) ((settings->flags_extend2 & FLAG_WORKING_LOAD_DOWN) != 0)
+#define isJitterHistogram(settings) ((settings->flags_extend2 & FLAG_JITTER_HISTOGRAM) != 0)
+#define isUTC(settings) ((settings->flags_extend2 & FLAG_UTC) != 0)
+
+#define setBuflenSet(settings) settings->flags |= FLAG_BUFLENSET
+#define setCompat(settings) settings->flags |= FLAG_COMPAT
+#define setDaemon(settings) settings->flags |= FLAG_DAEMON
+#define setIPV6(settings) settings->flags |= FLAG_DOMAINV6
+#define setIPV4(settings) settings->flags_extend2 |= FLAG_DOMAINV4
+#define setFileInput(settings) settings->flags |= FLAG_FILEINPUT
+#define setNoDelay(settings) settings->flags |= FLAG_NODELAY
+#define setPrintMSS(settings) settings->flags |= FLAG_PRINTMSS
+#define setRemoveService(settings) settings->flags |= FLAG_REMOVESERVICE
+#define setSTDIN(settings) settings->flags |= FLAG_STDIN
+#define setSTDOUT(settings) settings->flags |= FLAG_STDOUT
+#define setSuggestWin(settings) settings->flags |= FLAG_SUGGESTWIN
+#define setUDP(settings) settings->flags |= FLAG_UDP
+#define setModeTime(settings) settings->flags |= FLAG_MODETIME
+#define setReport(settings) settings->flags |= FLAG_REPORTSETTINGS
+#define setMulticast(settings) settings->flags |= FLAG_MULTICAST
+#define setSSMMulticast(settings) settings->flags |= FLAG_SSM_MULTICAST
+#define setNoSettReport(settings) settings->flags |= FLAG_NOSETTREPORT
+#define setNoConnReport(settings) settings->flags |= FLAG_NOCONNREPORT
+#define setNoDataReport(settings) settings->flags |= FLAG_NODATAREPORT
+#define setNoServReport(settings) settings->flags |= FLAG_NOSERVREPORT
+#define setNoMultReport(settings) settings->flags |= FLAG_NOMULTREPORT
+#define setSingleClient(settings) settings->flags |= FLAG_SINGLECLIENT
+#define setSingleUDP(settings) settings->flags |= FLAG_SINGLEUDP
+#define setCongestionControl(settings) settings->flags |= FLAG_CONGESTION
+#define setRealtime(settings) settings->flags |= FLAG_REALTIME
+#define setBWSet(settings) settings->flags |= FLAG_BWSET
+#define setEnhanced(settings) settings->flags |= FLAG_ENHANCEDREPORT
+#define setServerModeTime(settings) settings->flags |= FLAG_SERVERMODETIME
+#define setPeerVerDetect(settings) settings->flags_extend |= FLAG_PEERVER
+#define setSeqNo64b(settings) settings->flags_extend |= FLAG_SEQNO64
+#define setReverse(settings) settings->flags_extend |= FLAG_REVERSE
+#define setFullDuplex(settings) settings->flags_extend |= FLAG_FULLDUPLEX
+#define setServerReverse(settings) settings->flags_extend |= FLAG_SERVERREVERSE
+#define setIsochronous(settings) settings->flags_extend |= FLAG_ISOCHRONOUS
+#define setHistogram(settings) settings->flags_extend |= FLAG_HISTOGRAM
+#define setL2LengthCheck(settings) settings->flags_extend |= FLAG_L2LENGTHCHECK
+#define setIncrDstIP(settings) settings->flags_extend |= FLAG_INCRDSTIP
+#define setIncrSrcIP(settings) settings->flags_extend |= FLAG_INCRSRCIP
+#define setIncrDstPort(settings) settings->flags_extend |= FLAG_INCRDSTPORT
+#define setIncrSrcPort(settings) settings->flags_extend2 |= FLAG_INCRSRCPORT
+#define setTxStartTime(settings) settings->flags_extend |= FLAG_TXSTARTTIME
+#define setTxHoldback(settings) settings->flags_extend |= FLAG_TXHOLDBACK
+#define setVaryLoad(settings) settings->flags_extend |= FLAG_VARYLOAD
+#define setFQPacing(settings) settings->flags_extend |= FLAG_FQPACING
+#define setTripTime(settings) settings->flags_extend |= FLAG_TRIPTIME
+#define setSmallTripTime(settings) settings->flags_extend2 |= FLAG_SMALLTRIPTIME
+#define setModeInfinite(settings) settings->flags_extend |= FLAG_MODEINFINITE
+#define setConnectOnly(settings) settings->flags_extend |= FLAG_CONNECTONLY
+#define setWriteAck(settings) settings->flags_extend |= FLAG_WRITEACK
+#define setNoUDPfin(settings) settings->flags_extend |= FLAG_NOUDPFIN
+#define setNoConnectSync(settings) settings->flags_extend |= FLAG_NOCONNECTSYNC
+#define setSumOnly(settings) settings->flags_extend |= FLAG_SUMONLY
+#define setFrameInterval(settings) settings->flags_extend |= FLAG_FRAMEINTERVAL
+#define setIPG(settings) settings->flags_extend |= FLAG_IPG
+#define setDontRoute(settings) settings->flags_extend |= FLAG_DONTROUTE
+#define setNearCongest(settings) settings->flags_extend |= FLAG_NEARCONGEST
+#define setPermitKey(settings) settings->flags_extend |= FLAG_PERMITKEY
+#define setTCPMSS(settings) settings->flags_extend |= FLAG_SETTCPMSS
+#define setPeriodicBurst(settings) settings->flags_extend2 |= FLAG_PERIODICBURST
+#define setSumServerDstIP(settings) settings->flags_extend2 |= FLAG_SUMDSTIP
+#define setRxClamp(settings) settings->flags_extend2 |= FLAG_RXCLAMP
+#define setWritePrefetch(settings) settings->flags_extend2 |= FLAG_WRITEPREFETCH
+#define setTapDev(settings) settings->flags_extend2 |= FLAG_TAPDEV
+#define setTunDev(settings) settings->flags_extend2 |= FLAG_TUNDEV
+#define setHideIPs(settings) settings->flags_extend2 |= FLAG_HIDEIPS
+#define setBounceBack(settings) settings->flags_extend2 |= FLAG_BOUNCEBACK
+#define setTcpWriteTimes(settings) settings->flags_extend2 |= FLAG_TCPWRITETIMES
+#define setOverrideTOS(settings) settings->flags_extend2 |= FLAG_OVERRIDETOS
+#define setTcpQuickAck(settings) settings->flags_extend2 |= FLAG_TCPQUICKACK
+#define setWorkingLoadUp(settings) settings->flags_extend2 |= FLAG_WORKING_LOAD_UP
+#define setWorkingLoadDown(settings) settings->flags_extend2 |= FLAG_WORKING_LOAD_DOWN
+#define setJitterHistogram(settings) settings->flags_extend2 |= FLAG_JITTER_HISTOGRAM
+#define setUTC(settings) settings->flags_extend2 |= FLAG_UTC
+
+#define unsetBuflenSet(settings) settings->flags &= ~FLAG_BUFLENSET
+#define unsetCompat(settings) settings->flags &= ~FLAG_COMPAT
+#define unsetDaemon(settings) settings->flags &= ~FLAG_DAEMON
+#define unsetIPV6(settings) settings->flags &= ~FLAG_DOMAINV6
+#define unsetIPV4(settings) settings->flags_extend2 &= ~FLAG_DOMAINV4
+#define unsetFileInput(settings) settings->flags &= ~FLAG_FILEINPUT
+#define unsetNoDelay(settings) settings->flags &= ~FLAG_NODELAY
+#define unsetPrintMSS(settings) settings->flags &= ~FLAG_PRINTMSS
+#define unsetRemoveService(settings) settings->flags &= ~FLAG_REMOVESERVICE
+#define unsetSTDIN(settings) settings->flags &= ~FLAG_STDIN
+#define unsetSTDOUT(settings) settings->flags &= ~FLAG_STDOUT
+#define unsetSuggestWin(settings) settings->flags &= ~FLAG_SUGGESTWIN
+#define unsetUDP(settings) settings->flags &= ~FLAG_UDP
+#define unsetModeTime(settings) settings->flags &= ~FLAG_MODETIME
+#define unsetReport(settings) settings->flags &= ~FLAG_REPORTSETTINGS
+#define unsetMulticast(settings) settings->flags &= ~FLAG_MULTICAST
+#define unsetSSMMulticast(settings) settings->flags &= ~FLAG_SSM_MULTICAST
+#define unsetNoSettReport(settings) settings->flags &= ~FLAG_NOSETTREPORT
+#define unsetNoConnReport(settings) settings->flags &= ~FLAG_NOCONNREPORT
+#define unsetNoDataReport(settings) settings->flags &= ~FLAG_NODATAREPORT
+#define unsetNoServReport(settings) settings->flags &= ~FLAG_NOSERVREPORT
+#define unsetNoMultReport(settings) settings->flags &= ~FLAG_NOMULTREPORT
+#define unsetSingleClient(settings) settings->flags &= ~FLAG_SINGLECLIENT
+#define unsetSingleUDP(settings) settings->flags &= ~FLAG_SINGLEUDP
+#define unsetCongestionControl(settings) settings->flags &= ~FLAG_CONGESTION
+#define unsetRealtime(settings) settings->flags &= ~FLAG_REALTIME
+#define unsetBWSet(settings) settings->flags &= ~FLAG_BWSET
+#define unsetEnhanced(settings) settings->flags &= ~FLAG_ENHANCEDREPORT
+#define unsetServerModeTime(settings) settings->flags &= ~FLAG_SERVERMODETIME
+#define unsetPeerVerDetect(settings) settings->flags_extend &= ~FLAG_PEERVER
+#define unsetSeqNo64b(settings) settings->flags_extend &= ~FLAG_SEQNO64
+#define unsetReverse(settings) settings->flags_extend &= ~FLAG_REVERSE
+#define unsetFullDuplex(settings) settings->flags_extend &= ~FLAG_FULLDUPLEX
+#define unsetServerReverse(settings) settings->flags_extend &= ~FLAG_SERVERREVERSE
+#define unsetIsochronous(settings) settings->flags_extend &= ~FLAG_ISOCHRONOUS
+#define unsetHistogram(settings) settings->flags_extend &= ~FLAG_HISTOGRAM
+#define unsetL2LengthCheck(settings) settings->flags_extend &= ~FLAG_L2LENGTHCHECK
+#define unsetIncrDstIP(settings) settings->flags_extend &= ~FLAG_INCRDSTIP
+#define unsetIncrSrcIP(settings) settings->flags_extend &= ~FLAG_INCRSRCIP
+#define unsetIncrDstPort(settings) settings->flags_extend &= ~FLAG_INCRDSTPORT
+#define unsetIncrSrcPort(settings) settings->flags_extend2 &= ~FLAG_INCRSRCPORT
+#define unsetTxStartTime(settings) settings->flags_extend &= ~FLAG_TXSTARTTIME
+#define unsetTxHoldback(settings) settings->flags_extend &= ~FLAG_TXHOLDBACK
+#define unsetVaryLoad(settings) settings->flags_extend &= ~FLAG_VARYLOAD
+#define unsetFQPacing(settings) settings->flags_extend &= ~FLAG_FQPACING
+#define unsetTripTime(settings) settings->flags_extend &= ~FLAG_TRIPTIME
+#define unsetSmallTripTime(settings) settings->flags_extend2 &= ~FLAG_SMALLTRIPTIME
+#define unsetModeInfinite(settings) settings->flags_extend &= ~FLAG_MODEINFINITE
+#define unsetConnectOnly(settings) settings->flags_extend &= ~FLAG_CONNECTONLY
+#define unsetWriteAck(settings) settings->flags_extend &= ~FLAG_WRITEACK
+#define unsetNoUDPfin(settings) settings->flags_extend &= ~FLAG_NOUDPFIN
+#define unsetNoConnectSync(settings) settings->flags_extend &= ~FLAG_NOCONNECTSYNC
+#define unsetSumOnly(settings) settings->flags_extend &= ~FLAG_SUMONLY
+#define unsetFrameInterval(settings) settings->flags_extend &= ~FLAG_FRAMEINTERVAL
+#define unsetIPG(settings) settings->flags_extend &= ~FLAG_IPG
+#define unsetDontRoute(settings) settings->flags_extend &= ~FLAG_DONTROUTE
+#define unsetPermitKey(settings) settings->flags_extend &= ~FLAG_PERMITKEY
+#define unsetTCPMSS(settings) settings->flags_extend &= ~FLAG_SETTCPMSS
+#define unsetPeriodicBurst(settings) settings->flags_extend2 &= ~FLAG_PERIODICBURST
+#define unsetSumServerDstIP(settings) settings->flags_extend2 &= ~FLAG_SUMDSTIP
+#define unsetRxClamp(settings) settings->flags_extend2 &= ~FLAG_RXCLAMP
+#define unsetWritePrefetch(settings) settings->flags_extend2 &= ~FLAG_WRITEPREFETCH
+#define unsetTapDev(settings) settings->flags_extend2 &= ~FLAG_TAPDEV
+#define unsetTunDev(settings) settings->flags_extend2 &= ~FLAG_TUNDEV
+#define unsetHideIPs(settings) settings->flags_extend2 &= ~FLAG_HIDEIPS
+#define unsetBounceBack(settings) settings->flags_extend2 &= ~FLAG_BOUNCEBACK
+#define unsetTcpWriteTimes(settings) settings->flags_extend2 &= ~FLAG_TCPWRITETIMES
+#define unsetOverrideTOS(settings) settings->flags_extend2 &= ~FLAG_OVERRIDETOS
+#define unsetTcpQuickAck(settings) settings->flags_extend2 &= ~FLAG_TCPQUICKACK
+#define unsetWorkingLoadUp(settings) settings->flags_extend2 &= ~FLAG_WORKING_LOAD_UP
+#define unsetWorkingLoadDown(settings) settings->flags_extend2 &= ~FLAG_WORKING_LOAD_DOWN
+#define unsetJitterHistogram(settings) settings->flags_extend2 &= ~FLAG_JITTER_HISTOGRAM
+#define unsetUTC(settings) settings->flags_extend2 &= ~FLAG_UTC
+
+// set to defaults
+void Settings_Initialize(struct thread_Settings* main);
+
+// copy structure
+void Settings_Copy(struct thread_Settings* from, struct thread_Settings** into, int copyall);
+
+// free associated memory
+void Settings_Destroy(struct thread_Settings *mSettings);
+
+// parse settings from user's environment variables
+void Settings_ParseEnvironment(struct thread_Settings *mSettings);
+
+// parse settings from app's command line
+void Settings_ParseCommandLine(int argc, char **argv, struct thread_Settings *mSettings);
+
+// convert to lower case for [KMG]bits/sec
+void Settings_GetLowerCaseArg(const char *,char *);
+
+// convert to upper case for [KMG]bytes/sec
+void Settings_GetUpperCaseArg(const char *,char *);
+
+// generate settings for listener instance
+void Settings_GenerateListenerSettings(struct thread_Settings *client, struct thread_Settings **listener);
+
+// generate settings for speaker instance
+void Settings_GenerateClientSettings(struct thread_Settings *server, struct thread_Settings **client, void * mBuf);
+
+// generate client header for server
+int Settings_GenerateClientHdr(struct thread_Settings *client, void * hdr, struct timeval startTime);
+
+int Settings_ClientTestHdrLen(uint32_t flags, struct thread_Settings *inSettings);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif // SETTINGS_H
diff --git a/include/SocketAddr.h b/include/SocketAddr.h
new file mode 100644
index 0000000..be391a8
--- /dev/null
+++ b/include/SocketAddr.h
@@ -0,0 +1,119 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Socket.cpp
+ * by Ajay Tirumala <tirumala@ncsa.uiuc.edu>
+ * and Mark Gates <mgates@nlanr.net>
+ * ------------------------------------------------------------------- */
+
+
+#ifndef SOCKET_ADDR_H
+#define SOCKET_ADDR_H
+
+#include "headers.h"
+#include "Settings.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* ------------------------------------------------------------------- */
+void SockAddr_localAddr(struct thread_Settings *inSettings);
+void SockAddr_remoteAddr(struct thread_Settings *inSettings);
+
+void SockAddr_setHostname(const char* inHostname,
+ iperf_sockaddr *inSockAddr,
+ int isIPv6); // DNS lookup
+void SockAddr_getHostname(iperf_sockaddr *inSockAddr,
+ char* outHostname,
+ size_t len); // reverse DNS lookup
+void SockAddr_getHostAddress(iperf_sockaddr *inSockAddr,
+ char* outAddress,
+ size_t len); // dotted decimal
+
+void SockAddr_setPort(iperf_sockaddr *inSockAddr, unsigned short inPort);
+void SockAddr_setPortAny(iperf_sockaddr *inSockAddr);
+unsigned short SockAddr_getPort(iperf_sockaddr *inSockAddr);
+
+void SockAddr_setAddressAny(iperf_sockaddr *inSockAddr);
+
+// return pointer to the struct in_addr
+struct in_addr* SockAddr_get_in_addr(iperf_sockaddr *inSockAddr);
+#if HAVE_IPV6
+// return pointer to the struct in_addr
+struct in6_addr* SockAddr_get_in6_addr(iperf_sockaddr *inSockAddr);
+#endif
+// return the sizeof the addess structure (struct sockaddr_in)
+Socklen_t SockAddr_get_sizeof_sockaddr(iperf_sockaddr *inSockAddr);
+
+int SockAddr_isMulticast(iperf_sockaddr *inSockAddr);
+int SockAddr_isLinklocal(iperf_sockaddr *inSockAddr);
+
+int SockAddr_isIPv6(iperf_sockaddr *inSockAddr);
+
+int SockAddr_are_Equal(iperf_sockaddr *first, iperf_sockaddr *second);
+int SockAddr_Hostare_Equal(iperf_sockaddr *first, iperf_sockaddr *second);
+
+void SockAddr_zeroAddress(iperf_sockaddr *inSockAddr);
+int SockAddr_isZeroAddress(iperf_sockaddr *inSockAddr);
+void SockAddr_incrAddress(iperf_sockaddr *inSockAddr, int value);
+int SockAddr_Ifrname(struct thread_Settings *inSettings);
+#ifdef HAVE_LINUX_FILTER_H
+int SockAddr_v4_Accept_BPF(int socket, uint16_t port);
+int SockAddr_Accept_v4_TAP_BPF(int socket, uint32_t dstip, uint16_t port);
+int SockAddr_Drop_All_BPF(int socket);
+int SockAddr_v4_Connect_BPF(int socket, uint32_t dstip, uint32_t srcip, uint16_t dstport, uint16_t srcport);
+int SockAddr_v4_Connect_TAP_BPF(int socket, uint32_t dstip, uint32_t srcip, uint16_t dstport, uint16_t srcport);
+int SockAddr_v4_Connect_BPF_Drop(int socket, uint32_t dstip, uint32_t srcip, uint16_t dstport, uint16_t srcport);
+# if HAVE_IPV6
+int SockAddr_v6_Connect_BPF (int sock, struct in6_addr *dst, struct in6_addr *src, uint16_t dstport, uint16_t srcport);
+# endif // v6
+#endif // linux_filter
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* SOCKET_ADDR_H */
diff --git a/include/Thread.h b/include/Thread.h
new file mode 100644
index 0000000..f439a6a
--- /dev/null
+++ b/include/Thread.h
@@ -0,0 +1,176 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Thread.h
+ * by Kevin Gibbs <kgibbs@nlanr.net>
+ *
+ * Based on:
+ * Thread.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * The thread subsystem is responsible for all thread functions. It
+ * provides a thread implementation agnostic interface to Iperf. If
+ * threads are not available (HAVE_THREAD is undefined), thread_start
+ * does not start a new thread but just launches the specified object
+ * in the current thread. Everything that defines a thread of
+ * execution in Iperf is contained in an thread_Settings structure. To
+ * start a thread simply pass one such structure into thread_start.
+ * ------------------------------------------------------------------- */
+
+#ifndef THREAD_H
+#define THREAD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined(HAVE_POSIX_THREAD)
+
+/* Definitions for Posix Threads (pthreads) */
+#include <pthread.h>
+
+typedef pthread_t nthread_t;
+
+#define HAVE_THREAD 1
+
+#elif defined(HAVE_WIN32_THREAD)
+
+/* Definitions for Win32 NT Threads */
+typedef DWORD nthread_t;
+
+#define HAVE_THREAD 1
+
+#else
+
+/* Definitions for no threads */
+typedef int nthread_t;
+
+#undef HAVE_THREAD
+
+#endif
+
+// Forward declaration
+struct thread_Settings;
+
+#include "Condition.h"
+#include "Settings.hpp"
+
+#if HAVE_THREAD_DEBUG
+struct ReportHeader;
+void reporttype_text(struct ReportHeader *reporthdr, char *rs);
+void thread_debug(const char *format, ...);
+extern Mutex thread_debug_mutex;
+extern Mutex packetringdebug_mutex;
+#endif
+// initialize or destroy the thread subsystem
+void thread_init();
+void thread_destroy();
+
+// start or stop a thread executing
+void thread_start_all(struct thread_Settings* thread);
+void thread_start(struct thread_Settings* thread);
+void thread_stop(struct thread_Settings* thread);
+
+/* wait for this or all threads to complete */
+void thread_joinall(void);
+int thread_numuserthreads(void);
+int thread_numtrafficthreads(void);
+
+// set a thread to be ignorable, so joinall won't wait on it
+void thread_setignore(void);
+void thread_unsetignore(void);
+
+// Used for threads that may never terminate (ie Listener Thread)
+void thread_register_nonterm(void);
+void thread_unregister_nonterm(void);
+int thread_release_nonterm(int interrupt);
+
+/* -------------------------------------------------------------------
+ * Return the current thread's ID.
+ * ------------------------------------------------------------------- */
+#if defined(HAVE_POSIX_THREAD)
+#define thread_getid() pthread_self()
+#elif defined(HAVE_WIN32_THREAD)
+#define thread_getid() GetCurrentThreadId()
+#else
+#define thread_getid() 0
+#endif
+
+int thread_equalid(nthread_t inLeft, nthread_t inRight);
+
+nthread_t thread_zeroid(void);
+
+#if defined(HAVE_WIN32_THREAD)
+DWORD WINAPI thread_run_wrapper(void* paramPtr);
+#else
+void*thread_run_wrapper(void* paramPtr);
+#endif
+
+#if HAVE_SCHED_SETSCHEDULER
+void thread_setscheduler(struct thread_Settings *thread);
+#endif
+
+void thread_rest (void);
+
+// defined in launch.cpp
+void server_spawn(struct thread_Settings* thread);
+void client_spawn(struct thread_Settings* thread);
+void client_init(struct thread_Settings* clients);
+void listener_spawn(struct thread_Settings* thread);
+void listeners_init(struct thread_Settings* listeners);
+void writeack_server_spawn(struct thread_Settings* thread);
+void writeack_client_spawn(struct thread_Settings* thread);
+int fullduplex_start_barrier(struct BarrierMutex *barrier);
+int fullduplex_stop_barrier(struct BarrierMutex *barrier);
+
+// defined in reporter.c
+void reporter_spawn(struct thread_Settings* thread);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+#endif // THREAD_H
diff --git a/include/Timestamp.hpp b/include/Timestamp.hpp
new file mode 100644
index 0000000..e0c9f29
--- /dev/null
+++ b/include/Timestamp.hpp
@@ -0,0 +1,308 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * Timestamp.hpp
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * A generic interface to a timestamp.
+ * This implementation uses the unix gettimeofday().
+ * -------------------------------------------------------------------
+ * headers
+ * uses
+ * <sys/types.h>
+ * <sys/time.h>
+ * <unistd.h>
+ * ------------------------------------------------------------------- */
+
+#ifndef TIMESTAMP_H
+#define TIMESTAMP_H
+
+#include "headers.h"
+
+/* ------------------------------------------------------------------- */
+class Timestamp {
+public:
+ /* -------------------------------------------------------------------
+ * Create a timestamp, with the current time in it.
+ * ------------------------------------------------------------------- */
+ Timestamp(void) {
+ setnow();
+ }
+
+ /* -------------------------------------------------------------------
+ * Copy construcutor
+ * ------------------------------------------------------------------- */
+ Timestamp(const Timestamp &t2) {
+ mTime.tv_sec = t2.mTime.tv_sec;
+ mTime.tv_usec = t2.mTime.tv_usec;
+ }
+
+ /* -------------------------------------------------------------------
+ * Create a timestamp, with the given seconds/microseconds
+ * ------------------------------------------------------------------- */
+ Timestamp(long sec, long usec) {
+ set(sec, usec);
+ }
+
+ /* -------------------------------------------------------------------
+ * Create a timestamp, with the given seconds
+ * ------------------------------------------------------------------- */
+ Timestamp(double sec) {
+ set(sec);
+ }
+
+ /* -------------------------------------------------------------------
+ * Set timestamp to current time.
+ * ------------------------------------------------------------------- */
+ void inline setnow(void) {
+#ifdef HAVE_CLOCK_GETTIME
+ struct timespec t1;
+ clock_gettime(CLOCK_REALTIME, &t1);
+ mTime.tv_sec = t1.tv_sec;
+ mTime.tv_usec = t1.tv_nsec / 1000;
+#else
+ gettimeofday(&mTime, NULL);
+#endif
+ }
+
+ /* -------------------------------------------------------------------
+ * Set timestamp to the given seconds/microseconds
+ * ------------------------------------------------------------------- */
+ void set(long sec, long usec) {
+ assert(sec >= 0);
+ assert(usec >= 0 && usec < kMillion);
+
+ mTime.tv_sec = sec;
+ mTime.tv_usec = usec;
+ }
+
+ /* -------------------------------------------------------------------
+ * Set timestamp to the given seconds
+ * ------------------------------------------------------------------- */
+ void set(double sec) {
+ mTime.tv_sec = (long) sec;
+ mTime.tv_usec = (long) ((sec - mTime.tv_sec) * kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * return seconds portion of timestamp
+ * ------------------------------------------------------------------- */
+ long inline getSecs(void) {
+ return mTime.tv_sec;
+ }
+
+ /* -------------------------------------------------------------------
+ * return microseconds portion of timestamp
+ * ------------------------------------------------------------------- */
+ long inline getUsecs(void) {
+ return mTime.tv_usec;
+ }
+
+ /* -------------------------------------------------------------------
+ * return timestamp as a floating point seconds
+ * ------------------------------------------------------------------- */
+ double get(void) {
+ return mTime.tv_sec + mTime.tv_usec / ((double) kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * subtract the right timestamp from my timestamp.
+ * return the difference in microseconds.
+ * ------------------------------------------------------------------- */
+ long subUsec(Timestamp right) {
+ return(mTime.tv_sec - right.mTime.tv_sec) * kMillion +
+ (mTime.tv_usec - right.mTime.tv_usec);
+ }
+
+ /* -------------------------------------------------------------------
+ * subtract the right timestamp from my timestamp.
+ * return the difference in microseconds.
+ * ------------------------------------------------------------------- */
+ long subUsec(timeval right) {
+ return(mTime.tv_sec - right.tv_sec) * kMillion +
+ (mTime.tv_usec - right.tv_usec);
+ }
+
+ /* -------------------------------------------------------------------
+ * subtract my timestamp from the right timestamp
+ * return the difference in microseconds.
+ * ------------------------------------------------------------------- */
+ long mysubUsec(timeval right) {
+ return(right.tv_sec - mTime.tv_sec) * kMillion +
+ (right.tv_usec - mTime.tv_usec);
+ }
+
+ /* -------------------------------------------------------------------
+ * Return the number of microseconds from now to last time of setting.
+ * ------------------------------------------------------------------- */
+ long delta_usec(void) {
+ struct timeval previous = mTime;
+ setnow();
+ return subUsec(previous);
+ }
+
+ /* -------------------------------------------------------------------
+ * subtract the right timestamp from my timestamp.
+ * return the difference in seconds as a floating point.
+ * ------------------------------------------------------------------- */
+ double subSec(Timestamp right) {
+ return(mTime.tv_sec - right.mTime.tv_sec) +
+ (mTime.tv_usec - right.mTime.tv_usec) / ((double) kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * add the right timestamp to my timestamp.
+ * ------------------------------------------------------------------- */
+ void add(Timestamp right) {
+ mTime.tv_sec += right.mTime.tv_sec;
+ mTime.tv_usec += right.mTime.tv_usec;
+
+ // watch for under- and overflow
+ if (mTime.tv_usec < 0) {
+ mTime.tv_usec += kMillion;
+ mTime.tv_sec--;
+ }
+ if (mTime.tv_usec >= kMillion) {
+ mTime.tv_usec -= kMillion;
+ mTime.tv_sec++;
+ }
+
+ assert(mTime.tv_usec >= 0 &&
+ mTime.tv_usec < kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * add the right timestamp to my timestamp.
+ * ------------------------------------------------------------------- */
+ void add (struct timeval *right) {
+ mTime.tv_sec += right->tv_sec;
+ mTime.tv_usec += right->tv_usec;
+
+ // watch for under- and overflow
+ if (mTime.tv_usec < 0) {
+ mTime.tv_usec += kMillion;
+ mTime.tv_sec--;
+ }
+ if (mTime.tv_usec >= kMillion) {
+ mTime.tv_usec -= kMillion;
+ mTime.tv_sec++;
+ }
+
+ assert(mTime.tv_usec >= 0 &&
+ mTime.tv_usec < kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * add the seconds to my timestamp.
+ * TODO optimize?
+ * ------------------------------------------------------------------- */
+ void add(double sec) {
+ mTime.tv_sec += (long) sec;
+ mTime.tv_usec += (long) ((sec - ((long) sec)) * kMillion);
+
+ // watch for overflow
+ if (mTime.tv_usec >= kMillion) {
+ mTime.tv_usec -= kMillion;
+ mTime.tv_sec++;
+ }
+
+ assert(mTime.tv_usec >= 0 &&
+ mTime.tv_usec < kMillion);
+ }
+
+ /* -------------------------------------------------------------------
+ * add micro seconds to my timestamp.
+ * ------------------------------------------------------------------- */
+ void add(unsigned int usec) {
+ mTime.tv_usec += usec;
+ mTime.tv_sec += mTime.tv_usec / kMillion;
+ mTime.tv_usec = mTime.tv_usec % kMillion;
+ // assert((mTime.tv_usec >= 0) && (mTime.tv_usec < kMillion));
+ }
+
+ /* -------------------------------------------------------------------
+ * return true if my timestamp is before the right timestamp.
+ * ------------------------------------------------------------------- */
+ bool before(timeval right) {
+ return mTime.tv_sec < right.tv_sec ||
+ (mTime.tv_sec == right.tv_sec &&
+ mTime.tv_usec < right.tv_usec);
+ }
+ bool before(Timestamp right) { return before(right.mTime); }
+
+ /* -------------------------------------------------------------------
+ * return true if my timestamp is after the right timestamp.
+ * ------------------------------------------------------------------- */
+ bool after(timeval right) {
+ return mTime.tv_sec > right.tv_sec ||
+ (mTime.tv_sec == right.tv_sec &&
+ mTime.tv_usec > right.tv_usec);
+ }
+ bool after(Timestamp right) { return after(right.mTime); }
+
+ /**
+ * This function returns the fraction of time elapsed after the beginning
+ * till the end
+ */
+ double fraction(Timestamp currentTime, Timestamp endTime) {
+ if ((currentTime.after(*this)) && (endTime.after(currentTime))) {
+ return(((double)currentTime.subUsec(*this)) /
+ ((double)endTime.subUsec(*this)));
+ } else {
+ return -1.0;
+ }
+ }
+
+protected:
+ enum {
+ kMillion = 1000000
+ };
+
+ struct timeval mTime;
+
+}; // end class Timestamp
+
+#endif // TIMESTAMP_H
diff --git a/include/active_hosts.h b/include/active_hosts.h
new file mode 100644
index 0000000..9635032
--- /dev/null
+++ b/include/active_hosts.h
@@ -0,0 +1,95 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * List.h
+ * by Kevin Gibbs <kgibbs@ncsa.uiuc.edu>
+ *
+ * renamed to active_hosts.h
+ * -------------------------------------------------------------------
+ */
+
+#ifndef Iperf_LIST_H
+#define Iperf_LIST_H
+
+#include "headers.h"
+#include "Settings.hpp"
+#include "Mutex.h"
+
+/*
+ * A List entry that consists of a sockaddr
+ * a pointer to the Audience that sockaddr is
+ * associated with and a pointer to the next
+ * entry
+ */
+struct Iperf_ListEntry {
+ iperf_sockaddr host;
+ struct SumReport *sum_report;
+ int thread_count;
+#if WIN32
+ SOCKET socket;
+#else
+ int socket;
+#endif
+ struct Iperf_ListEntry *next;
+};
+
+struct Iperf_Table {
+ Mutex my_mutex;
+ struct Iperf_ListEntry *root;
+ int count;
+ int total_count;
+ int groupid;
+};
+
+/*
+ * Functions to modify or search the list
+ */
+void Iperf_initialize_active_table (void);
+void Iperf_destroy_active_table (void);
+int Iperf_push_host (struct thread_Settings *agent);
+int Iperf_push_host_port_conditional (struct thread_Settings *agent);
+void Iperf_remove_host (struct thread_Settings *agent);
+#endif
diff --git a/include/checksums.h b/include/checksums.h
new file mode 100644
index 0000000..2b3e594
--- /dev/null
+++ b/include/checksums.h
@@ -0,0 +1,62 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2018
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ *
+ * UDP checksums v4 and v6
+ *
+ * The checksum calculation is defined in RFC 768
+ * hints as to how to calculate it efficiently are in RFC 1071
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+
+#ifndef CHECKSUMS_H
+#define CHECKSUMS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+uint32_t udpchecksum(const void *l3pdu, const void *udp_hdr, int udplen, int v6);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* CHEKCSUMS_H */
diff --git a/include/config.win32.h b/include/config.win32.h
new file mode 100644
index 0000000..d648bf9
--- /dev/null
+++ b/include/config.win32.h
@@ -0,0 +1,82 @@
+/* config.h. Generated by hand for Windows. */
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* ===================================================================
+ * config.h
+ *
+ * config.h is derived from config.h.in -- do not edit config.h
+ *
+ * This contains variables that the configure script checks and
+ * then defines or undefines. The source code checks for these
+ * variables to know if certain features are present.
+ *
+ * by Mark Gates <mgates@nlanr.net>
+ *
+ * Copyright 1999 The Board of Trustees of the University of Illinois
+ * All rights reserved. See doc/license.txt for complete text.
+ *
+ * $Id: config.win32.h,v 1.1.1.1 2004/05/18 01:50:44 kgibbs Exp $
+ * =================================================================== */
+
+/* Define if threads exist (using pthreads or Win32 threads) */
+/* #undef HAVE_POSIX_THREAD */
+#define HAVE_WIN32_THREAD 1
+/* #undef _REENTRANT */
+
+/* Define if on OSF1 and need special extern "C" around some header files */
+/* #undef SPECIAL_OSF1_EXTERN */
+
+/* Define if the strings.h header file exists */
+/* #undef HAVE_STRINGS_H */
+
+/* Define the intXX_t, u_intXX_t, size_t, ssize_t, and socklen_t types */
+/* On the Cray J90 there is no 4 byte integer, so we define int32_t
+ * but it is 8 bytes, and we leave HAVE_INT32_T undefined. */
+#define SIZEOF_INT 4
+#define HAVE_U_INT16_T 1
+#define HAVE_INT32_T 1
+#define HAVE_INT64_T 1
+#define HAVE_U_INT32_T 1
+
+#define int32_t LONG32
+#define u_int16_t UINT16
+#define u_int32_t ULONG32
+/* #undef size_t */
+#define ssize_t int
+
+/* socklen_t usually defined in <sys/socket.h>. Unfortunately it doesn't
+ * work on some systems (like DEC OSF/1), so we'll use our own Socklen_t */
+#define Socklen_t int
+
+/* Define if you have these functions. */
+#define HAVE_SNPRINTF 1
+/* #undef HAVE_INET_PTON */
+/* #undef HAVE_INET_NTOP */
+/* #undef HAVE_GETTIMEOFDAY */
+/* #undef HAVE_PTHREAD_CANCEL */
+#define HAVE_USLEEP 1
+/* #undef HAVE_QUAD_SUPPORT */
+/* #undef HAVE_PRINTF_QD */
+
+/* standard C++, which isn't always... */
+/* #undef bool */
+#define true 1
+#define false 0
+
+/* Define if the host is Big Endian (network byte order) */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define if multicast support exists */
+#define HAVE_MULTICAST 1
+
+/* Define if all IPv6 headers/structures are present */
+#define HAVE_IPV6 1
+
+/* Define if IPv6 multicast support exists */
+#define HAVE_IPV6_MULTICAST 1
+
+/* Define if Debugging of sockets is desired */
+/* #undef DBG_MJZ */
+
+#endif /* CONFIG_H */
diff --git a/include/delay.h b/include/delay.h
new file mode 100644
index 0000000..fee44c0
--- /dev/null
+++ b/include/delay.h
@@ -0,0 +1,78 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * delay.h
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * accurate microsecond delay
+ * ------------------------------------------------------------------- */
+#ifndef DELAY_H
+#define DELAY_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <time.h>
+void delay_loop( unsigned long usecs );
+void delay_busyloop(unsigned long usecs);
+void delay_nanosleep(unsigned long usecs);
+int clock_usleep(struct timeval *request);
+int clock_usleep_abstime(struct timeval *request);
+#ifdef HAVE_KALMAN
+// Kalman filter states
+struct kalman_state {
+ double q; //process noise covariance
+ double r; //measurement noise covariance
+ double x; //value
+ double p; //estimation error covariance
+ double k; //kalman gain
+};
+void delay_kalman(unsigned long usecs);
+#endif
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* DELAY_H */
diff --git a/include/dscp.h b/include/dscp.h
new file mode 100644
index 0000000..fe5486e
--- /dev/null
+++ b/include/dscp.h
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2022
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * Header file for dscp parsing
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * ------------------------------------------------------------------- */
+
+#ifndef DSCP_H
+#define DSCP_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+int parse_ipqos(const char *cp);
+const char * iptos2str(int iptos);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* DSCP_H */
diff --git a/include/gettcpinfo.h b/include/gettcpinfo.h
new file mode 100644
index 0000000..995ee20
--- /dev/null
+++ b/include/gettcpinfo.h
@@ -0,0 +1,82 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2021
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * gettcpinfo.c
+ * Suppport for tcp info in a portable way
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef GETTCPINFO_H
+#define GETTCPINFO_H
+
+#include "headers.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct iperf_tcpstats {
+ bool isValid;
+ int rtt;
+ double connecttime;
+#if HAVE_TCP_STATS
+ int cwnd;
+ int rttvar;
+ intmax_t retry;
+ intmax_t retry_prev;
+ intmax_t retry_tot;
+ int mss_negotiated;
+#endif
+};
+
+#if WIN32
+void gettcpinfo(SOCKET sock, struct iperf_tcpstats *sample);
+#else
+void gettcpinfo(int sock, struct iperf_tcpstats *sample);
+#endif
+void tcpstats_copy (struct iperf_tcpstats *stats_dst, struct iperf_tcpstats *stats_src);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif
diff --git a/include/gettimeofday.h b/include/gettimeofday.h
new file mode 100644
index 0000000..56b0d89
--- /dev/null
+++ b/include/gettimeofday.h
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * gettimeofday.h
+ *
+ * Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * An implementation of gettimeofday for Windows.
+ * ------------------------------------------------------------------- */
+
+#ifndef GETTIMEOFDAY_H
+#define GETTIMEOFDAY_H
+
+#ifndef HAVE_GETTIMEOFDAY
+
+ #ifdef __cplusplus
+extern "C" {
+#endif
+
+int gettimeofday( struct timeval* tv, void* timezone );
+
+#ifdef __cplusplus
+} /* end extern "C" */
+ #endif
+
+#else
+#include <sys/time.h>
+#endif /* HAVE_GETTIMEOFDAY */
+#endif /* GETTIMEOFDAY_H */
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/gnu_getopt.h b/include/gnu_getopt.h
new file mode 100644
index 0000000..de8ba9f
--- /dev/null
+++ b/include/gnu_getopt.h
@@ -0,0 +1,136 @@
+/* Declarations for gnu_getopt.
+ Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in /gd/gnu/lib.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * modified July 9, 1999 by mark gates <mgates@nlanr.net>
+ * Dec 17, 1999
+ *
+ * renamed all functions and variables by prepending "gnu_"
+ * removed/redid a bunch of stuff under the assumption we're
+ * using a modern standard C compiler.
+ *
+ * $Id: gnu_getopt.h,v 1.1.1.1 2004/05/18 01:50:44 kgibbs Exp $
+ */
+
+#ifndef _GETOPT_H
+ #define _GETOPT_H 1
+
+ #ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `gnu_getopt' to the caller.
+ When `gnu_getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *gnu_optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `gnu_getopt'.
+
+ On entry to `gnu_getopt', zero means this is the first call; initialize.
+
+ When `gnu_getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `gnu_optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int gnu_optind;
+
+/* Callers store zero here to inhibit the error message `gnu_getopt' prints
+ for unrecognized options. */
+
+extern int gnu_opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int gnu_optopt;
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to gnu_getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `gnu_optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `gnu_getopt'
+ returns the contents of the `val' field. */
+
+/* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+
+struct option {
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+int gnu_getopt( int argc,
+ char *const *argv,
+ const char *optstring );
+
+int gnu_getopt_long( int argc,
+ char *const *argv,
+ const char *options,
+ const struct option *long_options,
+ int *opt_index );
+
+int gnu_getopt_long_only( int argc,
+ char *const *argv,
+ const char *options,
+ const struct option *long_options,
+ int *opt_index );
+
+/* Internal only. Users should not call this directly. */
+int _gnu_getopt_internal( int argc,
+ char *const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longind,
+ int long_only );
+
+#ifdef __cplusplus
+} /* end extern "C" */
+ #endif
+
+#endif /* _GETOPT_H */
diff --git a/include/headers.h b/include/headers.h
new file mode 100644
index 0000000..6fb499d
--- /dev/null
+++ b/include/headers.h
@@ -0,0 +1,302 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * headers.h
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * All system headers required by iperf.
+ * This could be processed to form a single precompiled header,
+ * to avoid overhead of compiling it multiple times.
+ * This also verifies a few things are defined, for portability.
+ * ------------------------------------------------------------------- */
+
+#ifndef HEADERS_H
+#define HEADERS_H
+
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+
+/* OSF1 (at least the system I use) needs extern C
+ * around the <netdb.h> and <arpa/inet.h> files. */
+ #if defined( SPECIAL_OSF1_EXTERN ) && defined( __cplusplus )
+ #define SPECIAL_OSF1_EXTERN_C_START extern "C" {
+ #define SPECIAL_OSF1_EXTERN_C_STOP }
+ #else
+ #define SPECIAL_OSF1_EXTERN_C_START
+ #define SPECIAL_OSF1_EXTERN_C_STOP
+ #endif
+#endif /* HAVE_CONFIG_H */
+
+/* standard C headers */
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+#include <float.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <limits.h>
+
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+# ifndef HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+# define _Bool signed char
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+#endif
+
+
+// v4: 1470 bytes UDP payload will fill one and only one ethernet datagram (IPv4 overhead is 20 bytes)
+#define kDefault_UDPBufLen 1470
+// v6: 1450 bytes UDP payload will fill one and only one ethernet datagram (IPv6 overhead is 40 bytes)
+#define kDefault_UDPBufLenV6 1450
+#define IPV4HDRLEN 20
+#define IPV6HDRLEN 40
+#define UDPHDRLEN 8
+
+#if ((defined HAVE_SSM_MULTICAST) || (defined HAVE_DECL_SO_BINDTODEVICE)) && (defined HAVE_NET_IF_H)
+#include <net/if.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
+#ifdef HAVE_LINUX_SOCKIOS_H
+#include <linux/sockios.h>
+#endif
+#if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET)
+#include <net/ethernet.h>
+#endif
+#if ((HAVE_TUNTAP_TAP) || (HAVE_TUNTAP_TUN))
+#include <linux/if_tun.h>
+#endif
+
+// AF_PACKET HEADERS
+#if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET)
+// Bummer, AF_PACKET requires kernel headers as <netpacket/packet.h> isn't sufficient
+#include <linux/filter.h>
+#include <linux/if_packet.h>
+#include <linux/ip.h>
+#include <linux/udp.h>
+// In older linux kernels, the kernel headers and glibc headers are in conflict,
+// specificially <linux/in6.h> and <netinit/in.h>
+// preventing the following include:
+// #include <linux/ipv6.h> (which includes <linux/in6.h>)
+// and the use of sizeof(struct ipv6hdr)
+//
+// See https://patchwork.ozlabs.org/patch/631400/
+//
+// "In upstream kernel 56c176c9 the _UAPI prefix was stripped and
+// this broke our synchronized headers again. We now need to check
+// for _LINUX_IN6_H and _IPV6_H, and keep checking the old versions
+// of the header guard checks for maximum backwards compatibility
+// with older Linux headers (the history is actually a bit muddled
+// here and it appears upstream linus kernel broke this 10 months
+// *before* our fix was ever applied to glibc, but without glibc
+// testing we didn't notice and distro kernels have their own
+// testing to fix this)."
+//
+// The use cases fixed by this patch are:
+// #include <linux/in6.h>
+// #include <netinet/in.h>
+//
+// force the ipv6hdr length to 40 vs use of sizeof(struct ipv6hdr)
+
+#endif // HAVE_AF_PACKET
+
+#ifdef WIN32
+
+/* Windows config file */
+// #include "config.win32.h"
+
+/* Windows headers */
+#ifdef _WIN32_WINNT
+#undef _WIN32_WINNT
+#endif
+ #define _WIN32_WINNT 0x0501 /* use (at least) WinXP API */
+ #define WIN32_LEAN_AND_MEAN /* exclude unnecesary headers */
+ #include <windows.h>
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ #include <process.h>
+
+/* define EINTR, just to help compile; it isn't useful */
+ #ifndef EINTR
+ #define EINTR WSAEINTR
+ #endif // EINTR
+
+/* Visual C++ has INT64, but not 'long long'.
+ * Metrowerks has 'long long', but INT64 doesn't work. */
+ #ifdef __MWERKS__
+ #define int64_t long long
+ #else
+ #define int64_t INT64
+ #endif // __MWERKS__
+
+/* Visual C++ has _snprintf instead of snprintf */
+ #ifndef __MWERKS__
+ #define snprintf _snprintf
+ #endif // __MWERKS__
+
+/* close, read, and write only work on files in Windows.
+ * I get away with #defining them because I don't read files. */
+ #define close( s ) closesocket( s )
+ #define read( s, b, l ) recv( s, (char*) b, l, 0 )
+ #define write( s, b, l ) send( s, (char*) b, l, 0 )
+
+/* usleep is in unistd.h, but that would conflict with the
+close/read/write redefinitin above */
+int usleep(useconds_t usec);
+
+#else /* not defined WIN32 */
+
+/* used in Win32 for error checking,
+ * rather than checking rc < 0 as unix usually does */
+#define SOCKET_ERROR -1
+#define INVALID_SOCKET -1
+
+#include <unistd.h>
+
+#endif /* not defined WIN32 */
+
+/* required on AIX for FD_SET (requires bzero).
+ * often this is the same as <string.h> */
+ #ifdef HAVE_STRINGS_H
+ #include <strings.h>
+ #endif // HAVE_STRINGS_H
+
+/* unix headers */
+#ifdef HAVE_SYS_SOCKET_H
+ #include <sys/socket.h>
+#endif
+ #include <sys/time.h>
+#ifdef HAVE_SIGNAL_H
+ #include <signal.h>
+#endif
+
+#ifdef HAVE_SYSLOG_H
+/** Added for daemonizing the process */
+ #include <syslog.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+SPECIAL_OSF1_EXTERN_C_START
+ #include <netdb.h>
+SPECIAL_OSF1_EXTERN_C_STOP
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+SPECIAL_OSF1_EXTERN_C_START
+ #include <arpa/inet.h> /* netinet/in.h must be before this on SunOS */
+SPECIAL_OSF1_EXTERN_C_STOP
+#endif
+#if HAVE_NETINET_TCP_H
+#include <netinet/tcp.h>
+#endif
+
+#ifdef HAVE_POSIX_THREAD
+#include <pthread.h>
+#endif // HAVE_POSIX_THREAD
+
+#ifndef INET6_ADDRSTRLEN
+ #define INET6_ADDRSTRLEN 40
+#endif
+#ifndef INET_ADDRSTRLEN
+ #define INET_ADDRSTRLEN 15
+#endif
+
+//#ifdef __cplusplus
+ #if HAVE_IPV6
+ #define REPORT_ADDRLEN (INET6_ADDRSTRLEN + 1)
+typedef struct sockaddr_storage iperf_sockaddr;
+ #else
+ #define REPORT_ADDRLEN (INET_ADDRSTRLEN + 1)
+typedef struct sockaddr_in iperf_sockaddr;
+ #endif
+//#endif
+
+// inttypes.h is already included
+
+#ifdef HAVE_FASTSAMPLING
+#define IPERFTimeFrmt "%4.4f-%4.4f"
+#define IPERFTimeSpace " "
+#else
+#define IPERFTimeFrmt "%4.2f-%4.2f"
+#define IPERFTimeSpace " "
+#endif
+
+/* in case the OS doesn't have these, we provide our own implementations */
+#include "gettimeofday.h"
+#include "inet_aton.h"
+#include "snprintf.h"
+
+#ifndef SHUT_RD
+ #define SHUT_RD 0
+ #define SHUT_WR 1
+ #define SHUT_RDWR 2
+#endif // SHUT_RD
+
+
+/* Internal debug */
+//#define INITIAL_PACKETID 0x7FFFFF00LL
+//#define SHOW_PACKETID
+
+#endif /* HEADERS_H */
diff --git a/include/histogram.h b/include/histogram.h
new file mode 100644
index 0000000..2cd7b3b
--- /dev/null
+++ b/include/histogram.h
@@ -0,0 +1,82 @@
+/*---------------------------------------------------------------
+ * Copyrighta (c) 2017
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * histogram.h
+ * Suppport for isochonronous traffic testing
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef HISTOGRAMC_H
+#define HISTOGRAMC_H
+
+struct histogram {
+ unsigned int id;
+ unsigned int *mybins;
+ unsigned int bincount;
+ unsigned int binwidth;
+ unsigned int populationcnt;
+ int final;
+ int maxbin;
+ int fmaxbin;
+ double maxval;
+ double fmaxval;
+ struct timeval maxts;
+ struct timeval fmaxts;
+ float offset;
+ unsigned int cntloweroutofbounds;
+ unsigned int cntupperoutofbounds;
+ char *myname;
+ char *outbuf;
+ float units;
+ double ci_lower;
+ double ci_upper;
+ struct histogram *prev;
+};
+
+extern struct histogram *histogram_init(unsigned int bincount, unsigned int binwidth, float offset,\
+ float units, double ci_lower, double ci_upper, unsigned int id, char *name);
+extern void histogram_delete(struct histogram *h);
+extern int histogram_insert(struct histogram *h, float value, struct timeval *ts);
+extern void histogram_clear(struct histogram *h);
+extern void histogram_add(struct histogram *to, struct histogram *from);
+extern void histogram_print(struct histogram *h, double, double);
+#endif // HISTOGRAMC_H
diff --git a/include/inet_aton.h b/include/inet_aton.h
new file mode 100644
index 0000000..08b9750
--- /dev/null
+++ b/include/inet_aton.h
@@ -0,0 +1,108 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * inet_aton.h
+ *
+ * Mark Gates <mgates@nlanr.net>
+ * Kevin Gibbs <kgibbs@ncsa.uiuc.edu> Sept. 2002
+ * to use this prototype, make sure HAVE_INET_PTON is not defined
+ * to use this prototype, make sure HAVE_INET_NTOP is not defined
+ *
+ * =================================================================== */
+
+#ifndef INET_ATON_H
+#define INET_ATON_H
+
+
+#include "headers.h"
+
+/*
+ * inet_pton is the new, better version of inet_aton.
+ * inet_aton is not IP version agnostic.
+ * inet_aton is the new, better version of inet_addr.
+ * inet_addr is incorrect in that it returns -1 as an error value,
+ * while -1 (0xFFFFFFFF) is a valid IP address (255.255.255.255).
+ */
+
+const char* inet_ntop_hide(int af, const void *src, char *dst, socklen_t size);
+const char* inet_ntop4_hide(const unsigned char *src, char *dst, socklen_t size);
+
+#ifndef HAVE_INET_NTOP
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+const char* inet_ntop(int af, const void *src, char *dst, socklen_t size);
+const char* inet_ntop4(const unsigned char *src, char *dst, socklen_t size);
+
+#if HAVE_IPV6
+const char* inet_ntop6(const unsigned char *src, char *dst,
+ socklen_t size);
+#endif
+
+
+#ifdef __cplusplus
+} /* end extern "C" */
+ #endif
+
+#endif /* HAVE_INET_NTOP */
+#ifndef HAVE_INET_PTON
+
+ #ifdef __cplusplus
+extern "C" {
+#endif
+int inet_pton(int af, const char *src, void *dst);
+int inet_pton4(const char *src, unsigned char *dst);
+#if HAVE_IPV6
+int inet_pton6(const char *src, unsigned char *dst);
+#endif
+
+#ifdef __cplusplus
+} /* end extern "C" */
+ #endif
+
+#endif /* HAVE_INET_PTON */
+#endif /* INET_ATON_H */
diff --git a/include/iperf_formattime.h b/include/iperf_formattime.h
new file mode 100644
index 0000000..d331550
--- /dev/null
+++ b/include/iperf_formattime.h
@@ -0,0 +1,69 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2023
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * iperf_formattime
+ * wrapper around strftime.c for iperf supported formatting
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef IPERFFORMATTIME_H
+#define IPERFFORMATTIME_H
+
+#include "headers.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum TimeFormatType {
+ YearThruSec = 0,
+ YearThruSecTZ,
+ CSV,
+ CSVTZ
+};
+void iperf_formattime (char *timestr, int buflen, struct timeval timestamp, bool prec_ms, bool utc_time, enum TimeFormatType ftype);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif
diff --git a/include/isochronous.hpp b/include/isochronous.hpp
new file mode 100644
index 0000000..7fb5a92
--- /dev/null
+++ b/include/isochronous.hpp
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2017
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * isochronous.hpp
+ * Suppport for isochonronous traffic testing
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef ISOCHRONOUS_H
+#define ISOCHRONOUS_H
+
+#include <time.h>
+#include "Settings.hpp"
+#include "Timestamp.hpp"
+
+/* ------------------------------------------------------------------- */
+namespace Isochronous {
+ class FrameCounter {
+ public :
+ FrameCounter(double, const Timestamp& start);
+ FrameCounter(double);
+ ~FrameCounter();
+ unsigned int get(void) const;
+ unsigned int get(long *);
+ unsigned int get(const Timestamp&) const;
+ unsigned int period_us(void);
+ unsigned int wait_tick(long *sched_err);
+ unsigned int wait_sync(long sec, long usec);
+ long getSecs(void);
+ long getUsecs(void);
+ void reset(void);
+ Timestamp next_slot(void);
+ unsigned int slip;
+ private :
+ double frequency;
+ Timestamp startTime;
+ Timestamp nextslotTime;
+ unsigned int period; // units microseconds or 100 ns
+ unsigned int lastcounter;
+ unsigned int slot_counter;
+#ifdef WIN32
+ int mySetWaitableTimer (long delay_time);
+ HANDLE my_timer; // Timer handle
+ LARGE_INTEGER delay; // units is 100 nanoseconds
+#endif
+
+ }; // end class FrameCounter
+}
+#endif // ISOCHRONOUS_H
diff --git a/include/packet_ring.h b/include/packet_ring.h
new file mode 100644
index 0000000..3ac6b91
--- /dev/null
+++ b/include/packet_ring.h
@@ -0,0 +1,127 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2019
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * packet_ring.h
+ * Suppport for packet rings between threads
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef PACKETRINGC_H
+#define PACKETRINGC_H
+
+#include "Condition.h"
+#include "gettcpinfo.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ACKRING_DEFAULTSIZE 100
+
+struct ReportStruct {
+ intmax_t packetID;
+ intmax_t packetLen;
+ struct timeval packetTime;
+ struct timeval prevPacketTime;
+ struct timeval sentTime;
+ struct timeval prevSentTime;
+ int errwrite;
+ int emptyreport;
+ int l2errors;
+ int l2len;
+ int expected_l2len;
+ // isochStartTime is overloaded: first write timestamp of the frame or burst w/trip-times or very first read w/o trip-times
+ // reporter calculation will compute latency accordingly
+ struct timeval isochStartTime;
+ uint32_t prevframeID;
+ uint32_t frameID;
+ uint32_t burstsize;
+ uint32_t burstperiod;
+ uint32_t remaining;
+ int transit_ready;
+ int writecnt;
+ long write_time;
+ bool scheduled;
+ long sched_err;
+ struct timeval sentTimeRX;
+ struct timeval sentTimeTX;
+ struct iperf_tcpstats tcpstats;
+};
+
+struct PacketRing {
+ // producer and consumer
+ // must be an atomic type, e.g. int
+ // otherwise reads/write can be torn
+ int producer;
+ int consumer;
+ int maxcount;
+ int consumerdone;
+ int awaitcounter;
+ int mutex_enable;
+ int bytes;
+
+ // Use a condition variables
+ // o) awake_producer - producer waits for the consumer thread to
+ // make space or end (signaled by the consumer)
+ // o) awake_consumer - signal the consumer thread to to run
+ // (signaled by the producer)
+ struct Condition *awake_producer;
+ struct Condition *awake_consumer;
+ struct ReportStruct *data;
+};
+
+extern struct PacketRing * packetring_init(int count, struct Condition *awake_consumer, struct Condition *awake_producer);
+extern void packetring_enqueue(struct PacketRing *pr, struct ReportStruct *metapacket);
+extern struct ReportStruct *packetring_dequeue(struct PacketRing * pr);
+extern void enqueue_ackring(struct PacketRing *pr, struct ReportStruct *metapacket);
+extern struct ReportStruct *dequeue_ackring(struct PacketRing * pr);
+extern void packetring_free(struct PacketRing *pr);
+extern void free_ackring(struct PacketRing *pr);
+#ifdef HAVE_THREAD_DEBUG
+extern int packetring_getcount(struct PacketRing *pr);
+#endif
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif // PACKETRINGC_H
diff --git a/include/payloads.h b/include/payloads.h
new file mode 100644
index 0000000..30080d9
--- /dev/null
+++ b/include/payloads.h
@@ -0,0 +1,622 @@
+/*---------------------------------------------------------------
+ * Copyrighta (c) 2019
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * payloads.h
+ * Iperf 2 packet or socket payloads/protocols
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * -------------------------------------------------------------------
+ */
+#ifndef PAYLOADSC_H
+#define PAYLOADSC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Message header flags
+ */
+
+#define TAPBYTESSLOP 512
+
+/* key for permit */
+#define HEADER_KEYCHECK 0x10000000
+#define HEADER_KEYL1 0x01000000
+#define HEADER_KEYL2 0x02000000
+#define HEADER_KEYLEN_MASK 0x0000FFFE // Lower bit used by V1 hdr
+#define DEFAULT_PERMITKEY_LEN 16
+#define MIN_PERMITKEY_LEN 4
+#define MAX_PERMITKEY_LEN 128
+
+/*
+ * base flags, keep compatible with older versions
+ */
+#define HEADER_VERSION1 0x80000000
+#define HEADER_EXTEND 0x40000000
+#define HEADER_UDPTESTS 0x20000000
+// reserved for keycheck flag 0x10000000
+#define HEADER_SEQNO64B 0x08000000
+#define HEADER_VERSION2 0x04000000
+#define HEADER_V2PEERDETECT 0x02000000
+#define HEADER_UDPAVOID2 0x02000000
+#define HEADER_UDPAVOID1 0x01000000
+#define HEADER_BOUNCEBACK 0x00800000
+
+#define HEADER32_SMALL_TRIPTIMES 0x00020000
+#define HEADER_LEN_BIT 0x00010000
+#define HEADER_LEN_MASK 0x000001FE
+#define MAX_HEADER_LEN 256
+#define SERVER_HEADER_EXTEND 0x40000000
+#define RUN_NOW 0x00000001
+#define HEADER16_SMALL_TRIPTIMES 0x0002 // use is 16 bits and not 32 bits
+
+// Bounceback flag
+#define HEADER_BBQUICKACK 0x8000
+#define HEADER_BBCLOCKSYNCED 0x4000 // used in the bb header only
+#define HEADER_BBTOS 0x2000
+#define HEADER_BBSTOP 0x1000
+
+// newer flags available per HEADER_EXTEND
+// Below flags are used to pass test settings in *every* UDP packet
+// and not just during the header exchange
+#define HEADER_ISOCH 0x0001
+#define HEADER_L2ETHPIPV6 0x0002
+#define HEADER_L2LENCHECK 0x0004
+#define HEADER_NOUDPFIN 0x0008
+#define HEADER_TRIPTIME 0x0010
+#define HEADER_UNUSED2 0x0020
+#define HEADER_ISOCH_SETTINGS 0x0040
+#define HEADER_UNITS_PPS 0x0080
+#define HEADER_BWSET 0x0100
+#define HEADER_FQRATESET 0x0200
+#define HEADER_REVERSE 0x0400
+#define HEADER_FULLDUPLEX 0x0800
+#define HEADER_EPOCH_START 0x1000
+#define HEADER_PERIODICBURST 0x2000
+#define HEADER_WRITEPREFETCH 0x4000
+#define HEADER_TCPQUICKACK 0x8000
+
+// later features
+#define HDRXACKMAX 2500000 // default 2.5 seconds, units microseconds
+#define HDRXACKMIN 10000 // default 10 ms, units microsecond
+/*
+ * Structures used for test messages which
+ * are exchanged between the client and the Server/Listener
+ */
+enum MsgType {
+ CLIENTHDR = 0x1,
+ CLIENTHDRACK,
+ CLIENTTCPHDR,
+ SERVERHDR,
+ SERVERHDRACK
+};
+
+#define MINIPERFPAYLOAD 18
+// Minimum IPv4 frame size = 18 (Ethernet) + 20 (IPv4) + 8 (UDP) + 18 (payload) = 64 bytes
+// Minimum IPv6 frame size = 18 (Ethernet) + 40 (IPv6) + 8 (UDP) + 18 (payload) = 84 bytes
+
+/*
+ * Structures below will be passed as network i/o
+ * between the client, listener and server
+ * and must be packed by the compilers
+ * Align on 32 bits (4 bytes)
+ */
+#pragma pack(push,4)
+struct UDP_datagram {
+// used to reference the 4 byte ID number we place in UDP datagrams
+// Support 64 bit seqno on machines that support them
+ uint32_t id;
+ uint32_t tv_sec;
+ uint32_t tv_usec;
+ uint32_t id2;
+};
+
+struct hdr_typelen {
+ int32_t type;
+ int32_t length;
+};
+
+struct TCP_datagram {
+// used to reference write ids and timestamps in TCP payloads
+ struct hdr_typelen typelen;
+ uint32_t id;
+ uint32_t id2;
+ uint32_t tv_sec;
+ uint32_t tv_usec;
+ uint32_t reserved1;
+ uint32_t reserved2;
+};
+
+/*
+ * The client_hdr structure is sent from clients
+ * to servers to alert them of things that need
+ * to happen. Order must be perserved in all
+ * future releases for backward compatibility.
+ * 1.7 has flags, numThreads, mPort, and bufferlen
+ */
+struct client_hdr_v1 {
+ /*
+ * flags is a bitmap for different options
+ * the most significant bits are for determining
+ * which information is available. So 1.7 uses
+ * 0x80000000 and the next time information is added
+ * the 1.7 bit will be set and 0x40000000 will be
+ * set signifying additional information. If no
+ * information bits are set then the header is ignored.
+ * The lowest order diferentiates between dualtest and
+ * tradeoff modes, wheither the speaker needs to start
+ * immediately or after the audience finishes.
+ */
+ int32_t flags;
+ int32_t numThreads;
+ int32_t mPort;
+ int32_t mBufLen;
+ int32_t mWinBand;
+ int32_t mAmount;
+};
+
+//
+// Payload used for the bounce back feature
+//
+// Notes:
+// o) flags is standard iperf 2 flags for test exchange info
+// o) burst size is the payload size and size of bounce back write
+// o) burst id is a running seq no
+// o) send is the write timestamp
+// o) bb_r2w_hold is an optional delay value between the read and bb write, typically expected as zero
+// o) triptimes will support OWD measurements in each direction (useful for asymmetry testing)
+// o) min payload
+// - seven 32b or 28 bytes with round trip only,
+// - eleven 32b or 44 bytes when including trip-times support
+// o) no need for a bb read timestamp to be passed in the payload
+// o) OWD calculations require e2e clock sync and --trip-times cli option
+// o) no need to copy bb payload as rx buffer with be used for bounce back write
+// o) single threaded design
+// o) these are packed, be careful that the union doesn't break this
+//
+
+struct bb_ts {
+ uint32_t sec;
+ uint32_t usec;
+};
+struct bounceback_hdr {
+ uint32_t flags;
+ uint32_t bbsize;
+ uint32_t bbid;
+ uint16_t bbflags;
+ uint16_t tos;
+ uint32_t bbRunTime; //units 10 ms
+ struct bb_ts bbclientTx_ts;
+ struct bb_ts bbserverRx_ts;
+ struct bb_ts bbserverTx_ts;
+ uint32_t bbhold; // up to here is mandatory
+ uint32_t bbrtt;
+ struct bb_ts bbread_ts;
+};
+
+struct client_hdrext_isoch_settings {
+ int32_t FPSl;
+ int32_t FPSu;
+ int32_t Meanl;
+ int32_t Meanu;
+ int32_t Variancel;
+ int32_t Varianceu;
+ int32_t BurstIPGl;
+ int32_t BurstIPGu;
+};
+
+struct client_hdrext {
+ int32_t type;
+ int32_t length;
+ int16_t upperflags;
+ int16_t lowerflags;
+ uint32_t version_u;
+ uint32_t version_l;
+ uint16_t reserved;
+ uint16_t tos;
+ uint32_t lRate;
+ uint32_t uRate;
+ uint32_t TCPWritePrefetch;
+};
+
+struct client_hdrext_starttime_fq {
+ uint32_t reserved;
+ uint32_t start_tv_sec;
+ uint32_t start_tv_usec;
+ uint32_t fqratel;
+ uint32_t fqrateu;
+};
+
+/*
+ * TCP Isoch/burst payload structure
+ *
+ * 0 7 8 15 16 23 24 31
+ * +--------+--------+--------+--------+
+ * 1 | type |
+ * +--------+--------+--------+--------+
+ * 2 | len |
+ * +--------+--------+--------+--------+
+ * 3 | flags |
+ * +--------+--------+--------+--------+
+ * 4 | reserved |
+ * +--------+--------+--------+--------+
+ * 5 | isoch burst period (us) |
+ * +--------+--------+--------+--------+
+ * 6 | isoch start timestamp (s) |
+ * +--------+--------+--------+--------+
+ * 7 | isoch start timestamp (us) |
+ * +--------+--------+--------+--------+
+ * 8 | burst id |
+ * +--------+--------+--------+--------+
+ * 9 | burtsize |
+ * +--------+--------+--------+--------+
+ * 10 | burst bytes remaining |
+ * +--------+--------+--------+--------+
+ * 11 | seqno lower |
+ * +--------+--------+--------+--------+
+ * 12 | seqno upper |
+ * +--------+--------+--------+--------+
+ * 13 | tv_sec (write) |
+ * +--------+--------+--------+--------+
+ * 14 | tv_usec (write) |
+ * +--------+--------+--------+--------+
+ * 15 | tv_sec (read) |
+ * +--------+--------+--------+--------+
+ * 16 | tv_usec (read) |
+ * +--------+--------+--------+--------+
+ * 17 | tv_sec (write-ack) |
+ * +--------+--------+--------+--------+
+ * 18 | tv_usec (write-ack) |
+ * +--------+--------+--------+--------+
+ * 19 | tv_sec (read-ack) |
+ * +--------+--------+--------+--------+
+ * 20 | tv_usec (read-ack) |
+ * +--------+--------+--------+--------+
+ * 21 | reserved |
+ * +--------+--------+--------+--------+
+ * 22 | reserved |
+ * +--------+--------+--------+--------+
+ * 23 | reserved |
+ * +--------+--------+--------+--------+
+ * 24 | reserved |
+ * +--------+--------+--------+--------+
+ *
+ */
+struct TCP_oneway_triptime {
+ uint32_t write_tv_sec;
+ uint32_t write_tv_usec;
+ uint32_t read_tv_sec;
+ uint32_t read_tv_usec;
+};
+
+struct TCP_burst_payload {
+ uint32_t flags;
+ struct hdr_typelen typelen;
+ uint32_t start_tv_sec;
+ uint32_t start_tv_usec;
+ struct TCP_oneway_triptime send_tt;
+ uint32_t reserved0;
+ uint32_t burst_period_us;
+ uint32_t burst_id;
+ uint32_t burst_size;
+ uint32_t seqno_lower;
+ uint32_t seqno_upper;
+ struct TCP_oneway_triptime writeacktt;
+ uint32_t reserved1;
+ uint32_t reserved2;
+ uint32_t reserved3;
+ uint32_t reserved4;
+};
+
+/*
+ * UDP Full Isoch payload structure
+ *
+ * 0 7 8 15 16 23 24 31
+ * +--------+--------+--------+--------+
+ * 0x00 1 | seqno lower |
+ * +--------+--------+--------+--------+
+ * 0x04 2 | tv_sec |
+ * +--------+--------+--------+--------+
+ * 0x08 3 | tv_usec |
+ * +--------+--------+--------+--------+
+ * 4 | seqno upper |
+ * +--------+--------+--------+--------+
+ * 5 | flags (v1) |
+ * +--------+--------+--------+--------+
+ * 6 | numThreads (v1) |
+ * +--------+--------+--------+--------+
+ * 7 | mPort (v1) |
+ * +--------+--------+--------+--------+
+ * 8 | bufferLen (v1) |
+ * +--------+--------+--------+--------+
+ * 9 | mWinBand (v1) |
+ * +--------+--------+--------+--------+
+ * 10 | mAmount (v1) |
+ * +--------+--------+--------+--------+
+ * 11 | up flags | low flags |
+ * +--------+--------+--------+--------+
+ * 12 | iperf version major |
+ * +--------+--------+--------+--------+
+ * 13 | iperf version minor |
+ * +--------+--------+--------+--------+
+ * 14 | reserved | TOS |
+ * +--------+--------+--------+--------+
+ * 15 | rate |
+ * +--------+--------+--------+--------+
+ * 16 | rate units |
+ * +--------+--------+--------+--------+
+ * 17 | realtime (0.13) |
+ * +--------+--------+--------+--------+
+ * 18 | isoch burst period (us) |
+ * +--------+--------+--------+--------+
+ * 19 | isoch start timestamp (s) |
+ * +--------+--------+--------+--------+
+ * 20 | isoch start timestamp (us) |
+ * +--------+--------+--------+--------+
+ * 21 | isoch prev frameid |
+ * +--------+--------+--------+--------+
+ * 22 | isoch frameid |
+ * +--------+--------+--------+--------+
+ * 23 | isoch burtsize |
+ * +--------+--------+--------+--------+
+ * 24 | isoch bytes remaining |
+ * +--------+--------+--------+--------+
+ * 25 | isoch reserved |
+ * +--------+--------+--------+--------+
+ * 26 | reserved (0.14 start) |
+ * +--------+--------+--------+--------+
+ * 28 | start tv_sec (0.14) |
+ * +--------+--------+--------+--------+
+ * 29 | start tv_usec |
+ * +--------+--------+--------+--------+
+ * 27 | fqratel |
+ * +--------+--------+--------+--------+
+ * 28 | fqrateu |
+ * +--------+--------+--------+--------+
+ * 29 | FPSl |
+ * +--------+--------+--------+--------+
+ * 30 | FPSu |
+ * +--------+--------+--------+--------+
+ * 31 | Meanl |
+ * +--------+--------+--------+--------+
+ * 32 | Meanu |
+ * +--------+--------+--------+--------+
+ * 33 | Variancel |
+ * +--------+--------+--------+--------+
+ * 34 | Varianceu |
+ * +--------+--------+--------+--------+
+ * 35 | BurstIPGl |
+ * +--------+--------+--------+--------+
+ * 36 | BurstIPG |
+ * +--------+--------+--------+--------+
+ *
+ */
+struct isoch_payload {
+ uint32_t burstperiod; //period units microseconds
+ uint32_t start_tv_sec;
+ uint32_t start_tv_usec;
+ uint32_t prevframeid;
+ uint32_t frameid;
+ uint32_t burstsize;
+ uint32_t remaining;
+ uint32_t reserved;
+};
+
+struct permitKey {
+ uint16_t length;
+ char value[MAX_PERMITKEY_LEN];
+};
+
+struct client_udp_testhdr {
+ struct UDP_datagram seqno_ts;
+ struct client_hdr_v1 base;
+ struct client_hdrext extend;
+ struct isoch_payload isoch;
+ struct client_hdrext_starttime_fq start_fq;
+ struct client_hdrext_isoch_settings isoch_settings;
+};
+
+struct client_udpsmall_testhdr {
+ struct UDP_datagram seqno_ts;
+ uint16_t flags;
+};
+
+struct client_hdr_ack_ts {
+ uint32_t sent_tv_sec;
+ uint32_t sent_tv_usec;
+ uint32_t sentrx_tv_sec;
+ uint32_t sentrx_tv_usec;
+ uint32_t ack_tv_sec;
+ uint32_t ack_tv_usec;
+};
+
+struct client_hdr_ack {
+ struct hdr_typelen typelen;
+ uint32_t flags;
+ uint32_t version_u;
+ uint32_t version_l;
+ uint32_t reserved1;
+ uint32_t reserved2;
+ struct client_hdr_ack_ts ts;
+};
+
+/*
+ * TCP first payload structure
+ *
+ * 0 7 8 15 16 23 24 31
+ * +--------+--------+--------+--------+
+ * 0x00 1 | flags (v1) |
+ * +--------+--------+--------+--------+
+ * 2 | numThreads (v1) |
+ * +--------+--------+--------+--------+
+ * 3 | mPort (v1) |
+ * +--------+--------+--------+--------+
+ * 4 | bufferLen (v1) |
+ * +--------+--------+--------+--------+
+ * 5 | mWinBand (v1) |
+ * +--------+--------+--------+--------+
+ * 6 | mAmount (v1) |
+ * +--------+--------+--------+--------+
+ * 7 | type (0.13) |
+ * +--------+--------+--------+--------+
+ * 8 | len (0.13) |
+ * +--------+--------+--------+--------+
+ * 9 | flags (0.13) |
+ * +--------+--------+--------+--------+
+ * 10 | iperf version major |
+ * +--------+--------+--------+--------+
+ * 11 | iperf version minor |
+ * +--------+--------+--------+--------+
+ * 12 | reserved | TOS |
+ * +--------+--------+--------+--------+
+ * 13 | rate |
+ * +--------+--------+--------+--------+
+ * 14 | rate units |
+ * +--------+--------+--------+--------+
+ * 15 | write prefetch (0.13) |
+ * +--------+--------+--------+--------+
+ * 16 | reserved (0.14 start) |
+ * +--------+--------+--------+--------+
+ * 17 | start tv_sec (0.14) |
+ * +--------+--------+--------+--------+
+ * 18 | start tv_usec |
+ * +--------+--------+--------+--------+
+ * 19 | fqratel |
+ * +--------+--------+--------+--------+
+ * 20 | fqrateu |
+ * +--------+--------+--------+--------+
+ * 21 | FPSl |
+ * +--------+--------+--------+--------+
+ * 22 | FPSu |
+ * +--------+--------+--------+--------+
+ * 23 | Meanl |
+ * +--------+--------+--------+--------+
+ * 24 | Meanu |
+ * +--------+--------+--------+--------+
+ * 25 | Variancel |
+ * +--------+--------+--------+--------+
+ * 26 | Varianceu |
+ * +--------+--------+--------+--------+
+ * 27 | BurstIPGl |
+ * +--------+--------+--------+--------+
+ * 28 | BurstIPG |
+ * +--------+--------+--------+--------+
+ */
+struct client_tcp_testhdr {
+ struct client_hdr_v1 base;
+ struct client_hdrext extend;
+ struct client_hdrext_starttime_fq start_fq;
+ struct client_hdrext_isoch_settings isoch_settings;
+ struct permitKey permitkey;
+};
+
+/*
+ * The server_hdr structure facilitates the server
+ * report of jitter and loss on the client side.
+ * It piggy_backs on the existing clear to close
+ * packet.
+ */
+struct server_hdr_v1 {
+ /*
+ * flags is a bitmap for different options
+ * the most significant bits are for determining
+ * which information is available. So 1.7 uses
+ * 0x80000000 and the next time information is added
+ * the 1.7 bit will be set and 0x40000000 will be
+ * set signifying additional information. If no
+ * information bits are set then the header is ignored.
+ */
+ int32_t flags;
+ int32_t total_len1;
+ int32_t total_len2;
+ int32_t stop_sec;
+ int32_t stop_usec;
+ int32_t error_cnt;
+ int32_t outorder_cnt;
+ int32_t datagrams;
+ int32_t jitter1;
+ int32_t jitter2;
+};
+
+struct server_hdr_extension {
+ int32_t minTransit1;
+ int32_t minTransit2;
+ int32_t maxTransit1;
+ int32_t maxTransit2;
+ int32_t sumTransit1;
+ int32_t sumTransit2;
+ int32_t meanTransit1;
+ int32_t meanTransit2;
+ int32_t m2Transit1;
+ int32_t m2Transit2;
+ int32_t vdTransit1;
+ int32_t vdTransit2;
+ int32_t cntTransit;
+ int32_t cntIPG;
+ int32_t IPGsum;
+};
+
+// Extension for 64bit datagram counts
+struct server_hdr_extension2 {
+ int32_t error_cnt2;
+ int32_t outorder_cnt2;
+ int32_t datagrams2;
+};
+
+struct server_hdr {
+ struct server_hdr_v1 base;
+ struct server_hdr_extension extend;
+ struct server_hdr_extension2 extend2;
+};
+
+#pragma pack(pop)
+
+#define SIZEOF_UDPHDRMSG_V1 (sizeof(struct client_hdrv1) + sizeof(struct UDP_datagram))
+#define SIZEOF_UDPHDRMSG_EXT (sizeof(struct client_udp_testhdr))
+#define SIZEOF_TCPHDRMSG_V1 (sizeof(struct client_hdr_v1))
+#define SIZEOF_TCPHDRMSG_EXT (sizeof(struct client_tcp_testhdr))
+#define MINMBUFALLOCSIZE (int) (sizeof(struct client_tcp_testhdr)) + TAPBYTESSLOP
+#define MINTRIPTIMEPLAYOAD (int) (sizeof(struct client_udp_testhdr) - sizeof(struct client_hdrext_isoch_settings))
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif // PAYLOADS
diff --git a/include/pdfs.h b/include/pdfs.h
new file mode 100644
index 0000000..1a3a47d
--- /dev/null
+++ b/include/pdfs.h
@@ -0,0 +1,60 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 2017
+ * Broadcom Corporation
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the name of Broadcom Coporation,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ *
+ * Produce probability distribution functions, expected to be used
+ * for iperf client traffic emulations
+ *
+ * by Robert J. McMahon (rjmcmahon@rjmcmahon.com, bob.mcmahon@broadcom.com)
+ * ------------------------------------------------------------------- */
+
+#ifndef PDFS_H
+#define PDFS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+float normal(float mean, float variance);
+float lognormal(float mu, float sigma);
+float box_muller(void);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* PDFS_H */
diff --git a/include/snprintf.h b/include/snprintf.h
new file mode 100644
index 0000000..26e870f
--- /dev/null
+++ b/include/snprintf.h
@@ -0,0 +1,40 @@
+#ifndef SNPRINTF_H
+#define SNPRINTF_H
+
+/* ===================================================================
+ * snprintf.h
+ *
+ * This is from
+ * W. Richard Stevens, 'UNIX Network Programming', Vol 1, 2nd Edition,
+ * Prentice Hall, 1998.
+ *
+ * Mark Gates <mgates@nlanr.net>
+ * July 1998
+ *
+ * to use this prototype, make sure HAVE_SNPRINTF is not defined
+ *
+ * =================================================================== */
+
+/*
+ * Throughout the book I use snprintf() because it's safer than sprintf().
+ * But as of the time of this writing, not all systems provide this
+ * function. The function below should only be built on those systems
+ * that do not provide a real snprintf().
+ * The function below just acts like sprintf(); it is not safe, but it
+ * tries to detect overflow.
+ */
+
+#ifndef HAVE_SNPRINTF
+
+ #ifdef __cplusplus
+extern "C" {
+#endif
+
+int snprintf(char *buf, size_t size, const char *fmt, ...);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+ #endif
+
+#endif /* HAVE_SNPRINTF */
+#endif /* SNPRINTF_H */
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..0f28ce4
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,281 @@
+/*---------------------------------------------------------------
+ * Copyright (c) 1999,2000,2001,2002,2003
+ * The Board of Trustees of the University of Illinois
+ * All Rights Reserved.
+ *---------------------------------------------------------------
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software (Iperf) and associated
+ * documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ *
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and
+ * the following disclaimers.
+ *
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * Neither the names of the University of Illinois, NCSA,
+ * nor the names of its contributors may be used to endorse
+ * or promote products derived from this Software without
+ * specific prior written permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ________________________________________________________________
+ * National Laboratory for Applied Network Research
+ * National Center for Supercomputing Applications
+ * University of Illinois at Urbana-Champaign
+ * http://www.ncsa.uiuc.edu
+ * ________________________________________________________________
+ *
+ * util.h
+ * by Mark Gates <mgates@nlanr.net>
+ * -------------------------------------------------------------------
+ * various C utility functions.
+ * ------------------------------------------------------------------- */
+
+#ifndef UTIL_H
+#define UTIL_H
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int sInterupted;
+
+/* -------------------------------------------------------------------
+ * set/getsockopt wrappers for SO_RCVBUF and SO_SNDBUF; TCP_MAXSEG
+ * socket.c
+ * ------------------------------------------------------------------- */
+int setsock_tcp_windowsize(int inSock, int inTCPWin, int inSend);
+int getsock_tcp_windowsize(int inSock, int inSend);
+
+bool setsock_blocking(int fd, bool blocking);
+#if HAVE_DECL_TCP_WINDOW_CLAMP
+int getsock_tcp_windowclamp(int inSock);
+int setsock_tcp_windowclamp(int inSock, int clampsize);
+#endif
+#if HAVE_DECL_TCP_NOTSENT_LOWAT
+int getsock_tcp_notsent_low_watermark(int inSock);
+int setsock_tcp_notsent_low_watermark(int inSock, int clampsize);
+#endif
+int recvn(int inSock, char *outBuf, int inLen, int flags);
+int writen(int inSock, const void *inBuf, int inLen, int *count);
+
+void disarm_itimer(void);
+int set_itimer(uintmax_t);
+/* -------------------------------------------------------------------
+ * signal handlers
+ * signal.c
+ * ------------------------------------------------------------------- */
+typedef void Sigfunc(int);
+void sig_exit(int inSigno);
+
+typedef Sigfunc *SigfuncPtr;
+
+SigfuncPtr my_signal(int inSigno, SigfuncPtr inFunc);
+
+#ifdef WIN32
+
+#ifdef HAVE_SIGNAL_H
+ #define _NSIG NSIG
+#else
+/* under windows, emulate unix signals */
+enum {
+ SIGINT,
+ SIGTERM,
+ SIGPIPE,
+ _NSIG
+};
+#endif
+
+BOOL WINAPI sig_dispatcher(DWORD type);
+
+#endif
+
+/* -------------------------------------------------------------------
+ * error handlers
+ * error.c
+ * ------------------------------------------------------------------- */
+void warn (const char *inMessage, const char *inFile, int inLine);
+void warn_errno(const char *inMessage, const char *inFile, int inLine);
+
+#define FAIL_exit(cond, msg) \
+ do { \
+ if (cond) { \
+ warn(msg, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ } while(0)
+
+#if defined(HAVE_POSIX_THREAD) || defined(HAVE_WIN32_THREAD)
+#define FAIL(cond, msg, settings) \
+ do { \
+ if (cond) { \
+ warn(msg, __FILE__, __LINE__); \
+ thread_stop(settings); \
+ } \
+ } while(0)
+#else
+#define FAIL(cond, msg, settings) \
+ do { \
+ if (cond) { \
+ warn(msg, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ } while(0)
+#endif
+
+#define WARN(cond, msg) \
+ do { \
+ if (cond) { \
+ warn(msg, __FILE__, __LINE__); \
+ } \
+ } while(0)
+
+#if defined(HAVE_POSIX_THREAD) || defined(HAVE_WIN32_THREAD)
+#define FAIL_errno(cond, msg, settings) \
+ do { \
+ if (cond) { \
+ warn_errno(msg, __FILE__, __LINE__); \
+ thread_stop(settings); \
+ } \
+ } while(0)
+#else
+#define FAIL_errno(cond, msg, settings) \
+ do { \
+ if (cond) { \
+ warn_errno(msg, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ } while(0)
+#endif
+
+#define WARN_errno(cond, msg) \
+ do { \
+ if (cond) { \
+ warn_errno(msg, __FILE__, __LINE__); \
+ } \
+ } while(0)
+
+/* -------------------------------------------------------------------
+ * initialize buffer to a pattern
+ * ------------------------------------------------------------------- */
+void pattern(char *outBuf, int inBytes);
+
+/* -------------------------------------------------------------------
+ * input and output numbers, converting with kilo, mega, giga
+ * stdio.c
+ * ------------------------------------------------------------------- */
+double byte_atof(const char *inString);
+double bitorbyte_atof(const char *inString);
+intmax_t byte_atoi(const char *inString);
+uintmax_t bitorbyte_atoi(const char *inString);
+void byte_snprintf(char* outString, int inLen, double inNum, char inFormat);
+
+/*
+ * Time macros for C-code (not the include Timestamp.hpp)
+ */
+#define rMillion 1000000
+
+#define TimeZero(timeval) ((timeval.tv_sec == 0) && (timeval.tv_usec == 0))
+
+#define TimeDifference(left, right) ((left.tv_sec - right.tv_sec) + \
+ (left.tv_usec - right.tv_usec) / ((double) rMillion))
+
+#define TimeDifferenceUsec(left, right) ((1e6 * (left.tv_sec - right.tv_sec)) + \
+ (double) (left.tv_usec - right.tv_usec))
+
+#define TimeDouble(timeval) (timeval.tv_sec + timeval.tv_usec / ((double) rMillion))
+
+#define TimeAdd(left, right) do { \
+ left.tv_usec += right.tv_usec; \
+ if (left.tv_usec > rMillion) { \
+ left.tv_usec -= rMillion; \
+ left.tv_sec++; \
+ } \
+ left.tv_sec += right.tv_sec; \
+ } while (0)
+
+/* -------------------------------------------------------------------
+ * redirect the stdout to a specified file
+ * stdio.c
+ * ------------------------------------------------------------------- */
+void redirect(const char *inOutputFileName);
+
+/* -------------------------------------------------------------------
+ * delete macro
+ * ------------------------------------------------------------------- */
+#define DELETE_PTR(ptr) \
+ do { \
+ if (ptr != NULL) { \
+ delete ptr; \
+ ptr = NULL; \
+ } \
+ } while(false)
+
+#define DELETE_ARRAY(ptr) \
+ do { \
+ if (ptr != NULL) { \
+ delete [] ptr; \
+ ptr = NULL; \
+ } \
+ } while(false)
+
+#define FREE_ARRAY(ptr) \
+ do { \
+ if (ptr != NULL) { \
+ free(ptr); \
+ ptr = NULL; \
+ } \
+ } while(false)
+
+
+// Readn and write error macros
+// Define fatal and nonfatal write errors
+#ifdef WIN32
+#define FATALTCPREADERR(errno) (WSAGetLastError() != WSAEWOULDBLOCK)
+#define FATALUDPREADERR(errno) (((errno = WSAGetLastError()) != WSAEWOULDBLOCK))
+#define FATALTCPWRITERR(errno) ((errno = WSAGetLastError()) != WSAETIMEDOUT)
+#define NONFATALTCPWRITERR(errno) ((errno = WSAGetLastError()) == WSAETIMEDOUT)
+#define FATALUDPWRITERR(errno) (((errno = WSAGetLastError()) != WSAETIMEDOUT) \
+ && (errno != WSAECONNREFUSED))
+#else
+#define FATALTCPREADERR(errno) ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR))
+#define FATALUDPREADERR(errno) ((errno != EAGAIN) && (errno != EWOULDBLOCK) && \
+ (errno != EINTR))
+#define FATALTCPWRITERR(errno) (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
+#define NONFATALTCPWRITERR(errno) (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
+#define FATALUDPWRITERR(errno) ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR) \
+ && (errno != ECONNREFUSED) && (errno != ENOBUFS))
+#endif
+
+#ifdef WIN32
+#else
+#endif
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* UTIL_H */
diff --git a/include/version.h b/include/version.h
new file mode 100644
index 0000000..d28d4b0
--- /dev/null
+++ b/include/version.h
@@ -0,0 +1,27 @@
+#include "config.h"
+#define IPERF_VERSION VERSION
+#define IPERF_VERSION_DATE "14 March 2023"
+#define IPERF_VERSION_MAJORHEX 0x00020001
+#define IPERF_VERSION_MINORHEX 0x00090003
+
+/*
+ * case 0:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1,"-dev)");
+ * break;
+ * case 1:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1,"-rc)");
+ * break;
+ * case 2:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1,"-rc2)");
+ * break;
+ * case 3:
+ * break;
+ * case 4:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1,"-private)");
+ * break;
+ * case 5:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1,"-master)");
+ * break;
+ * default:
+ * sprintf(report->peerversion + strlen(report->peerversion) - 1, "-unk)");
+ */